瀏覽代碼

[feat]键盘插件,实现权限提示条UI

hezihao 8 月之前
父節點
當前提交
1ebb60d2d9

+ 36 - 0
plugins/keyboard_android/android/src/main/kotlin/com/atmob/keyboard_android/component/PermissionTipComponent.kt

@@ -0,0 +1,36 @@
+package com.atmob.keyboard_android.component
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import android.widget.TextView
+import com.atmob.keyboard_android.R
+import com.atmob.keyboard_android.component.base.BaseUIComponent
+import com.atmob.keyboard_android.ext.click
+
+/**
+ * 权限提示条
+ */
+class PermissionTipComponent @JvmOverloads constructor(
+    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
+) : BaseUIComponent(context, attrs, defStyleAttr) {
+    private lateinit var vTip: TextView
+    private lateinit var vCloseBtn: View
+
+    override fun onInflateViewId(): Int {
+        return R.layout.component_permission_tip
+    }
+
+    override fun findView(view: View) {
+        vTip = view.findViewById(R.id.tip)
+        vCloseBtn = view.findViewById(R.id.close_btn)
+    }
+
+    override fun bindView(view: View) {
+        // 提示文案
+        vTip.text = context.resources.getString(R.string.paste_permission_tip)
+        vCloseBtn.click {
+            // 关闭提示条
+        }
+    }
+}

+ 7 - 0
plugins/keyboard_android/android/src/main/res/drawable/bg_permission_tip.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <solid android:color="@color/bg_permission_tip" />
+    <corners android:radius="9dp" />
+</shape>

+ 11 - 1
plugins/keyboard_android/android/src/main/res/layout/component_ai_keyboard.xml

@@ -6,12 +6,22 @@
     android:orientation="vertical"
     tools:background="@mipmap/bg_keyboard">
 
+    <com.atmob.keyboard_android.component.PermissionTipComponent
+        android:id="@+id/permission_tip"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="12dp"
+        android:layout_marginTop="8dp"
+        android:layout_marginEnd="12dp"
+        android:visibility="gone"
+        tools:visibility="visible" />
+
     <FrameLayout
         android:id="@+id/tar_bar_layout"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
-        android:layout_marginTop="14dp"
+        android:layout_marginTop="6dp"
         android:layout_marginBottom="14dp"
         android:background="@drawable/bg_tab_indicator"
         android:padding="2dp"

+ 36 - 0
plugins/keyboard_android/android/src/main/res/layout/component_permission_tip.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@drawable/bg_permission_tip"
+        android:gravity="center_vertical"
+        android:orientation="horizontal">
+
+        <TextView
+            android:id="@+id/tip"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="8dp"
+            android:layout_marginTop="3dp"
+            android:layout_marginBottom="3dp"
+            android:layout_weight="1"
+            android:ellipsize="end"
+            android:maxLines="1"
+            android:text="@string/paste_permission_tip"
+            android:textColor="@color/text_permission_tip"
+            android:textSize="11sp"
+            android:textStyle="normal" />
+
+        <ImageView
+            android:id="@+id/close_btn"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_marginStart="8dp"
+            android:layout_marginEnd="8dp"
+            android:src="@mipmap/ic_close" />
+    </LinearLayout>
+</FrameLayout>

二進制
plugins/keyboard_android/android/src/main/res/mipmap-xxxhdpi/ic_close.png


+ 4 - 0
plugins/keyboard_android/android/src/main/res/values/colors.xml

@@ -30,4 +30,8 @@
     <color name="text_paste_tip">#996DFF</color>
     <!-- AI生成内容的边框 -->
     <color name="bg_ai_chat_content_border">#996DFF</color>
+    <!-- 权限提示的背景 -->
+    <color name="bg_permission_tip">#FFF8EF</color>
+    <!-- 权限提示的文字颜色 -->
+    <color name="text_permission_tip">#FFA616</color>
 </resources>

+ 1 - 0
plugins/keyboard_android/android/src/main/res/values/string.xml

@@ -18,4 +18,5 @@
     <string name="send">发送</string>
     <string name="paste_tip">粘贴你想说的话,润色升华</string>
     <string name="re_generate">重新生成</string>
+    <string name="paste_permission_tip">“允许”【从其他app粘贴】,不再弹出询问弹窗></string>
 </resources>