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 @@ + + + + + + + + + + + + + + + +