Skip to content

Commit 7949ee2

Browse files
authored
Merge pull request #56 from kbiakov/develop
Release 1.3.2
2 parents f2b0dfd + 3374b36 commit 7949ee2

File tree

10 files changed

+130
-172
lines changed

10 files changed

+130
-172
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android:
1010
- tools # to get the new `repository-11.xml`
1111
- tools # to install latest Android SDK tools
1212
- platform-tools
13-
- build-tools-25.0.3
14-
- android-25
13+
- build-tools-28.0.3
14+
- android-28
1515
- extra-android-m2repository # Design Support library
1616
- android-21
1717
- sys-img-armeabi-v7a-android-21 # system image (emulator)
@@ -24,7 +24,7 @@ env:
2424

2525
before_script:
2626
# Automatically accept all SDK licences
27-
- echo yes | android update sdk --no-ui --all --filter build-tools-24.0.2,android-24,extra-android-m2repository
27+
- echo yes | android update sdk --no-ui --all --filter build-tools-28.0.3,android-28,extra-android-m2repository
2828
# Emulator Management: create, start & wait
2929
- echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
3030
- emulator -avd test -no-skin -no-audio -no-window &

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# CodeView (Android)
22

33
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-codeview--android-blue.svg)](https://android-arsenal.com/details/1/4216)
4-
[![Release](https://jitpack.io/v/kbiakov/CodeView-android.svg)](https://jitpack.io/#kbiakov/CodeView-android)
5-
[![Build Status](https://travis-ci.org/kbiakov/CodeView-android.svg?branch=master)](https://travis-ci.org/kbiakov/CodeView-android)
4+
[![Release](https://jitpack.io/v/kbiakov/CodeView-android.svg)](https://jitpack.io/#kbiakov/CodeView-Android)
5+
[![Build Status](https://travis-ci.org/kbiakov/CodeView-android.svg?branch=master)](https://travis-ci.org/kbiakov/CodeView-Android)
66
<a href="http://www.methodscount.com/?lib=com.github.kbiakov%3ACodeView-android%3A1.3.0"><img src="https://img.shields.io/badge/Methods and size-core: 969 | 1396 KB-e91e63.svg"/></a>
77

88
<b>CodeView</b> helps to show code content with syntax highlighting in native way.
@@ -29,7 +29,7 @@ allprojects {
2929

3030
Add the dependency:
3131
```groovy
32-
compile 'com.github.kbiakov:CodeView-android:1.3.1'
32+
compile 'com.github.kbiakov:CodeView-android:1.3.2'
3333
```
3434

3535
## Usage

build.gradle

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.1.2-5'
4+
ext.kotlinVersion = '1.3.11'
5+
ext.minSdk = 15
6+
ext.compileSdk = 28
7+
ext.buildTools = '28.0.3'
8+
ext.supportLibrary = '28.0.0'
9+
510
repositories {
611
jcenter()
12+
google()
713
}
814
dependencies {
9-
classpath 'com.android.tools.build:gradle:2.3.3'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
12-
// NOTE: Do not place your application dependencies here; they belong
13-
// in the individual module build.gradle files
15+
classpath 'com.android.tools.build:gradle:3.3.0'
16+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1417
}
1518
}
1619

1720
allprojects {
1821
repositories {
1922
jcenter()
23+
google()
2024
}
2125
}
2226

codeview/build.gradle

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 25
6-
buildToolsVersion '25.0.3'
5+
compileSdkVersion compileSdk
6+
buildToolsVersion buildTools
77

88
defaultConfig {
9-
minSdkVersion 15
10-
targetSdkVersion 25
9+
minSdkVersion minSdk
10+
targetSdkVersion compileSdk
1111
versionCode 1
12-
versionName '1.3.0'
12+
versionName '1.3.2'
1313
}
1414
buildTypes {
1515
release {
@@ -23,8 +23,7 @@ android {
2323
}
2424

2525
dependencies {
26-
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
27-
28-
compile 'com.android.support:appcompat-v7:25.3.1'
29-
compile 'com.android.support:recyclerview-v7:25.3.1'
26+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
27+
implementation "com.android.support:appcompat-v7:$supportLibrary"
28+
implementation "com.android.support:recyclerview-v7:$supportLibrary"
3029
}

codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt

+22-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import io.github.kbiakov.codeview.highlight.color
2222
*
2323
* @author Kirill Biakov
2424
*/
25-
class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) {
25+
class CodeView @JvmOverloads constructor(
26+
context: Context,
27+
attrs: AttributeSet? = null,
28+
defStyleAttr: Int = 0
29+
) : RelativeLayout(context, attrs, defStyleAttr) {
2630

2731
private val vCodeList: RecyclerView
2832
private val vShadows: Map<ShadowPosition, View>
@@ -32,17 +36,20 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
3236
*/
3337
init {
3438
inflate(context, R.layout.layout_code_view, this)
35-
checkStartAnimation(attrs)
39+
attrs?.let(::checkStartAnimation)
3640

37-
vCodeList = findViewById(R.id.rv_code_content) as RecyclerView
38-
vCodeList.layoutManager = LinearLayoutManager(context)
39-
vCodeList.isNestedScrollingEnabled = true
41+
vCodeList = findViewById<RecyclerView>(R.id.rv_code_content).apply {
42+
layoutManager = LinearLayoutManager(context)
43+
isNestedScrollingEnabled = true
44+
}
4045

4146
vShadows = mapOf(
4247
ShadowPosition.RightBorder to R.id.shadow_right_border,
4348
ShadowPosition.NumBottom to R.id.shadow_num_bottom,
4449
ShadowPosition.ContentBottom to R.id.shadow_content_bottom
45-
).mapValues { findViewById(it.value) }
50+
).mapValues {
51+
findViewById<View>(it.value)
52+
}
4653
}
4754

4855
private fun checkStartAnimation(attrs: AttributeSet) {
@@ -52,8 +59,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
5259
animate()
5360
.setDuration(Const.DefaultDelay * 5)
5461
.alpha(Const.Alpha.Initial)
55-
} else
62+
} else {
5663
alpha = Const.Alpha.Initial
64+
}
5765
}
5866

5967
private fun AbstractCodeAdapter<*>.checkHighlightAnimation(action: () -> Unit) {
@@ -65,7 +73,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
6573
animate().alpha(Const.Alpha.Visible)
6674
action()
6775
}
68-
} else action()
76+
} else {
77+
action()
78+
}
6979
}
7080

7181
/**
@@ -75,7 +85,7 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
7585
private fun highlight() {
7686
getAdapter()?.apply {
7787
highlight {
78-
checkHighlightAnimation(this::notifyDataSetChanged)
88+
checkHighlightAnimation(::notifyDataSetChanged)
7989
}
8090
}
8191
}
@@ -222,9 +232,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
222232
RightBorder -> GradientDrawable.Orientation.LEFT_RIGHT to theme.bgContent
223233
NumBottom -> GradientDrawable.Orientation.TOP_BOTTOM to theme.bgNum
224234
ContentBottom -> GradientDrawable.Orientation.TOP_BOTTOM to theme.bgContent
225-
}.let {
226-
val colors = arrayOf(android.R.color.transparent, it.second)
227-
GradientDrawable(it.first, colors.map(Int::color).toIntArray())
235+
}.let { (orientation, color) ->
236+
val colors = arrayOf(android.R.color.transparent, color)
237+
GradientDrawable(orientation, colors.map(Int::color).toIntArray())
228238
}
229239
}
230240
}

0 commit comments

Comments
 (0)