From ac00b4d6fb6ff8d4e4b9ef54233b2f6b30287eef Mon Sep 17 00:00:00 2001 From: qinglong Date: Sat, 23 May 2026 22:00:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=20APPBase=20=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appbase/build.properties | 4 +- libappbase/build.properties | 4 +- .../studio/libappbase/views/AboutView.java | 2 +- .../views/DebugSwitchInfoImageView.java | 127 ++++++++++++++++++ .../res/layout-night/layout_about_view.xml | 2 +- .../src/main/res/layout/layout_about_view.xml | 2 +- 6 files changed, 134 insertions(+), 7 deletions(-) create mode 100644 libappbase/src/main/java/cc/winboll/studio/libappbase/views/DebugSwitchInfoImageView.java diff --git a/appbase/build.properties b/appbase/build.properties index 2792515..bf134a9 100644 --- a/appbase/build.properties +++ b/appbase/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Wed May 20 16:12:26 HKT 2026 +#Sat May 23 21:29:59 HKT 2026 stageCount=21 libraryProject=libappbase baseVersion=15.20 publishVersion=15.20.20 -buildCount=0 +buildCount=10 baseBetaVersion=15.20.21 diff --git a/libappbase/build.properties b/libappbase/build.properties index 0fab579..bf134a9 100644 --- a/libappbase/build.properties +++ b/libappbase/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Wed May 20 16:12:13 HKT 2026 +#Sat May 23 21:29:59 HKT 2026 stageCount=21 libraryProject=libappbase baseVersion=15.20 publishVersion=15.20.20 -buildCount=0 +buildCount=10 baseBetaVersion=15.20.21 diff --git a/libappbase/src/main/java/cc/winboll/studio/libappbase/views/AboutView.java b/libappbase/src/main/java/cc/winboll/studio/libappbase/views/AboutView.java index 050a8b6..7dafdd8 100644 --- a/libappbase/src/main/java/cc/winboll/studio/libappbase/views/AboutView.java +++ b/libappbase/src/main/java/cc/winboll/studio/libappbase/views/AboutView.java @@ -74,7 +74,7 @@ public class AboutView extends LinearLayout { private EditText metDevUserPassword; // ===================================== 页面视图控件 ===================================== - private DebugSwitchImageView ivAppIcon; + private DebugSwitchInfoImageView ivAppIcon; private TextView tvAppNameVersion; private TextView tvAppDesc; private LinearLayout llFunctionContainer; diff --git a/libappbase/src/main/java/cc/winboll/studio/libappbase/views/DebugSwitchInfoImageView.java b/libappbase/src/main/java/cc/winboll/studio/libappbase/views/DebugSwitchInfoImageView.java new file mode 100644 index 0000000..72679ed --- /dev/null +++ b/libappbase/src/main/java/cc/winboll/studio/libappbase/views/DebugSwitchInfoImageView.java @@ -0,0 +1,127 @@ +package cc.winboll.studio.libappbase.views; + +import android.app.AlertDialog; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.util.AttributeSet; +import android.view.View; +import android.widget.ImageView; +import java.util.UUID; +import cc.winboll.studio.libappbase.GlobalApplication; + +/** + * @Author 豆包&ZhanGSKen + * @Date 2026/04/06 19:32 + * @Describe 应用Logo控件,连续点击6次弹出调试Token对话框,支持复制与重置 + */ +public class DebugSwitchInfoImageView extends ImageView { + + public static final String TAG = "DebugSwitchInfoImageView"; + + // 连续点击计数 + private int mClickCount = 0; + // 目标点击次数 + private static final int TARGET_CLICK_COUNT = 7; + + private static String mDebugToken = null; + private static final String SP_DEBUG_TOKEN = "debug_token_prefs"; + private static final String KEY_DEBUG_TOKEN = "debug_token"; + + public static String getDebugToken() { + if (mDebugToken != null) { + return mDebugToken; + } + Context context = GlobalApplication.getInstance(); + if (context != null) { + SharedPreferences sp = context.getSharedPreferences(SP_DEBUG_TOKEN, Context.MODE_PRIVATE); + mDebugToken = sp.getString(KEY_DEBUG_TOKEN, null); + if (mDebugToken == null) { + mDebugToken = UUID.randomUUID().toString(); + sp.edit().putString(KEY_DEBUG_TOKEN, mDebugToken).apply(); + } + } + return mDebugToken; + } + + public static void resetDebugToken() { + Context context = GlobalApplication.getInstance(); + if (context != null) { + mDebugToken = UUID.randomUUID().toString(); + SharedPreferences sp = context.getSharedPreferences(SP_DEBUG_TOKEN, Context.MODE_PRIVATE); + sp.edit().putString(KEY_DEBUG_TOKEN, mDebugToken).apply(); + } + } + + private void showDebugTokenDialog() { + final AlertDialog dialog = new AlertDialog.Builder(getContext()).create(); + dialog.setTitle("调试Token"); + dialog.setMessage(getDebugToken()); + dialog.setCanceledOnTouchOutside(true); + dialog.setButton(DialogInterface.BUTTON_POSITIVE, "复制到剪贴板", (DialogInterface.OnClickListener) null); + dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "重置", (DialogInterface.OnClickListener) null); + dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "关闭", (DialogInterface.OnClickListener) null); + dialog.setOnShowListener(new DialogInterface.OnShowListener() { + @Override + public void onShow(DialogInterface d) { + dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ClipboardManager cm = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); + cm.setPrimaryClip(ClipData.newPlainText("DebugToken", getDebugToken())); + } + }); + dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + resetDebugToken(); + dialog.setMessage(getDebugToken()); + } + }); + dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + } + }); + } + }); + dialog.show(); + } + + public DebugSwitchInfoImageView(Context context) { + super(context); + init(); + } + + public DebugSwitchInfoImageView(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + public DebugSwitchInfoImageView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(); + } + + public DebugSwitchInfoImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + init(); + } + + private void init() { + setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mClickCount++; + if (mClickCount >= TARGET_CLICK_COUNT) { + mClickCount = 0; + showDebugTokenDialog(); + } + } + }); + } +} + diff --git a/libappbase/src/main/res/layout-night/layout_about_view.xml b/libappbase/src/main/res/layout-night/layout_about_view.xml index a1753ff..14185d1 100644 --- a/libappbase/src/main/res/layout-night/layout_about_view.xml +++ b/libappbase/src/main/res/layout-night/layout_about_view.xml @@ -15,7 +15,7 @@ android:paddingRight="16dp" android:paddingBottom="16dp"> - -