|
|
@@ -2,6 +2,8 @@ package com.atmob.keyboard_android.component.child.impl
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
import android.content.Context
|
|
|
+import android.os.Handler
|
|
|
+import android.os.Looper
|
|
|
import android.util.AttributeSet
|
|
|
import android.view.View
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
|
|
@@ -22,7 +24,10 @@ import com.atmob.keyboard_android.ext.setGone
|
|
|
import com.atmob.keyboard_android.ext.setVisible
|
|
|
import com.atmob.keyboard_android.model.AddCharacterModel
|
|
|
import com.atmob.keyboard_android.model.AiKeyboardKeyModel
|
|
|
+import com.atmob.keyboard_android.ui.popup.guide.KeyboardGuideDialog
|
|
|
import com.atmob.keyboard_android.util.InputMethodUtil
|
|
|
+import com.atmob.keyboard_android.util.KeyboardGuideDialogUtil
|
|
|
+import com.atmob.keyboard_android.util.KeyboardGuideRecordUtil
|
|
|
import com.atmob.keyboard_android.util.KeyboardHolder
|
|
|
import com.atmob.keyboard_android.util.LogUtil
|
|
|
import com.atmob.keyboard_android.util.UserInfoHelper
|
|
|
@@ -59,6 +64,16 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
|
|
|
private lateinit var mKeyListAdapter: MultiTypeAdapter
|
|
|
|
|
|
/**
|
|
|
+ * 键盘引导Handler
|
|
|
+ */
|
|
|
+ private val mKeyboardGuideHandler = Handler(Looper.getMainLooper())
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 键盘引导,是否正在显示
|
|
|
+ */
|
|
|
+ private var mKeyboardGuideShowing = false
|
|
|
+
|
|
|
+ /**
|
|
|
* 当前点击的条目,用于点击重新生成时,重新生成内容
|
|
|
*/
|
|
|
private var mCurrentClickItem: AiKeyboardKeyModel? = null
|
|
|
@@ -98,9 +113,9 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
|
|
|
mKeyListItems = Items()
|
|
|
mKeyListAdapter = MultiTypeAdapter(mKeyListItems).apply {
|
|
|
// 键盘按键条目
|
|
|
- register(AiKeyboardKeyModel::class.java, AiKeyboardKeyViewBinder {
|
|
|
+ register(AiKeyboardKeyModel::class.java, AiKeyboardKeyViewBinder { itemView, item ->
|
|
|
// 当前点击的条目,正在加载中,忽略点击
|
|
|
- if (it.isLoading) {
|
|
|
+ if (item.isLoading) {
|
|
|
return@AiKeyboardKeyViewBinder
|
|
|
}
|
|
|
// 其他条目正在加载中,忽略点击
|
|
|
@@ -112,15 +127,15 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
|
|
|
return@AiKeyboardKeyViewBinder
|
|
|
}
|
|
|
// 点击键盘按键,打开AI生成内容面板
|
|
|
- if (it.isVip) {
|
|
|
+ if (item.isVip) {
|
|
|
// 检查是否VIP
|
|
|
UserInfoHelper.checkVip {
|
|
|
- handleItemClickLogic(it)
|
|
|
+ handleItemClickLogic(item)
|
|
|
LogUtil.d("Ai键盘,已经是VIP,打开Ai内容面板")
|
|
|
}
|
|
|
} else {
|
|
|
// 不需要VIP,直接打开
|
|
|
- handleItemClickLogic(it)
|
|
|
+ handleItemClickLogic(item)
|
|
|
LogUtil.d("Ai键盘,不需要VIP,直接进行下一步")
|
|
|
}
|
|
|
})
|
|
|
@@ -295,12 +310,64 @@ class AiKeyboardCommonPanelComponent @JvmOverloads constructor(
|
|
|
// 添加人设按钮
|
|
|
mKeyListItems.add(AddCharacterModel())
|
|
|
mKeyListAdapter.notifyDataSetChanged()
|
|
|
+
|
|
|
+ // 显示键盘引导页
|
|
|
+ tryShowKeyboardGuide()
|
|
|
}, onFail = {
|
|
|
ToastUtils.showShort(it)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 显示键盘引导
|
|
|
+ */
|
|
|
+ private fun tryShowKeyboardGuide() {
|
|
|
+ val action = Runnable {
|
|
|
+ // 正在显示,忽略
|
|
|
+ if (mKeyboardGuideShowing) {
|
|
|
+ return@Runnable
|
|
|
+ }
|
|
|
+
|
|
|
+ // 不是第一次引导,忽略
|
|
|
+ if (!KeyboardGuideRecordUtil.isFirstShowKeyboardGuide()) {
|
|
|
+ return@Runnable
|
|
|
+ }
|
|
|
+
|
|
|
+ val targetIndex = Constants.KEYBOARD_GUIDE_KEY_POSITION
|
|
|
+
|
|
|
+ // 获取所有按键数据
|
|
|
+ val keyList = mKeyListItems.filterIsInstance<AiKeyboardKeyModel>().toList()
|
|
|
+ if (keyList.isEmpty()) {
|
|
|
+ return@Runnable
|
|
|
+ }
|
|
|
+ // 目标超出范围,忽略
|
|
|
+ if (targetIndex > keyList.size - 1) {
|
|
|
+ return@Runnable
|
|
|
+ }
|
|
|
+
|
|
|
+ // 条目数据
|
|
|
+ val itemData = keyList[targetIndex]
|
|
|
+ // 通过position,获取ViewHolder
|
|
|
+ val viewHolder =
|
|
|
+ vKeyList.findViewHolderForAdapterPosition(targetIndex)
|
|
|
+
|
|
|
+ // 找到目标条目,则显示引导
|
|
|
+ if (viewHolder != null) {
|
|
|
+ val itemView = viewHolder.itemView
|
|
|
+ KeyboardGuideDialogUtil.showGuideDialog(itemView, itemData, object :
|
|
|
+ KeyboardGuideDialog.OnActionCallback {
|
|
|
+ override fun onFinishGuide() {
|
|
|
+ mKeyboardGuideShowing = false
|
|
|
+ KeyboardGuideRecordUtil.setFirstShowKeyboardGuide(false)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ mKeyboardGuideShowing = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mKeyboardGuideHandler.postDelayed(action, 350)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 控制Ai生成内容面板,是否显示
|
|
|
*/
|
|
|
private fun controlAiChatPageShowing(isShow: Boolean) {
|