@momo-kits/calculator-keyboard 0.153.1-beta.4 → 0.153.1-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,12 +4,15 @@ import android.annotation.SuppressLint
|
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import android.graphics.Color
|
|
6
6
|
import android.graphics.Typeface
|
|
7
|
+
import android.graphics.drawable.Drawable
|
|
7
8
|
import android.os.Build
|
|
8
9
|
import android.text.Editable
|
|
9
10
|
import android.text.TextWatcher
|
|
10
11
|
import android.view.KeyEvent
|
|
11
12
|
import android.view.inputmethod.InputMethodManager
|
|
13
|
+
import android.widget.TextView
|
|
12
14
|
import androidx.annotation.RequiresApi
|
|
15
|
+
import androidx.appcompat.content.res.AppCompatResources
|
|
13
16
|
import androidx.core.graphics.toColorInt
|
|
14
17
|
import androidx.core.view.ViewCompat
|
|
15
18
|
import androidx.core.view.WindowInsetsCompat
|
|
@@ -113,14 +116,43 @@ class InputCalculatorViewManager : SimpleViewManager<ReactEditText>(), NativeInp
|
|
|
113
116
|
keyboardView?.setMode(mode ?: "NumDefault")
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
@
|
|
119
|
+
@SuppressLint("DiscouragedPrivateApi")
|
|
117
120
|
override fun setSelectionColor(
|
|
118
121
|
view: ReactEditText?,
|
|
119
122
|
value: String?
|
|
120
123
|
) {
|
|
121
|
-
if (value == null) return
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
if (view == null || value == null) return
|
|
125
|
+
val color = value.toColorInt()
|
|
126
|
+
|
|
127
|
+
view.highlightColor = color
|
|
128
|
+
|
|
129
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
130
|
+
view.textCursorDrawable?.setTint(color)
|
|
131
|
+
} else {
|
|
132
|
+
try {
|
|
133
|
+
val field = TextView::class.java.getDeclaredField("mCursorDrawableRes")
|
|
134
|
+
field.isAccessible = true
|
|
135
|
+
val drawableResId = field.getInt(view)
|
|
136
|
+
|
|
137
|
+
val drawables = arrayOfNulls<Drawable>(2)
|
|
138
|
+
val drawable = AppCompatResources.getDrawable(view.context, drawableResId)
|
|
139
|
+
drawable?.setTint(color)
|
|
140
|
+
|
|
141
|
+
drawables[0] = drawable
|
|
142
|
+
drawables[1] = drawable
|
|
143
|
+
|
|
144
|
+
val editorField = TextView::class.java.getDeclaredField("mEditor")
|
|
145
|
+
editorField.isAccessible = true
|
|
146
|
+
val editor = editorField.get(view)
|
|
147
|
+
|
|
148
|
+
val cursorField = editor.javaClass.getDeclaredField("mCursorDrawable")
|
|
149
|
+
cursorField.isAccessible = true
|
|
150
|
+
cursorField.set(editor, drawables)
|
|
151
|
+
|
|
152
|
+
} catch (e: Exception) {
|
|
153
|
+
e.printStackTrace()
|
|
154
|
+
}
|
|
155
|
+
}
|
|
124
156
|
}
|
|
125
157
|
|
|
126
158
|
@ReactProp(name = "customKeyText")
|