Skip to content

Commit 3374b36

Browse files
authored
Merge pull request #55 from kbiakov/feature/update
Update versions, code cleanup
2 parents 9b5c128 + f21e02e commit 3374b36

File tree

8 files changed

+46
-38
lines changed

8 files changed

+46
-38
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
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-27.0.3
14-
- android-27
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-27.0.3,android-27,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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
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.2.21'
4+
ext.kotlinVersion = '1.3.11'
55
ext.minSdk = 15
6-
ext.compileSdk = 27
7-
ext.buildTools = '27.0.3'
8-
ext.supportLibrary = '27.1.0'
6+
ext.compileSdk = 28
7+
ext.buildTools = '28.0.3'
8+
ext.supportLibrary = '28.0.0'
99

1010
repositories {
1111
jcenter()
1212
google()
1313
}
1414
dependencies {
15-
classpath 'com.android.tools.build:gradle:3.0.1'
16-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15+
classpath 'com.android.tools.build:gradle:3.3.0'
16+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1717
}
1818
}
1919

codeview/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ android {
99
minSdkVersion minSdk
1010
targetSdkVersion compileSdk
1111
versionCode 1
12-
versionName '1.3.0'
12+
versionName '1.3.2'
1313
}
1414
buildTypes {
1515
release {
@@ -23,7 +23,7 @@ android {
2323
}
2424

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

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

Lines changed: 13 additions & 8 deletions
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,11 +36,12 @@ 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<RecyclerView>(R.id.rv_code_content)
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,
@@ -227,9 +232,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
227232
RightBorder -> GradientDrawable.Orientation.LEFT_RIGHT to theme.bgContent
228233
NumBottom -> GradientDrawable.Orientation.TOP_BOTTOM to theme.bgNum
229234
ContentBottom -> GradientDrawable.Orientation.TOP_BOTTOM to theme.bgContent
230-
}.let {
231-
val colors = arrayOf(android.R.color.transparent, it.second)
232-
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())
233238
}
234239
}
235240
}

codeview/src/main/java/io/github/kbiakov/codeview/views/BidirectionalScrollView.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,18 @@ class BidirectionalScrollView : HorizontalScrollView {
6868
}
6969

7070
override fun measureChild(child: View, parentWidthMeasureSpec: Int, parentHeightMeasureSpec: Int) {
71-
val measureSpecZero = makeMeasureSpec(0)
72-
child.measure(measureSpecZero, measureSpecZero)
71+
val zeroMeasureSpec = makeMeasureSpec(0)
72+
child.measure(zeroMeasureSpec, zeroMeasureSpec)
7373
}
7474

75-
override fun measureChildWithMargins(child: View,
76-
parentWidthMeasureSpec: Int, widthUsed: Int,
77-
parentHeightMeasureSpec: Int, heightUsed: Int) {
78-
val params = child.layoutParams as MarginLayoutParams
79-
val childWidthMeasureSpec = makeMeasureSpec(params.leftMargin + params.rightMargin)
80-
val childHeightMeasureSpec = makeMeasureSpec(params.topMargin + params.bottomMargin)
81-
child.measure(childWidthMeasureSpec, childHeightMeasureSpec)
75+
override fun measureChildWithMargins(
76+
child: View,
77+
parentWidthMeasureSpec: Int, widthUsed: Int,
78+
parentHeightMeasureSpec: Int, heightUsed: Int
79+
) = with(child.layoutParams as MarginLayoutParams) {
80+
val widthMeasureSpec = makeMeasureSpec(leftMargin + rightMargin, MeasureSpec.UNSPECIFIED)
81+
val heightMeasureSpec = makeMeasureSpec(topMargin + bottomMargin, MeasureSpec.UNSPECIFIED)
82+
child.measure(widthMeasureSpec, heightMeasureSpec)
8283
}
8384

8485
private fun makeMeasureSpec(size: Int) = makeMeasureSpec(size, MeasureSpec.UNSPECIFIED)

example/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ android {
2424
}
2525

2626
dependencies {
27-
compile project(path: ':codeview')
28-
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
29-
compile "com.android.support:appcompat-v7:$supportLibrary"
27+
implementation project(':codeview')
28+
29+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
30+
implementation "com.android.support:appcompat-v7:$supportLibrary"
31+
implementation "com.android.support:recyclerview-v7:$supportLibrary"
3032
}
3133
repositories {
3234
mavenCentral()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Mar 23 19:00:37 MSK 2018
1+
#Thu Jan 17 15:59:44 MSK 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip

0 commit comments

Comments
 (0)