@@ -21,21 +21,18 @@ import android.view.Gravity
21
21
import android.view.MotionEvent
22
22
import android.view.View
23
23
import android.view.ViewGroup
24
- import android.view.inputmethod.EditorInfo
25
24
import android.widget.PopupWindow
26
25
import com.osfans.trime.core.Rime
27
26
import com.osfans.trime.data.prefs.AppPrefs
28
27
import com.osfans.trime.data.theme.ColorManager
29
28
import com.osfans.trime.data.theme.FontManager
30
29
import com.osfans.trime.data.theme.ThemeManager
31
- import com.osfans.trime.data.theme.model.EnterLabel
32
30
import com.osfans.trime.databinding.KeyboardPopupKeyboardBinding
33
31
import com.osfans.trime.ime.enums.KeyEventType
34
32
import com.osfans.trime.util.LeakGuardHandlerWrapper
35
33
import com.osfans.trime.util.indexOfStateSet
36
34
import com.osfans.trime.util.sp
37
35
import com.osfans.trime.util.stateDrawableAt
38
- import splitties.bitflags.hasFlag
39
36
import splitties.dimensions.dp
40
37
import splitties.systemservices.layoutInflater
41
38
import splitties.views.dsl.core.textView
@@ -53,20 +50,6 @@ class KeyboardView(
53
50
context : Context ,
54
51
) : View(context),
55
52
View .OnClickListener {
56
- enum class EnterLabelMode {
57
- ACTION_LABEL_NEVER ,
58
- ACTION_LABEL_ONLY ,
59
- ACTION_LABEL_PREFERRED ,
60
- CUSTOM_PREFERRED ,
61
- ;
62
-
63
- companion object {
64
- fun fromOrdinal (ordinal : Int ) =
65
- runCatching { entries[ordinal] }
66
- .getOrDefault(ACTION_LABEL_NEVER )
67
- }
68
- }
69
-
70
53
private val theme get() = ThemeManager .activeTheme
71
54
72
55
private var mKeyboard: Keyboard ? = null
@@ -237,58 +220,10 @@ class KeyboardView(
237
220
private val mHeadsetRequiredToHearPasswordsAnnounced = false
238
221
var showKeyHint = ! Rime .getOption(" _hide_key_hint" )
239
222
var showKeySymbol = ! Rime .getOption(" _hide_key_symbol" )
240
- private lateinit var labelEnter: String
241
- private val mEnterLabels: EnterLabel = theme.generalStyle.enterLabel
242
- private val enterLabelMode = EnterLabelMode .fromOrdinal(theme.generalStyle.enterLabelMode)
223
+ private var labelEnter: String = theme.generalStyle.enterLabel.default
243
224
244
- private fun handleEnterLabel () {
245
- labelEnter = mEnterLabels.default ? : " ⏎"
246
- }
247
-
248
- fun updateEnterLabelOnEditorInfo (info : EditorInfo ) {
249
- if (info.imeOptions.hasFlag(EditorInfo .IME_FLAG_NO_ENTER_ACTION )) {
250
- labelEnter = mEnterLabels.default
251
- } else {
252
- val action = info.imeOptions and EditorInfo .IME_MASK_ACTION
253
- val actionLabel = info.actionLabel
254
- when (enterLabelMode) {
255
- EnterLabelMode .ACTION_LABEL_ONLY -> {
256
- labelEnter = actionLabel.toString()
257
- }
258
- EnterLabelMode .ACTION_LABEL_PREFERRED -> {
259
- labelEnter =
260
- if (! actionLabel.isNullOrEmpty()) {
261
- actionLabel.toString()
262
- } else {
263
- mEnterLabels.default
264
- }
265
- }
266
- EnterLabelMode .CUSTOM_PREFERRED ,
267
- EnterLabelMode .ACTION_LABEL_NEVER ,
268
- -> {
269
- labelEnter =
270
- when (action) {
271
- EditorInfo .IME_ACTION_DONE -> mEnterLabels.done
272
- EditorInfo .IME_ACTION_GO -> mEnterLabels.go
273
- EditorInfo .IME_ACTION_NEXT -> mEnterLabels.next
274
- EditorInfo .IME_ACTION_PREVIOUS -> mEnterLabels.pre
275
- EditorInfo .IME_ACTION_SEARCH -> mEnterLabels.search
276
- EditorInfo .IME_ACTION_SEND -> mEnterLabels.send
277
- else -> {
278
- if (enterLabelMode == EnterLabelMode .ACTION_LABEL_NEVER ) {
279
- mEnterLabels.default
280
- } else {
281
- if (! actionLabel.isNullOrEmpty()) {
282
- actionLabel.toString()
283
- } else {
284
- mEnterLabels.default
285
- }
286
- }
287
- }
288
- }
289
- }
290
- }
291
- }
225
+ fun onEnterKeyLabelUpdate (label : String ) {
226
+ labelEnter = label
292
227
}
293
228
294
229
private val mHandler = MyHandler (this )
@@ -317,7 +252,6 @@ class KeyboardView(
317
252
318
253
init {
319
254
initGestureDetector()
320
- handleEnterLabel()
321
255
invalidateAllKeys()
322
256
}
323
257
0 commit comments