fix: 修正固定壁纸逻辑,仅作为收藏功能
- 移除固定壁纸停止自动更新的检查逻辑 - 固定壁纸只是保存用户喜欢的壁纸 URL - app 的启用/禁用使用独立的 isEnabled 标志控制 - 四指点击:在相册中打开固定壁纸并设置 app 为禁用 - 四指点击检查的是 isEnabled 而不是 isFixedWallpaperEnabled Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f13bd89b06
commit
fe6b9ca029
1 file changed
+6
-35
@@ -358,35 +358,6 @@ public class AutoWallpaperService extends WallpaperService {
|
|||||||
// Load current wallpaper config
|
// Load current wallpaper config
|
||||||
AppConfig config = prefs.loadConfig();
|
AppConfig config = prefs.loadConfig();
|
||||||
|
|
||||||
// 检查是否启用了固定壁纸
|
|
||||||
if (config.isFixedWallpaperEnabled() && config.getFixedWallpaperUri() != null) {
|
|
||||||
String fixedUri = config.getFixedWallpaperUri();
|
|
||||||
fileLogger.log(TAG, "Fixed wallpaper enabled: " + fixedUri);
|
|
||||||
|
|
||||||
// 停止视频播放
|
|
||||||
stopVideo();
|
|
||||||
|
|
||||||
// 加载固定壁纸(仅支持图片)
|
|
||||||
// 从 URI 中提取文件名作为显示名称
|
|
||||||
String displayName = "Fixed Wallpaper";
|
|
||||||
if (fixedUri.contains("/")) {
|
|
||||||
String[] parts = fixedUri.split("/");
|
|
||||||
displayName = parts[parts.length - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
WallpaperMedia fixedMedia = new WallpaperMedia(
|
|
||||||
fixedUri,
|
|
||||||
null, // folderPath
|
|
||||||
displayName,
|
|
||||||
System.currentTimeMillis(), // lastModified
|
|
||||||
0, // fileSize
|
|
||||||
MediaType.IMAGE
|
|
||||||
);
|
|
||||||
fileLogger.log(TAG, "Displaying fixed wallpaper: " + fixedUri);
|
|
||||||
loadAndDrawImageAsync(holder, fixedMedia, config, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config.isEnabled() || !hasAvailableMedia(config)) {
|
if (!config.isEnabled() || !hasAvailableMedia(config)) {
|
||||||
Log.w(TAG, "Wallpaper not enabled or no media. Enabled: " + config.isEnabled() + ", HasMedia: " + hasAvailableMedia(config));
|
Log.w(TAG, "Wallpaper not enabled or no media. Enabled: " + config.isEnabled() + ", HasMedia: " + hasAvailableMedia(config));
|
||||||
// 直接绘制占位符(不需要后台线程)
|
// 直接绘制占位符(不需要后台线程)
|
||||||
@@ -990,8 +961,8 @@ public class AutoWallpaperService extends WallpaperService {
|
|||||||
// 获取当前配置
|
// 获取当前配置
|
||||||
AppConfig config = prefs.loadConfig();
|
AppConfig config = prefs.loadConfig();
|
||||||
|
|
||||||
// 检查当前是否是禁用状态
|
// 检查 app 是否已经禁用
|
||||||
if (config.isFixedWallpaperEnabled()) {
|
if (!config.isEnabled()) {
|
||||||
// app 已经是禁用状态,什么都不做
|
// app 已经是禁用状态,什么都不做
|
||||||
fileLogger.log(TAG, "App already disabled, ignoring four-finger tap");
|
fileLogger.log(TAG, "App already disabled, ignoring four-finger tap");
|
||||||
return;
|
return;
|
||||||
@@ -1014,12 +985,12 @@ public class AutoWallpaperService extends WallpaperService {
|
|||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
// 打开相册后,将 app 状态改为禁用
|
// 打开相册后,将 app 设置为禁用
|
||||||
config.setFixedWallpaperEnabled(true);
|
config.setEnabled(false);
|
||||||
prefs.saveConfig(config);
|
prefs.saveConfig(config);
|
||||||
|
|
||||||
fileLogger.log(TAG, "Opened gallery for fixed wallpaper, app disabled");
|
fileLogger.log(TAG, "Opened gallery, app disabled");
|
||||||
android.widget.Toast.makeText(AutoWallpaperService.this, "已在相册中打开固定壁纸,请在相册中设置为壁纸", android.widget.Toast.LENGTH_LONG).show();
|
android.widget.Toast.makeText(AutoWallpaperService.this, "已在相册中打开固定壁纸,自动更新已禁用", android.widget.Toast.LENGTH_LONG).show();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Failed to open gallery", e);
|
Log.e(TAG, "Failed to open gallery", e);
|
||||||
fileLogger.error(TAG, "Failed to open gallery: " + e.getMessage(), e);
|
fileLogger.error(TAG, "Failed to open gallery: " + e.getMessage(), e);
|
||||||
|
|||||||
Reference in new issue
Block a user