From b32ab8d07be03a0c2c4a49985794e1ab9c0cbad4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=97=A0=E5=BF=A7?=
<69062567+wuyou-123@users.noreply.github.com>
Date: Tue, 26 Mar 2024 20:58:56 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B3=BB=E7=BB=9F=E6=A1=8C=E9=9D=A2-?=
=?UTF-8?q?=E5=BA=95=E6=A0=8F-=E4=B8=8A=E6=BB=91=E5=8F=AA=E5=B1=95?=
=?UTF-8?q?=E7=A4=BA=20Dock=20=E6=A0=8F=20&=20=E9=9A=90=E8=97=8F=20Dock=20?=
=?UTF-8?q?=E6=A0=8F=20(#492)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat: 系统桌面-底栏-上滑只展示 Dock 栏
* feat: 系统桌面-底栏-隐藏 Dock 栏
---
.../sevtinge/hyperceiler/module/app/Home.java | 4 +
.../module/hook/home/dock/HideDock.kt | 23 +++
.../hook/home/dock/SlideUpOnlyShowDock.kt | 161 ++++++++++++++++++
app/src/main/res/values-zh-rCN/strings.xml | 4 +
app/src/main/res/values/strings.xml | 4 +
app/src/main/res/xml/home_dock.xml | 10 ++
6 files changed, 206 insertions(+)
create mode 100644 app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/HideDock.kt
create mode 100644 app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/SlideUpOnlyShowDock.kt
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home.java
index 15c7765531..6b6b4d57dc 100644
--- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home.java
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home.java
@@ -39,7 +39,9 @@
import com.sevtinge.hyperceiler.module.hook.home.dock.DockCustomNew;
import com.sevtinge.hyperceiler.module.hook.home.dock.FoldDeviceDock;
import com.sevtinge.hyperceiler.module.hook.home.dock.FoldDock;
+import com.sevtinge.hyperceiler.module.hook.home.dock.HideDock;
import com.sevtinge.hyperceiler.module.hook.home.dock.ShowDockIconTitle;
+import com.sevtinge.hyperceiler.module.hook.home.dock.SlideUpOnlyShowDock;
import com.sevtinge.hyperceiler.module.hook.home.drawer.AllAppsContainerViewBlur;
import com.sevtinge.hyperceiler.module.hook.home.drawer.AppDrawer;
import com.sevtinge.hyperceiler.module.hook.home.drawer.PinyinArrangement;
@@ -251,6 +253,8 @@ public void handleLoadPackage() {
initHook(ShowDockIconTitle.INSTANCE, mPrefsMap.getBoolean("home_dock_icon_title"));
initHook(new HideNavigationBar(), mPrefsMap.getBoolean("system_ui_hide_navigation_bar"));
initHook(DisableRecentsIcon.INSTANCE, mPrefsMap.getBoolean("home_dock_disable_recents_icon"));
+ initHook(SlideUpOnlyShowDock.INSTANCE, mPrefsMap.getBoolean("home_dock_slide_up_only_show_dock"));
+ initHook(HideDock.INSTANCE, mPrefsMap.getBoolean("home_dock_hide_dock"));
// 其他
initHook(new LockApp(), mPrefsMap.getBoolean("system_framework_guided_access"));
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/HideDock.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/HideDock.kt
new file mode 100644
index 0000000000..5b56aabda6
--- /dev/null
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/HideDock.kt
@@ -0,0 +1,23 @@
+package com.sevtinge.hyperceiler.module.hook.home.dock
+
+import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
+import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
+import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
+import com.sevtinge.hyperceiler.module.base.*
+
+
+object HideDock : BaseHook() {
+ override fun init() {
+ // 上滑时忽略dock,直接触发最近任务手势
+ loadClass("com.miui.home.recents.GestureTouchEventTracker").methodFinder()
+ .filterByName("isTouchCountAndHotSeatSupport").single().createHook {
+ returnConstant(false)
+ }
+
+ // 拦截dock出现动画
+ loadClass("com.miui.home.launcher.dock.DockStateMachine").methodFinder()
+ .filterByName("transitionToAppearingState\$default").single().createHook {
+ replace { }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/SlideUpOnlyShowDock.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/SlideUpOnlyShowDock.kt
new file mode 100644
index 0000000000..9409846483
--- /dev/null
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/SlideUpOnlyShowDock.kt
@@ -0,0 +1,161 @@
+package com.sevtinge.hyperceiler.module.hook.home.dock
+
+import android.view.*
+import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
+import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
+import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
+import com.sevtinge.hyperceiler.module.base.*
+import com.sevtinge.hyperceiler.utils.*
+
+
+object SlideUpOnlyShowDock : BaseHook() {
+ override fun init() {
+ loadClass("com.miui.home.recents.DockGestureHelper").methodFinder()
+ .filterByName("dispatchTouchEvent").single().createHook {
+ replace {
+ // ================
+ // DockController dockController = getDockController();
+ // if (dockController == null) {
+ // Log.e("DockGestureHelper", "onTouchEvent: dockController=" + getDockController());
+ // return;
+ // }
+ // ================
+ val dockController = it.thisObject.callMethod("getDockController")
+ ?: return@replace null
+
+ // ================
+ // int actionMasked = motionEvent.getActionMasked();
+ // if (actionMasked == 3 || actionMasked == 1) {
+ // this.mTransitionYStyle.cancel();
+ // this.mIsDockTransitionAnimStart = false;
+ // }
+ // ================
+ val motionEvent = it.args[0] as MotionEvent
+ val actionMasked = motionEvent.actionMasked
+ if (actionMasked == 3 || actionMasked == 1) {
+ it.thisObject.getObjectField("mTransitionYStyle")?.callMethod("cancel")
+ it.thisObject.setBooleanField("mIsDockTransitionAnimStart", false)
+ }
+
+
+ // ================
+ // if (!dockController.isFloatingDockShowing()) {
+ // if (motionEvent.getEventTime() - motionEvent.getDownTime() >= 180) {
+ // if (actionMasked == 3 || actionMasked == 1 || actionMasked == 6 || actionMasked == 5) {
+ // dockController.dispatchUpEvent(motionEvent, this.mTouchTracker.getUpType());
+ // } else {
+ // animationTransitionDock(motionEvent, dockController);
+ // dockController.addMovement(motionEvent);
+ // dockController.updateLeaveSafeAreaStatus(motionEvent.getRawX(), motionEvent.getRawY(), true);
+ // }
+ // } else if (actionMasked != 3 && actionMasked != 1) {
+ // dockController.addMovement(motionEvent);
+ // dockController.updateLeaveSafeAreaStatus(motionEvent.getRawX(), motionEvent.getRawY(), false);
+ // }
+ // ================
+ val b = dockController.callMethod("isFloatingDockShowing") as Boolean
+ if (!b) {
+ // 将判断时间设置为0
+ // if (motionEvent.eventTime - motionEvent.downTime >= 180) {
+ if (actionMasked == 3 || actionMasked == 1 || actionMasked == 6 || actionMasked == 5) {
+ // dockController.callMethod("dispatchUpEvent", motionEvent, it.thisObject.getObjectField("mTouchTracker")?.callMethod("getUpType"))
+ // 设置为10, 表示是慢速上滑,后面就会执行打开dock的逻辑,如果是5则为快速上滑,会执行跳转桌面的逻辑
+ dockController.callMethod("dispatchUpEvent", motionEvent, 10)
+ } else {
+ it.thisObject.callMethod(
+ "animationTransitionDock", motionEvent, dockController
+ )
+ dockController.callMethod("addMovement", motionEvent)
+ dockController.callMethod(
+ "updateLeaveSafeAreaStatus",
+ motionEvent.rawX,
+ motionEvent.rawY,
+ true
+ )
+ }
+ // } else if (actionMasked != 3 && actionMasked != 1) {
+ // dockController.callMethod("addMovement", motionEvent)
+ // dockController.callMethod(
+ // "updateLeaveSafeAreaStatus",
+ // motionEvent.rawX,
+ // motionEvent.rawY,
+ // false
+ // )
+ // }
+ }
+
+ // ================
+ // if (!this.isStartedGesture) {
+ // if (isTargetValue(actionMasked, 2) && (dockController.isLeaveSafeArea() || this.mTouchTracker.isTaskStartMove(motionEvent.getRawY()))) {
+ // startGestureModeGesture(0);
+ // } else if (isTargetValue(actionMasked, 1, 3) && this.mTouchTracker.getUpType() == 5) {
+ // startGestureModeGesture(1);
+ // }
+ // }
+ // ================
+ // val isStartedGesture = it.thisObject.getBooleanField("isStartedGesture")
+ // if (!isStartedGesture) {
+ // if (it.thisObject.callMethod(
+ // "isTargetValue",
+ // actionMasked,
+ // 2
+ // ) as Boolean && (dockController.callMethod("isLeaveSafeArea") as Boolean || it.thisObject.callMethod(
+ // "mTouchTracker"
+ // )?.callMethod("isTaskStartMove", motionEvent.rawY) as Boolean)
+ // ) {
+ // it.thisObject.callMethod("startGestureModeGesture", 0)
+ // } else if (it.thisObject.callMethod(
+ // "isTargetValue",
+ // actionMasked,
+ // 1,
+ // 3
+ // ) as Boolean && it.thisObject.callMethod("mTouchTracker")
+ // ?.callMethod("getUpType") == 5
+ // ) {
+ // it.thisObject.callMethod("startGestureModeGesture", 1)
+ // }
+ // }
+ // 这部分是跳转最近任务或者桌面的逻辑,直接去掉
+
+
+ // ================
+ // if (this.isStartedGesture) {
+ // this.mGestureInputHelper.dispatchGestureModeTouchEvent(motionEvent);
+ // } else if ((actionMasked == 1 || actionMasked == 6) && (launcher = Application.getLauncher()) != null) {
+ // launcher.notifyPowerKeeperGesture("gesture_end", !this.mTouchTracker.isKeyboardEventTracker());
+ // }
+ // ================
+
+
+ val isStartedGesture0 = it.thisObject.getBooleanField("isStartedGesture")
+ if (isStartedGesture0) {
+ it.thisObject.callMethod("mGestureInputHelper")
+ ?.callMethod("dispatchGestureModeTouchEvent", motionEvent)
+ } else if (actionMasked == 1 || actionMasked == 6) {
+ val launcher = findClassIfExists(
+ "com.miui.home.launcher.Application", lpparam.classLoader
+ ).callStaticMethod("getLauncher")
+ launcher?.javaClass?.getDeclaredMethod(
+ "notifyPowerKeeperGesture",
+ String::class.java,
+ Boolean::class.javaPrimitiveType
+ )?.invoke(
+ launcher,
+ "gesture_end",
+ !(it.thisObject.getObjectField("mTouchTracker")!!
+ .callMethod("isKeyboardEventTracker") as Boolean)
+ )
+ } else {
+ }
+ }
+ }
+
+ // 拦截通过dock快速上滑进入桌面的方法
+ loadClass("com.miui.home.recents.DockGestureHelper").methodFinder()
+ .filterByName("startGestureModeGesture").single().createHook {
+ replace { }
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 12ba55e95e..2aa80e7919 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -1228,6 +1228,10 @@
显示应用标题
隐藏 Dock 栏最近应用的图标
添加 Dock 栏背景模糊
+ 上滑只展示 Dock 栏
+ 第二次上滑再跳转到最近任务
+ 隐藏 Dock 栏
+ 开启后 \"上滑只展示 Dock 栏\" 将失效
其他
快捷菜单
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2e215f1324..c058f042f4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1201,6 +1201,10 @@
Show icon title in dock
Hide recent app icons from the Dock
Custom background blur
+ Swipe up to show only the Dock
+ Swipe up a second time and jump to the recent task
+ Hide the Dock
+ After turning it on, \"Swipe up to show only the Dock\" will be invalid.
Other
Shortcut
diff --git a/app/src/main/res/xml/home_dock.xml b/app/src/main/res/xml/home_dock.xml
index a6482c3b41..98a415489c 100644
--- a/app/src/main/res/xml/home_dock.xml
+++ b/app/src/main/res/xml/home_dock.xml
@@ -128,5 +128,15 @@
android:dependency="prefs_key_home_dock_bg_custom_enable" />-->
+
+
\ No newline at end of file