Skip to content

Commit

Permalink
feat: 系统桌面-底栏-上滑只展示 Dock 栏 & 隐藏 Dock 栏 (#492)
Browse files Browse the repository at this point in the history
* feat: 系统桌面-底栏-上滑只展示 Dock 栏

* feat: 系统桌面-底栏-隐藏 Dock 栏
  • Loading branch information
wuyou-123 authored Mar 26, 2024
1 parent 5284b85 commit b32ab8d
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand Down
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 { }
}
}
}
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 { }
}
}


}
4 changes: 4 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,10 @@
<string name="home_dock_icon_title">显示应用标题</string>
<string name="home_dock_disable_recents_icon">隐藏 Dock 栏最近应用的图标</string>
<string name="home_dock_add_blur">添加 Dock 栏背景模糊</string>
<string name="home_dock_slide_up_only_show_dock">上滑只展示 Dock 栏</string>
<string name="home_dock_slide_up_only_show_dock_desc">第二次上滑再跳转到最近任务</string>
<string name="home_dock_hide_dock">隐藏 Dock 栏</string>
<string name="home_dock_hide_dock_desc">开启后 \"上滑只展示 Dock 栏\" 将失效</string>

<string name="home_other">其他</string>
<string name="home_other_shortcut_title">快捷菜单</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,10 @@
<string name="home_dock_icon_title">Show icon title in dock</string>
<string name="home_dock_disable_recents_icon">Hide recent app icons from the Dock</string>
<string name="home_dock_add_blur">Custom background blur</string>
<string name="home_dock_slide_up_only_show_dock">Swipe up to show only the Dock</string>
<string name="home_dock_slide_up_only_show_dock_desc">Swipe up a second time and jump to the recent task</string>
<string name="home_dock_hide_dock">Hide the Dock</string>
<string name="home_dock_hide_dock_desc">After turning it on, \"Swipe up to show only the Dock\" will be invalid.</string>

<string name="home_other">Other</string>
<string name="home_other_shortcut_title">Shortcut</string>
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/xml/home_dock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,15 @@
android:dependency="prefs_key_home_dock_bg_custom_enable" />-->

</PreferenceCategory>
<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_home_dock_slide_up_only_show_dock"
android:summary="@string/home_dock_slide_up_only_show_dock_desc"
android:title="@string/home_dock_slide_up_only_show_dock" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_home_dock_hide_dock"
android:summary="@string/home_dock_hide_dock_desc"
android:title="@string/home_dock_hide_dock" />
</PreferenceScreen>

0 comments on commit b32ab8d

Please sign in to comment.