|
@@ -3,11 +3,14 @@ package com.atmob.keyboard_android.component.child.impl
|
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
import android.util.AttributeSet
|
|
import android.util.AttributeSet
|
|
|
import android.view.View
|
|
import android.view.View
|
|
|
|
|
+import android.widget.ImageView
|
|
|
import com.atmob.keyboard_android.R
|
|
import com.atmob.keyboard_android.R
|
|
|
import com.atmob.keyboard_android.component.base.BaseUIComponent
|
|
import com.atmob.keyboard_android.component.base.BaseUIComponent
|
|
|
import com.atmob.keyboard_android.component.child.IToolBarComponent
|
|
import com.atmob.keyboard_android.component.child.IToolBarComponent
|
|
|
|
|
+import com.atmob.keyboard_android.enums.KeyboardGlobalType
|
|
|
import com.atmob.keyboard_android.ext.click
|
|
import com.atmob.keyboard_android.ext.click
|
|
|
import com.atmob.keyboard_android.ext.longClick
|
|
import com.atmob.keyboard_android.ext.longClick
|
|
|
|
|
+import com.atmob.keyboard_android.ext.setGone
|
|
|
import com.atmob.keyboard_android.keyboard.InputMethodPickerActivity
|
|
import com.atmob.keyboard_android.keyboard.InputMethodPickerActivity
|
|
|
import com.atmob.keyboard_android.util.KeyboardHolder
|
|
import com.atmob.keyboard_android.util.KeyboardHolder
|
|
|
|
|
|
|
@@ -18,6 +21,7 @@ class ToolBarComponent @JvmOverloads constructor(
|
|
|
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
|
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
|
|
) : BaseUIComponent<IToolBarComponent>(context, attrs, defStyleAttr), IToolBarComponent {
|
|
) : BaseUIComponent<IToolBarComponent>(context, attrs, defStyleAttr), IToolBarComponent {
|
|
|
private lateinit var vIcon: View
|
|
private lateinit var vIcon: View
|
|
|
|
|
+ private lateinit var vPinyinSwitchBtn: ImageView
|
|
|
private lateinit var vKeyboardSwitchBtn: View
|
|
private lateinit var vKeyboardSwitchBtn: View
|
|
|
private lateinit var vIntimacyLayout: View
|
|
private lateinit var vIntimacyLayout: View
|
|
|
|
|
|
|
@@ -27,18 +31,36 @@ class ToolBarComponent @JvmOverloads constructor(
|
|
|
|
|
|
|
|
override fun findView(view: View) {
|
|
override fun findView(view: View) {
|
|
|
vIcon = view.findViewById(R.id.icon)
|
|
vIcon = view.findViewById(R.id.icon)
|
|
|
|
|
+ vPinyinSwitchBtn = view.findViewById(R.id.pinyin_switch_btn)
|
|
|
vKeyboardSwitchBtn = view.findViewById(R.id.keyboard_switch_btn)
|
|
vKeyboardSwitchBtn = view.findViewById(R.id.keyboard_switch_btn)
|
|
|
vIntimacyLayout = view.findViewById(R.id.intimacy_layout)
|
|
vIntimacyLayout = view.findViewById(R.id.intimacy_layout)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun bindView(view: View) {
|
|
override fun bindView(view: View) {
|
|
|
|
|
+ // TODO: hezihao,拼音键盘还没实现,先隐藏切换入口
|
|
|
|
|
+ vPinyinSwitchBtn.setGone()
|
|
|
|
|
+
|
|
|
vIcon.click {
|
|
vIcon.click {
|
|
|
// 切换到设置页
|
|
// 切换到设置页
|
|
|
KeyboardHolder.getKeyboardService()?.getKeyboardViewModel()
|
|
KeyboardHolder.getKeyboardService()?.getKeyboardViewModel()
|
|
|
?.updateSettingPageShowing(true)
|
|
?.updateSettingPageShowing(true)
|
|
|
}
|
|
}
|
|
|
|
|
+ vPinyinSwitchBtn.click {
|
|
|
|
|
+ // 切换拼音键盘或AI键盘
|
|
|
|
|
+ KeyboardHolder.getKeyboardService()?.getKeyboardViewModel()?.run {
|
|
|
|
|
+ // 当前为Ai键盘,则切换为拼音键盘
|
|
|
|
|
+ val newGlobalType =
|
|
|
|
|
+ if (keyboardGlobalType.value == KeyboardGlobalType.AI_KEYBOARD) {
|
|
|
|
|
+ KeyboardGlobalType.PINYIN_KEYBOARD
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 当前为拼音键盘,则切换为Ai键盘
|
|
|
|
|
+ KeyboardGlobalType.AI_KEYBOARD
|
|
|
|
|
+ }
|
|
|
|
|
+ updateKeyboardGlobalType(newGlobalType)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // TODO: hezhiao,测试显示vip页,记得要去掉
|
|
|
vIcon.longClick {
|
|
vIcon.longClick {
|
|
|
- // TODO: hezhiao,测试显示vip页
|
|
|
|
|
KeyboardHolder.getKeyboardService()?.getKeyboardViewModel()
|
|
KeyboardHolder.getKeyboardService()?.getKeyboardViewModel()
|
|
|
?.updateVipPageShowing(true)
|
|
?.updateVipPageShowing(true)
|
|
|
true
|
|
true
|
|
@@ -52,6 +74,22 @@ class ToolBarComponent @JvmOverloads constructor(
|
|
|
KeyboardHolder.getKeyboardService()?.getKeyboardViewModel()
|
|
KeyboardHolder.getKeyboardService()?.getKeyboardViewModel()
|
|
|
?.updateLoginPageShowing(true)
|
|
?.updateLoginPageShowing(true)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ setupViewModel()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private fun setupViewModel() {
|
|
|
|
|
+ KeyboardHolder.getKeyboardService()?.run {
|
|
|
|
|
+ // 监听全局键盘类型变化,切换拼音切换图标
|
|
|
|
|
+ getKeyboardViewModel().keyboardGlobalType.observe(getLifecycleOwner()) { currentGlobalType ->
|
|
|
|
|
+ val switchIconResId = if (currentGlobalType == KeyboardGlobalType.PINYIN_KEYBOARD) {
|
|
|
|
|
+ R.mipmap.ic_pinyin_btn_selected
|
|
|
|
|
+ } else {
|
|
|
|
|
+ R.mipmap.ic_pinyin_btn_normal
|
|
|
|
|
+ }
|
|
|
|
|
+ vPinyinSwitchBtn.setImageResource(switchIconResId)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun getComponentInterfaceClazz(): Class<IToolBarComponent> {
|
|
override fun getComponentInterfaceClazz(): Class<IToolBarComponent> {
|