feat: 添加设置页面的双击切换壁纸开关
- 在 SettingsFragment 中添加双击开关控件 - 添加双击设置的加载和保存逻辑 - 在布局文件中添加"交互设置"卡片 - 包含双击开关和说明文字 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
@@ -214,6 +214,60 @@
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<!-- 双击设置卡片 -->
|
||||
<TextView
|
||||
android:id="@+id/tvDoubleTapSettingsLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_lg"
|
||||
android:text="交互设置"
|
||||
android:textSize="@dimen/text_size_xxl"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/text_primary"
|
||||
app:layout_constraintTop_toBottomOf="@id/cardVideoSettings"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/cardDoubleTapSettings"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_sm"
|
||||
app:cardElevation="@dimen/card_elevation"
|
||||
app:cardCornerRadius="@dimen/corner_radius_md"
|
||||
app:cardBackgroundColor="@color/bg_card"
|
||||
app:strokeColor="@color/glass_border"
|
||||
app:strokeWidth="@dimen/glass_border_width"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDoubleTapSettingsLabel"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/card_padding">
|
||||
|
||||
<!-- 启用双击切换 -->
|
||||
<Switch
|
||||
android:id="@+id/switchDoubleTapEnabled"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="启用双击切换壁纸"
|
||||
android:textSize="@dimen/text_size_md"
|
||||
android:textColor="@color/text_primary"
|
||||
android:minHeight="48dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="在桌面双击可快速切换到下一张壁纸"
|
||||
android:textSize="@dimen/text_size_sm"
|
||||
android:textColor="@color/text_secondary" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
Reference in new issue
Block a user