feat: 添加详细日志到按钮点击事件以调试问题

- 在 CurrentWallpaperFragment 的 changeWallpaperNow() 和 showNextWallpaper() 添加详细日志
- 在 HomeFragment 的 changeWallpaperNow() 添加详细日志
- 追踪按钮点击、文件夹数量检查、广播发送等步骤

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hughhuangandClaude Sonnet 4.5 committed 2026-01-23 17:55:18 +08:00
1 parent 6b17d31069
commit 37aa54989e
2 files changed
+28 -1

No files matched your search

@@ -116,14 +116,23 @@ public class CurrentWallpaperFragment extends Fragment {
} }
private void changeWallpaperNow() { private void changeWallpaperNow() {
android.util.Log.i("CurrentWallpaperFragment", "changeWallpaperNow() called");
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log("CurrentWallpaperFragment", "changeWallpaperNow() called");
cn.hugh.bz.gk2.model.AppConfig config = prefs.loadConfig(); cn.hugh.bz.gk2.model.AppConfig config = prefs.loadConfig();
android.util.Log.i("CurrentWallpaperFragment", "Selected folders count: " + config.getSelectedFolders().size());
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log("CurrentWallpaperFragment", "Selected folders count: " + config.getSelectedFolders().size());
if (config.getSelectedFolders().isEmpty()) { if (config.getSelectedFolders().isEmpty()) {
android.util.Log.w("CurrentWallpaperFragment", "No folders selected, showing toast");
Toast.makeText(requireContext(), "请先选择文件夹", Toast.LENGTH_SHORT).show(); Toast.makeText(requireContext(), "请先选择文件夹", Toast.LENGTH_SHORT).show();
return; return;
} }
android.util.Log.i("CurrentWallpaperFragment", "changeWallpaperNow: sending broadcast"); android.util.Log.i("CurrentWallpaperFragment", "changeWallpaperNow: sending broadcast");
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log("CurrentWallpaperFragment", "changeWallpaperNow: sending broadcast");
// 发送广播通知壁纸服务立即更换壁纸 // 发送广播通知壁纸服务立即更换壁纸
Intent intent = new Intent("cn.hugh.bz.gk2.ACTION_CHANGE_WALLPAPER"); Intent intent = new Intent("cn.hugh.bz.gk2.ACTION_CHANGE_WALLPAPER");
intent.putExtra("force_change", true); // 用户主动触发 intent.putExtra("force_change", true); // 用户主动触发
@@ -139,14 +148,23 @@ public class CurrentWallpaperFragment extends Fragment {
} }
private void showNextWallpaper() { private void showNextWallpaper() {
android.util.Log.i("CurrentWallpaperFragment", "showNextWallpaper() called");
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log("CurrentWallpaperFragment", "showNextWallpaper() called");
cn.hugh.bz.gk2.model.AppConfig config = prefs.loadConfig(); cn.hugh.bz.gk2.model.AppConfig config = prefs.loadConfig();
android.util.Log.i("CurrentWallpaperFragment", "showNextWallpaper: Selected folders count: " + config.getSelectedFolders().size());
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log("CurrentWallpaperFragment", "showNextWallpaper: Selected folders count: " + config.getSelectedFolders().size());
if (config.getSelectedFolders().isEmpty()) { if (config.getSelectedFolders().isEmpty()) {
android.util.Log.w("CurrentWallpaperFragment", "showNextWallpaper: No folders selected, showing toast");
Toast.makeText(requireContext(), "请先选择文件夹", Toast.LENGTH_SHORT).show(); Toast.makeText(requireContext(), "请先选择文件夹", Toast.LENGTH_SHORT).show();
return; return;
} }
android.util.Log.i("CurrentWallpaperFragment", "showNextWallpaper: sending broadcast"); android.util.Log.i("CurrentWallpaperFragment", "showNextWallpaper: sending broadcast");
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log("CurrentWallpaperFragment", "showNextWallpaper: sending broadcast");
// 发送广播通知壁纸服务切换到下一张 // 发送广播通知壁纸服务切换到下一张
Intent intent = new Intent("cn.hugh.bz.gk2.ACTION_CHANGE_WALLPAPER"); Intent intent = new Intent("cn.hugh.bz.gk2.ACTION_CHANGE_WALLPAPER");
intent.putExtra("force_change", true); // 用户主动触发 intent.putExtra("force_change", true); // 用户主动触发
@@ -233,12 +233,21 @@ public class HomeFragment extends Fragment {
} }
private void changeWallpaperNow() { private void changeWallpaperNow() {
android.util.Log.i(TAG, "changeWallpaperNow() called");
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log(TAG, "changeWallpaperNow() called");
android.util.Log.i(TAG, "Selected folders count: " + config.getSelectedFolders().size());
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log(TAG, "Selected folders count: " + config.getSelectedFolders().size());
if (config.getSelectedFolders().isEmpty()) { if (config.getSelectedFolders().isEmpty()) {
android.util.Log.w(TAG, "No folders selected, showing toast");
Toast.makeText(requireContext(), "请先选择文件夹", Toast.LENGTH_SHORT).show(); Toast.makeText(requireContext(), "请先选择文件夹", Toast.LENGTH_SHORT).show();
return; return;
} }
android.util.Log.i("HomeFragment", "changeWallpaperNow: sending broadcast"); android.util.Log.i(TAG, "changeWallpaperNow: sending broadcast");
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log(TAG, "changeWallpaperNow: sending broadcast");
// 发送广播通知壁纸服务立即更换壁纸 // 发送广播通知壁纸服务立即更换壁纸
Intent intent = new Intent("cn.hugh.bz.gk2.ACTION_CHANGE_WALLPAPER"); Intent intent = new Intent("cn.hugh.bz.gk2.ACTION_CHANGE_WALLPAPER");
intent.putExtra("force_change", true); // 用户主动触发 intent.putExtra("force_change", true); // 用户主动触发