diff --git a/positions/build.properties b/positions/build.properties index 86aca6e3..5cdb7e0d 100644 --- a/positions/build.properties +++ b/positions/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Mon Nov 10 03:35:32 GMT 2025 +#Mon Nov 10 12:54:12 GMT 2025 stageCount=18 libraryProject= baseVersion=15.0 publishVersion=15.0.17 -buildCount=71 +buildCount=76 baseBetaVersion=15.0.18 diff --git a/positions/src/beta/res/xml/shortcuts.xml b/positions/src/beta/res/xml/shortcuts.xml deleted file mode 100644 index 3b6d5865..00000000 --- a/positions/src/beta/res/xml/shortcuts.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - diff --git a/positions/src/beta/res/xml/shortcutsmain.xml b/positions/src/beta/res/xml/shortcutsmain.xml new file mode 100644 index 00000000..caa5f196 --- /dev/null +++ b/positions/src/beta/res/xml/shortcutsmain.xml @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/positions/src/beta/res/xml/shortcutsplus.xml b/positions/src/beta/res/xml/shortcutsplus.xml new file mode 100644 index 00000000..b486fbf9 --- /dev/null +++ b/positions/src/beta/res/xml/shortcutsplus.xml @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/positions/src/main/AndroidManifest.xml b/positions/src/main/AndroidManifest.xml index e50e3a00..d91a459f 100644 --- a/positions/src/main/AndroidManifest.xml +++ b/positions/src/main/AndroidManifest.xml @@ -48,15 +48,15 @@ + android:resource="@xml/shortcutsmain" /> @@ -68,7 +68,7 @@ + android:resource="@xml/shortcutsplus" /> diff --git a/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java b/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java index ebf92599..1df78aeb 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java +++ b/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java @@ -22,7 +22,7 @@ import cc.winboll.studio.positions.activities.LocationActivity; import cc.winboll.studio.positions.activities.WinBoLLActivity; import cc.winboll.studio.positions.utils.AppConfigsUtil; import cc.winboll.studio.positions.utils.ServiceUtil; -import cc.winboll.studio.positions.utils.AppIconSwitcher; +import cc.winboll.studio.positions.utils.AppIconUtils; /** * 主页面:仅负责 @@ -102,16 +102,13 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity { } /** - * 处理快捷菜单的「切换入口」请求 + * 处理应用图标快捷菜单的请求 */ private void handleSwitchRequest() { Intent intent = getIntent(); - if (intent != null && "switch_launcher_main".equals(intent.getDataString())) { - ToastUtils.show("应用级别切换到悟空笔记"); - AppIconSwitcher.switchToWukongIcon(this); - } else if (intent != null && "switch_launcher_laojun".equals(intent.getDataString())) { - ToastUtils.show("應用級別切換到老君道說"); - AppIconSwitcher.switchToLaojunIcon(this); + if (intent != null && "open_app_plus".equals(intent.getDataString())) { + ToastUtils.show("已添加" + getString(R.string.app_name) + "附加组件"); + AppIconUtils.addPlusIcon(this); } } diff --git a/positions/src/main/java/cc/winboll/studio/positions/activities/PlusActivity.java b/positions/src/main/java/cc/winboll/studio/positions/activities/PlusActivity.java new file mode 100644 index 00000000..7e3112cb --- /dev/null +++ b/positions/src/main/java/cc/winboll/studio/positions/activities/PlusActivity.java @@ -0,0 +1,36 @@ +package cc.winboll.studio.positions.activities; + +import android.content.Intent; +import android.os.Bundle; +import cc.winboll.studio.libappbase.ToastUtils; +import cc.winboll.studio.positions.MainActivity; +import cc.winboll.studio.positions.R; +import cc.winboll.studio.positions.utils.AppIconUtils; + +/** + * @Author ZhanGSKen&豆包大模型 + * @Date 2025/11/10 18:17 + */ +public class PlusActivity extends MainActivity { + + public static final String TAG = "PlusActivity"; + public static final String ACTION_HIDE_APP_PLUS = "cc.winboll.studio.positions.PlusActivity.ACTION_HIDE_APP_PLUS"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + handleSwitchRequest(); + } + + /** + * 处理应用图标快捷菜单的请求 + */ + private void handleSwitchRequest() { + Intent intent = getIntent(); + if (intent != null && "hide_app_plus".equals(intent.getDataString())) { + ToastUtils.show("已移除" + getString(R.string.app_name) + "附加组件"); + AppIconUtils.addPlusIcon(this); + } + } +} diff --git a/positions/src/main/java/cc/winboll/studio/positions/utils/AppIconSwitcher.java b/positions/src/main/java/cc/winboll/studio/positions/utils/AppIconUtils.java similarity index 57% rename from positions/src/main/java/cc/winboll/studio/positions/utils/AppIconSwitcher.java rename to positions/src/main/java/cc/winboll/studio/positions/utils/AppIconUtils.java index 535242b7..0361e1e3 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/utils/AppIconSwitcher.java +++ b/positions/src/main/java/cc/winboll/studio/positions/utils/AppIconUtils.java @@ -12,104 +12,77 @@ import android.content.pm.PackageManager; import android.os.Build; import android.util.Log; import android.widget.Toast; +import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.positions.R; +import cc.winboll.studio.positions.activities.PlusActivity; -public class AppIconSwitcher { - public static final String TAG = "AppIconSwitcher"; - - // 组件名常量(需与 AndroidManifest 一致) - private static final String WUKONG_ACTIVITY = "cc.winboll.studio.positions.MainActivityWukong"; - private static final String LAOJUN_ACTIVITY = "cc.winboll.studio.positions.MainActivityLaojun"; +public class AppIconUtils { + public static final String TAG = "AppIconUtils"; // 快捷方式配置(名称+图标,需与实际资源匹配) - private static final String WUKONG_SHORTCUT_NAME = "位置服务-Wukong"; - private static final int WUKONG_SHORTCUT_ICON = R.drawable.ic_launcher; // Wukong 图标资源 - private static final String LAOJUN_SHORTCUT_NAME = "位置服务-Laojun"; - private static final int LAOJUN_SHORTCUT_ICON = R.mipmap.ic_launcher; // Laojun 图标资源 +// private static final String PLUS_SHORTCUT_NAME = "位置服务-Laojun"; +// private static final int PLUS_SHORTCUT_ICON = R.mipmap.ic_launcher; // Laojun 图标资源 /** - * 切换到 Laojun 图标:禁用 Wukong,启用 Laojun + 创建 Laojun 快捷方式 + * 添加Plus组件与图标 */ - public static boolean switchToLaojunIcon(Context context) { + public static boolean addPlusIcon(Context context) { if (context == null) { - Log.e(TAG, "切换失败:上下文为空"); + LogUtils.d(TAG, "切换失败:上下文为空"); Toast.makeText(context, "图标切换失败", Toast.LENGTH_SHORT).show(); return false; } PackageManager pm = context.getPackageManager(); - ComponentName wukongComponent = new ComponentName(context, WUKONG_ACTIVITY); - ComponentName laojunComponent = new ComponentName(context, LAOJUN_ACTIVITY); + ComponentName plusComponent = new ComponentName(context, PlusActivity.ACTION_HIDE_APP_PLUS); try { - // 1. 禁用 Wukong 组件,启用 Laojun 组件 - disableComponent(pm, wukongComponent); - enableComponent(pm, laojunComponent); + enableComponent(pm, plusComponent); // 2. 创建 Laojun 组件对应的快捷方式(自动去重) - boolean shortcutCreated = createComponentShortcut(context, laojunComponent, LAOJUN_SHORTCUT_NAME, LAOJUN_SHORTCUT_ICON); - - // 3. 通知桌面刷新图标 - context.sendBroadcast(new Intent(Intent.ACTION_PACKAGE_CHANGED) - .setData(android.net.Uri.parse("package:" + context.getPackageName()))); - - // 4. 反馈结果 - String logMsg = shortcutCreated ? "启用 Laojun + 快捷方式创建成功" : "启用 Laojun 成功,快捷方式创建失败"; - String toastMsg = shortcutCreated ? "图标切换为 Laojun,已创建快捷方式" : "图标切换为 Laojun,快捷方式创建失败"; - Log.d(TAG, logMsg); - Toast.makeText(context, toastMsg, Toast.LENGTH_SHORT).show(); - +// boolean shortcutCreated = createComponentShortcut(context, plusComponent, PLUS_SHORTCUT_NAME, PLUS_SHORTCUT_ICON); +// +// // 3. 通知桌面刷新图标 +// context.sendBroadcast(new Intent(Intent.ACTION_PACKAGE_CHANGED) +// .setData(android.net.Uri.parse("package:" + context.getPackageName()))); +// +// // 4. 反馈结果 +// String logMsg = shortcutCreated ? "启用 Laojun + 快捷方式创建成功" : "启用 Laojun 成功,快捷方式创建失败"; +// String toastMsg = shortcutCreated ? "图标切换为 Laojun,已创建快捷方式" : "图标切换为 Laojun,快捷方式创建失败"; +// LogUtils.d(TAG, logMsg); +// Toast.makeText(context, toastMsg, Toast.LENGTH_SHORT).show(); +// return true; } catch (Exception e) { - Log.e(TAG, "Laojun 图标切换失败:" + e.getMessage()); + LogUtils.e(TAG, "Laojun 图标切换失败:" + e.getMessage()); // 失败兜底:启用 Wukong 组件 - enableComponent(pm, wukongComponent); - Toast.makeText(context, "图标切换失败", Toast.LENGTH_SHORT).show(); + //enableComponent(pm, wukongComponent); + Toast.makeText(context, "图标切换失败" + e.getMessage(), Toast.LENGTH_SHORT).show(); return false; } } + /** - * 切换到 Wukong 图标:启用 Wukong,禁用 Laojun + 创建 Wukong 快捷方式 + * 移除Plus组件 */ - public static boolean switchToWukongIcon(Context context) { + public static boolean removePlusIcon(Context context) { if (context == null) { - Log.e(TAG, "切换失败:上下文为空"); + LogUtils.d(TAG, "切换失败:上下文为空"); Toast.makeText(context, "图标切换失败", Toast.LENGTH_SHORT).show(); return false; } PackageManager pm = context.getPackageManager(); - ComponentName wukongComponent = new ComponentName(context, WUKONG_ACTIVITY); - ComponentName laojunComponent = new ComponentName(context, LAOJUN_ACTIVITY); + ComponentName plusComponent = new ComponentName(context, PlusActivity.ACTION_HIDE_APP_PLUS); try { - // 1. 启用 Wukong 组件,禁用 Laojun 组件 - enableComponent(pm, wukongComponent); - disableComponent(pm, laojunComponent); - - // 2. 创建 Wukong 组件对应的快捷方式(自动去重) - boolean shortcutCreated = createComponentShortcut(context, wukongComponent, WUKONG_SHORTCUT_NAME, WUKONG_SHORTCUT_ICON); - - // 3. 通知桌面刷新图标 - context.sendBroadcast(new Intent(Intent.ACTION_PACKAGE_CHANGED) - .setData(android.net.Uri.parse("package:" + context.getPackageName()))); - - // 4. 反馈结果 - String logMsg = shortcutCreated ? "启用 Wukong + 快捷方式创建成功" : "启用 Wukong 成功,快捷方式创建失败"; - String toastMsg = shortcutCreated ? "图标切换为 Wukong,已创建快捷方式" : "图标切换为 Wukong,快捷方式创建失败"; - Log.d(TAG, logMsg); - Toast.makeText(context, toastMsg, Toast.LENGTH_SHORT).show(); - - return true; - + disableComponent(pm, plusComponent); + return true; } catch (Exception e) { - Log.e(TAG, "Wukong 图标切换失败:" + e.getMessage()); - // 失败兜底:启用 Wukong 组件 - enableComponent(pm, wukongComponent); - Toast.makeText(context, "图标切换失败", Toast.LENGTH_SHORT).show(); - return false; + LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); + return false; } } @@ -122,7 +95,7 @@ public class AppIconSwitcher { */ private static boolean createComponentShortcut(Context context, ComponentName component, String name, int iconRes) { if (context == null || component == null || name == null || iconRes == 0) { - Log.e(TAG, "快捷方式创建失败:参数为空"); + LogUtils.d(TAG, "快捷方式创建失败:参数为空"); return false; } @@ -132,14 +105,14 @@ public class AppIconSwitcher { PackageManager pm = context.getPackageManager(); android.content.pm.ShortcutManager shortcutManager = context.getSystemService(android.content.pm.ShortcutManager.class); if (shortcutManager == null || !shortcutManager.isRequestPinShortcutSupported()) { - Log.e(TAG, "系统不支持创建快捷方式"); + LogUtils.d(TAG, "系统不支持创建快捷方式"); return false; } // 检查是否已存在该组件的快捷方式(去重) for (android.content.pm.ShortcutInfo info : shortcutManager.getPinnedShortcuts()) { if (component.getClassName().equals(info.getIntent().getComponent().getClassName())) { - Log.d(TAG, "快捷方式已存在:" + component.getClassName()); + LogUtils.d(TAG, "快捷方式已存在:" + component.getClassName()); return true; } } @@ -163,7 +136,7 @@ public class AppIconSwitcher { return true; } catch (Exception e) { - Log.e(TAG, "Android O+ 快捷方式创建失败:" + e.getMessage()); + LogUtils.d(TAG, "Android O+ 快捷方式创建失败:" + e.getMessage()); return false; } } else { @@ -187,7 +160,7 @@ public class AppIconSwitcher { return true; } catch (Exception e) { - Log.e(TAG, "Android O- 快捷方式创建失败:" + e.getMessage()); + LogUtils.d(TAG, "Android O- 快捷方式创建失败:" + e.getMessage()); return false; } } diff --git a/positions/src/main/res/drawable/ic_positions_plus.png b/positions/src/main/res/drawable/ic_positions_plus.png new file mode 100644 index 00000000..4155d069 Binary files /dev/null and b/positions/src/main/res/drawable/ic_positions_plus.png differ diff --git a/positions/src/main/res/values/strings.xml b/positions/src/main/res/values/strings.xml index 4dfd1953..77c9ad14 100644 --- a/positions/src/main/res/values/strings.xml +++ b/positions/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ Positions - Positions - 切换到悟空笔记 - 切换到老君道說 - 切换功能不可用 + PositionsPlus + 隐藏附加组件 + 开启隐藏组件 + 隐藏组件切换功能不可用 diff --git a/positions/src/main/res/xml/shortcuts.xml b/positions/src/main/res/xml/shortcuts.xml deleted file mode 100644 index c14f0a72..00000000 --- a/positions/src/main/res/xml/shortcuts.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - diff --git a/positions/src/main/res/xml/shortcutsmain.xml b/positions/src/main/res/xml/shortcutsmain.xml new file mode 100644 index 00000000..522051bb --- /dev/null +++ b/positions/src/main/res/xml/shortcutsmain.xml @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/positions/src/main/res/xml/shortcutsplus.xml b/positions/src/main/res/xml/shortcutsplus.xml new file mode 100644 index 00000000..0c160ea9 --- /dev/null +++ b/positions/src/main/res/xml/shortcutsplus.xml @@ -0,0 +1,19 @@ + + + + + + + + +