From 61267764f5415954b3cfe7703de4154ef80e5013 Mon Sep 17 00:00:00 2001 From: Byakov Kirill Date: Fri, 23 Mar 2018 20:39:49 +0300 Subject: [PATCH 1/8] Update versions, code cleanup --- build.gradle | 14 +- codeview/build.gradle | 13 +- .../io/github/kbiakov/codeview/CodeView.kt | 15 +- .../codeview/adapters/AbstractCodeAdapter.kt | 165 ++++++------------ .../codeview/highlight/CodeHighlighter.kt | 9 +- .../codeview/views/BidirectionalScrollView.kt | 10 +- example/build.gradle | 10 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 8 files changed, 95 insertions(+), 145 deletions(-) diff --git a/build.gradle b/build.gradle index 1f9ae80..8a83714 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,26 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.1.2-5' + ext.kotlin_version = '1.2.21' + ext.minSdk = 15 + ext.compileSdk = 27 + ext.buildTools = '27.0.3' + ext.supportLibrary = '27.1.0' + repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.0.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files } } allprojects { repositories { jcenter() + google() } } diff --git a/codeview/build.gradle b/codeview/build.gradle index ad2d870..5bfc9fb 100644 --- a/codeview/build.gradle +++ b/codeview/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 25 - buildToolsVersion '25.0.3' + compileSdkVersion compileSdk + buildToolsVersion buildTools defaultConfig { - minSdkVersion 15 - targetSdkVersion 25 + minSdkVersion minSdk + targetSdkVersion compileSdk versionCode 1 versionName '1.3.0' } @@ -24,7 +24,6 @@ android { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - - compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.android.support:recyclerview-v7:25.3.1' + compile "com.android.support:appcompat-v7:$supportLibrary" + compile "com.android.support:recyclerview-v7:$supportLibrary" } diff --git a/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt b/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt index 0d3d4e2..c836693 100644 --- a/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt +++ b/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt @@ -34,7 +34,7 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context, inflate(context, R.layout.layout_code_view, this) checkStartAnimation(attrs) - vCodeList = findViewById(R.id.rv_code_content) as RecyclerView + vCodeList = findViewById(R.id.rv_code_content) vCodeList.layoutManager = LinearLayoutManager(context) vCodeList.isNestedScrollingEnabled = true @@ -42,7 +42,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context, ShadowPosition.RightBorder to R.id.shadow_right_border, ShadowPosition.NumBottom to R.id.shadow_num_bottom, ShadowPosition.ContentBottom to R.id.shadow_content_bottom - ).mapValues { findViewById(it.value) } + ).mapValues { + findViewById(it.value) + } } private fun checkStartAnimation(attrs: AttributeSet) { @@ -52,8 +54,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context, animate() .setDuration(Const.DefaultDelay * 5) .alpha(Const.Alpha.Initial) - } else + } else { alpha = Const.Alpha.Initial + } } private fun AbstractCodeAdapter<*>.checkHighlightAnimation(action: () -> Unit) { @@ -65,7 +68,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context, animate().alpha(Const.Alpha.Visible) action() } - } else action() + } else { + action() + } } /** @@ -75,7 +80,7 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context, private fun highlight() { getAdapter()?.apply { highlight { - checkHighlightAnimation(this::notifyDataSetChanged) + checkHighlightAnimation(::notifyDataSetChanged) } } } diff --git a/codeview/src/main/java/io/github/kbiakov/codeview/adapters/AbstractCodeAdapter.kt b/codeview/src/main/java/io/github/kbiakov/codeview/adapters/AbstractCodeAdapter.kt index 93cdd08..68ac317 100644 --- a/codeview/src/main/java/io/github/kbiakov/codeview/adapters/AbstractCodeAdapter.kt +++ b/codeview/src/main/java/io/github/kbiakov/codeview/adapters/AbstractCodeAdapter.kt @@ -62,9 +62,9 @@ abstract class AbstractCodeAdapter : RecyclerView.Adapter + lines = linesToShow + options.shortcutNote.toUpperCase() + droppedLines = dropped } } } @@ -178,15 +178,15 @@ abstract class AbstractCodeAdapter : RecyclerView.Adapter : RecyclerView.Adapter : RecyclerView.Adapter - val footerView = createFooter(context, entity, idx == 0) - holder.llLineFooter.addView(footerView) + forEachIndexed { idx, entity -> + addView(createFooter(context, entity, idx == 0)) + } } } } companion object { private const val MaxShortcutLines = 6 - - private fun Pair, List>.linesToShow() = first - private fun Pair, List>.droppedLines() = second } // - View holder types @@ -266,7 +264,7 @@ abstract class AbstractCodeAdapter : RecyclerView.Adapter @@ -336,114 +334,53 @@ data class Options( internal var isHighlighted: Boolean = false - fun withCode(code: String): Options { - this.code = code - return this - } - - fun withCode(codeResId: Int): Options { - this.code = context.getString(codeResId) - return this - } - - fun setCode(codeResId: Int) { - withCode(codeResId) - } - - fun withLanguage(language: String): Options { - this.language = language - return this - } - - fun withTheme(theme: ColorThemeData): Options { - this.theme = theme - return this - } - - fun withTheme(theme: ColorTheme): Options { - this.theme = theme.theme() - return this - } + fun withCode(code: String) = apply { this.code = code } + fun withCode(codeResId: Int) = apply { code = context.getString(codeResId) } + fun setCode(codeResId: Int) { withCode(codeResId) } + fun withLanguage(language: String) = apply { this.language = language } - fun setTheme(theme: ColorTheme) { - withTheme(theme) - } + fun withTheme(theme: ColorThemeData) = apply { this.theme = theme } + fun withTheme(theme: ColorTheme) = apply { this.theme = theme.theme() } + fun setTheme(theme: ColorTheme) { withTheme(theme) } - fun withFont(font: Font): Options { - this.font = FontCache.get(context).getTypeface(context, font) - return this - } + fun withFont(font: Font) = apply { this.font = font.get() } + fun withFont(font: Typeface) = font saveAndThen { apply { this.font = font } } + fun withFont(fontPath: String) = apply { this.font = fontPath.get() } + fun setFont(fontPath: String) { withFont(fontPath) } + fun setFont(font: Font) { withFont(font) } + fun withFormat(format: Format) = apply { this.format = format } - fun withFont(font: Typeface): Options { - FontCache.get(context).saveTypeface(font) - this.font = font - return this - } + fun animateOnHighlight() = apply { animateOnHighlight = true } + fun disableHighlightAnimation() = apply { animateOnHighlight = false } + fun withShadows() = apply { shadows = true } + fun withoutShadows() = apply { shadows = false } - fun withFont(fontPath: String): Options { - this.font = FontCache.get(context).getTypeface(context, fontPath) - return this - } + fun addCodeLineClickListener(listener: OnCodeLineClickListener) = apply { lineClickListener = listener } + fun removeCodeLineClickListener() = apply { lineClickListener = null } - fun setFont(fontPath: String) { - withFont(fontPath) - } - - fun setFont(font: Font) { - withFont(font) - } - - fun withFormat(format: Format): Options { - this.format = format - return this - } - - fun animateOnHighlight(): Options { - this.animateOnHighlight = true - return this - } - - fun disableHighlightAnimation(): Options { - this.animateOnHighlight = false - return this - } - - fun withShadows(): Options { - this.shadows = true - return this - } - - fun withoutShadows(): Options { - this.shadows = false - return this - } - - fun shortcut(maxLines: Int, shortcutNote: String): Options { + fun shortcut(maxLines: Int, shortcutNote: String) = apply { this.shortcut = true this.maxLines = maxLines this.shortcutNote = shortcutNote - return this - } - - fun addCodeLineClickListener(listener: OnCodeLineClickListener): Options { - this.lineClickListener = listener - return this - } - - fun removeCodeLineClickListener(): Options { - this.lineClickListener = null - return this } companion object Default { fun get(context: Context) = Options(context) } + + // - Font helpers + + private val fontCache = FontCache.get(context) + private fun Font.get() = fontCache.getTypeface(context, this) + private fun String.get() = fontCache.getTypeface(context, this) + private infix fun Typeface.saveAndThen(body: () -> T): T = fontCache.saveTypeface(this).let { body() } } -data class Format(val scaleFactor: Float = 1f, - val lineHeight: Int = (LineHeight * scaleFactor).toInt(), - val borderHeight: Int = (BorderHeight * scaleFactor).toInt(), - val fontSize: Float = FontSize.toFloat()) { +data class Format( + val scaleFactor: Float = 1f, + val lineHeight: Int = (LineHeight * scaleFactor).toInt(), + val borderHeight: Int = (BorderHeight * scaleFactor).toInt(), + val fontSize: Float = FontSize.toFloat()) { companion object Default { private const val LineHeight = 18 diff --git a/codeview/src/main/java/io/github/kbiakov/codeview/highlight/CodeHighlighter.kt b/codeview/src/main/java/io/github/kbiakov/codeview/highlight/CodeHighlighter.kt index d64684f..581172c 100644 --- a/codeview/src/main/java/io/github/kbiakov/codeview/highlight/CodeHighlighter.kt +++ b/codeview/src/main/java/io/github/kbiakov/codeview/highlight/CodeHighlighter.kt @@ -237,20 +237,21 @@ infix fun String.applyFontParams(color: String?): String { var idx = 0 var newIdx = indexOf("\n") - if (newIdx.notFound()) // covers expected tag coverage (within only one line) + if (newIdx.notFound()) { // covers expected tag coverage (within only one line) parametrizedString += inFontTag(color) - else { // may contain multiple lines with line breaks + } else { // may contain multiple lines with line breaks // put tag on the borders (end & start of line, ..., end of tag) do { // until closing tag is reached - parametrizedString += (substring(idx .. newIdx - 1) inFontTag color) + "\n" + parametrizedString += "${substring(idx until newIdx) inFontTag color}\n" idx = newIdx + 1 newIdx = indexOf("\n", idx) } while (newIdx.isFound()) - if (idx != indexOf("\n")) // if not replaced only once (for multiline tag coverage) + if (idx != indexOf("\n")) { // if not replaced only once (for multiline tag coverage) parametrizedString += substring(idx) inFontTag color + } } return parametrizedString } diff --git a/codeview/src/main/java/io/github/kbiakov/codeview/views/BidirectionalScrollView.kt b/codeview/src/main/java/io/github/kbiakov/codeview/views/BidirectionalScrollView.kt index 5c90791..4c138d6 100644 --- a/codeview/src/main/java/io/github/kbiakov/codeview/views/BidirectionalScrollView.kt +++ b/codeview/src/main/java/io/github/kbiakov/codeview/views/BidirectionalScrollView.kt @@ -39,15 +39,19 @@ class BidirectionalScrollView : HorizontalScrollView { scroll(event) val movedOnDistance = dpToPx(context, 2) - if (deltaX > movedOnDistance || deltaY > movedOnDistance) + if (deltaX > movedOnDistance || deltaY > movedOnDistance) { isMoved = true + } } MotionEvent.ACTION_UP -> { - if (!isMoved) + if (!isMoved) { return super.dispatchTouchEvent(event) + } + isMoved = false + } + MotionEvent.ACTION_CANCEL -> { isMoved = false } - MotionEvent.ACTION_CANCEL -> isMoved = false } return true } diff --git a/example/build.gradle b/example/build.gradle index 7ad5510..2d7a13b 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -2,13 +2,13 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { - compileSdkVersion 25 - buildToolsVersion '25.0.3' + compileSdkVersion compileSdk + buildToolsVersion buildTools defaultConfig { applicationId 'io.github.kbiakov.codeviewexample' - minSdkVersion 15 - targetSdkVersion 25 + minSdkVersion minSdk + targetSdkVersion compileSdk versionCode 1 versionName '1.0' } @@ -24,9 +24,9 @@ android { } dependencies { - compile 'com.android.support:appcompat-v7:25.3.1' compile project(path: ':codeview') compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + compile "com.android.support:appcompat-v7:$supportLibrary" } repositories { mavenCentral() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c1b0c03..7a891ad 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Aug 26 20:57:29 MSK 2017 +#Fri Mar 23 19:00:37 MSK 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip From 961467c3b6fea717b804f014fabe558de37c3aa2 Mon Sep 17 00:00:00 2001 From: Kirill Biakov Date: Fri, 23 Mar 2018 23:54:18 +0300 Subject: [PATCH 2/8] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index badb566..502b8be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ android: - tools # to get the new `repository-11.xml` - tools # to install latest Android SDK tools - platform-tools - - build-tools-25.0.3 - - android-25 + - build-tools-27.0.3 + - android-27 - extra-android-m2repository # Design Support library - android-21 - sys-img-armeabi-v7a-android-21 # system image (emulator) @@ -24,7 +24,7 @@ env: before_script: # Automatically accept all SDK licences - - echo yes | android update sdk --no-ui --all --filter build-tools-24.0.2,android-24,extra-android-m2repository + - echo yes | android update sdk --no-ui --all --filter build-tools-27.0.3,android-27,extra-android-m2repository # Emulator Management: create, start & wait - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a - emulator -avd test -no-skin -no-audio -no-window & From 844805e01fab414c6084c74354feeaa88e31898f Mon Sep 17 00:00:00 2001 From: Byakov Kirill Date: Thu, 17 Jan 2019 17:46:57 +0300 Subject: [PATCH 3/8] Update versions --- build.gradle | 12 ++++++------ codeview/build.gradle | 8 ++++---- example/build.gradle | 8 +++++--- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index 8a83714..37ef2a4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,19 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.21' + ext.kotlinVersion = '1.3.11' ext.minSdk = 15 - ext.compileSdk = 27 - ext.buildTools = '27.0.3' - ext.supportLibrary = '27.1.0' + ext.compileSdk = 28 + ext.buildTools = '28.0.3' + ext.supportLibrary = '28.0.0' repositories { jcenter() google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.android.tools.build:gradle:3.3.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" } } diff --git a/codeview/build.gradle b/codeview/build.gradle index 5bfc9fb..c799a15 100644 --- a/codeview/build.gradle +++ b/codeview/build.gradle @@ -9,7 +9,7 @@ android { minSdkVersion minSdk targetSdkVersion compileSdk versionCode 1 - versionName '1.3.0' + versionName '1.3.1' } buildTypes { release { @@ -23,7 +23,7 @@ android { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "com.android.support:appcompat-v7:$supportLibrary" - compile "com.android.support:recyclerview-v7:$supportLibrary" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" + implementation "com.android.support:appcompat-v7:$supportLibrary" + implementation "com.android.support:recyclerview-v7:$supportLibrary" } diff --git a/example/build.gradle b/example/build.gradle index 2d7a13b..6ab7624 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -24,9 +24,11 @@ android { } dependencies { - compile project(path: ':codeview') - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "com.android.support:appcompat-v7:$supportLibrary" + implementation project(':codeview') + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" + implementation "com.android.support:appcompat-v7:$supportLibrary" + implementation "com.android.support:recyclerview-v7:$supportLibrary" } repositories { mavenCentral() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7a891ad..9279f53 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Mar 23 19:00:37 MSK 2018 +#Thu Jan 17 15:59:44 MSK 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip From 7a0efcb4a46b3f49331dd8e19cd0ba9543c76329 Mon Sep 17 00:00:00 2001 From: Byakov Kirill Date: Thu, 17 Jan 2019 17:48:24 +0300 Subject: [PATCH 4/8] Add default view constructors --- .../java/io/github/kbiakov/codeview/CodeView.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt b/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt index c836693..d8a9ffa 100644 --- a/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt +++ b/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt @@ -22,7 +22,11 @@ import io.github.kbiakov.codeview.highlight.color * * @author Kirill Biakov */ -class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) { +class CodeView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : RelativeLayout(context, attrs, defStyleAttr) { private val vCodeList: RecyclerView private val vShadows: Map @@ -32,7 +36,7 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context, */ init { inflate(context, R.layout.layout_code_view, this) - checkStartAnimation(attrs) + attrs?.let(::checkStartAnimation) vCodeList = findViewById(R.id.rv_code_content) vCodeList.layoutManager = LinearLayoutManager(context) @@ -227,9 +231,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context, RightBorder -> GradientDrawable.Orientation.LEFT_RIGHT to theme.bgContent NumBottom -> GradientDrawable.Orientation.TOP_BOTTOM to theme.bgNum ContentBottom -> GradientDrawable.Orientation.TOP_BOTTOM to theme.bgContent - }.let { - val colors = arrayOf(android.R.color.transparent, it.second) - GradientDrawable(it.first, colors.map(Int::color).toIntArray()) + }.let { (orientation, color) -> + val colors = arrayOf(android.R.color.transparent, color) + GradientDrawable(orientation, colors.map(Int::color).toIntArray()) } } } From c7a41817a6338aeeeca292514e824afa20a2a1e8 Mon Sep 17 00:00:00 2001 From: Byakov Kirill Date: Thu, 17 Jan 2019 18:28:37 +0300 Subject: [PATCH 5/8] Code cleanup --- .../io/github/kbiakov/codeview/CodeView.kt | 7 ++++--- .../codeview/views/BidirectionalScrollView.kt | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt b/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt index d8a9ffa..f8f6d0c 100644 --- a/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt +++ b/codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt @@ -38,9 +38,10 @@ class CodeView @JvmOverloads constructor( inflate(context, R.layout.layout_code_view, this) attrs?.let(::checkStartAnimation) - vCodeList = findViewById(R.id.rv_code_content) - vCodeList.layoutManager = LinearLayoutManager(context) - vCodeList.isNestedScrollingEnabled = true + vCodeList = findViewById(R.id.rv_code_content).apply { + layoutManager = LinearLayoutManager(context) + isNestedScrollingEnabled = true + } vShadows = mapOf( ShadowPosition.RightBorder to R.id.shadow_right_border, diff --git a/codeview/src/main/java/io/github/kbiakov/codeview/views/BidirectionalScrollView.kt b/codeview/src/main/java/io/github/kbiakov/codeview/views/BidirectionalScrollView.kt index 4c138d6..ad5c0b1 100644 --- a/codeview/src/main/java/io/github/kbiakov/codeview/views/BidirectionalScrollView.kt +++ b/codeview/src/main/java/io/github/kbiakov/codeview/views/BidirectionalScrollView.kt @@ -68,17 +68,18 @@ class BidirectionalScrollView : HorizontalScrollView { } override fun measureChild(child: View, parentWidthMeasureSpec: Int, parentHeightMeasureSpec: Int) { - val measureSpecZero = makeMeasureSpec(0) - child.measure(measureSpecZero, measureSpecZero) + val zeroMeasureSpec = makeMeasureSpec(0) + child.measure(zeroMeasureSpec, zeroMeasureSpec) } - override fun measureChildWithMargins(child: View, - parentWidthMeasureSpec: Int, widthUsed: Int, - parentHeightMeasureSpec: Int, heightUsed: Int) { - val params = child.layoutParams as MarginLayoutParams - val childWidthMeasureSpec = makeMeasureSpec(params.leftMargin + params.rightMargin) - val childHeightMeasureSpec = makeMeasureSpec(params.topMargin + params.bottomMargin) - child.measure(childWidthMeasureSpec, childHeightMeasureSpec) + override fun measureChildWithMargins( + child: View, + parentWidthMeasureSpec: Int, widthUsed: Int, + parentHeightMeasureSpec: Int, heightUsed: Int + ) = with(child.layoutParams as MarginLayoutParams) { + val widthMeasureSpec = makeMeasureSpec(leftMargin + rightMargin, MeasureSpec.UNSPECIFIED) + val heightMeasureSpec = makeMeasureSpec(topMargin + bottomMargin, MeasureSpec.UNSPECIFIED) + child.measure(widthMeasureSpec, heightMeasureSpec) } private fun makeMeasureSpec(size: Int) = makeMeasureSpec(size, MeasureSpec.UNSPECIFIED) From a98fcbc4ee6517fb14ade4a6c9a105870bf1b72b Mon Sep 17 00:00:00 2001 From: Byakov Kirill Date: Thu, 17 Jan 2019 18:31:43 +0300 Subject: [PATCH 6/8] Update Travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 502b8be..f5cfa4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ android: - tools # to get the new `repository-11.xml` - tools # to install latest Android SDK tools - platform-tools - - build-tools-27.0.3 - - android-27 + - build-tools-28.0.3 + - android-28 - extra-android-m2repository # Design Support library - android-21 - sys-img-armeabi-v7a-android-21 # system image (emulator) @@ -24,7 +24,7 @@ env: before_script: # Automatically accept all SDK licences - - echo yes | android update sdk --no-ui --all --filter build-tools-27.0.3,android-27,extra-android-m2repository + - echo yes | android update sdk --no-ui --all --filter build-tools-28.0.3,android-28,extra-android-m2repository # Emulator Management: create, start & wait - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a - emulator -avd test -no-skin -no-audio -no-window & From 27d838a7fdfa31ce3063a7d37fad29ac104c96f4 Mon Sep 17 00:00:00 2001 From: Byakov Kirill Date: Thu, 17 Jan 2019 18:42:45 +0300 Subject: [PATCH 7/8] Bump version to 3.2 --- codeview/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codeview/build.gradle b/codeview/build.gradle index c799a15..c460859 100644 --- a/codeview/build.gradle +++ b/codeview/build.gradle @@ -9,7 +9,7 @@ android { minSdkVersion minSdk targetSdkVersion compileSdk versionCode 1 - versionName '1.3.1' + versionName '1.3.2' } buildTypes { release { From f21e02eca43048b8ff0a5f17fd2ab3cccfa89da9 Mon Sep 17 00:00:00 2001 From: Byakov Kirill Date: Thu, 17 Jan 2019 18:43:44 +0300 Subject: [PATCH 8/8] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 877a15c..23995c1 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # CodeView (Android) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-codeview--android-blue.svg)](https://android-arsenal.com/details/1/4216) -[![Release](https://jitpack.io/v/kbiakov/CodeView-android.svg)](https://jitpack.io/#kbiakov/CodeView-android) -[![Build Status](https://travis-ci.org/kbiakov/CodeView-android.svg?branch=master)](https://travis-ci.org/kbiakov/CodeView-android) +[![Release](https://jitpack.io/v/kbiakov/CodeView-android.svg)](https://jitpack.io/#kbiakov/CodeView-Android) +[![Build Status](https://travis-ci.org/kbiakov/CodeView-android.svg?branch=master)](https://travis-ci.org/kbiakov/CodeView-Android) CodeView helps to show code content with syntax highlighting in native way. @@ -29,7 +29,7 @@ allprojects { Add the dependency: ```groovy -compile 'com.github.kbiakov:CodeView-android:1.3.1' +compile 'com.github.kbiakov:CodeView-android:1.3.2' ``` ## Usage