diff --git a/README.md b/README.md
index 8ed526f..fdd46ed 100644
--- a/README.md
+++ b/README.md
@@ -88,9 +88,9 @@ allprojects {
And add our dependency to your app `bundle.gradle`.
```gradle
-implementation 'com.devrapid.jieyi:kotlinknifer:2.0.2'
+implementation 'com.devrapid.jieyi:kotlinknifer:2.0.3'
-implementation 'com.devrapid.jieyi:kotlinshaver:1.0.2'
+implementation 'com.devrapid.jieyi:kotlinshaver:1.0.3'
```
Then you can use it!!!
@@ -101,14 +101,14 @@ Then you can use it!!!
com.devrapid.jieyi
kotlinknifer
- 2.0.2
+ 2.0.3
pom
com.devrapid.jieyi
kotlinshaver
- 1.0.2
+ 1.0.3
pom
```
@@ -129,14 +129,14 @@ Then you can use it!!!
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:2.0.2', {
+implementation('com.devrapid.jieyi:kotlinknifer:2.0.3', {
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:1.0.3', {
exclude group: 'io.reactivex.rxjava2', module: 'rxjava'
exclude group: 'io.reactivex.rxjava2', module: 'rxkotlin'
})
diff --git a/gradle.properties b/gradle.properties
index 1dbcba4..58f2e00 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -21,7 +21,7 @@ proj_name=kotlinknifer
proj_libname=KotlinKnifer
proj_group=com.devrapid.jieyi
proj_artifactid=kotlinknifer
-proj_version=2.0.2
+proj_version=2.0.3
proj_description=For developing an Android conveniently and rapidly.
proj_websiteurl=https://github.com/pokk/KotlinKnifer
proj_issuetrackerurl=https://github.com/pokk/KotlinKnifer/issues
@@ -39,4 +39,4 @@ developer_email=pokkbaby@gmail.com
proj_kotlin_name=kotlinshaver
proj_kotlin_libname=KotlinShaver
proj_kotlin_artifactid=kotlinshaver
-proj_kotlin_version=1.0.2
+proj_kotlin_version=1.0.3
diff --git a/kotlinknifer/src/main/java/com/devrapid/kotlinknifer/EditText.kt b/kotlinknifer/src/main/java/com/devrapid/kotlinknifer/EditText.kt
new file mode 100644
index 0000000..675b6cf
--- /dev/null
+++ b/kotlinknifer/src/main/java/com/devrapid/kotlinknifer/EditText.kt
@@ -0,0 +1,35 @@
+package com.devrapid.kotlinknifer
+
+import android.graphics.PorterDuff.Mode.SRC_IN
+import android.widget.EditText
+import android.widget.TextView
+import androidx.annotation.ColorInt
+import androidx.annotation.DrawableRes
+import androidx.core.content.ContextCompat
+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
+}
diff --git a/kotlinshaver/src/main/java/com/devrapid/kotlinshaver/Field.kt b/kotlinshaver/src/main/java/com/devrapid/kotlinshaver/Field.kt
new file mode 100644
index 0000000..32ca079
--- /dev/null
+++ b/kotlinshaver/src/main/java/com/devrapid/kotlinshaver/Field.kt
@@ -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 }