From ebdb85fa0ece2cbdf6c9042f0a8190750d10b477 Mon Sep 17 00:00:00 2001 From: hugh <1012760428@qq.com> Date: Sat, 31 Jan 2026 17:14:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E5=8F=8C=E5=87=BB=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=A3=81=E7=BA=B8=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 SettingsFragment 中添加双击开关控件 - 添加双击设置的加载和保存逻辑 - 在布局文件中添加"交互设置"卡片 - 包含双击开关和说明文字 Co-Authored-By: Claude Sonnet 4.5 --- .../cn/hugh/bz/gk2/ui/SettingsFragment.java | 28 ++++++++++ app/src/main/res/layout/fragment_settings.xml | 54 +++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/app/src/main/java/cn/hugh/bz/gk2/ui/SettingsFragment.java b/app/src/main/java/cn/hugh/bz/gk2/ui/SettingsFragment.java index 59e095a..b373de4 100644 --- a/app/src/main/java/cn/hugh/bz/gk2/ui/SettingsFragment.java +++ b/app/src/main/java/cn/hugh/bz/gk2/ui/SettingsFragment.java @@ -47,6 +47,9 @@ public class SettingsFragment extends Fragment { private Switch switchVideoMuted; private Switch switchVideoPauseOnBattery; + // 双击设置控件 + private Switch switchDoubleTapEnabled; + // 图片选择器 private ActivityResultLauncher pickImageLauncher; @@ -68,6 +71,7 @@ public class SettingsFragment extends Fragment { initViews(view); loadBackgroundConfig(); loadVideoSettings(); + loadDoubleTapSettings(); } private void initViews(View view) { @@ -116,7 +120,11 @@ public class SettingsFragment extends Fragment { switchVideoMuted = view.findViewById(R.id.switchVideoMuted); switchVideoPauseOnBattery = view.findViewById(R.id.switchVideoPauseOnBattery); + // 双击设置控件 + switchDoubleTapEnabled = view.findViewById(R.id.switchDoubleTapEnabled); + setupVideoSettingsListeners(); + setupDoubleTapListener(); } private void setupVideoSettingsListeners() { @@ -241,10 +249,30 @@ public class SettingsFragment extends Fragment { switchVideoPauseOnBattery.setEnabled(enabled); } + /** + * 设置双击开关监听器 + */ + private void setupDoubleTapListener() { + switchDoubleTapEnabled.setOnCheckedChangeListener((buttonView, isChecked) -> { + AppConfig config = wallpaperPrefs.loadConfig(); + config.setDoubleTapEnabled(isChecked); + wallpaperPrefs.saveConfig(config); + }); + } + + /** + * 加载双击设置 + */ + private void loadDoubleTapSettings() { + AppConfig config = wallpaperPrefs.loadConfig(); + switchDoubleTapEnabled.setChecked(config.isDoubleTapEnabled()); + } + @Override public void onResume() { super.onResume(); loadBackgroundConfig(); loadVideoSettings(); + loadDoubleTapSettings(); } } diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index 69b0dd4..b33b082 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -214,6 +214,60 @@ + + + + + + + + + + + + + + + +