diff --git a/library/core/src/main/res/values-zh-rCN/strings_app.xml b/library/core/src/main/res/values-zh-rCN/strings_app.xml
index ccb25b3eda..e2add53670 100644
--- a/library/core/src/main/res/values-zh-rCN/strings_app.xml
+++ b/library/core/src/main/res/values-zh-rCN/strings_app.xml
@@ -1293,6 +1293,8 @@
在快捷菜单中添加小窗菜单
多开模式
在快捷菜单中添加多开菜单
+ 强制停止应用
+ 在快捷菜单中添加强制停止应用菜单
允许分享应用
始终模糊桌面壁纸
图标背景色
diff --git a/library/core/src/main/res/values/strings_app.xml b/library/core/src/main/res/values/strings_app.xml
index 63910b0579..ef7c361d14 100644
--- a/library/core/src/main/res/values/strings_app.xml
+++ b/library/core/src/main/res/values/strings_app.xml
@@ -1342,6 +1342,8 @@
Add Freeform menu to the shortcut menu
More tasks mode
Add More tasks mode to the shortcut menu
+ Force stop app
+ Add Force stop app menu to the shortcut menu
Allow share app
Always blur launcher wallpaper
Icon background color
diff --git a/library/core/src/main/res/xml/home_other.xml b/library/core/src/main/res/xml/home_other.xml
index 9a71369cca..d3852c4640 100644
--- a/library/core/src/main/res/xml/home_other.xml
+++ b/library/core/src/main/res/xml/home_other.xml
@@ -33,6 +33,12 @@
android:summary="@string/home_other_tasks_shortcut_menu_desc"
android:title="@string/home_other_tasks_shortcut_menu" />
+
+
+
+
0);
initHook(new InfiniteScroll(), PrefsBridge.getBoolean("home_other_infinite_scroll"));
- initHook(new FreeformShortcutMenu(), PrefsBridge.getBoolean("home_other_tasks_shortcut_menu"));
+ initHook(new FreeformShortcutMenu(), PrefsBridge.getBoolean("home_other_tasks_shortcut_menu") || PrefsBridge.getBoolean("home_other_force_stop_shortcut_menu"));
initHook(new EnableIconMonoChrome(), PrefsBridge.getBoolean("home_other_icon_mono_chrome"));
initHook(new HomePortraitReverse(), PrefsBridge.getBoolean("home_other_portrait_reverse"));
initHook(AlwaysBlurWallpaper.INSTANCE, PrefsBridge.getBoolean("home_other_always_blur_launcher_wallpaper"));
diff --git a/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os2/HomePhoneOld.java b/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os2/HomePhoneOld.java
index 819164aea3..56917b393b 100644
--- a/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os2/HomePhoneOld.java
+++ b/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os2/HomePhoneOld.java
@@ -266,7 +266,7 @@ public void onPackageLoaded() {
// 其他
initHook(new HomeMode(), PrefsBridge.getStringAsInt("home_other_home_mode", 0) > 0);
initHook(new InfiniteScroll(), PrefsBridge.getBoolean("home_other_infinite_scroll"));
- initHook(new FreeformShortcutMenu(), (PrefsBridge.getBoolean("home_other_freeform_shortcut_menu") || (PrefsBridge.getBoolean("home_other_tasks_shortcut_menu"))));
+ initHook(new FreeformShortcutMenu(), (PrefsBridge.getBoolean("home_other_freeform_shortcut_menu") || PrefsBridge.getBoolean("home_other_tasks_shortcut_menu") || PrefsBridge.getBoolean("home_other_force_stop_shortcut_menu")));
initHook(new EnableIconMonoChrome(), PrefsBridge.getBoolean("home_other_icon_mono_chrome"));
initHook(new HomePortraitReverse(), PrefsBridge.getBoolean("home_other_portrait_reverse"));
initHook(AlwaysBlurWallpaper.INSTANCE, PrefsBridge.getBoolean("home_other_always_blur_launcher_wallpaper"));
diff --git a/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePad.java b/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePad.java
index 169ca66f91..28361ac085 100644
--- a/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePad.java
+++ b/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePad.java
@@ -200,7 +200,7 @@ public void onPackageLoaded() {
initHook(AlwaysShowMiuiWidget.INSTANCE, PrefsBridge.getBoolean("home_widget_show_miui_widget"));
// 其他
- initHook(new FreeformShortcutMenu(), PrefsBridge.getBoolean("home_other_tasks_shortcut_menu"));
+ initHook(new FreeformShortcutMenu(), PrefsBridge.getBoolean("home_other_tasks_shortcut_menu") || PrefsBridge.getBoolean("home_other_force_stop_shortcut_menu"));
initHook(ShortcutItemCount.INSTANCE, PrefsBridge.getBoolean("home_other_shortcut_remove_restrictions"));
initHook(SetDeviceLevel.INSTANCE, PrefsBridge.getBoolean("home_other_high_models"));
diff --git a/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePhone.java b/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePhone.java
index 7c512aab0b..70d949f023 100644
--- a/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePhone.java
+++ b/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePhone.java
@@ -211,7 +211,7 @@ public void onPackageLoaded() {
initHook(AllowMoveAllWidgetToMinus.INSTANCE, PrefsBridge.getBoolean("home_widget_allow_moved_to_minus_one_screen"));
// 其他
- initHook(new FreeformShortcutMenu(), (PrefsBridge.getBoolean("home_other_freeform_shortcut_menu") || (PrefsBridge.getBoolean("home_other_tasks_shortcut_menu"))));
+ initHook(new FreeformShortcutMenu(), (PrefsBridge.getBoolean("home_other_freeform_shortcut_menu") || PrefsBridge.getBoolean("home_other_tasks_shortcut_menu") || PrefsBridge.getBoolean("home_other_force_stop_shortcut_menu")));
initHook(new AllowShareApk(), PrefsBridge.getBoolean("home_other_allow_share_apk"));
initHook(ShortcutItemCount.INSTANCE, PrefsBridge.getBoolean("home_other_shortcut_remove_restrictions"));
diff --git a/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/rules/home/other/FreeformShortcutMenu.java b/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/rules/home/other/FreeformShortcutMenu.java
index 4215c9450c..a5979e592d 100644
--- a/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/rules/home/other/FreeformShortcutMenu.java
+++ b/library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/rules/home/other/FreeformShortcutMenu.java
@@ -22,6 +22,7 @@
import static com.sevtinge.hyperceiler.libhook.utils.hookapi.tool.AppsTool.getModuleRes;
import static com.sevtinge.hyperceiler.libhook.utils.hookapi.tool.EzxHelpUtils.newInstance;
+
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ComponentName;
@@ -163,6 +164,9 @@ public Object intercept(XposedInterface.Chain chain) throws Throwable {
if (titleStr.contentEquals(modRes.getString(R.string.new_task))) {
return createFreeformClickListener(shortcut, true);
}
+ if (titleStr.contentEquals(modRes.getString(R.string.system_notifrowmenu_forceclose))) {
+ return createForceStopClickListener(shortcut);
+ }
return chain.proceed();
}
});
@@ -223,6 +227,14 @@ private void addCustomShortcuts() {
}
}
+ if (PrefsBridge.getBoolean("home_other_force_stop_shortcut_menu")) {
+ Object forceStop = createShortcutItem(
+ R.string.system_notifrowmenu_forceclose, "ic_forceclose12");
+ if (forceStop != null) {
+ newItems.add(forceStop);
+ }
+ }
+
if (existingItems != null) {
newItems.addAll(existingItems);
}
@@ -275,6 +287,29 @@ private View.OnClickListener createFreeformClickListener(Object shortcut, boolea
};
}
+ private View.OnClickListener createForceStopClickListener(Object shortcut) {
+ return view -> {
+ try {
+ ComponentName component = (ComponentName) callMethod(shortcut, "getComponentName");
+ if (component == null) {
+ return;
+ }
+ String packageName = component.getPackageName();
+ if (packageName == null || packageName.isEmpty()) {
+ return;
+ }
+ android.app.ActivityManager am = (android.app.ActivityManager)
+ view.getContext().getSystemService(Context.ACTIVITY_SERVICE);
+ callMethod(am, "forceStopPackage", packageName);
+ if (view.getContext() instanceof Activity) {
+ ((Activity) view.getContext()).onBackPressed();
+ }
+ } catch (Throwable t) {
+ XposedLog.e(TAG, getPackageName(), "forceStopApp failed", t);
+ }
+ };
+ }
+
private Intent createFreeformIntent(ComponentName component, boolean isMultiTask) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);