feat: 添加设置页面的双击切换壁纸开关

- 在 SettingsFragment 中添加双击开关控件
- 添加双击设置的加载和保存逻辑
- 在布局文件中添加"交互设置"卡片
- 包含双击开关和说明文字

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hughhuangandClaude Sonnet 4.5 committed 2026-01-31 17:14:52 +08:00
1 parent 520435831f
commit ebdb85fa0e
2 files changed
+82

No files matched your search

@@ -47,6 +47,9 @@ public class SettingsFragment extends Fragment {
private Switch switchVideoMuted;
private Switch switchVideoPauseOnBattery;
// 双击设置控件
private Switch switchDoubleTapEnabled;
// 图片选择器
private ActivityResultLauncher<Intent> 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();
}
}