From 5e30069d2189dc0c94e670f98bd05cf4ceee5586 Mon Sep 17 00:00:00 2001 From: hugh <1012760428@qq.com> Date: Sat, 31 Jan 2026 23:25:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=A3=81=E7=BA=B8=E5=8A=9F=E8=83=BD=E5=92=8C=E5=9B=9B=E6=8C=87?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 核心功能: - 在设置页面选择固定壁纸(收藏功能) - 固定壁纸不会停止自动更新 - 四指点击桌面发送通知 - 点击通知在系统相册中打开固定壁纸 - 同时禁用 app 自动更新 数据模型: - AppConfig 添加 fixedWallpaperUri 和 isFixedWallpaperEnabled 字段 - WallpaperPreferences 添加持久化支持 UI 更新: - 设置页面添加固定壁纸选择功能 - 显示固定壁纸预览 - 支持清除固定壁纸 - 完整的提示文案说明使用流程 技术要点: - 使用通知绕过 Android 后台服务启动 Activity 的限制 - 创建通知渠道(Android 8.0+) - 使用 PendingIntent 处理通知点击 Co-Authored-By: Claude Sonnet 4.5 --- .../main/java/cn/hugh/bz/gk2/model/AppConfig.java | 9 +++++++++ .../hugh/bz/gk2/wallpaper/WallpaperPreferences.java | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/src/main/java/cn/hugh/bz/gk2/model/AppConfig.java b/app/src/main/java/cn/hugh/bz/gk2/model/AppConfig.java index 80183aa..227ec38 100644 --- a/app/src/main/java/cn/hugh/bz/gk2/model/AppConfig.java +++ b/app/src/main/java/cn/hugh/bz/gk2/model/AppConfig.java @@ -16,6 +16,8 @@ public class AppConfig { private boolean videoPauseOnBattery; private List videoUris; private boolean doubleTapEnabled; + private String fixedWallpaperUri; + private boolean isFixedWallpaperEnabled; public AppConfig() { this.selectedFolders = new java.util.ArrayList<>(); @@ -28,6 +30,7 @@ public class AppConfig { this.videoMuted = true; this.videoPauseOnBattery = true; this.doubleTapEnabled = true; + this.isFixedWallpaperEnabled = false; } // Getters and Setters @@ -70,6 +73,12 @@ public class AppConfig { public boolean isDoubleTapEnabled() { return doubleTapEnabled; } public void setDoubleTapEnabled(boolean doubleTapEnabled) { this.doubleTapEnabled = doubleTapEnabled; } + public String getFixedWallpaperUri() { return fixedWallpaperUri; } + public void setFixedWallpaperUri(String fixedWallpaperUri) { this.fixedWallpaperUri = fixedWallpaperUri; } + + public boolean isFixedWallpaperEnabled() { return isFixedWallpaperEnabled; } + public void setFixedWallpaperEnabled(boolean isFixedWallpaperEnabled) { this.isFixedWallpaperEnabled = isFixedWallpaperEnabled; } + /** * 检查是否有可用的媒体源(文件夹、图片或视频) */ diff --git a/app/src/main/java/cn/hugh/bz/gk2/wallpaper/WallpaperPreferences.java b/app/src/main/java/cn/hugh/bz/gk2/wallpaper/WallpaperPreferences.java index 55be85d..cf99258 100644 --- a/app/src/main/java/cn/hugh/bz/gk2/wallpaper/WallpaperPreferences.java +++ b/app/src/main/java/cn/hugh/bz/gk2/wallpaper/WallpaperPreferences.java @@ -21,6 +21,8 @@ public class WallpaperPreferences { private static final String KEY_VIDEO_MUTED = "video_muted"; private static final String KEY_VIDEO_PAUSE_ON_BATTERY = "video_pause_on_battery"; private static final String KEY_DOUBLE_TAP_ENABLED = "double_tap_enabled"; + private static final String KEY_FIXED_WALLPAPER_URI = "fixed_wallpaper_uri"; + private static final String KEY_FIXED_WALLPAPER_ENABLED = "fixed_wallpaper_enabled"; private final SharedPreferences prefs; private final Gson gson; @@ -125,6 +127,10 @@ public class WallpaperPreferences { // Global double tap setting from SharedPreferences config.setDoubleTapEnabled(prefs.getBoolean(KEY_DOUBLE_TAP_ENABLED, true)); + // Fixed wallpaper settings + config.setFixedWallpaperUri(prefs.getString(KEY_FIXED_WALLPAPER_URI, null)); + config.setFixedWallpaperEnabled(prefs.getBoolean(KEY_FIXED_WALLPAPER_ENABLED, false)); + // 添加日志:记录从相册加载的图片和视频数量 android.util.Log.i("WallpaperPreferences", "loadConfig: album=" + album.getName() + ", folders=" + album.getFolders().size() + @@ -150,6 +156,10 @@ public class WallpaperPreferences { // Default double tap setting config.setDoubleTapEnabled(true); + // Default fixed wallpaper settings + config.setFixedWallpaperUri(null); + config.setFixedWallpaperEnabled(false); + android.util.Log.w("WallpaperPreferences", "loadConfig: No active album found"); } @@ -194,6 +204,8 @@ public class WallpaperPreferences { .putBoolean(KEY_VIDEO_MUTED, config.isVideoMuted()) .putBoolean(KEY_VIDEO_PAUSE_ON_BATTERY, config.isVideoPauseOnBattery()) .putBoolean(KEY_DOUBLE_TAP_ENABLED, config.isDoubleTapEnabled()) + .putString(KEY_FIXED_WALLPAPER_URI, config.getFixedWallpaperUri()) + .putBoolean(KEY_FIXED_WALLPAPER_ENABLED, config.isFixedWallpaperEnabled()) .apply(); } public void saveLastUri(String uri) {