fix: 修正四指点击逻辑
- 四指点击只在 app 启用状态且有固定壁纸时才触发 - 触发后调用系统壁纸设置,并将 app 状态改为禁用 - 如果 app 已经禁用,什么都不做 - 如果没有设置固定壁纸,提示用户先在设置页面选择 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2fa0902b72
commit
c314c2d365
1 file changed
+25
-18
@@ -982,14 +982,25 @@ public class AutoWallpaperService extends WallpaperService {
|
||||
int action = event.getAction() & android.view.MotionEvent.ACTION_MASK;
|
||||
|
||||
if (pointerCount >= 4 && action == android.view.MotionEvent.ACTION_POINTER_DOWN) {
|
||||
fileLogger.log(TAG, "Four-finger tap detected, launching wallpaper picker");
|
||||
fileLogger.log(TAG, "Four-finger tap detected");
|
||||
|
||||
// 获取固定壁纸的 URI
|
||||
// 获取当前配置
|
||||
AppConfig config = prefs.loadConfig();
|
||||
|
||||
// 检查当前是否是禁用状态
|
||||
if (config.isFixedWallpaperEnabled()) {
|
||||
// app 已经是禁用状态,什么都不做
|
||||
fileLogger.log(TAG, "App already disabled, ignoring four-finger tap");
|
||||
return;
|
||||
}
|
||||
|
||||
// app 是启用状态,检查是否有设置固定壁纸
|
||||
String fixedWallpaperUri = config.getFixedWallpaperUri();
|
||||
|
||||
if (fixedWallpaperUri != null && !fixedWallpaperUri.isEmpty()) {
|
||||
// 有固定壁纸,直接启动系统壁纸设置并传入 URI
|
||||
// 有固定壁纸,调用系统壁纸设置
|
||||
fileLogger.log(TAG, "Launching system wallpaper picker with fixed wallpaper");
|
||||
|
||||
Uri uri = Uri.parse(fixedWallpaperUri);
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
|
||||
@@ -1000,26 +1011,22 @@ public class AutoWallpaperService extends WallpaperService {
|
||||
|
||||
try {
|
||||
startActivity(intent);
|
||||
fileLogger.log(TAG, "Launched system wallpaper picker with fixed wallpaper");
|
||||
|
||||
// 设置完成后,将 app 状态改为禁用
|
||||
config.setFixedWallpaperEnabled(true);
|
||||
prefs.saveConfig(config);
|
||||
|
||||
fileLogger.log(TAG, "Fixed wallpaper set to system, app disabled");
|
||||
android.widget.Toast.makeText(AutoWallpaperService.this, "已将固定壁纸设置为系统壁纸,自动更新已禁用", android.widget.Toast.LENGTH_LONG).show();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to launch wallpaper picker", e);
|
||||
fileLogger.error(TAG, "Failed to launch wallpaper picker: " + e.getMessage(), e);
|
||||
android.widget.Toast.makeText(AutoWallpaperService.this, "打开壁纸设置失败", android.widget.Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
// 没有固定壁纸,只恢复自动更新
|
||||
fileLogger.log(TAG, "No fixed wallpaper set, just resuming auto-update");
|
||||
|
||||
// 清除固定壁纸设置(确保干净)
|
||||
config.setFixedWallpaperEnabled(false);
|
||||
config.setFixedWallpaperUri(null);
|
||||
prefs.saveConfig(config);
|
||||
|
||||
// 恢复自动更新
|
||||
forceChangeNext = true;
|
||||
handler.post(() -> {
|
||||
android.widget.Toast.makeText(AutoWallpaperService.this, "已恢复自动更新", android.widget.Toast.LENGTH_SHORT).show();
|
||||
drawWallpaper();
|
||||
});
|
||||
// 没有设置固定壁纸,提示用户
|
||||
fileLogger.log(TAG, "No fixed wallpaper set, showing hint");
|
||||
android.widget.Toast.makeText(AutoWallpaperService.this, "请先在设置页面选择固定壁纸", android.widget.Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user