新增修改划卡动画&桌面快捷小窗

This commit is contained in:
LittleTurtle2333
2023-02-18 21:50:10 +08:00
parent 4ce55d1fb3
commit 990ea8ef7e
4 changed files with 86 additions and 96 deletions

View File

@@ -35,8 +35,7 @@ class OtherPageForT : BasePage() {
textId = R.string.miuihome_recentwiew_wallpaper_darkening, tipsId = R.string.miuihome_recentwiew_wallpaper_darkening_summary textId = R.string.miuihome_recentwiew_wallpaper_darkening, tipsId = R.string.miuihome_recentwiew_wallpaper_darkening_summary
), SwitchV("miuihome_recentwiew_wallpaper_darkening", false) ), SwitchV("miuihome_recentwiew_wallpaper_darkening", false)
) )
//TODO未开发完成 TextSummaryWithSwitch(
/*TextSummaryWithSwitch(
TextSummaryV( TextSummaryV(
textId = R.string.miuihome_recentview_remove_card_animation, tipsId = R.string.miuihome_recentview_remove_card_animation_summary textId = R.string.miuihome_recentview_remove_card_animation, tipsId = R.string.miuihome_recentview_remove_card_animation_summary
), SwitchV("miuihome_recentview_remove_card_animation", false) ), SwitchV("miuihome_recentview_remove_card_animation", false)
@@ -44,7 +43,7 @@ class OtherPageForT : BasePage() {
TextSummaryWithSwitch( TextSummaryWithSwitch(
TextSummaryV(textId = R.string.miuihome_shortcut_add_small_window, tipsId = R.string.miuihome_shortcut_add_small_window_summary), TextSummaryV(textId = R.string.miuihome_shortcut_add_small_window, tipsId = R.string.miuihome_shortcut_add_small_window_summary),
SwitchV("miuihome_shortcut_add_small_window", false) SwitchV("miuihome_shortcut_add_small_window", false)
)*/ )
TextSummaryWithSwitch( TextSummaryWithSwitch(
TextSummaryV(textId = R.string.miuihome_scroll_icon_name, tipsId = R.string.miuihome_scroll_icon_name_summary), TextSummaryV(textId = R.string.miuihome_scroll_icon_name, tipsId = R.string.miuihome_scroll_icon_name_summary),
SwitchV("miuihome_scroll_icon_name", false) SwitchV("miuihome_scroll_icon_name", false)

View File

@@ -1,53 +1,45 @@
package com.lt2333.simplicitytools.hooks.rules.all.miuihome package com.lt2333.simplicitytools.hooks.rules.all.miuihome
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.animation.TimeInterpolator
import android.view.MotionEvent
import android.view.View import android.view.View
import com.github.kyuubiran.ezxhelper.utils.args import com.lt2333.simplicitytools.utils.*
import com.github.kyuubiran.ezxhelper.utils.findMethod
import com.github.kyuubiran.ezxhelper.utils.getObject
import com.github.kyuubiran.ezxhelper.utils.hookAfter
import com.github.kyuubiran.ezxhelper.utils.hookReplace
import com.github.kyuubiran.ezxhelper.utils.invokeMethod
import com.github.kyuubiran.ezxhelper.utils.invokeStaticMethod
import com.github.kyuubiran.ezxhelper.utils.loadClass
import com.github.kyuubiran.ezxhelper.utils.putObject
import com.lt2333.simplicitytools.utils.hasEnable
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
import de.robv.android.xposed.XposedHelpers
object ModifyRecentViewRemoveCardAnimForAll : HookRegister() { object ModifyRecentViewRemoveCardAnimForAll : HookRegister() {
override fun init() = hasEnable("miuihome_recentview_remove_card_animation") { override fun init() = hasEnable("miuihome_recentview_remove_card_animation") {
findMethod("com.miui.home.recents.views.SwipeHelperForRecents") { "com.miui.home.recents.views.SwipeHelperForRecents".hookAfterMethod("onTouchEvent", MotionEvent::class.java) {
name == "onTouchEvent" && parameterCount == 1 val mCurrView = it.thisObject.getObjectField("mCurrView") as View?
}.hookAfter {
val mCurrView = it.thisObject.getObject("mCurrView") as View?
if (mCurrView != null) { if (mCurrView != null) {
mCurrView.alpha = 1f mCurrView.alpha = 1f
mCurrView.scaleX = 1f mCurrView.scaleX = 1f
mCurrView.scaleY = 1f mCurrView.scaleY = 1f
} }
} }
findMethod("com.miui.home.recents.TaskStackViewLayoutStyleHorizontal") {
name == "createScaleDismissAnimation" && parameterCount == 2 "com.miui.home.recents.TaskStackViewLayoutStyleHorizontal".replaceMethod("createScaleDismissAnimation", View::class.java, Float::class.java) {
}.hookReplace {
val view = it.args[0] as View val view = it.args[0] as View
val getScreenHeight = loadClass("com.miui.home.launcher.DeviceConfig").invokeStaticMethod("getScreenHeight") as Int val getScreenHeight = "com.miui.home.launcher.DeviceConfig".findClass().callStaticMethod("getScreenHeight") as Int
val ofFloat = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, view.translationY, -getScreenHeight * 1.1484375f) val ofFloat = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, view.translationY, -getScreenHeight * 1.1484375f)
ofFloat.duration = 200 val physicBasedInterpolator = XposedHelpers.newInstance("com.miui.home.launcher.anim.PhysicBasedInterpolator".findClass(), 0.9f, 0.78f)
return@hookReplace ofFloat ofFloat.interpolator = physicBasedInterpolator as TimeInterpolator
ofFloat.duration = 400
return@replaceMethod ofFloat
} }
findMethod("com.miui.home.recents.views.VerticalSwipe") {
name == "calculate" && parameterCount == 1 "com.miui.home.recents.views.VerticalSwipe".hookAfterMethod("calculate", Float::class.java) {
}.hookAfter {
val f = it.args[0] as Float val f = it.args[0] as Float
val asScreenHeightWhenDismiss = loadClass("com.miui.home.recents.views.VerticalSwipe").invokeStaticMethod("getAsScreenHeightWhenDismiss") as Int val asScreenHeightWhenDismiss = "com.miui.home.recents.views.VerticalSwipe".findClass().callStaticMethod("getAsScreenHeightWhenDismiss") as Int
val f2 = f / asScreenHeightWhenDismiss val f2 = f / asScreenHeightWhenDismiss
val mTaskViewHeight = it.thisObject.getObject("mTaskViewHeight") as Float val mTaskViewHeight = it.thisObject.getObjectField("mTaskViewHeight") as Float
val mCurScale = it.thisObject.getObject("mCurScale") as Float val mCurScale = it.thisObject.getObjectField("mCurScale") as Float
val f3: Float = mTaskViewHeight * mCurScale val f3: Float = mTaskViewHeight * mCurScale
val i = if (f2 > 0.0f) 1 else if (f2 == 0.0f) 0 else -1 val i = if (f2 > 0.0f) 1 else if (f2 == 0.0f) 0 else -1
val afterFrictionValue: Float = it.thisObject.invokeMethod("afterFrictionValue", args(f, asScreenHeightWhenDismiss)) as Float val afterFrictionValue: Float = it.thisObject.callMethod("afterFrictionValue", f, asScreenHeightWhenDismiss) as Float
if (i < 0) it.thisObject.putObject("mCurTransY", (mTaskViewHeight / 2.0f + afterFrictionValue * 2) - (f3 / 2.0f)) if (i < 0) it.thisObject.setObjectField("mCurTransY", (mTaskViewHeight / 2.0f + afterFrictionValue * 2) - (f3 / 2.0f))
} }
} }

View File

@@ -1,8 +1,10 @@
package com.lt2333.simplicitytools.hooks.rules.all.miuihome package com.lt2333.simplicitytools.hooks.rules.all.miuihome
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context
import android.text.TextUtils import android.text.TextUtils
import android.view.View import android.view.View
import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import com.github.kyuubiran.ezxhelper.utils.Log import com.github.kyuubiran.ezxhelper.utils.Log
import com.github.kyuubiran.ezxhelper.utils.args import com.github.kyuubiran.ezxhelper.utils.args
@@ -10,54 +12,57 @@ import com.github.kyuubiran.ezxhelper.utils.findMethod
import com.github.kyuubiran.ezxhelper.utils.getObject import com.github.kyuubiran.ezxhelper.utils.getObject
import com.github.kyuubiran.ezxhelper.utils.hookAfter import com.github.kyuubiran.ezxhelper.utils.hookAfter
import com.github.kyuubiran.ezxhelper.utils.invokeMethod import com.github.kyuubiran.ezxhelper.utils.invokeMethod
import com.lt2333.simplicitytools.utils.hasEnable import com.lt2333.simplicitytools.utils.*
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
object ScrollIconNameForAll : HookRegister() { object ScrollIconNameForAll : HookRegister() {
@SuppressLint("DiscouragedApi") @SuppressLint("DiscouragedApi")
override fun init() = hasEnable("miuihome_scroll_icon_name") { override fun init() = hasEnable("miuihome_scroll_icon_name") {
val launcherClass = "com.miui.home.launcher.Launcher".findClass()
val shortcutInfoClass = "com.miui.home.launcher.ShortcutInfo".findClass()
try { try {
findMethod("com.miui.home.launcher.ItemIcon") { "com.miui.home.launcher.ItemIcon".hookAfterMethod(
name == "onFinishInflate" "onFinishInflate"
}.hookAfter { ) {
val mTitle = it.thisObject.getObject("mTitle") as TextView val mTitle = it.thisObject.getObjectField("mTitle") as TextView
mTitleScrolling(mTitle) mTitleScrolling(mTitle)
} }
findMethod("com.miui.home.launcher.maml.MaMlWidgetView") { "com.miui.home.launcher.maml.MaMlWidgetView".hookAfterMethod(
name == "onFinishInflate" "onFinishInflate"
}.hookAfter { ) {
val mTitle = it.thisObject.getObject("mTitle") as TextView val mTitle = it.thisObject.getObjectField("mTitleTextView") as TextView
mTitleScrolling(mTitle) mTitleScrolling(mTitle)
} }
findMethod("com.miui.home.launcher.LauncherMtzGadgetView") { "com.miui.home.launcher.LauncherMtzGadgetView".hookAfterMethod(
name == "onFinishInflate" "onFinishInflate"
}.hookAfter { ) {
val mTitle = it.thisObject.getObject("mTitle") as TextView val mTitle = it.thisObject.getObjectField("mTitleTextView") as TextView
mTitleScrolling(mTitle) mTitleScrolling(mTitle)
} }
findMethod("com.miui.home.launcher.LauncherWidgetView") { "com.miui.home.launcher.LauncherWidgetView".hookAfterMethod(
name == "onFinishInflate" "onFinishInflate"
}.hookAfter { ) {
val mTitle = it.thisObject.getObject("mTitle") as TextView val mTitle = it.thisObject.getObjectField("mTitleTextView") as TextView
mTitleScrolling(mTitle) mTitleScrolling(mTitle)
} }
findMethod("com.miui.home.launcher.ShortcutIcon") { "com.miui.home.launcher.ShortcutIcon".hookAfterMethod(
name == "fromXml" && parameterCount == 4 "fromXml", Int::class.javaPrimitiveType, launcherClass, ViewGroup::class.java, shortcutInfoClass
}.hookAfter { ) {
val buddyIconView = it.args[3].invokeMethod("getBuddyIconView", args(it.args[2])) as View val buddyIconView = it.args[3].callMethod("getBuddyIconView", it.args[2]) as View
val mTitle = buddyIconView.getObject("mTitle") as TextView val mTitle = buddyIconView.getObjectField("mTitle") as TextView
mTitleScrolling(mTitle) mTitleScrolling(mTitle)
} }
findMethod("com.miui.home.launcher.ShortcutIcon") { "com.miui.home.launcher.ShortcutIcon".hookAfterMethod(
name == "createShortcutIcon" && parameterCount == 3 "createShortcutIcon", Int::class.javaPrimitiveType, launcherClass, ViewGroup::class.java
}.hookAfter { ) {
val buddyIcon = it.result as View val buddyIcon = it.result as View
val mTitle = buddyIcon.getObject("mTitle") as TextView val mTitle = buddyIcon.getObjectField("mTitle") as TextView
mTitleScrolling(mTitle) mTitleScrolling(mTitle)
} }
findMethod("com.miui.home.launcher.common.Utilities") { "com.miui.home.launcher.common.Utilities".hookAfterMethod(
name == "adaptTitleStyleToWallpaper" && parameterCount == 4 "adaptTitleStyleToWallpaper", Context::class.java, TextView::class.java, Int::class.javaPrimitiveType, Int::class.javaPrimitiveType
}.hookAfter { ) {
val mTitle = it.args[1] as TextView val mTitle = it.args[1] as TextView
if (mTitle.id == mTitle.resources.getIdentifier("icon_title", "id", "com.miui.home")) { if (mTitle.id == mTitle.resources.getIdentifier("icon_title", "id", "com.miui.home")) {
mTitleScrolling(mTitle) mTitleScrolling(mTitle)

View File

@@ -18,77 +18,71 @@ import com.github.kyuubiran.ezxhelper.utils.invokeStaticMethod
import com.github.kyuubiran.ezxhelper.utils.loadClass import com.github.kyuubiran.ezxhelper.utils.loadClass
import com.github.kyuubiran.ezxhelper.utils.putStaticObject import com.github.kyuubiran.ezxhelper.utils.putStaticObject
import com.lt2333.simplicitytools.R import com.lt2333.simplicitytools.R
import com.lt2333.simplicitytools.utils.hasEnable import com.lt2333.simplicitytools.utils.*
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
import de.robv.android.xposed.XposedHelpers import de.robv.android.xposed.XposedHelpers
object ShortcutAddSmallWindowForAll : HookRegister() { object ShortcutAddSmallWindowForAll : HookRegister() {
override fun init() = hasEnable("miuihome_shortcut_add_small_window") { override fun init() = hasEnable("miuihome_shortcut_add_small_window") {
val mViewDarkModeHelper = loadClass("com.miui.home.launcher.util.ViewDarkModeHelper") val mViewDarkModeHelper = ("com.miui.home.launcher.util.ViewDarkModeHelper").findClass()
val mSystemShortcutMenu = loadClass("com.miui.home.launcher.shortcuts.SystemShortcutMenu") val mSystemShortcutMenu = ("com.miui.home.launcher.shortcuts.SystemShortcutMenu").findClass()
val mSystemShortcutMenuItem = loadClass("com.miui.home.launcher.shortcuts.SystemShortcutMenuItem") val mSystemShortcutMenuItem = ("com.miui.home.launcher.shortcuts.SystemShortcutMenuItem").findClass()
val mAppShortcutMenu = loadClass("com.miui.home.launcher.shortcuts.AppShortcutMenu") val mAppShortcutMenu = ("com.miui.home.launcher.shortcuts.AppShortcutMenu").findClass()
val mShortcutMenuItem = loadClass("com.miui.home.launcher.shortcuts.ShortcutMenuItem") val mShortcutMenuItem = ("com.miui.home.launcher.shortcuts.ShortcutMenuItem").findClass()
val mAppDetailsShortcutMenuItem = loadClass("com.miui.home.launcher.shortcuts.SystemShortcutMenuItem\$AppDetailsShortcutMenuItem") val mAppDetailsShortcutMenuItem = ("com.miui.home.launcher.shortcuts.SystemShortcutMenuItem\$AppDetailsShortcutMenuItem").findClass()
val mActivityUtilsCompat = loadClass("com.miui.launcher.utils.ActivityUtilsCompat") val mActivityUtilsCompat = ("com.miui.launcher.utils.ActivityUtilsCompat").findClass()
findAllMethods(mViewDarkModeHelper) {
name == "onConfigurationChanged" mViewDarkModeHelper.hookAfterAllMethods("onConfigurationChanged") {
}.hookAfter { mSystemShortcutMenuItem.callStaticMethod("createAllSystemShortcutMenuItems")
mSystemShortcutMenuItem.invokeStaticMethod("createAllSystemShortcutMenuItems")
} }
findAllMethods(mShortcutMenuItem) {
name == "getShortTitle" mShortcutMenuItem.hookAfterAllMethods("getShortTitle") {
}.hookAfter {
if (it.result == "应用信息") { if (it.result == "应用信息") {
it.result = "信息" it.result = "信息"
} }
} }
findMethod(mAppDetailsShortcutMenuItem) {
name == "lambda\$getOnClickListener$0" && parameterCount == 2 mAppDetailsShortcutMenuItem.hookBeforeMethod("lambda\$getOnClickListener$0", mAppDetailsShortcutMenuItem, View::class.java) {
}.hookBefore {
val obj = it.args[0] val obj = it.args[0]
val view: View = it.args[1] as View val view: View = it.args[1] as View
val mShortTitle = obj.invokeMethod("getShortTitle") as CharSequence val mShortTitle = obj.callMethod("getShortTitle") as CharSequence
if (mShortTitle == moduleRes.getString(R.string.miuihome_shortcut_add_small_window_title)) { if (mShortTitle == moduleRes.getString(R.string.miuihome_shortcut_add_small_window_title)) {
it.result = null it.result = null
val intent = Intent() val intent = Intent()
val mComponentName = obj.invokeMethod("getComponentName") as ComponentName val mComponentName = obj.callMethod("getComponentName") as ComponentName
intent.action = "android.intent.action.MAIN" intent.action = "android.intent.action.MAIN"
intent.addCategory("android.intent.category.LAUNCHER") intent.addCategory("android.intent.category.LAUNCHER")
intent.component = mComponentName intent.component = mComponentName
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val callStaticMethod = mActivityUtilsCompat.invokeStaticMethod("makeFreeformActivityOptions", args(view.context, mComponentName.packageName)) val callStaticMethod = mActivityUtilsCompat.callStaticMethod("makeFreeformActivityOptions", view.context, mComponentName.packageName)
if (callStaticMethod != null) { if (callStaticMethod != null) {
view.context.startActivity(intent, callStaticMethod.invokeMethod("toBundle") as Bundle) view.context.startActivity(intent, callStaticMethod.callMethod("toBundle") as Bundle)
} }
} }
} }
findAllMethods(mSystemShortcutMenu) {
name == "getMaxShortcutItemCount" mSystemShortcutMenu.hookAfterAllMethods("getMaxShortcutItemCount") {
}.hookAfter {
it.result = 5 it.result = 5
} }
findAllMethods(mAppShortcutMenu) {
name == "getMaxShortcutItemCount" mAppShortcutMenu.hookAfterAllMethods("getMaxShortcutItemCount") {
}.hookAfter {
it.result = 5 it.result = 5
} }
findAllMethods(mSystemShortcutMenuItem) {
name == "createAllSystemShortcutMenuItems" mSystemShortcutMenuItem.hookAfterAllMethods("createAllSystemShortcutMenuItems") {
}.hookAfter {
val isDarkMode = val isDarkMode =
AndroidAppHelper.currentApplication().applicationContext.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES AndroidAppHelper.currentApplication().applicationContext.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
val mAllSystemShortcutMenuItems = mSystemShortcutMenuItem.getStaticObject("sAllSystemShortcutMenuItems") as Collection<Any> val mAllSystemShortcutMenuItems = mSystemShortcutMenuItem.getStaticObjectField("sAllSystemShortcutMenuItems") as Collection<Any>
val mSmallWindowInstance = XposedHelpers.newInstance(mAppDetailsShortcutMenuItem) val mSmallWindowInstance = XposedHelpers.newInstance(mAppDetailsShortcutMenuItem)
mSmallWindowInstance.invokeMethod("setShortTitle", args(moduleRes.getString(R.string.miuihome_shortcut_add_small_window_title))) mSmallWindowInstance.callMethod("setShortTitle", moduleRes.getString(R.string.miuihome_shortcut_add_small_window_title))
mSmallWindowInstance.invokeMethod( mSmallWindowInstance.callMethod(
"setIconDrawable", "setIconDrawable",
args(if (isDarkMode) moduleRes.getDrawable(R.drawable.ic_small_window_dark) else moduleRes.getDrawable(R.drawable.ic_small_window_light)) if (isDarkMode) moduleRes.getDrawable(R.drawable.ic_small_window_dark) else moduleRes.getDrawable(R.drawable.ic_small_window_light)
) )
val sAllSystemShortcutMenuItems = ArrayList<Any>() val sAllSystemShortcutMenuItems = ArrayList<Any>()
sAllSystemShortcutMenuItems.add(mSmallWindowInstance) sAllSystemShortcutMenuItems.add(mSmallWindowInstance)
sAllSystemShortcutMenuItems.addAll(mAllSystemShortcutMenuItems) sAllSystemShortcutMenuItems.addAll(mAllSystemShortcutMenuItems)
mSystemShortcutMenuItem.putStaticObject("sAllSystemShortcutMenuItems", sAllSystemShortcutMenuItems) mSystemShortcutMenuItem.setStaticObjectField("sAllSystemShortcutMenuItems", sAllSystemShortcutMenuItems)
} }
} }