mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-14 04:11:17 +08:00
Compare commits
3 Commits
2bc68e9724
...
ebb5e1435b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebb5e1435b | ||
|
|
40c24cbb40 | ||
|
|
2830c8f48a |
@@ -47,6 +47,7 @@ class MenuPage : BasePage() {
|
||||
"killall com.miui.screenshot",
|
||||
"killall com.milink.service",
|
||||
"killall com.xiaomi.misubscreenui",
|
||||
"killall com.miui.packageinstaller"
|
||||
)
|
||||
ShellUtils.execCommand(command, true)
|
||||
dismiss()
|
||||
|
||||
@@ -172,6 +172,12 @@ class OtherPageForS : BasePage() {
|
||||
TextSummaryV(textId = R.string.remove_thememanager_ads),
|
||||
SwitchV("remove_thememanager_ads")
|
||||
)
|
||||
Line()
|
||||
TitleText(textId = R.string.pkg_installer)
|
||||
TextSummaryWithSwitch(
|
||||
TextSummaryV(textId = R.string.pkg_installer_summary),
|
||||
SwitchV("pkg_installer_count_checking")
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -172,6 +172,12 @@ class OtherPageForT : BasePage() {
|
||||
TextSummaryV(textId = R.string.remove_thememanager_ads),
|
||||
SwitchV("remove_thememanager_ads")
|
||||
)
|
||||
Line()
|
||||
TitleText(textId = R.string.pkg_installer)
|
||||
TextSummaryWithSwitch(
|
||||
TextSummaryV(textId = R.string.pkg_installer_summary),
|
||||
SwitchV("pkg_installer_count_checking")
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.lt2333.simplicitytools.hooks
|
||||
|
||||
import com.lt2333.simplicitytools.BuildConfig
|
||||
import com.lt2333.simplicitytools.hooks.apps.*
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.CorePatchMainHook
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.corepatch.CorePatchMainHook
|
||||
import com.lt2333.simplicitytools.utils.xposed.EasyXposedInit
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.IXposedHookZygoteInit
|
||||
@@ -25,6 +25,7 @@ class MainHook : EasyXposedInit() {
|
||||
ScreenShot, // 截屏
|
||||
Cast, //投屏
|
||||
RearDisplay, //背屏
|
||||
PackageInstaller, // 应用包管理组件
|
||||
)
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import android.os.Build
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.CorePatchMainHook
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.android.AllowUntrustedTouchesForAll
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.android.DeleteOnPostNotificationForAll
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.android.DisableFlagSecureForAll
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.corepatch.CorePatchMainHook
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.android.*
|
||||
import com.lt2333.simplicitytools.hooks.rules.t.android.MaxWallpaperScaleForT
|
||||
import com.lt2333.simplicitytools.hooks.rules.t.android.SystemPropertiesHookForT
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
@@ -17,23 +21,23 @@ object Android : AppRegister() {
|
||||
Build.VERSION_CODES.TIRAMISU -> {
|
||||
autoInitHooks(
|
||||
lpparam,
|
||||
DisableFlagSecureForS, //允许截图
|
||||
DeleteOnPostNotificationForS, //上层显示
|
||||
DisableFlagSecureForAll, //允许截图
|
||||
DeleteOnPostNotificationForAll, //上层显示
|
||||
RemoveSmallWindowRestrictionsForS, //解除小窗限制
|
||||
MaxWallpaperScaleForT, //壁纸缩放比例
|
||||
SystemPropertiesHookForS, //SystemPropertiesHook
|
||||
AllowUntrustedTouchesForS, //允许不受信任的触摸
|
||||
SystemPropertiesHookForT, //SystemPropertiesHook
|
||||
AllowUntrustedTouchesForAll, //允许不受信任的触摸
|
||||
)
|
||||
}
|
||||
Build.VERSION_CODES.S -> {
|
||||
autoInitHooks(
|
||||
lpparam,
|
||||
DisableFlagSecureForS, //允许截图
|
||||
DeleteOnPostNotificationForS, //上层显示
|
||||
DisableFlagSecureForAll, //允许截图
|
||||
DeleteOnPostNotificationForAll, //上层显示
|
||||
RemoveSmallWindowRestrictionsForS, //解除小窗限制
|
||||
MaxWallpaperScaleForS, //壁纸缩放比例
|
||||
SystemPropertiesHookForS, //SystemPropertiesHook
|
||||
AllowUntrustedTouchesForS, //允许不受信任的触摸
|
||||
AllowUntrustedTouchesForAll, //允许不受信任的触摸
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import android.os.Build
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.cast.ForceSupportSendAppForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.cast.ForceSupportSendAppForAll
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
@@ -12,12 +12,12 @@ object Cast: AppRegister() {
|
||||
when (Build.VERSION.SDK_INT) {
|
||||
Build.VERSION_CODES.TIRAMISU -> {
|
||||
autoInitHooks(lpparam,
|
||||
ForceSupportSendAppForS, //强制允许所有应用接力
|
||||
ForceSupportSendAppForAll, //强制允许所有应用接力
|
||||
)
|
||||
}
|
||||
Build.VERSION_CODES.S -> {
|
||||
autoInitHooks(lpparam,
|
||||
ForceSupportSendAppForS, //强制允许所有应用接力
|
||||
ForceSupportSendAppForAll, //强制允许所有应用接力
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import android.os.Build
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.miuihome.AlwaysDisplayTimeForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.miuihome.DoubleTapToSleepForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.miuihome.AlwaysDisplayTimeForAll
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.miuihome.DoubleTapToSleepForAll
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
@@ -14,15 +14,15 @@ object MiuiHome : AppRegister() {
|
||||
Build.VERSION_CODES.TIRAMISU -> {
|
||||
autoInitHooks(
|
||||
lpparam,
|
||||
AlwaysDisplayTimeForS, //时钟显示时钟
|
||||
DoubleTapToSleepForS, //双击锁屏
|
||||
AlwaysDisplayTimeForAll, //时钟显示时钟
|
||||
DoubleTapToSleepForAll, //双击锁屏
|
||||
)
|
||||
}
|
||||
Build.VERSION_CODES.S -> {
|
||||
autoInitHooks(
|
||||
lpparam,
|
||||
AlwaysDisplayTimeForS, //时钟显示时钟
|
||||
DoubleTapToSleepForS, //双击锁屏
|
||||
AlwaysDisplayTimeForAll, //时钟显示时钟
|
||||
DoubleTapToSleepForAll, //双击锁屏
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
object PackageInstaller: AppRegister() {
|
||||
|
||||
override val packageName: String = "com.miui.packageinstaller"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
hasEnable("pkg_installer_count_checking") {
|
||||
findMethod("com.miui.packageInstaller.model.RiskControlRules") {
|
||||
name == "getCurrentLevel"
|
||||
}.hookBefore { param ->
|
||||
XposedBridge.log("Hooked getCurrentLevel, param result = ${param.result}")
|
||||
param.result = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import android.os.Build
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.powerkeeper.LockMaxFpsForAll
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.powerkeeper.DoNotClearAppForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.powerkeeper.LockMaxFpsForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.powerkeeper.MakeMilletMoreAggressiveForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.powerkeeper.PreventRecoveryOfBatteryOptimizationWhitelistForS
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
@@ -15,7 +15,7 @@ object PowerKeeper: AppRegister() {
|
||||
when (Build.VERSION.SDK_INT) {
|
||||
Build.VERSION_CODES.TIRAMISU -> {
|
||||
autoInitHooks(lpparam,
|
||||
LockMaxFpsForS, //锁定最高刷新率
|
||||
LockMaxFpsForAll, //锁定最高刷新率
|
||||
PreventRecoveryOfBatteryOptimizationWhitelistForS, //防止恢复电池优化白名单
|
||||
DoNotClearAppForS,//阻止杀后台
|
||||
MakeMilletMoreAggressiveForS,//使 Millet 更激进
|
||||
@@ -23,7 +23,7 @@ object PowerKeeper: AppRegister() {
|
||||
}
|
||||
Build.VERSION_CODES.S -> {
|
||||
autoInitHooks(lpparam,
|
||||
LockMaxFpsForS, //锁定最高刷新率
|
||||
LockMaxFpsForAll, //锁定最高刷新率
|
||||
PreventRecoveryOfBatteryOptimizationWhitelistForS, //防止恢复电池优化白名单
|
||||
DoNotClearAppForS,//阻止杀后台
|
||||
MakeMilletMoreAggressiveForS,//使 Millet 更激进
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import android.os.Build
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.reardisplay.RearDisplayWeatherForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.reardisplay.RearDisplayWeatherForAll
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
@@ -12,12 +12,12 @@ object RearDisplay: AppRegister() {
|
||||
when (Build.VERSION.SDK_INT) {
|
||||
Build.VERSION_CODES.TIRAMISU -> {
|
||||
autoInitHooks(lpparam,
|
||||
RearDisplayWeatherForS, //背屏显示天气
|
||||
RearDisplayWeatherForAll, //背屏显示天气
|
||||
)
|
||||
}
|
||||
Build.VERSION_CODES.S -> {
|
||||
autoInitHooks(lpparam,
|
||||
RearDisplayWeatherForS, //背屏显示天气
|
||||
RearDisplayWeatherForAll, //背屏显示天气
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import android.os.Build
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.securitycenter.*
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.securitycenter.LockOneHundredForAll
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.securitycenter.RemoveOpenAppConfirmationPopupForAll
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.securitycenter.SkipWaitingTimeForAll
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.securitycenter.RemoveMacroBlacklistForAll
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.securitycenter.ShowBatteryTemperatureForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.t.securitycenter.ShowBatteryTemperatureForT
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
@@ -13,20 +17,20 @@ object SecurityCenter: AppRegister() {
|
||||
when (Build.VERSION.SDK_INT) {
|
||||
Build.VERSION_CODES.TIRAMISU -> {
|
||||
autoInitHooks(lpparam,
|
||||
SkipWaitingTimeForS, //跳过 5/10秒等待时间
|
||||
LockOneHundredForS, //锁定 100分
|
||||
RemoveMacroBlacklistForS, //去除自动连招黑名单
|
||||
SkipWaitingTimeForAll, //跳过 5/10秒等待时间
|
||||
LockOneHundredForAll, //锁定 100分
|
||||
RemoveMacroBlacklistForAll, //去除自动连招黑名单
|
||||
ShowBatteryTemperatureForT, //显示电池温度
|
||||
RemoveOpenAppConfirmationPopupForS, //去除打开应用弹窗
|
||||
RemoveOpenAppConfirmationPopupForAll, //去除打开应用弹窗
|
||||
)
|
||||
}
|
||||
Build.VERSION_CODES.S -> {
|
||||
autoInitHooks(lpparam,
|
||||
SkipWaitingTimeForS, //跳过 5/10秒等待时间
|
||||
LockOneHundredForS, //锁定 100分
|
||||
RemoveMacroBlacklistForS, //去除自动连招黑名单
|
||||
SkipWaitingTimeForAll, //跳过 5/10秒等待时间
|
||||
LockOneHundredForAll, //锁定 100分
|
||||
RemoveMacroBlacklistForAll, //去除自动连招黑名单
|
||||
ShowBatteryTemperatureForS, //显示电池温度
|
||||
RemoveOpenAppConfirmationPopupForS, //去除打开应用弹窗
|
||||
RemoveOpenAppConfirmationPopupForAll, //去除打开应用弹窗
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import android.os.Build
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.settings.ShowNotificationImportanceForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.settings.ShowNotificationImportanceForAll
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
@@ -12,12 +12,12 @@ object Settings: AppRegister() {
|
||||
when (Build.VERSION.SDK_INT) {
|
||||
Build.VERSION_CODES.TIRAMISU -> {
|
||||
autoInitHooks(lpparam,
|
||||
ShowNotificationImportanceForS, //显示通知重要程度
|
||||
ShowNotificationImportanceForAll, //显示通知重要程度
|
||||
)
|
||||
}
|
||||
Build.VERSION_CODES.S -> {
|
||||
autoInitHooks(lpparam,
|
||||
ShowNotificationImportanceForS, //显示通知重要程度
|
||||
ShowNotificationImportanceForAll, //显示通知重要程度
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import android.os.Build
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.systemui.*
|
||||
import com.lt2333.simplicitytools.hooks.rules.t.systemui.*
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
@@ -12,39 +13,37 @@ object SystemUI: AppRegister() {
|
||||
when (Build.VERSION.SDK_INT) {
|
||||
Build.VERSION_CODES.TIRAMISU -> {
|
||||
autoInitHooks(lpparam,
|
||||
HideStatusBarIconForS, //隐藏状态栏图标
|
||||
HideBatteryIconForS, //隐藏电池
|
||||
HideHDIconForS, //隐藏HD图标
|
||||
HideSimIconForS, //隐藏SIM卡图标
|
||||
HideMobileActivityIconForS, //隐藏移动箭头图标
|
||||
HideMobileTypeIconForS, //隐藏移动类型图标
|
||||
HideStatusBarNetworkSpeedSecondForS, //隐藏状态栏网速/s
|
||||
HideWifiActivityIconForS, //隐藏WIFI活动箭头图标
|
||||
MaximumNumberOfNotificationIconsForS, //通知图标上限
|
||||
StatusBarNetworkSpeedRefreshSpeedForS, //状态栏网速秒刷新
|
||||
StatusBarTimeCustomizationForS, //状态栏时钟自定义
|
||||
RemoveTheLeftSideOfTheLockScreenForS, //移除锁屏负一屏功能
|
||||
RemoveLockScreenCameraForS, //移除锁屏相机功能
|
||||
NotificationWeatherForS, //通知面板天气
|
||||
NewNotificationWeatherForS, // 新控制中心天气
|
||||
OldNotificationWeatherForS,
|
||||
ControlCenterWeatherForS, //控制中心天气
|
||||
//StatusBarCurrent, //TODO:状态栏电流
|
||||
StatusBarLayoutForS, //状态栏布局
|
||||
HideNetworkSpeedSplitterForS, //隐藏时钟与实时网速之间的分隔符
|
||||
WaveChargeForS, //Alpha充电动画
|
||||
LockScreenCurrentForS, //锁屏电流
|
||||
LockScreenDoubleTapToSleepForS, //锁屏下双击锁屏
|
||||
StatusBarDoubleTapToSleepForS, //双击状态栏锁屏
|
||||
OldQSCustomForS, //旧版快速设置自定义
|
||||
DoubleLineNetworkSpeedForS, //双排网速
|
||||
StatusBarBigMobileTypeIconForS, //大移动类型
|
||||
BatteryPercentageForS, //电量百分比
|
||||
CustomMobileTypeTextForS, //自定义移动类型文本
|
||||
CanNotificationSlideForS, //允许下滑通知打开小窗
|
||||
LockScreenClockDisplaySecondsForS, // 锁屏时钟显示秒
|
||||
ShowWifiStandardForS, // 显示 WIFI 角标
|
||||
NoPasswordHookForS, // 显示 WIFI 角标
|
||||
HideStatusBarIconForT, //隐藏状态栏图标
|
||||
HideBatteryIconForT, //隐藏电池
|
||||
HideHDIconForT, //隐藏HD图标
|
||||
HideSimIconForT, //隐藏SIM卡图标
|
||||
HideMobileActivityIconForT, //隐藏移动箭头图标
|
||||
HideMobileTypeIconForT, //隐藏移动类型图标
|
||||
HideStatusBarNetworkSpeedSecondForT, //隐藏状态栏网速/s
|
||||
HideWifiActivityIconForT, //隐藏WIFI活动箭头图标
|
||||
MaximumNumberOfNotificationIconsForT, //通知图标上限
|
||||
StatusBarNetworkSpeedRefreshSpeedForT, //状态栏网速秒刷新
|
||||
StatusBarTimeCustomizationForT, //状态栏时钟自定义
|
||||
RemoveTheLeftSideOfTheLockScreenForT, //移除锁屏负一屏功能
|
||||
RemoveLockScreenCameraForT, //移除锁屏相机功能
|
||||
NotificationWeatherForT, //通知面板天气
|
||||
NewNotificationWeatherForT, // 新控制中心天气
|
||||
OldNotificationWeatherForT,
|
||||
ControlCenterWeatherForT, //控制中心天气
|
||||
StatusBarLayoutForT, //状态栏布局
|
||||
HideNetworkSpeedSplitterForT, //隐藏时钟与实时网速之间的分隔符
|
||||
WaveChargeForT, //Alpha充电动画
|
||||
LockScreenCurrentForT, //锁屏电流
|
||||
LockScreenDoubleTapToSleepForT, //锁屏下双击锁屏
|
||||
StatusBarDoubleTapToSleepForT, //双击状态栏锁屏
|
||||
OldQSCustomForT, //旧版快速设置自定义
|
||||
DoubleLineNetworkSpeedForT, //双排网速
|
||||
StatusBarBigMobileTypeIconForT, //大移动类型
|
||||
BatteryPercentageForT, //电量百分比
|
||||
CustomMobileTypeTextForT, //自定义移动类型文本
|
||||
CanNotificationSlideForT, //允许下滑通知打开小窗
|
||||
LockScreenClockDisplaySecondsForT, // 锁屏时钟显示秒
|
||||
ShowWifiStandardForT, // 显示 WIFI 角标
|
||||
)
|
||||
}
|
||||
Build.VERSION_CODES.S -> {
|
||||
@@ -66,7 +65,6 @@ object SystemUI: AppRegister() {
|
||||
NewNotificationWeatherForS, // 新控制中心天气
|
||||
OldNotificationWeatherForS,
|
||||
ControlCenterWeatherForS, //控制中心天气
|
||||
//StatusBarCurrent, //TODO:状态栏电流
|
||||
StatusBarLayoutForS, //状态栏布局
|
||||
HideNetworkSpeedSplitterForS, //隐藏时钟与实时网速之间的分隔符
|
||||
WaveChargeForS, //Alpha充电动画
|
||||
@@ -81,7 +79,6 @@ object SystemUI: AppRegister() {
|
||||
CanNotificationSlideForS, //允许下滑通知打开小窗
|
||||
LockScreenClockDisplaySecondsForS, // 锁屏时钟显示秒
|
||||
ShowWifiStandardForS, // 显示 WIFI 角标
|
||||
NoPasswordHookForS, // 显示 WIFI 角标
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.lt2333.simplicitytools.hooks.apps
|
||||
|
||||
import android.os.Build
|
||||
import com.lt2333.simplicitytools.hooks.rules.s.thememanager.RemoveAdsForS
|
||||
import com.lt2333.simplicitytools.hooks.rules.all.thememanager.RemoveAdsForAll
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
@@ -12,12 +12,12 @@ object ThemeManager: AppRegister() {
|
||||
when (Build.VERSION.SDK_INT) {
|
||||
Build.VERSION_CODES.TIRAMISU -> {
|
||||
autoInitHooks(lpparam,
|
||||
RemoveAdsForS, //移除主题壁纸的广告
|
||||
RemoveAdsForAll, //移除主题壁纸的广告
|
||||
)
|
||||
}
|
||||
Build.VERSION_CODES.S -> {
|
||||
autoInitHooks(lpparam,
|
||||
RemoveAdsForS, //移除主题壁纸的广告
|
||||
RemoveAdsForAll, //移除主题壁纸的广告
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all;
|
||||
|
||||
public class CorePatchForSv2 extends CorePatchForS{
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.android
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.android
|
||||
|
||||
import android.content.Context
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
@@ -6,7 +6,7 @@ import com.github.kyuubiran.ezxhelper.utils.hookReturnConstant
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object AllowUntrustedTouchesForS : HookRegister() {
|
||||
object AllowUntrustedTouchesForAll : HookRegister() {
|
||||
override fun init() = hasEnable("allow_untrusted_touches") {
|
||||
findMethod("android.hardware.input.InputManager") {
|
||||
name == "getBlockUntrustedTouchesMode" && parameterTypes[0] == Context::class.java
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.android
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.android
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object DeleteOnPostNotificationForS : HookRegister() {
|
||||
object DeleteOnPostNotificationForAll : HookRegister() {
|
||||
override fun init() {
|
||||
findMethod("com.android.server.wm.AlertWindowNotification") {
|
||||
name == "onPostNotification"
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.android
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.android
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object DisableFlagSecureForS : HookRegister() {
|
||||
object DisableFlagSecureForAll : HookRegister() {
|
||||
override fun init() {
|
||||
// TODO: 23.1.30及之后的版本无法在部分场景生效,疑似MIUI做了修改
|
||||
findMethod("com.android.server.wm.WindowState") {
|
||||
name == "isSecureLocked"
|
||||
}.hookBefore {
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.cast
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.cast
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object ForceSupportSendAppForS : HookRegister() {
|
||||
object ForceSupportSendAppForAll : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("force_support_send_app") {
|
||||
findMethod("com.xiaomi.mirror.synergy.MiuiSynergySdk") {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all;
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.corepatch;
|
||||
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all;
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.corepatch;
|
||||
|
||||
|
||||
import android.app.AndroidAppHelper;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all;
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.corepatch;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.corepatch;
|
||||
|
||||
public class CorePatchForSv2 extends CorePatchForS{
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all;
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.corepatch;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all;
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.corepatch;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all;
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.corepatch;
|
||||
|
||||
import de.robv.android.xposed.XC_MethodHook;
|
||||
import de.robv.android.xposed.XSharedPreferences;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all;
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.corepatch;
|
||||
|
||||
import com.lt2333.simplicitytools.BuildConfig;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.miuihome
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object AlwaysDisplayTimeForAll : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
try {
|
||||
findMethod("com.miui.home.launcher.Workspace") {
|
||||
name == "isScreenHasClockGadget"
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
findMethod("com.miui.home.launcher.Workspace") {
|
||||
name == "isScreenHasClockWidget"
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
findMethod("com.miui.home.launcher.Workspace") {
|
||||
name == "isClockWidget"
|
||||
}
|
||||
}.hookBefore {
|
||||
hasEnable("home_time") {
|
||||
it.result = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.miuihome
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.miuihome
|
||||
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
@@ -6,7 +6,7 @@ import android.view.MotionEvent
|
||||
import android.view.ViewConfiguration
|
||||
import kotlin.math.abs
|
||||
|
||||
class DoubleTapControllerForS internal constructor(mContext: Context) {
|
||||
class DoubleTapControllerForAll internal constructor(mContext: Context) {
|
||||
|
||||
private val maxDuration: Long = 500
|
||||
private var mActionDownRawX: Float = 0f
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.miuihome
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.miuihome
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -8,14 +8,14 @@ import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
|
||||
object DoubleTapToSleepForS : HookRegister() {
|
||||
object DoubleTapToSleepForAll : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("double_tap_to_sleep") {
|
||||
hookAllConstructorAfter("com.miui.home.launcher.Workspace") {
|
||||
var mDoubleTapControllerEx =
|
||||
XposedHelpers.getAdditionalInstanceField(it.thisObject, "mDoubleTapControllerEx")
|
||||
if (mDoubleTapControllerEx != null) return@hookAllConstructorAfter
|
||||
mDoubleTapControllerEx = DoubleTapControllerForS((it.args[0] as Context))
|
||||
mDoubleTapControllerEx = DoubleTapControllerForAll((it.args[0] as Context))
|
||||
XposedHelpers.setAdditionalInstanceField(
|
||||
it.thisObject,
|
||||
"mDoubleTapControllerEx",
|
||||
@@ -28,7 +28,7 @@ object DoubleTapToSleepForS : HookRegister() {
|
||||
val mDoubleTapControllerEx = XposedHelpers.getAdditionalInstanceField(
|
||||
it.thisObject,
|
||||
"mDoubleTapControllerEx"
|
||||
) as DoubleTapControllerForS
|
||||
) as DoubleTapControllerForAll
|
||||
if (!mDoubleTapControllerEx.isDoubleTapEvent(it.args[0] as MotionEvent)) return@hookBefore
|
||||
val mCurrentScreenIndex = it.thisObject.getObject("mCurrentScreenIndex") as Int
|
||||
val cellLayout = it.thisObject.invokeMethodAuto("getCellLayout", mCurrentScreenIndex)
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.powerkeeper
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.powerkeeper
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object LockMaxFpsForS : HookRegister() {
|
||||
object LockMaxFpsForAll: HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.miui.powerkeeper.statemachine.DisplayFrameSetting") {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.reardisplay
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.reardisplay
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.util.TypedValue
|
||||
@@ -15,7 +15,7 @@ import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import com.lt2333.simplicitytools.views.WeatherView
|
||||
|
||||
object RearDisplayWeatherForS : HookRegister() {
|
||||
object RearDisplayWeatherForAll : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("rear_show_weather") {
|
||||
findMethod("com.xiaomi.misubscreenui.light.aod.view.VerticalClockView") {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.securitycenter
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.securitycenter
|
||||
|
||||
import android.view.View
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
@@ -6,7 +6,7 @@ import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object LockOneHundredForS : HookRegister() {
|
||||
object LockOneHundredForAll : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
//防止点击重新检测
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.securitycenter
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.securitycenter
|
||||
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
|
||||
object RemoveMacroBlacklistForS : HookRegister() {
|
||||
object RemoveMacroBlacklistForAll : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
// TODO: 新版已失效
|
||||
if (XSPUtils.getBoolean("remove_macro_blacklist", false)) {
|
||||
var letter = 'a'
|
||||
for (i in 0..25) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.securitycenter
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.securitycenter
|
||||
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
@@ -6,7 +6,7 @@ import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object RemoveOpenAppConfirmationPopupForS : HookRegister() {
|
||||
object RemoveOpenAppConfirmationPopupForAll : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("android.widget.TextView") {
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.securitycenter
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.securitycenter
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object SkipWaitingTimeForS : HookRegister() {
|
||||
object SkipWaitingTimeForAll : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("android.widget.TextView") {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.settings
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.settings
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
@@ -6,7 +6,7 @@ import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
|
||||
object ShowNotificationImportanceForS : HookRegister() {
|
||||
object ShowNotificationImportanceForAll : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.settings.notification.ChannelNotificationSettings") {
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.thememanager
|
||||
package com.lt2333.simplicitytools.hooks.rules.all.thememanager
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object RemoveAdsForS : HookRegister() {
|
||||
object RemoveAdsForAll : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.thememanager.basemodule.ad.model.AdInfoResponse") {
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.miuihome
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object AlwaysDisplayTimeForS : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.miui.home.launcher.Workspace") {
|
||||
name == "isScreenHasClockGadget" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
hasEnable("home_time") {
|
||||
it.result = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,6 @@ object NewNotificationWeatherForS : HookRegister() {
|
||||
val time = it.args[0]?.toString()
|
||||
val view = it.thisObject as TextView
|
||||
if (view.id == clockId && time != null && this::weather.isInitialized) {
|
||||
// TODO("调高天气位置")
|
||||
// val layout = view.layoutParams as ViewGroup.MarginLayoutParams
|
||||
// val y = view.height / 2
|
||||
// layout.topMargin = -y
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.s.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object NoPasswordHookForS : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
hasEnable("no_need_to_enter_password_when_power_on") {
|
||||
findMethod("com.android.internal.widget.LockPatternUtils\$StrongAuthTracker") { name == "isBiometricAllowedForUser" }.hookBefore {
|
||||
it.result = true
|
||||
}
|
||||
findMethod("com.android.internal.widget.LockPatternUtils") { name == "isBiometricAllowedForUser" }.hookBefore {
|
||||
it.result = true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.android
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object SystemPropertiesHookForT : HookRegister() {
|
||||
override fun init() {
|
||||
val mediaStepsSwitch = XSPUtils.getBoolean("media_volume_steps_switch", false)
|
||||
val mediaSteps = XSPUtils.getInt("media_volume_steps", 15)
|
||||
|
||||
findMethod("android.os.SystemProperties") {
|
||||
name == "getInt" && returnType == Int::class.java
|
||||
}.hookBefore {
|
||||
when (it.args[0] as String) {
|
||||
"ro.config.media_vol_steps" -> if (mediaStepsSwitch) it.result = mediaSteps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.util.TypedValue
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object BatteryPercentageForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
val size = XSPUtils.getFloat("battery_percentage_font_size", 0f)
|
||||
if (size == 0f) return
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiBatteryMeterView") {
|
||||
name == "updateResources"
|
||||
}.hookAfter {
|
||||
(it.thisObject.getObjectAs<TextView>("mBatteryPercentView")).setTextSize(
|
||||
TypedValue.COMPLEX_UNIT_DIP, size
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object CanNotificationSlideForT: HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.notification.NotificationSettingsManager") {
|
||||
name == "canSlide"
|
||||
}.hookAfter {
|
||||
hasEnable("can_notification_slide") {
|
||||
it.result = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.utils.SystemProperties
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import com.lt2333.simplicitytools.views.WeatherView
|
||||
|
||||
object ControlCenterWeatherForT : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("control_center_weather") {
|
||||
var mWeatherView: TextView? = null
|
||||
var mConstraintLayout: ConstraintLayout? = null
|
||||
val isDisplayCity = XSPUtils.getBoolean("control_center_weather_city", false)
|
||||
findMethod("com.android.systemui.controlcenter.phone.widget.QSControlCenterHeaderView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter { param ->
|
||||
val viewGroup = param.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
|
||||
// MIUI编译时间大于 2022-03-12 00:00:00 且为内测版
|
||||
if (SystemProperties[context, "ro.build.date.utc"]!!.toInt() >= 1647014400 &&
|
||||
!SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM")
|
||||
) {
|
||||
//获取原组件
|
||||
val bigTimeId =
|
||||
context.resources.getIdentifier("big_time", "id", context.packageName)
|
||||
val big_time: TextView = viewGroup.findViewById(bigTimeId)
|
||||
|
||||
val dateTimeId =
|
||||
context.resources.getIdentifier("date_time", "id", context.packageName)
|
||||
val dateTime: TextView = viewGroup.findViewById(dateTimeId)
|
||||
|
||||
//创建新布局
|
||||
val mConstraintLayoutLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.topMargin = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"qs_control_header_tiles_margin_top",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
mConstraintLayout =
|
||||
ConstraintLayout(context).also { it.layoutParams = mConstraintLayoutLp }
|
||||
|
||||
(big_time.parent as ViewGroup).addView(mConstraintLayout, 0)
|
||||
|
||||
//从原布局中删除组件
|
||||
(big_time.parent as ViewGroup).removeView(big_time)
|
||||
(dateTime.parent as ViewGroup).removeView(dateTime)
|
||||
|
||||
//添加组件至新布局
|
||||
mConstraintLayout!!.addView(big_time)
|
||||
mConstraintLayout!!.addView(dateTime)
|
||||
|
||||
//组件属性
|
||||
val dateTimeLp = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.startToEnd = bigTimeId
|
||||
it.bottomToBottom = 0
|
||||
it.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
it.bottomMargin = dp2px(context, 5f)
|
||||
}
|
||||
dateTime.layoutParams = dateTimeLp
|
||||
|
||||
|
||||
//创建天气组件
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.QSControl.Date",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
mConstraintLayout!!.addView(mWeatherView)
|
||||
|
||||
val mweatherviewLp = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.startToEnd = bigTimeId
|
||||
it.bottomToTop = dateTimeId
|
||||
it.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
(mWeatherView as WeatherView).layoutParams = mweatherviewLp
|
||||
|
||||
} else {
|
||||
val layoutParam =
|
||||
loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams").getConstructor(
|
||||
Int::class.java,
|
||||
Int::class.java
|
||||
).newInstance(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
) as ViewGroup.MarginLayoutParams
|
||||
layoutParam.putObject(
|
||||
"bottomToTop",
|
||||
context.resources.getIdentifier("date_time", "id", context.packageName)
|
||||
)
|
||||
layoutParam.putObject(
|
||||
"startToEnd",
|
||||
context.resources.getIdentifier("big_time", "id", context.packageName)
|
||||
)
|
||||
layoutParam.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.QSControl.Date",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParams = layoutParam
|
||||
}
|
||||
viewGroup.addView(mWeatherView)
|
||||
}
|
||||
|
||||
(mWeatherView as WeatherView).setOnClickListener {
|
||||
try {
|
||||
val intent = Intent().apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
component = ComponentName(
|
||||
"com.miui.weather2",
|
||||
"com.miui.weather2.ActivityWeatherMain"
|
||||
)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(context, "启动失败", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//解决横屏重叠
|
||||
findMethod("com.android.systemui.controlcenter.phone.widget.QSControlCenterHeaderView") {
|
||||
name == "updateLayout"
|
||||
}.hookAfter {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val mOrientation = viewGroup.getObject("mOrientation") as Int
|
||||
// MIUI编译时间大于 2022-03-12 00:00:00 且为内测版
|
||||
if (SystemProperties[context, "ro.build.date.utc"]!!.toInt() >= 1647014400 && !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith(
|
||||
"DEV"
|
||||
) && !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM")
|
||||
) {
|
||||
if (mOrientation == 1) {
|
||||
mConstraintLayout!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mConstraintLayout!!.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
if (mOrientation == 1) {
|
||||
mWeatherView!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mWeatherView!!.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object CustomMobileTypeTextForT : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("custom_mobile_type_text_switch") {
|
||||
// TODO: Android13自定义网络类型文本不可用
|
||||
findMethod("com.android.systemui.statusbar.policy.MobileSignalController") {
|
||||
name == "getMobileTypeName" && parameterTypes[0] == Int::class.java
|
||||
}.hookAfter {
|
||||
it.result = XSPUtils.getString("custom_mobile_type_text", "5G")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.content.Context
|
||||
import android.net.TrafficStats
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.init.InitFields
|
||||
import com.github.kyuubiran.ezxhelper.utils.findConstructor
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.R
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import java.text.DecimalFormat
|
||||
|
||||
object DoubleLineNetworkSpeedForT : HookRegister() {
|
||||
|
||||
private var mLastTotalUp: Long = 0
|
||||
private var mLastTotalDown: Long = 0
|
||||
|
||||
private var lastTimeStampTotalUp: Long = 0
|
||||
private var lastTimeStampTotalDown: Long = 0
|
||||
|
||||
private var upIcon = ""
|
||||
private var downIcon = ""
|
||||
|
||||
private val getDualSize = XSPUtils.getInt("status_bar_network_speed_dual_row_size", 0)
|
||||
private val getDualAlign = XSPUtils.getInt("status_bar_network_speed_dual_row_gravity", 0)
|
||||
|
||||
override fun init() = hasEnable("status_bar_dual_row_network_speed") {
|
||||
|
||||
val none = InitFields.moduleRes.getString(R.string.none)
|
||||
|
||||
if (XSPUtils.getString("status_bar_network_speed_dual_row_icon", none) != none) {
|
||||
upIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)?.firstOrNull().toString()
|
||||
downIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)?.lastOrNull().toString()
|
||||
}
|
||||
|
||||
findConstructor("com.android.systemui.statusbar.views.NetworkSpeedView") {
|
||||
parameterCount == 2
|
||||
}.hookAfter {
|
||||
val mView = it.thisObject as TextView
|
||||
mView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 7f)
|
||||
if (getDualSize != 0) {
|
||||
mView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, getDualSize.toFloat())
|
||||
}
|
||||
mView.isSingleLine = false
|
||||
mView.setLineSpacing(0F, 0.8F)
|
||||
if (getDualAlign == 0) {
|
||||
mView.gravity = Gravity.START or Gravity.CENTER_VERTICAL
|
||||
} else {
|
||||
mView.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.policy.NetworkSpeedController") {
|
||||
name == "formatSpeed" && parameterCount == 2
|
||||
}.hookBefore {
|
||||
if (getDualAlign == 0) {
|
||||
it.result = "$upIcon ${getTotalUpSpeed(it.args[0] as Context)}\n$downIcon ${
|
||||
getTotalDownloadSpeed(it.args[0] as Context)
|
||||
}"
|
||||
} else {
|
||||
it.result = "${getTotalUpSpeed(it.args[0] as Context)} $upIcon\n${
|
||||
getTotalDownloadSpeed(it.args[0] as Context)
|
||||
} $downIcon"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取总的上行速度
|
||||
private fun getTotalUpSpeed(context: Context): String {
|
||||
val totalUpSpeed: Float
|
||||
|
||||
val currentTotalTxBytes = TrafficStats.getTotalTxBytes()
|
||||
val nowTimeStampTotalUp = System.currentTimeMillis()
|
||||
|
||||
//计算上传速度
|
||||
val bytes = (currentTotalTxBytes - mLastTotalUp) * 1000 / (nowTimeStampTotalUp - lastTimeStampTotalUp).toFloat()
|
||||
val unit: String
|
||||
|
||||
if (bytes >= 1048576) {
|
||||
totalUpSpeed = DecimalFormat("0.0").format(bytes / 1048576).toFloat()
|
||||
unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second", "string", context.packageName))
|
||||
} else {
|
||||
totalUpSpeed = DecimalFormat("0.0").format(bytes / 1024).toFloat()
|
||||
unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second", "string", context.packageName))
|
||||
}
|
||||
|
||||
//保存当前的流量总和和上次的时间戳
|
||||
mLastTotalUp = currentTotalTxBytes
|
||||
lastTimeStampTotalUp = nowTimeStampTotalUp
|
||||
|
||||
return if (totalUpSpeed >= 100) {
|
||||
"${totalUpSpeed.toInt()}$unit"
|
||||
} else {
|
||||
"${totalUpSpeed}$unit"
|
||||
}
|
||||
}
|
||||
|
||||
//获取总的下行速度
|
||||
private fun getTotalDownloadSpeed(context: Context): String {
|
||||
val totalDownSpeed: Float
|
||||
val currentTotalRxBytes = TrafficStats.getTotalRxBytes()
|
||||
val nowTimeStampTotalDown = System.currentTimeMillis()
|
||||
|
||||
//计算下行速度
|
||||
val bytes = (currentTotalRxBytes - mLastTotalDown) * 1000 / (nowTimeStampTotalDown - lastTimeStampTotalDown).toFloat()
|
||||
|
||||
val unit: String
|
||||
|
||||
if (bytes >= 1048576) {
|
||||
totalDownSpeed = DecimalFormat("0.0").format(bytes / 1048576).toFloat()
|
||||
unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second", "string", context.packageName))
|
||||
} else {
|
||||
totalDownSpeed = DecimalFormat("0.0").format(bytes / 1024).toFloat()
|
||||
unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second", "string", context.packageName))
|
||||
}
|
||||
//保存当前的流量总和和上次的时间戳
|
||||
mLastTotalDown = currentTotalRxBytes
|
||||
lastTimeStampTotalDown = nowTimeStampTotalDown
|
||||
|
||||
return if (totalDownSpeed >= 100) {
|
||||
"${totalDownSpeed.toInt()}$unit"
|
||||
} else {
|
||||
"${totalDownSpeed}$unit"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObject
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object HideBatteryIconForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiBatteryMeterView") {
|
||||
name == "updateResources"
|
||||
}.hookAfter {
|
||||
//隐藏电池图标
|
||||
hasEnable("hide_battery_icon") {
|
||||
(it.thisObject.getObjectAs<ImageView>("mBatteryIconView")).visibility = View.GONE
|
||||
if (it.thisObject.getObject("mBatteryStyle") == 1) {
|
||||
(it.thisObject.getObjectAs<FrameLayout>("mBatteryDigitalView")).visibility =
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
//隐藏电池内的百分比
|
||||
hasEnable("hide_battery_percentage_icon") {
|
||||
(it.thisObject.getObjectAs<TextView>("mBatteryPercentMarkView")).textSize = 0F
|
||||
}
|
||||
//隐藏电池百分号
|
||||
hasEnable("hide_battery_percentage_icon") {
|
||||
(it.thisObject.getObjectAs<TextView>("mBatteryPercentMarkView")).textSize = 0F
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiBatteryMeterView") {
|
||||
name == "updateChargeAndText"
|
||||
}.hookAfter {
|
||||
//隐藏电池充电图标
|
||||
hasEnable("hide_battery_charging_icon") {
|
||||
(it.thisObject.getObjectAs<ImageView>("mBatteryChargingInView")).visibility =
|
||||
View.GONE
|
||||
(it.thisObject.getObjectAs<ImageView>("mBatteryChargingView")).visibility =
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
object HideHDIconForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
hasEnable("hide_new_hd_icon") {
|
||||
findMethod("com.android.systemui.statusbar.policy.HDController") { name == "update" }.hookBefore {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun hide(it: XC_MethodHook.MethodHookParam) {
|
||||
hasEnable("hide_big_hd_icon") {
|
||||
(it.thisObject.getObjectAs<ImageView>("mVolte")).visibility = View.GONE
|
||||
}
|
||||
hasEnable("hide_small_hd_icon") {
|
||||
(it.thisObject.getObjectAs<ImageView>("mSmallHd")).visibility = View.GONE
|
||||
}
|
||||
hasEnable("hide_hd_no_service_icon") {
|
||||
(it.thisObject.getObjectAs<ImageView>("mVolteNoService")).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
object HideMobileActivityIconForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hide(it: XC_MethodHook.MethodHookParam) {
|
||||
hasEnable("hide_mobile_activity_icon") {
|
||||
(it.thisObject.getObjectAs<ImageView>("mLeftInOut")).visibility = View.GONE
|
||||
(it.thisObject.getObjectAs<ImageView>("mRightInOut")).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
object HideMobileTypeIconForT : HookRegister() {
|
||||
|
||||
private val isBigType = XSPUtils.getBoolean("big_mobile_type_icon", false)
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hideMobileTypeIcon(it)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hideMobileTypeIcon(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideMobileTypeIcon(it: XC_MethodHook.MethodHookParam) {
|
||||
hasEnable("hide_mobile_type_icon") {
|
||||
if (isBigType) {
|
||||
(it.thisObject.getObjectAs<TextView>("mMobileType")).visibility =
|
||||
View.GONE
|
||||
(it.thisObject.getObjectAs<ImageView>("mMobileTypeImage")).visibility =
|
||||
View.GONE
|
||||
(it.thisObject.getObjectAs<TextView>("mMobileTypeSingle")).visibility =
|
||||
View.GONE
|
||||
} else {
|
||||
(it.thisObject.getObjectAs<TextView>("mMobileType")).visibility =
|
||||
View.INVISIBLE
|
||||
(it.thisObject.getObjectAs<ImageView>("mMobileTypeImage")).visibility =
|
||||
View.INVISIBLE
|
||||
(it.thisObject.getObjectAs<TextView>("mMobileTypeSingle")).visibility =
|
||||
View.INVISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object HideNetworkSpeedSplitterForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.views.NetworkSpeedSplitter") {
|
||||
name == "init"
|
||||
}.hookAfter {
|
||||
hasEnable("hide_network_speed_splitter") {
|
||||
val textView = it.thisObject as TextView
|
||||
textView.text = " "
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object HideSimIconForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.phone.StatusBarSignalPolicy") {
|
||||
name == "hasCorrectSubs" && parameterTypes[0] == MutableList::class.java
|
||||
}.hookBefore {
|
||||
val list = it.args[0] as MutableList<*>
|
||||
val size = list.size
|
||||
hasEnable("hide_sim_two_icon", extraCondition = { size == 2 }) {
|
||||
list.removeAt(1)
|
||||
}
|
||||
hasEnable("hide_sim_one_icon", extraCondition = { size >= 1 }) {
|
||||
list.removeAt(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
object HideStatusBarIconForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.phone.StatusBarIconControllerImpl") {
|
||||
name == "setIconVisibility" && parameterCount == 2
|
||||
}.hookBefore {
|
||||
hideIcon(it)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.phone.MiuiDripLeftStatusBarIconControllerImpl") {
|
||||
name == "setIconVisibility" && parameterCount == 2
|
||||
}.hookBefore {
|
||||
hideIcon(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideIcon(it: XC_MethodHook.MethodHookParam) {
|
||||
//Log.d("图标名字", "handleLoadPackage: " + it.args[0])
|
||||
when (it.args[0] as String) {
|
||||
//隐藏蓝牙
|
||||
"bluetooth" -> hasEnable("hide_bluetooth_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏蓝牙电量
|
||||
"bluetooth_handsfree_battery" -> hasEnable("hide_bluetooth_battery_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏勿扰
|
||||
"zen" -> hasEnable("hide_zen_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏声音
|
||||
"volume" -> hasEnable("hide_volume_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏WIFI
|
||||
"wifi" -> hasEnable("hide_wifi_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏WIFI辅助
|
||||
"slave_wifi" -> hasEnable("hide_slave_wifi_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏飞行模式
|
||||
"airplane" -> hasEnable("hide_airplane_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏闹钟
|
||||
"alarm_clock" -> hasEnable("hide_alarm_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏定位
|
||||
"location" -> hasEnable("hide_gps_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏热点
|
||||
"hotspot" -> hasEnable("hide_hotspot_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏耳机
|
||||
"headset" -> hasEnable("hide_headset_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏VPN
|
||||
"vpn" -> hasEnable("hide_vpn_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏无SIM卡
|
||||
"no_sim" -> hasEnable("hide_no_sim_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏NFC图标
|
||||
"nfc" -> hasEnable("hide_nfc_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object HideStatusBarNetworkSpeedSecondForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.views.NetworkSpeedView") {
|
||||
name == "setNetworkSpeed" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
hasEnable("hide_status_bar_network_speed_second") {
|
||||
if (it.args[0] != null) {
|
||||
val mText = (it.args[0] as String)
|
||||
.replace("/", "")
|
||||
.replace("s", "")
|
||||
.replace("\'", "")
|
||||
.replace("วิ", "")
|
||||
it.args[0] = mText
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
object HideWifiActivityIconForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarWifiView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarWifiView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hide(it: XC_MethodHook.MethodHookParam) {
|
||||
//隐藏WIFI箭头
|
||||
hasEnable("hide_wifi_activity_icon") {
|
||||
(it.thisObject.getObjectAs<ImageView>("mWifiActivityView")).visibility =
|
||||
View.INVISIBLE
|
||||
}
|
||||
//隐藏WIFI标准图标
|
||||
hasEnable("hide_wifi_standard_icon") {
|
||||
(it.thisObject.getObjectAs<TextView>("mWifiStandardView")).visibility =
|
||||
View.INVISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import java.lang.reflect.Method
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
object LockScreenClockDisplaySecondsForT : HookRegister() {
|
||||
|
||||
private var nowTime: Date = Calendar.getInstance().time
|
||||
|
||||
override fun init() = hasEnable("lock_screen_clock_display_seconds") {
|
||||
findConstructor("com.miui.clock.MiuiBaseClock") {
|
||||
paramCount == 2
|
||||
}.hookAfter {
|
||||
try {
|
||||
val viewGroup = it.thisObject as LinearLayout
|
||||
val d: Method = viewGroup.javaClass.getDeclaredMethod("updateTime")
|
||||
val r = Runnable {
|
||||
d.isAccessible = true
|
||||
d.invoke(viewGroup)
|
||||
}
|
||||
|
||||
class T : TimerTask() {
|
||||
override fun run() {
|
||||
Handler(viewGroup.context.mainLooper).post(r)
|
||||
}
|
||||
}
|
||||
Timer().scheduleAtFixedRate(T(), 1000 - System.currentTimeMillis() % 1000, 1000)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.miui.clock.MiuiLeftTopClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter { updateTime(it, false) }
|
||||
|
||||
findMethod("com.miui.clock.MiuiCenterHorizontalClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter { updateTime(it, false) }
|
||||
|
||||
findMethod("com.miui.clock.MiuiLeftTopLargeClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter { updateTime(it, false) }
|
||||
|
||||
findMethod("com.miui.clock.MiuiVerticalClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter { updateTime(it, true) }
|
||||
}
|
||||
|
||||
private fun updateTime(it: XC_MethodHook.MethodHookParam, isVertical: Boolean) {
|
||||
val textV = it.thisObject.getObjectAs<TextView>("mTimeText")
|
||||
val c: Context = textV.context
|
||||
|
||||
Log.d("lock_screen_clock_display_seconds", "updateTime: ${it.thisObject.javaClass.simpleName}")
|
||||
val is24 = Settings.System.getString(c.contentResolver, Settings.System.TIME_12_24) == "24"
|
||||
|
||||
nowTime = Calendar.getInstance().time
|
||||
|
||||
textV.text = getTime(is24, isVertical)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun getTime(is24: Boolean, isVertical: Boolean): String {
|
||||
var timePattern = ""
|
||||
timePattern += if (isVertical) { //垂直
|
||||
if (is24) "HH\nmm\nss" else "hh\nmm\nss"
|
||||
} else { //水平
|
||||
if (is24) "HH:mm:ss" else "h:mm:ss"
|
||||
}
|
||||
timePattern = SimpleDateFormat(timePattern).format(nowTime)
|
||||
return timePattern
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
|
||||
import android.app.AndroidAppHelper
|
||||
import android.content.Context
|
||||
import android.os.BatteryManager
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.init.InitFields
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObject
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.R
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import java.io.BufferedReader
|
||||
import java.io.FileReader
|
||||
import kotlin.math.abs
|
||||
|
||||
object LockScreenCurrentForT : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("lock_screen_charging_current") {
|
||||
findMethod("com.android.keyguard.charge.ChargeUtils") {
|
||||
name == "getChargingHintText" && parameterCount == 3
|
||||
}.hookAfter {
|
||||
it.result = "${getCurrent()}\n${it.result}"
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.phone.KeyguardBottomAreaView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter {
|
||||
(it.thisObject.getObject("mIndicationText") as TextView).isSingleLine = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun getCurrent(): String {
|
||||
val batteryManager = AndroidAppHelper.currentApplication().getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||
val current = abs(batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW) / 1000)
|
||||
return "${InitFields.moduleRes.getString(R.string.current_current)} ${current}mA"
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平均电流值
|
||||
* 获取 filePath 文件 totalCount 次数的平均值,每次采样间隔 intervalMs 时间
|
||||
*/
|
||||
private fun getMeanCurrentVal(filePath: String, totalCount: Int, intervalMs: Int): Float {
|
||||
var meanVal = 0.0f
|
||||
if (totalCount <= 0) {
|
||||
return 0.0f
|
||||
}
|
||||
for (i in 0 until totalCount) {
|
||||
try {
|
||||
val f: Float = readFile(filePath, 0).toFloat()
|
||||
meanVal += f / totalCount
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
if (intervalMs <= 0) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
Thread.sleep(intervalMs.toLong())
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return meanVal
|
||||
}
|
||||
|
||||
private fun readFile(path: String, defaultValue: Int): Int {
|
||||
try {
|
||||
val bufferedReader = BufferedReader(FileReader(path))
|
||||
val i: Int = bufferedReader.readLine().toInt(10)
|
||||
bufferedReader.close()
|
||||
return i
|
||||
} catch (_: java.lang.Exception) {
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.View.OnTouchListener
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import kotlin.math.abs
|
||||
|
||||
object LockScreenDoubleTapToSleepForT : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("lock_screen_double_tap_to_sleep") {
|
||||
findMethod("com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer") {
|
||||
name == "onFinishInflate"
|
||||
}.hookBefore {
|
||||
val view = it.thisObject as View
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchTime", 0L)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", 0f)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", 0f)
|
||||
view.setOnTouchListener(OnTouchListener { v, event ->
|
||||
if (event.action != MotionEvent.ACTION_DOWN) return@OnTouchListener false
|
||||
var currentTouchTime =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchTime") as Long
|
||||
var currentTouchX =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchX") as Float
|
||||
var currentTouchY =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchY") as Float
|
||||
val lastTouchTime = currentTouchTime
|
||||
val lastTouchX = currentTouchX
|
||||
val lastTouchY = currentTouchY
|
||||
currentTouchTime = System.currentTimeMillis()
|
||||
currentTouchX = event.x
|
||||
currentTouchY = event.y
|
||||
if (currentTouchTime - lastTouchTime < 250L && abs(currentTouchX - lastTouchX) < 100f && abs(
|
||||
currentTouchY - lastTouchY
|
||||
) < 100f
|
||||
) {
|
||||
val keyguardMgr =
|
||||
v.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
if (keyguardMgr.isKeyguardLocked) {
|
||||
XposedHelpers.callMethod(
|
||||
v.context.getSystemService(Context.POWER_SERVICE),
|
||||
"goToSleep",
|
||||
SystemClock.uptimeMillis()
|
||||
)
|
||||
}
|
||||
currentTouchTime = 0L
|
||||
currentTouchX = 0f
|
||||
currentTouchY = 0f
|
||||
}
|
||||
XposedHelpers.setAdditionalInstanceField(
|
||||
view,
|
||||
"currentTouchTime",
|
||||
currentTouchTime
|
||||
)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", currentTouchX)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", currentTouchY)
|
||||
v.performClick()
|
||||
false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookReplace
|
||||
import com.github.kyuubiran.ezxhelper.utils.invokeMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object MaximumNumberOfNotificationIconsForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
val icons = XSPUtils.getInt("maximum_number_of_notification_icons", 3)
|
||||
val dots = XSPUtils.getInt("maximum_number_of_notification_dots", 3)
|
||||
findMethod("com.android.systemui.statusbar.phone.NotificationIconContainer") {
|
||||
name == "miuiShowNotificationIcons" && parameterCount == 1
|
||||
}.hookReplace {
|
||||
if (it.args[0] as Boolean) {
|
||||
it.thisObject.putObject("MAX_DOTS", dots)
|
||||
it.thisObject.putObject("MAX_STATIC_ICONS", icons)
|
||||
it.thisObject.putObject("MAX_VISIBLE_ICONS_ON_LOCK", icons)
|
||||
} else {
|
||||
it.thisObject.putObject("MAX_DOTS", 0)
|
||||
it.thisObject.putObject("MAX_STATIC_ICONS", 0)
|
||||
it.thisObject.putObject("MAX_VISIBLE_ICONS_ON_LOCK", 0)
|
||||
}
|
||||
it.thisObject.invokeMethod("updateState")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import com.lt2333.simplicitytools.views.WeatherData
|
||||
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object NewNotificationWeatherForT : HookRegister() {
|
||||
// TODO: Android13控制中心天气不可用
|
||||
lateinit var weather: WeatherData
|
||||
var clockId: Int = -2
|
||||
|
||||
@SuppressLint("DiscouragedApi", "ClickableViewAccessibility")
|
||||
override fun init() = hasEnable("control_center_weather") {
|
||||
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
|
||||
findMethod("com.android.systemui.controlcenter.phone.widget.ControlCenterDateView", findSuper = true) { name == "onDetachedFromWindow" }.hookBefore {
|
||||
if ((it.thisObject as TextView).id == clockId && this::weather.isInitialized) {
|
||||
weather.onDetachedFromWindow()
|
||||
}
|
||||
}
|
||||
findMethod("com.android.systemui.controlcenter.phone.widget.ControlCenterDateView", findSuper = true) { name == "setText" }.hookBefore {
|
||||
val time = it.args[0]?.toString()
|
||||
val view = it.thisObject as TextView
|
||||
if (view.id == clockId && time != null && this::weather.isInitialized) {
|
||||
// val layout = view.layoutParams as ViewGroup.MarginLayoutParams
|
||||
// val y = view.height / 2
|
||||
// layout.topMargin = -y
|
||||
it.args[0] = "${weather.weatherData}$time"
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.shared.plugins.PluginManagerImpl") { name == "getClassLoader" }.hookAfter { getClassLoader ->
|
||||
val appInfo = getClassLoader.args[0] as ApplicationInfo
|
||||
val classLoader = getClassLoader.result as ClassLoader
|
||||
if (appInfo.packageName == "miui.systemui.plugin") {
|
||||
findMethod("miui.systemui.controlcenter.windowview.MainPanelHeaderController", classLoader = classLoader) { name == "addClockViews" }.hookAfter {
|
||||
val dateView = it.thisObject.getObjectAs<TextView>("dateView")
|
||||
clockId = dateView.id
|
||||
weather = WeatherData(dateView.context, isDisplayCity)
|
||||
weather.callBacks = {
|
||||
dateView.invokeMethod("updateTime")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.utils.SystemProperties
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import com.lt2333.simplicitytools.views.WeatherView
|
||||
|
||||
object NotificationWeatherForT : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("notification_weather") {
|
||||
var mWeatherView: TextView? = null
|
||||
var mConstraintLayout: ConstraintLayout? = null
|
||||
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
|
||||
findMethod("com.android.systemui.qs.MiuiNotificationHeaderView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter { param ->
|
||||
val viewGroup = param.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
|
||||
// MIUI编译时间大于 2022-03-12 00:00:00 且为内测版
|
||||
if (SystemProperties[context, "ro.build.date.utc"].toInt() >= 1647014400 &&
|
||||
!SystemProperties[context, "ro.build.version.incremental"].endsWith("XM")
|
||||
) {
|
||||
//获取原组件
|
||||
val bigTimeId =
|
||||
context.resources.getIdentifier("big_time", "id", context.packageName)
|
||||
val bigTime: TextView = viewGroup.findViewById(bigTimeId)
|
||||
|
||||
val dateTimeId =
|
||||
context.resources.getIdentifier("date_time", "id", context.packageName)
|
||||
val dateTime: TextView = viewGroup.findViewById(dateTimeId)
|
||||
|
||||
//创建新布局
|
||||
val mConstraintLayoutLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.topMargin = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"qs_control_header_tiles_margin_top",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
mConstraintLayout =
|
||||
ConstraintLayout(context).also { it.layoutParams = mConstraintLayoutLp }
|
||||
|
||||
(bigTime.parent as ViewGroup).addView(mConstraintLayout, 0)
|
||||
|
||||
|
||||
//从原布局中删除组件
|
||||
(bigTime.parent as ViewGroup).removeView(bigTime)
|
||||
(dateTime.parent as ViewGroup).removeView(dateTime)
|
||||
|
||||
|
||||
//添加组件至新布局
|
||||
mConstraintLayout!!.addView(bigTime)
|
||||
mConstraintLayout!!.addView(dateTime)
|
||||
|
||||
//组件属性
|
||||
|
||||
val dateTimeLp = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.startToEnd = bigTimeId
|
||||
it.bottomToBottom = 0
|
||||
it.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
it.bottomMargin = dp2px(context, 5f)
|
||||
}
|
||||
dateTime.layoutParams = dateTimeLp
|
||||
|
||||
|
||||
//创建天气组件
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.QSControl.Date",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
mConstraintLayout!!.addView(mWeatherView)
|
||||
|
||||
val mweatherviewLp = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.startToEnd = bigTimeId
|
||||
it.bottomToTop = dateTimeId
|
||||
it.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
(mWeatherView as WeatherView).layoutParams = mweatherviewLp
|
||||
|
||||
} else {
|
||||
val layoutParam =
|
||||
loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams").getConstructor(
|
||||
Int::class.java,
|
||||
Int::class.java
|
||||
).newInstance(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
) as ViewGroup.MarginLayoutParams
|
||||
layoutParam.putObject(
|
||||
"bottomToTop",
|
||||
context.resources.getIdentifier("date_time", "id", context.packageName)
|
||||
)
|
||||
layoutParam.putObject(
|
||||
"startToEnd",
|
||||
context.resources.getIdentifier("big_time", "id", context.packageName)
|
||||
)
|
||||
layoutParam.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.QSControl.Date",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParams = layoutParam
|
||||
}
|
||||
viewGroup.addView(mWeatherView)
|
||||
}
|
||||
|
||||
(mWeatherView as WeatherView).setOnClickListener {
|
||||
try {
|
||||
val intent = Intent().apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
component = ComponentName(
|
||||
"com.miui.weather2",
|
||||
"com.miui.weather2.ActivityWeatherMain"
|
||||
)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(context, "启动失败", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.qs.MiuiNotificationHeaderView") {
|
||||
name == "updateLayout"
|
||||
}.hookAfter {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val mOrientation = viewGroup.getObject("mOrientation") as Int
|
||||
// MIUI编译时间大于 2022-03-12 00:00:00 且为内测版
|
||||
if (SystemProperties[context, "ro.build.date.utc"]!!.toInt() >= 1647014400 && !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith(
|
||||
"DEV"
|
||||
) && !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM")
|
||||
) {
|
||||
if (mOrientation == 1) {
|
||||
mConstraintLayout!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mConstraintLayout!!.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
if (mOrientation == 1) {
|
||||
mWeatherView!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mWeatherView!!.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import com.lt2333.simplicitytools.views.WeatherView
|
||||
|
||||
object OldNotificationWeatherForT : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("notification_weather") {
|
||||
var mWeatherView: TextView? = null
|
||||
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
|
||||
findMethod("com.android.systemui.qs.MiuiQSHeaderView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val layoutParam =
|
||||
loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams")
|
||||
.getConstructor(Int::class.java, Int::class.java)
|
||||
.newInstance(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
) as ViewGroup.MarginLayoutParams
|
||||
|
||||
layoutParam.putObject(
|
||||
"endToStart",
|
||||
context.resources.getIdentifier(
|
||||
"notification_shade_shortcut",
|
||||
"id",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParam.putObject(
|
||||
"topToTop",
|
||||
context.resources.getIdentifier(
|
||||
"notification_shade_shortcut",
|
||||
"id",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParam.putObject(
|
||||
"bottomToBottom",
|
||||
context.resources.getIdentifier(
|
||||
"notification_shade_shortcut",
|
||||
"id",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.StatusBar.Expanded.Clock.QuickSettingDate",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParams = layoutParam
|
||||
}
|
||||
viewGroup.addView(mWeatherView)
|
||||
(mWeatherView as WeatherView).setOnClickListener {
|
||||
try {
|
||||
val intent = Intent().apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
component = ComponentName(
|
||||
"com.miui.weather2",
|
||||
"com.miui.weather2.ActivityWeatherMain"
|
||||
)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(context, "启动失败,可能是不支持", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//解决横屏重叠
|
||||
findMethod("com.android.systemui.qs.MiuiQSHeaderView") {
|
||||
name == "updateLayout"
|
||||
}.hookAfter {
|
||||
val mOritation = it.thisObject.getObject("mOrientation") as Int
|
||||
if (mOritation == 1) {
|
||||
mWeatherView!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mWeatherView!!.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.view.ViewGroup
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object OldQSCustomForT : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("old_qs_custom_switch") {
|
||||
val mRows = XSPUtils.getInt("qs_custom_rows", 3)
|
||||
val mRowsHorizontal = XSPUtils.getInt("qs_custom_rows_horizontal", 2)
|
||||
val mColumns = XSPUtils.getInt("qs_custom_columns", 4)
|
||||
val mColumnsUnexpanded = XSPUtils.getInt("qs_custom_columns_unexpanded", 5)
|
||||
|
||||
findMethod("com.android.systemui.qs.MiuiQuickQSPanel") {
|
||||
name == "setMaxTiles" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
//未展开时的列数
|
||||
it.args[0] = mColumnsUnexpanded
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.qs.MiuiTileLayout") {
|
||||
name == "updateColumns"
|
||||
}.hookAfter {
|
||||
//展开时的列数
|
||||
it.thisObject.putObject("mColumns", mColumns)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.qs.MiuiTileLayout") {
|
||||
name == "updateResources"
|
||||
}.hookAfter {
|
||||
//展开时的行数
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val mConfiguration: Configuration = viewGroup.context.resources.configuration
|
||||
if (mConfiguration.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
viewGroup.putObject("mMaxAllowedRows", mRows)
|
||||
} else {
|
||||
viewGroup.putObject("mMaxAllowedRows", mRowsHorizontal)
|
||||
}
|
||||
viewGroup.requestLayout()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
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.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object RemoveLockScreenCameraForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
//屏蔽右下角组件显示
|
||||
findMethod("com.android.systemui.statusbar.phone.KeyguardBottomAreaView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter {
|
||||
hasEnable("remove_lock_screen_camera") {
|
||||
(it.thisObject.getObject("mRightAffordanceViewLayout") as LinearLayout).visibility =
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
//屏蔽滑动撞墙动画
|
||||
findMethod("com.android.keyguard.KeyguardMoveRightController") {
|
||||
name == "onTouchMove" && parameterCount == 2
|
||||
}.hookBefore {
|
||||
hasEnable("remove_lock_screen_camera") {
|
||||
it.result = false
|
||||
}
|
||||
}
|
||||
findMethod("com.android.keyguard.KeyguardMoveRightController") {
|
||||
name == "reset"
|
||||
}.hookBefore {
|
||||
hasEnable("remove_lock_screen_camera") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object RemoveTheLeftSideOfTheLockScreenForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.keyguard.negative.MiuiKeyguardMoveLeftViewContainer") {
|
||||
name == "inflateLeftView"
|
||||
}.hookBefore {
|
||||
hasEnable("remove_the_left_side_of_the_lock_screen") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object ShowWifiStandardForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarWifiView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
hasEnable("show_wifi_standard") {
|
||||
findMethod("com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState") {
|
||||
name == "copyTo" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
val wifiStandard = it.thisObject.getObjectAs<Int>("wifiStandard")
|
||||
it.thisObject.putObject("showWifiStandard", wifiStandard != 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarWifiView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
hasEnable("show_wifi_standard") {
|
||||
findMethod("com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState") {
|
||||
name == "copyTo" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
val wifiStandard = it.thisObject.getObjectAs<Int>("wifiStandard")
|
||||
it.thisObject.putObject("showWifiStandard", wifiStandard != 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Typeface
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookReturnConstant
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
|
||||
object StatusBarBigMobileTypeIconForT : HookRegister() {
|
||||
|
||||
private val upAndDownPosition = XSPUtils.getInt("big_mobile_type_icon_up_and_down_position", 0)
|
||||
private val leftAndRightMargin =
|
||||
XSPUtils.getInt("big_mobile_type_icon_left_and_right_margins", 0)
|
||||
private val isBold = XSPUtils.getBoolean("big_mobile_type_icon_bold", true)
|
||||
private val size = XSPUtils.getFloat("big_mobile_type_icon_size", 12.5f)
|
||||
|
||||
override fun init() = hasEnable("big_mobile_type_icon") {
|
||||
// TODO: Android13大移动类型图标不可用
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "init"
|
||||
}.hookAfter { param ->
|
||||
val statusBarMobileView = param.thisObject as ViewGroup
|
||||
val context: Context = statusBarMobileView.context
|
||||
val res: Resources = context.resources
|
||||
|
||||
//获取组件
|
||||
val mobileContainerLeftId: Int =
|
||||
res.getIdentifier("mobile_container_left", "id", "com.android.systemui")
|
||||
val mobileContainerLeft =
|
||||
statusBarMobileView.findViewById<ViewGroup>(mobileContainerLeftId)
|
||||
|
||||
val mobileTypeId: Int =
|
||||
res.getIdentifier("mobile_type", "id", "com.android.systemui")
|
||||
val mobileType = statusBarMobileView.findViewById<TextView>(mobileTypeId)
|
||||
|
||||
val mobileLeftMobileInoutId: Int = res.getIdentifier(
|
||||
"mobile_left_mobile_inout",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val mobileLeftMobileInout =
|
||||
statusBarMobileView.findViewById<ImageView>(mobileLeftMobileInoutId)
|
||||
|
||||
|
||||
//获取插入位置
|
||||
val mobileContainerRightId: Int = res.getIdentifier(
|
||||
"mobile_container_right",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val mobileContainerRight =
|
||||
statusBarMobileView.findViewById<ViewGroup>(mobileContainerRightId)
|
||||
val rightParentLayout = mobileContainerRight.parent as ViewGroup
|
||||
val mobileContainerRightIndex =
|
||||
rightParentLayout.indexOfChild(mobileContainerRight)
|
||||
|
||||
//创建新布局
|
||||
val newLinearLayoutLP = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
val newLinearlayout = LinearLayout(context).also {
|
||||
it.layoutParams = newLinearLayoutLP
|
||||
it.id = mobileContainerLeftId
|
||||
it.setPadding(leftAndRightMargin, 0, leftAndRightMargin, 0)
|
||||
}
|
||||
param.thisObject.putObject("mMobileLeftContainer", newLinearlayout)
|
||||
rightParentLayout.addView(
|
||||
newLinearlayout,
|
||||
mobileContainerRightIndex
|
||||
)
|
||||
|
||||
//将组件插入新的布局
|
||||
(mobileType.parent as ViewGroup).removeView(mobileType)
|
||||
(mobileLeftMobileInout.parent as ViewGroup).removeView(mobileLeftMobileInout)
|
||||
(mobileContainerLeft.parent as ViewGroup).removeView(mobileContainerLeft)
|
||||
|
||||
|
||||
newLinearlayout.addView(mobileType) //类型
|
||||
val mobileTypeLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.gravity = Gravity.CENTER_VERTICAL
|
||||
it.topMargin = upAndDownPosition
|
||||
}
|
||||
mobileType.also {
|
||||
it.setTextSize(TypedValue.COMPLEX_UNIT_DIP, size)
|
||||
if (isBold) {
|
||||
it.typeface = Typeface.DEFAULT_BOLD
|
||||
}
|
||||
it.layoutParams = mobileTypeLp
|
||||
}
|
||||
|
||||
|
||||
newLinearlayout.addView(mobileLeftMobileInout) //箭头
|
||||
val mobileLeftMobileInoutLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
mobileLeftMobileInout.also {
|
||||
it.layoutParams = mobileLeftMobileInoutLp
|
||||
}
|
||||
|
||||
//屏蔽更新布局
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "updateMobileTypeLayout" && parameterTypes[0] == String::class.java
|
||||
}.hookReturnConstant(null)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import android.view.View.OnTouchListener
|
||||
import android.view.ViewGroup
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import kotlin.math.abs
|
||||
|
||||
object StatusBarDoubleTapToSleepForT : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("status_bar_double_tap_to_sleep") {
|
||||
findMethod("com.android.systemui.statusbar.phone.MiuiPhoneStatusBarView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookBefore {
|
||||
val view = it.thisObject as ViewGroup
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchTime", 0L)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", 0f)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", 0f)
|
||||
view.setOnTouchListener(OnTouchListener { v, event ->
|
||||
if (event.action != MotionEvent.ACTION_DOWN) return@OnTouchListener false
|
||||
var currentTouchTime =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchTime") as Long
|
||||
var currentTouchX =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchX") as Float
|
||||
var currentTouchY =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchY") as Float
|
||||
val lastTouchTime = currentTouchTime
|
||||
val lastTouchX = currentTouchX
|
||||
val lastTouchY = currentTouchY
|
||||
currentTouchTime = System.currentTimeMillis()
|
||||
currentTouchX = event.x
|
||||
currentTouchY = event.y
|
||||
if (currentTouchTime - lastTouchTime < 250L && abs(currentTouchX - lastTouchX) < 100f && abs(
|
||||
currentTouchY - lastTouchY
|
||||
) < 100f
|
||||
) {
|
||||
XposedHelpers.callMethod(
|
||||
v.context.getSystemService(Context.POWER_SERVICE),
|
||||
"goToSleep",
|
||||
SystemClock.uptimeMillis()
|
||||
)
|
||||
currentTouchTime = 0L
|
||||
currentTouchX = 0f
|
||||
currentTouchY = 0f
|
||||
}
|
||||
XposedHelpers.setAdditionalInstanceField(
|
||||
view,
|
||||
"currentTouchTime",
|
||||
currentTouchTime
|
||||
)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", currentTouchX)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", currentTouchY)
|
||||
v.performClick()
|
||||
false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object StatusBarLayoutForT : HookRegister() {
|
||||
|
||||
private val getMode = XSPUtils.getInt("status_bar_layout_mode", 0)
|
||||
private val getHoleLocation = XSPUtils.getInt("screen_hole_location", 0)
|
||||
|
||||
private var statusBarLeft = 0
|
||||
private var statusBarTop = 0
|
||||
private var statusBarRight = 0
|
||||
private var statusBarBottom = 0
|
||||
|
||||
override fun init() {
|
||||
|
||||
// TODO: Android13状态栏布局不可用
|
||||
|
||||
var mLeftLayout: LinearLayout? = null
|
||||
var mRightLayout: LinearLayout? = null
|
||||
var mCenterLayout: LinearLayout?
|
||||
var statusBar: ViewGroup? = null
|
||||
|
||||
fun updateLayout(context: Context) {
|
||||
//判断屏幕方向
|
||||
val mConfiguration: Configuration = context.resources.configuration
|
||||
if (mConfiguration.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
mLeftLayout!!.setPadding(statusBarLeft, 0, 0, 0)
|
||||
mRightLayout!!.setPadding(0, 0, statusBarRight, 0)
|
||||
statusBar!!.setPadding(0, statusBarTop, 0, statusBarBottom)
|
||||
} else {
|
||||
//横屏状态
|
||||
mLeftLayout!!.setPadding(175, 0, 0, 0)
|
||||
mRightLayout!!.setPadding(0, 0, 175, 0)
|
||||
statusBar!!.setPadding(0, statusBarTop, 0, statusBarBottom)
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否开启居中挖孔兼容模式
|
||||
if (getHoleLocation == 1) {
|
||||
findMethod("com.android.systemui.ScreenDecorations\$DisplayCutoutView") {
|
||||
name == "boundsFromDirection" && parameterCount == 3 && isStatic
|
||||
}.hookBefore {
|
||||
it.args[1] = 0
|
||||
}
|
||||
}
|
||||
|
||||
when (getMode) {
|
||||
//默认
|
||||
0 -> return
|
||||
//时钟居中
|
||||
1 -> {
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter { param ->
|
||||
val miuiPhoneStatusBarView =
|
||||
param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
|
||||
val context: Context = miuiPhoneStatusBarView.context
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
val statusBarId: Int =
|
||||
res.getIdentifier("status_bar", "id", "com.android.systemui")
|
||||
val statusBarContentsId: Int =
|
||||
res.getIdentifier("status_bar_contents", "id", "com.android.systemui")
|
||||
val systemIconAreaId: Int =
|
||||
res.getIdentifier("system_icon_area", "id", "com.android.systemui")
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val phoneStatusBarLeftContainerId: Int =
|
||||
res.getIdentifier(
|
||||
"phone_status_bar_left_container",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val notificationIconAreaInnerId: Int =
|
||||
res.getIdentifier(
|
||||
"notification_icon_area_inner",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
|
||||
val statusBarContents: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(statusBarContentsId)
|
||||
if (statusBar == null) return@hookAfter
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
val phoneStatusBarLeftContainer: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(phoneStatusBarLeftContainerId)
|
||||
val notificationIconAreaInner: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(notificationIconAreaInnerId)
|
||||
val systemIconArea: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(systemIconAreaId)
|
||||
|
||||
(clock.parent as ViewGroup).removeView(clock)
|
||||
(phoneStatusBarLeftContainer.parent as ViewGroup).removeView(
|
||||
phoneStatusBarLeftContainer
|
||||
)
|
||||
(notificationIconAreaInner.parent as ViewGroup).removeView(
|
||||
notificationIconAreaInner
|
||||
)
|
||||
(systemIconArea.parent as ViewGroup).removeView(systemIconArea)
|
||||
|
||||
val mConstraintLayout =
|
||||
ConstraintLayout(context).also {
|
||||
it.layoutParams = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
}
|
||||
|
||||
mConstraintLayout.addView(notificationIconAreaInner)
|
||||
|
||||
val fullscreenNotificationIconAreaLp = LinearLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
|
||||
notificationIconAreaInner.layoutParams = fullscreenNotificationIconAreaLp
|
||||
|
||||
//增加一个左对齐布局
|
||||
mLeftLayout = LinearLayout(context)
|
||||
val leftLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mLeftLayout!!.layoutParams = leftLp
|
||||
mLeftLayout!!.gravity = Gravity.START or Gravity.CENTER_VERTICAL
|
||||
|
||||
//增加一个居中布局
|
||||
mCenterLayout = LinearLayout(context)
|
||||
val centerLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
mCenterLayout!!.layoutParams = centerLp
|
||||
mCenterLayout!!.gravity = Gravity.CENTER or Gravity.CENTER_VERTICAL
|
||||
mRightLayout = LinearLayout(context)
|
||||
val rightLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mRightLayout!!.layoutParams = rightLp
|
||||
mRightLayout!!.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
mLeftLayout!!.addView(phoneStatusBarLeftContainer)
|
||||
mLeftLayout!!.addView(mConstraintLayout)
|
||||
|
||||
mCenterLayout!!.addView(clock)
|
||||
mRightLayout!!.addView(systemIconArea)
|
||||
statusBarContents.addView(mLeftLayout, 0)
|
||||
statusBarContents.addView(mCenterLayout)
|
||||
statusBarContents.addView(mRightLayout)
|
||||
|
||||
statusBarLeft = statusBar!!.paddingLeft
|
||||
statusBarTop = statusBar!!.paddingTop
|
||||
statusBarRight = statusBar!!.paddingRight
|
||||
statusBarBottom = statusBar!!.paddingBottom
|
||||
|
||||
|
||||
if (getHoleLocation == 2) {
|
||||
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
|
||||
if (customLeftMargin != 0) {
|
||||
statusBarLeft = customLeftMargin
|
||||
}
|
||||
|
||||
val customRightMargin = XSPUtils.getInt("status_bar_right_margin", 0)
|
||||
if (customRightMargin != 0) {
|
||||
statusBarRight = customRightMargin
|
||||
}
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.phone.PhoneStatusBarView") {
|
||||
name == "updateLayoutForCutout"
|
||||
}.hookAfter {
|
||||
hasEnable("layout_compatibility_mode") {
|
||||
val context = (it.thisObject as ViewGroup).context
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
//时钟居右
|
||||
2 -> {
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter { param ->
|
||||
val miuiPhoneStatusBarView =
|
||||
param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
|
||||
val context: Context = miuiPhoneStatusBarView.context
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
|
||||
//组件ID
|
||||
val statusBarId: Int =
|
||||
res.getIdentifier("status_bar", "id", "com.android.systemui")
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val batteryId: Int = res.getIdentifier("battery", "id", "com.android.systemui")
|
||||
|
||||
//查找组件
|
||||
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
|
||||
if (statusBar == null) return@hookAfter
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
val battery: ViewGroup = miuiPhoneStatusBarView.findViewById(batteryId)
|
||||
|
||||
//新建布局
|
||||
val rightLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
).also {
|
||||
it.marginStart = dp2px(context, 5f)
|
||||
}
|
||||
mRightLayout = LinearLayout(context).also {
|
||||
it.layoutParams = rightLp
|
||||
}
|
||||
|
||||
//添加布局与组件
|
||||
battery.addView(mRightLayout)
|
||||
(clock.parent as ViewGroup).removeView(clock)
|
||||
mRightLayout!!.addView(clock)
|
||||
}
|
||||
}
|
||||
//时钟居中+图标居左
|
||||
3 -> {
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter { param ->
|
||||
val miuiPhoneStatusBarView =
|
||||
param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
|
||||
val context: Context = miuiPhoneStatusBarView.context
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
val statusBarId: Int =
|
||||
res.getIdentifier("status_bar", "id", "com.android.systemui")
|
||||
val statusBarContentsId: Int =
|
||||
res.getIdentifier("status_bar_contents", "id", "com.android.systemui")
|
||||
val systemIconAreaId: Int =
|
||||
res.getIdentifier("system_icon_area", "id", "com.android.systemui")
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val phoneStatusBarLeftContainerId: Int =
|
||||
res.getIdentifier(
|
||||
"phone_status_bar_left_container",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val fullscreenNotificationIconAreaId: Int =
|
||||
res.getIdentifier(
|
||||
"fullscreen_notification_icon_area",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val statusIconsId: Int =
|
||||
res.getIdentifier(
|
||||
"statusIcons",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val systemIconsId: Int =
|
||||
res.getIdentifier(
|
||||
"system_icons",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val batteryId: Int =
|
||||
res.getIdentifier(
|
||||
"battery",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
|
||||
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
|
||||
val statusBarContents: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(statusBarContentsId)
|
||||
if (statusBar == null) return@hookAfter
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
val phoneStatusBarLeftContainer: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(phoneStatusBarLeftContainerId)
|
||||
val fullscreenNotificationIconArea: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(fullscreenNotificationIconAreaId)
|
||||
val systemIconArea: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(systemIconAreaId)
|
||||
val statusIcons: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(statusIconsId)
|
||||
val systemIcons: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(systemIconsId)
|
||||
val battery: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(batteryId)
|
||||
|
||||
(clock.parent as ViewGroup).removeView(clock)
|
||||
(phoneStatusBarLeftContainer.parent as ViewGroup).removeView(
|
||||
phoneStatusBarLeftContainer
|
||||
)
|
||||
(systemIconArea.parent as ViewGroup).removeView(systemIconArea)
|
||||
(statusIcons.parent as ViewGroup).removeView(statusIcons)
|
||||
(systemIcons.parent as ViewGroup).removeView(systemIcons)
|
||||
(battery.parent as ViewGroup).removeView(battery)
|
||||
(fullscreenNotificationIconArea.parent as ViewGroup).removeView(
|
||||
fullscreenNotificationIconArea
|
||||
)
|
||||
|
||||
val mConstraintLayout =
|
||||
ConstraintLayout(context).also {
|
||||
it.layoutParams = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
}
|
||||
|
||||
mConstraintLayout.addView(fullscreenNotificationIconArea)
|
||||
mConstraintLayout.addView(battery)
|
||||
|
||||
|
||||
battery.layoutParams = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
).also {
|
||||
it.endToEnd = 0
|
||||
}
|
||||
|
||||
|
||||
fullscreenNotificationIconArea.layoutParams = ConstraintLayout.LayoutParams(
|
||||
0,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
).also {
|
||||
it.startToEnd = batteryId
|
||||
it.endToEnd = 0
|
||||
}
|
||||
fullscreenNotificationIconArea.layoutDirection = View.LAYOUT_DIRECTION_RTL
|
||||
|
||||
|
||||
//增加一个左对齐布局
|
||||
mLeftLayout = LinearLayout(context)
|
||||
val leftLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mLeftLayout!!.layoutParams = leftLp
|
||||
mLeftLayout!!.gravity = Gravity.START or Gravity.CENTER_VERTICAL
|
||||
|
||||
//增加一个居中布局
|
||||
mCenterLayout = LinearLayout(context)
|
||||
val centerLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
mCenterLayout!!.layoutParams = centerLp
|
||||
mCenterLayout!!.gravity = Gravity.CENTER or Gravity.CENTER_VERTICAL
|
||||
|
||||
//增加一个右布局
|
||||
mRightLayout = LinearLayout(context)
|
||||
val rightLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mRightLayout!!.layoutParams = rightLp
|
||||
mRightLayout!!.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
|
||||
|
||||
mLeftLayout!!.addView(phoneStatusBarLeftContainer)
|
||||
mLeftLayout!!.addView(statusIcons)
|
||||
statusIcons.layoutDirection = View.LAYOUT_DIRECTION_RTL
|
||||
|
||||
mCenterLayout!!.addView(clock)
|
||||
|
||||
mRightLayout!!.addView(mConstraintLayout)
|
||||
fullscreenNotificationIconArea.layoutDirection = View.LAYOUT_DIRECTION_RTL
|
||||
|
||||
|
||||
statusBarContents.addView(mLeftLayout, 0)
|
||||
statusBarContents.addView(mCenterLayout)
|
||||
statusBarContents.addView(mRightLayout)
|
||||
|
||||
|
||||
|
||||
statusBarLeft = statusBar!!.paddingLeft
|
||||
statusBarTop = statusBar!!.paddingTop
|
||||
statusBarRight = statusBar!!.paddingRight
|
||||
statusBarBottom = statusBar!!.paddingBottom
|
||||
|
||||
|
||||
if (getHoleLocation == 2) {
|
||||
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
|
||||
if (customLeftMargin != 0) {
|
||||
statusBarLeft = customLeftMargin
|
||||
}
|
||||
|
||||
val customRightMargin = XSPUtils.getInt("status_bar_right_margin", 0)
|
||||
if (customRightMargin != 0) {
|
||||
statusBarRight = customRightMargin
|
||||
}
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
//兼容模式
|
||||
findMethod("com.android.systemui.statusbar.phone.PhoneStatusBarView") {
|
||||
name == "updateLayoutForCutout"
|
||||
}.hookAfter {
|
||||
if (getHoleLocation == 2) {
|
||||
val context = (it.thisObject as ViewGroup).context
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
|
||||
//解决重叠
|
||||
findMethod("com.android.systemui.statusbar.phone.MiuiCollapsedStatusBarFragment") {
|
||||
name == "showClock" && parameterTypes[0] == Boolean::class.java
|
||||
}.hookAfter {
|
||||
val miuiPhoneStatusBarView = it.thisObject.getObjectAs<ViewGroup>("mStatusBar")
|
||||
val res = miuiPhoneStatusBarView.resources
|
||||
val statusBarId =
|
||||
res.getIdentifier("status_bar", "id", "com.android.systemui")
|
||||
val statusBar1 = miuiPhoneStatusBarView.findViewById<ViewGroup>(statusBarId)
|
||||
//非锁屏下整个状态栏布局
|
||||
val keyguardMgr =
|
||||
statusBar1.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
if (keyguardMgr.isKeyguardLocked) {
|
||||
statusBar1!!.visibility = View.GONE
|
||||
} else {
|
||||
statusBar1!!.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object StatusBarNetworkSpeedRefreshSpeedForT : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.policy.NetworkSpeedController") {
|
||||
name == "postUpdateNetworkSpeedDelay" && parameterTypes[0] == Long::class.java
|
||||
}.hookBefore {
|
||||
hasEnable("status_bar_network_speed_refresh_speed") {
|
||||
it.args[0] = 1000L
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.os.Handler
|
||||
import android.provider.Settings
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.utils.XSPUtils
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
import java.lang.reflect.Method
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
object StatusBarTimeCustomizationForT : HookRegister() {
|
||||
|
||||
private val getMode = XSPUtils.getInt("custom_clock_mode", 0)
|
||||
private val getClockSize = XSPUtils.getInt("status_bar_clock_size", 0)
|
||||
private val getClockDoubleSize = XSPUtils.getInt("status_bar_clock_double_line_size", 0)
|
||||
private val isYear = XSPUtils.getBoolean("status_bar_time_year", false)
|
||||
private val isMonth = XSPUtils.getBoolean("status_bar_time_month", false)
|
||||
private val isDay = XSPUtils.getBoolean("status_bar_time_day", false)
|
||||
private val isWeek = XSPUtils.getBoolean("status_bar_time_week", false)
|
||||
private val isHideSpace = XSPUtils.getBoolean("status_bar_time_hide_space", false)
|
||||
private val isDoubleLine = XSPUtils.getBoolean("status_bar_time_double_line", false)
|
||||
private val isSecond = XSPUtils.getBoolean("status_bar_time_seconds", false)
|
||||
private val isDoubleHour = XSPUtils.getBoolean("status_bar_time_double_hour", false)
|
||||
private val isPeriod = XSPUtils.getBoolean("status_bar_time_period", true)
|
||||
private val isCenterAlign =
|
||||
XSPUtils.getBoolean("status_bar_time_double_line_center_align", false)
|
||||
|
||||
//极客模式
|
||||
private val getGeekClockSize = XSPUtils.getInt("status_bar_clock_size_geek", 0)
|
||||
private val getGeekFormat = XSPUtils.getString("custom_clock_format_geek", "HH:mm:ss")
|
||||
private val isGeekCenterAlign =
|
||||
XSPUtils.getBoolean("status_bar_time_center_align_geek", false)
|
||||
|
||||
private lateinit var nowTime: Date
|
||||
private var str = ""
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun init() {
|
||||
when (getMode) {
|
||||
//预设模式
|
||||
1 -> {
|
||||
var c: Context? = null
|
||||
|
||||
findConstructor("com.android.systemui.statusbar.views.MiuiClock") {
|
||||
paramCount == 3
|
||||
}.hookAfter {
|
||||
try {
|
||||
c = it.args[0] as Context
|
||||
val textV = it.thisObject as TextView
|
||||
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@hookAfter
|
||||
textV.isSingleLine = false
|
||||
if (isDoubleLine) {
|
||||
str = "\n"
|
||||
var clockDoubleLineSize = 7F
|
||||
if (getClockDoubleSize != 0) {
|
||||
clockDoubleLineSize = getClockDoubleSize.toFloat()
|
||||
}
|
||||
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clockDoubleLineSize)
|
||||
textV.setLineSpacing(0F, 0.8F)
|
||||
} else {
|
||||
if (getClockSize != 0) {
|
||||
val clockSize = getClockSize.toFloat()
|
||||
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clockSize)
|
||||
}
|
||||
}
|
||||
val d: Method = textV.javaClass.getDeclaredMethod("updateTime")
|
||||
val r = Runnable {
|
||||
d.isAccessible = true
|
||||
d.invoke(textV)
|
||||
}
|
||||
|
||||
class T : TimerTask() {
|
||||
override fun run() {
|
||||
Handler(textV.context.mainLooper).post(r)
|
||||
}
|
||||
}
|
||||
Timer().scheduleAtFixedRate(
|
||||
T(),
|
||||
1000 - System.currentTimeMillis() % 1000,
|
||||
1000
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter {
|
||||
try {
|
||||
val textV = it.thisObject as TextView
|
||||
if (textV.resources.getResourceEntryName(textV.id) == "clock") {
|
||||
val t = Settings.System.getString(
|
||||
c!!.contentResolver,
|
||||
Settings.System.TIME_12_24
|
||||
)
|
||||
val is24 = t == "24"
|
||||
nowTime = Calendar.getInstance().time
|
||||
textV.text = getDate(c!!) + str + getTime(c!!, is24)
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isCenterAlign) {
|
||||
// TODO: Android13时间居中对齐不可用
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter {
|
||||
val miuiPhoneStatusBarView =
|
||||
it.thisObject.getObject("mStatusBar") as ViewGroup
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
clock.gravity = Gravity.CENTER
|
||||
}
|
||||
}
|
||||
}
|
||||
//极客模式
|
||||
2 -> {
|
||||
var c: Context? = null
|
||||
|
||||
findConstructor("com.android.systemui.statusbar.views.MiuiClock") {
|
||||
paramCount == 3
|
||||
}.hookAfter {
|
||||
try {
|
||||
c = it.args[0] as Context
|
||||
val textV = it.thisObject as TextView
|
||||
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@hookAfter
|
||||
textV.isSingleLine = false
|
||||
textV.setLineSpacing(0F, 0.8F)
|
||||
if (getGeekClockSize != 0) {
|
||||
val clockSize = getGeekClockSize.toFloat()
|
||||
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clockSize)
|
||||
}
|
||||
|
||||
val d: Method = textV.javaClass.getDeclaredMethod("updateTime")
|
||||
val r = Runnable {
|
||||
d.isAccessible = true
|
||||
d.invoke(textV)
|
||||
}
|
||||
|
||||
class T : TimerTask() {
|
||||
override fun run() {
|
||||
Handler(textV.context.mainLooper).post(r)
|
||||
}
|
||||
}
|
||||
Timer().scheduleAtFixedRate(
|
||||
T(),
|
||||
1000 - System.currentTimeMillis() % 1000,
|
||||
1000
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter {
|
||||
try {
|
||||
val textV = it.thisObject as TextView
|
||||
if (textV.resources.getResourceEntryName(textV.id) == "clock") {
|
||||
nowTime = Calendar.getInstance().time
|
||||
textV.text = SimpleDateFormat(getGeekFormat).format(nowTime)
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isGeekCenterAlign) {
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter {
|
||||
val miuiPhoneStatusBarView =
|
||||
it.thisObject.getObject("mStatusBar") as ViewGroup
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
clock.gravity = Gravity.CENTER
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun getDate(context: Context): String {
|
||||
var datePattern = ""
|
||||
val isZh = isZh(context)
|
||||
|
||||
if (isYear) {
|
||||
if (isZh) {
|
||||
datePattern += "YY年"
|
||||
// if (!isHideSpace) datePattern = "$datePattern "
|
||||
} else {
|
||||
datePattern += "YY"
|
||||
if (isMonth || isDay) datePattern += "/"
|
||||
}
|
||||
}
|
||||
if (isMonth) {
|
||||
if (isZh) {
|
||||
datePattern += "M月"
|
||||
// if (!isHideSpace) datePattern = "$datePattern "
|
||||
} else {
|
||||
datePattern += "M"
|
||||
if (isDay) datePattern += "/"
|
||||
}
|
||||
}
|
||||
if (isDay) {
|
||||
datePattern += if (isZh) {
|
||||
"d日"
|
||||
} else {
|
||||
"d"
|
||||
}
|
||||
}
|
||||
if (isWeek) {
|
||||
if (!isHideSpace) datePattern = "$datePattern "
|
||||
datePattern += "E"
|
||||
if (!isDoubleLine) {
|
||||
if (!isHideSpace) datePattern = "$datePattern "
|
||||
}
|
||||
}
|
||||
datePattern = SimpleDateFormat(datePattern).format(nowTime)
|
||||
return datePattern
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun getTime(context: Context, t: Boolean): String {
|
||||
var timePattern = ""
|
||||
val isZh = isZh(context)
|
||||
timePattern += if (t) "HH:mm" else "h:mm"
|
||||
if (isSecond) timePattern += ":ss"
|
||||
timePattern = SimpleDateFormat(timePattern).format(nowTime)
|
||||
if (isZh) timePattern = getPeriod(isZh) + timePattern else timePattern += getPeriod(isZh)
|
||||
timePattern = getDoubleHour() + timePattern
|
||||
return timePattern
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun getPeriod(isZh: Boolean): String {
|
||||
var period = ""
|
||||
if (isPeriod) {
|
||||
if (isZh) {
|
||||
when (SimpleDateFormat("HH").format(nowTime)) {
|
||||
"00", "01", "02", "03", "04", "05" -> {
|
||||
period = "凌晨"
|
||||
}
|
||||
"06", "07", "08", "09", "10", "11" -> {
|
||||
period = "上午"
|
||||
}
|
||||
"12" -> {
|
||||
period = "中午"
|
||||
}
|
||||
"13", "14", "15", "16", "17" -> {
|
||||
period = "下午"
|
||||
}
|
||||
"18" -> {
|
||||
period = "傍晚"
|
||||
}
|
||||
"19", "20", "21", "22", "23" -> {
|
||||
period = "晚上"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
period = SimpleDateFormat("a").format(nowTime)
|
||||
if (!isHideSpace) {
|
||||
period = " $period"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return period
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun getDoubleHour(): String {
|
||||
var doubleHour = ""
|
||||
if (isDoubleHour) {
|
||||
when (SimpleDateFormat("HH").format(nowTime)) {
|
||||
"23", "00" -> {
|
||||
doubleHour = "子时"
|
||||
}
|
||||
"01", "02" -> {
|
||||
doubleHour = "丑时"
|
||||
}
|
||||
"03", "04" -> {
|
||||
doubleHour = "寅时"
|
||||
}
|
||||
"05", "06" -> {
|
||||
doubleHour = "卯时"
|
||||
}
|
||||
"07", "08" -> {
|
||||
doubleHour = "辰时"
|
||||
}
|
||||
"09", "10" -> {
|
||||
doubleHour = "巳时"
|
||||
}
|
||||
"11", "12" -> {
|
||||
doubleHour = "午时"
|
||||
}
|
||||
"13", "14" -> {
|
||||
doubleHour = "未时"
|
||||
}
|
||||
"15", "16" -> {
|
||||
doubleHour = "申时"
|
||||
}
|
||||
"17", "18" -> {
|
||||
doubleHour = "酉时"
|
||||
}
|
||||
"19", "20" -> {
|
||||
doubleHour = "戌时"
|
||||
}
|
||||
"21", "22" -> {
|
||||
doubleHour = "亥时"
|
||||
}
|
||||
}
|
||||
if (!isHideSpace) {
|
||||
doubleHour += " "
|
||||
}
|
||||
}
|
||||
return doubleHour
|
||||
}
|
||||
|
||||
private fun isZh(context: Context): Boolean {
|
||||
val locale = context.resources.configuration.locale
|
||||
val language = locale.language
|
||||
return language.endsWith("zh")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.lt2333.simplicitytools.hooks.rules.t.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.utils.hasEnable
|
||||
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
|
||||
object WaveChargeForT: HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
hasEnable("enable_wave_charge_animation") {
|
||||
findMethod("com.android.keyguard.charge.ChargeUtils") {
|
||||
name == "supportWaveChargeAnimation"
|
||||
}.hookAfter {
|
||||
val ex = Throwable()
|
||||
val stackElement = ex.stackTrace
|
||||
var mResult = false
|
||||
val classTrue = setOf(
|
||||
"com.android.keyguard.charge.ChargeUtils",
|
||||
"com.android.keyguard.charge.container.MiuiChargeContainerView"
|
||||
)
|
||||
for (i in stackElement.indices) {
|
||||
when (stackElement[i].className) {
|
||||
in classTrue -> {
|
||||
mResult = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
it.result = mResult
|
||||
}
|
||||
findMethod("com.android.keyguard.charge.wave.WaveView") {
|
||||
name == "updateWaveHeight"
|
||||
}.hookAfter {
|
||||
it.thisObject.putObject("mWaveXOffset", 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -233,4 +233,6 @@
|
||||
<string name="make_millet_more_aggressive_summary">允许 Millet 在后台应用有通知、有服务运行、有进程运行的情况下冻结应用。\n不希望被冻结的应用可将省电策略设置为无限制\n启用前请先卸载墓碑和 NoANR 相关模块。</string>
|
||||
<string name="make_millet_ignore_active">允许 Millet 冻结活跃的应用</string>
|
||||
<string name="make_millet_ignore_active_summary">非常激进,可能会影响应用运行</string>
|
||||
<string name="pkg_installer">应用包管理组件</string>
|
||||
<string name="pkg_installer_summary">禁用频繁安装应用检查</string>
|
||||
</resources>
|
||||
|
||||
@@ -156,4 +156,6 @@
|
||||
<string name="hide_zen_icon">隱藏 勿擾 圖標</string>
|
||||
<string name="hide_icon">隱藏圖標</string>
|
||||
<string name="double_tap_to_sleep">雙擊鎖定螢幕</string>
|
||||
<string name="pkg_installer">應用包管理組件</string>
|
||||
<string name="pkg_installer_summary">禁用頻繁安裝應用檢查</string>
|
||||
</resources>
|
||||
|
||||
@@ -224,4 +224,6 @@
|
||||
<string name="off">關閉</string>
|
||||
<string name="center">置中</string>
|
||||
<string name="left_or_right">左右</string>
|
||||
<string name="pkg_installer">應用包管理組件</string>
|
||||
<string name="pkg_installer_summary">禁用頻繁安裝應用檢查</string>
|
||||
</resources>
|
||||
|
||||
@@ -13,5 +13,6 @@
|
||||
<item>com.miui.screenshot</item>
|
||||
<item>com.milink.service</item>
|
||||
<item>com.xiaomi.misubscreenui</item>
|
||||
<item>com.miui.packageinstaller</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -237,4 +237,6 @@
|
||||
<string name="make_millet_more_aggressive_summary">Allows Millet to freeze apps while background apps have notifications, services running, and processes running.\nApps that don\'t want to be frozen can set Battery saver to No restriction\nPlease uninstall tombstone and NoANR related modules before enabling.</string>
|
||||
<string name="make_millet_ignore_active">Allow Millet to freeze active apps</string>
|
||||
<string name="make_millet_ignore_active_summary">Very aggressive and may affect application running</string>
|
||||
<string name="pkg_installer">Package Installer</string>
|
||||
<string name="pkg_installer_summary">Disable the app installation\'s count checking</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user