Skip to content

Commit

Permalink
Upgrade: upgraded the new version and add few new feature api.
Browse files Browse the repository at this point in the history
  • Loading branch information
pokk committed Aug 30, 2018
1 parent a4097e1 commit 8f5e451
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 30 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ allprojects {
And add our dependency to your app `bundle.gradle`.

```gradle
implementation 'com.devrapid.jieyi:kotlinknifer:1.5.7'
implementation 'com.devrapid.jieyi:kotlinknifer:1.5.8'
implementation 'com.devrapid.jieyi:kotlinshaver:0.2.2'
implementation 'com.devrapid.jieyi:kotlinshaver:0.2.3'
```

Then you can use it!!!
Expand All @@ -100,14 +100,14 @@ Then you can use it!!!
<dependency>
<groupId>com.devrapid.jieyi</groupId>
<artifactId>kotlinknifer</artifactId>
<version>1.5.7</version>
<version>1.5.8</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.devrapid.jieyi</groupId>
<artifactId>kotlinshaver</artifactId>
<version>0.2.2</version>
<version>0.2.3</version>
<type>pom</type>
</dependency>
```
Expand All @@ -116,25 +116,25 @@ Then you can use it!!!

## kotlinknifer

1. Gson 2.8.2
2. Glide 4.6.1
1. Gson 2.8.5
2. Glide 4.8.0

## kotlinshaver

1. RxJava 2.1.10
2. RxKotlin 2.2.0
1. RxJava 2.2.1
2. RxKotlin 2.3.0

If you'd not like to use them to your project, you can add the exclude as like below

```gradle
implementation('com.devrapid.jieyi:kotlinknifer:1.5.7', {
implementation('com.devrapid.jieyi:kotlinknifer:1.5.8', {
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'com.github.bumptech.glide', module: 'glide'
})
```

```gradle
implementation('com.devrapid.jieyi:kotlinshaverr:0.2.2', {
implementation('com.devrapid.jieyi:kotlinshaverr:0.2.3', {
exclude group: 'io.reactivex.rxjava2', module: 'rxjava'
exclude group: 'io.reactivex.rxjava2', module: 'rxkotlin'
})
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.31'
ext.kotlin_version = '1.2.61'
repositories {
jcenter()
google()
Expand All @@ -12,7 +12,7 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0"
classpath "com.github.dcendents:android-maven-gradle-plugin:1.5"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ proj_name=kotlinknifer
proj_libname=KotlinKnifer
proj_group=com.devrapid.jieyi
proj_artifactid=kotlinknifer
proj_version=1.5.7
proj_version=1.5.8
proj_description=For developing an Android conveniently and rapidly.
proj_websiteurl=https://github.com/pokk/KotlinKnifer
proj_issuetrackerurl=https://github.com/pokk/KotlinKnifer/issues
Expand All @@ -36,4 +36,4 @@ [email protected]
proj_kotlin_name=kotlinshaver
proj_kotlin_libname=KotlinShaver
proj_kotlin_artifactid=kotlinshaver
proj_kotlin_version=0.2.2
proj_kotlin_version=0.2.3
18 changes: 9 additions & 9 deletions kotlinknifer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ kotlin {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// 'compile' can also import to the new project with this.
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.github.bumptech.glide:glide:4.6.1'
compile 'com.google.code.gson:gson:2.8.5'
compile 'com.github.bumptech.glide:glide:4.8.0'
// 'implementation' can't import to the new project.
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-common:0.22.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.22.5'
implementation 'org.jetbrains.anko:anko-commons:0.10.4'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:palette-v7:27.1.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.25.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-common:0.25.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.25.0'
implementation 'org.jetbrains.anko:anko-commons:0.10.5'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:palette-v7:27.1.1'
compile project(':kotlinshaver')
}

Expand Down
35 changes: 35 additions & 0 deletions kotlinknifer/src/main/java/com/devrapid/kotlinknifer/EditText.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.devrapid.kotlinknifer

import android.graphics.PorterDuff.Mode.SRC_IN
import android.support.annotation.ColorInt
import android.support.annotation.DrawableRes
import android.support.v4.content.ContextCompat
import android.widget.EditText
import android.widget.TextView
import com.devrapid.kotlinshaver.accessible

fun setCursorPointerColor(view: EditText, @ColorInt color: Int, @DrawableRes drawable: Int = -1) {
// Get the editor.
val editor = TextView::class.java.getDeclaredField("mEditor").accessible().get(view)
// Get all drawable's selection points.
val drawables = if (-1 == drawable)
listOf("mTextSelectHandleRes" // Selection cursor point.
, "mTextSelectHandleLeftRes" // Selection the highlight left cursor point.
, "mTextSelectHandleRightRes") // Selection the highlight right cursor point.
.asSequence()
.map { TextView::class.java.getDeclaredField(it).accessible() } // Get the drawables' field.
.map { it.getInt(view) } // Get the drawable resource id.
.map { requireNotNull(ContextCompat.getDrawable(view.context, it)) } // Get the drawable.
.map { it.setColorFilter(color, SRC_IN); it } // Change the color we set.
.toList()
else
(0..2).map { requireNotNull(ContextCompat.getDrawable(view.context, drawable)) }
// Get all handle fields.
val fields = listOf("mSelectHandleCenter"
, "mSelectHandleLeft"
, "mSelectHandleRight")
.map { editor.javaClass.getDeclaredField(it).accessible() }
fields.zip(drawables).forEach { (field, drawable) -> field.set(editor, drawable) }

view.highlightColor = color
}
10 changes: 5 additions & 5 deletions kotlinshaver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apply plugin: 'kotlin'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-common:0.22.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.25.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-common:0.25.0'

compile 'io.reactivex.rxjava2:rxkotlin:2.2.0'
compile 'io.reactivex.rxjava2:rxjava:2.1.10'
compile 'io.reactivex.rxjava2:rxkotlin:2.3.0'
compile 'io.reactivex.rxjava2:rxjava:2.2.1'
}

sourceCompatibility = "1.8"
Expand Down Expand Up @@ -115,4 +115,4 @@ bintray {
}
}
}
}
}
13 changes: 13 additions & 0 deletions kotlinshaver/src/main/java/com/devrapid/kotlinshaver/Casting.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.devrapid.kotlinshaver

inline fun <reified T> castOrNull(from: Any?) = from as? T
inline fun <reified T> cast(from: Any?): T {
if (null == from) throw NullPointerException("Null object can't cast.")

try {
return T::class.java.cast(from)
}
catch (castExcept: ClassCastException) {
throw ClassCastException("Class casting failed.")
}
}
7 changes: 7 additions & 0 deletions kotlinshaver/src/main/java/com/devrapid/kotlinshaver/Field.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@file:Suppress("NOTHING_TO_INLINE")

package com.devrapid.kotlinshaver

import java.lang.reflect.Field

inline fun Field.accessible() = apply { isAccessible = true }
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta6'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation project(':kotlinknifer')
// implementation "com.devrapid.jieyi:kotlinknifer:1.4.1"
Expand Down

0 comments on commit 8f5e451

Please sign in to comment.