-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 系统桌面-底栏-上滑只展示 Dock 栏 & 隐藏 Dock 栏 (#492)
* feat: 系统桌面-底栏-上滑只展示 Dock 栏 * feat: 系统桌面-底栏-隐藏 Dock 栏
- Loading branch information
Showing
6 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/HideDock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { } | ||
} | ||
} | ||
} |
161 changes: 161 additions & 0 deletions
161
app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/dock/SlideUpOnlyShowDock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { } | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters