Skip to content

Commit

Permalink
Merge pull request #56 from kbiakov/develop
Browse files Browse the repository at this point in the history
Release 1.3.2
  • Loading branch information
kbiakov authored Jan 17, 2019
2 parents f2b0dfd + 3374b36 commit 7949ee2
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 172 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-28.0.3
- android-28
- extra-android-m2repository # Design Support library
- android-21
- sys-img-armeabi-v7a-android-21 # system image (emulator)
Expand All @@ -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-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 &
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
<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>

<b>CodeView</b> helps to show code content with syntax highlighting in native way.
Expand All @@ -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
Expand Down
16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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.kotlinVersion = '1.3.11'
ext.minSdk = 15
ext.compileSdk = 28
ext.buildTools = '28.0.3'
ext.supportLibrary = '28.0.0'

repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
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
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}

allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
17 changes: 8 additions & 9 deletions codeview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ 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'
versionName '1.3.2'
}
buildTypes {
release {
Expand All @@ -23,8 +23,7 @@ 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'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "com.android.support:appcompat-v7:$supportLibrary"
implementation "com.android.support:recyclerview-v7:$supportLibrary"
}
34 changes: 22 additions & 12 deletions codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<ShadowPosition, View>
Expand All @@ -32,17 +36,20 @@ 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) as RecyclerView
vCodeList.layoutManager = LinearLayoutManager(context)
vCodeList.isNestedScrollingEnabled = true
vCodeList = findViewById<RecyclerView>(R.id.rv_code_content).apply {
layoutManager = LinearLayoutManager(context)
isNestedScrollingEnabled = true
}

vShadows = mapOf(
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<View>(it.value)
}
}

private fun checkStartAnimation(attrs: AttributeSet) {
Expand All @@ -52,8 +59,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) {
Expand All @@ -65,7 +73,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
animate().alpha(Const.Alpha.Visible)
action()
}
} else action()
} else {
action()
}
}

/**
Expand All @@ -75,7 +85,7 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
private fun highlight() {
getAdapter()?.apply {
highlight {
checkHighlightAnimation(this::notifyDataSetChanged)
checkHighlightAnimation(::notifyDataSetChanged)
}
}
}
Expand Down Expand Up @@ -222,9 +232,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())
}
}
}
Expand Down
Loading

0 comments on commit 7949ee2

Please sign in to comment.