Merge pull request #213

* Fix MaxWallpaperScale on MIUI14

* Fix ShowBatteryTemperature on MIUI14

* fix UnlockUnlimitedCropping on MIUI14

* Update UnlockUnlimitedCropping.kt
This commit is contained in:
YuKongA
2023-02-07 18:52:10 +08:00
committed by GitHub
parent 60f61649fb
commit 916522331d
7 changed files with 89 additions and 53 deletions

View File

@@ -924,8 +924,8 @@ class SettingsActivity : MIUIActivity() {
setTitle(R.string.max_wallpaper_scale)
setEditText(
"",
"${activity.getString(R.string.def)}1.1, ${activity.getString(R.string.current)}${
safeSP.getFloat("max_wallpaper_scale", 1.1f)
"${activity.getString(R.string.def)}1.2, ${activity.getString(R.string.current)}${
safeSP.getFloat("max_wallpaper_scale", 1.2f)
}"
)
setLButton(textId = R.string.cancel) {

View File

@@ -1,6 +1,7 @@
package com.lt2333.simplicitytools.hook.app.android
import com.github.kyuubiran.ezxhelper.utils.findMethod
import com.github.kyuubiran.ezxhelper.utils.hookAllConstructorAfter
import com.github.kyuubiran.ezxhelper.utils.hookBefore
import com.github.kyuubiran.ezxhelper.utils.putObject
import com.lt2333.simplicitytools.util.XSPUtils
@@ -11,7 +12,11 @@ object MaxWallpaperScale : HookRegister() {
findMethod("com.android.server.wm.WallpaperController") {
name == "zoomOutToScale" && parameterTypes[0] == Float::class.java
}.hookBefore {
val value = XSPUtils.getFloat("max_wallpaper_scale", 1.1f)
val value = XSPUtils.getFloat("max_wallpaper_scale", 1.2f)
it.thisObject.putObject("mMaxWallpaperScale", value)
}
hookAllConstructorAfter("com.android.server.wm.WallpaperController") {
val value = XSPUtils.getFloat("max_wallpaper_scale", 1.2f)
it.thisObject.putObject("mMaxWallpaperScale", value)
}
}

View File

@@ -2,6 +2,7 @@ package com.lt2333.simplicitytools.hook.app.mediaeditor
import com.github.kyuubiran.ezxhelper.utils.findMethod
import com.github.kyuubiran.ezxhelper.utils.hookBefore
import com.github.kyuubiran.ezxhelper.utils.loadClassOrNull
import com.lt2333.simplicitytools.util.hasEnable
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
@@ -9,21 +10,57 @@ object UnlockUnlimitedCropping : HookRegister() {
override fun init() {
//解锁图库裁切最小值
findMethod("com.miui.gallery.editor.photo.core.imports.obsoletes.Crop\$ResizeDetector") {
name == "calculateMinSize"
}.hookBefore {
hasEnable("unlock_unlimited_cropping") {
it.result = 0
val resizeDetectorClass = loadClassOrNull("com.miui.gallery.editor.photo.core.imports.obsoletes.Crop\$ResizeDetector")
if (resizeDetectorClass != null) {
findMethod("com.miui.gallery.editor.photo.core.imports.obsoletes.Crop\$ResizeDetector") {
name == "calculateMinSize"
}.hookBefore {
hasEnable("unlock_unlimited_cropping") {
it.result = 0
}
}
} else {
var resizeDetector = 'a'
for (i in 0..25) {
try {
findMethod("com.miui.gallery.editor.photo.screen.crop.ScreenCropView\$${resizeDetector}") {
returnType == Int::class.javaPrimitiveType && parameterCount == 0
}.hookBefore {
hasEnable("unlock_unlimited_cropping") {
it.result = 0
}
}
} catch (t: Throwable) {
resizeDetector++
}
}
}
//截图无限裁切
findMethod("com.miui.gallery.editor.photo.screen.crop.ScreenCropView\$ResizeDetector") {
name == "calculateMinSize"
}.hookBefore {
hasEnable("unlock_unlimited_cropping") {
it.result = 0
val resizeDetectorClass1 = loadClassOrNull("com.miui.gallery.editor.photo.screen.crop.ScreenCropView\$ResizeDetector")
if (resizeDetectorClass1 != null) {
findMethod("com.miui.gallery.editor.photo.screen.crop.ScreenCropView\$ResizeDetector") {
name == "calculateMinSize"
}.hookBefore {
hasEnable("unlock_unlimited_cropping") {
it.result = 0
}
}
} else {
var resizeDetector1 = 'a'
for (i in 0..25) {
try {
findMethod("com.miui.gallery.editor.photo.core.imports.obsoletes.Crop\$${resizeDetector1}") {
returnType == Int::class.javaPrimitiveType && parameterCount == 0
}.hookBefore {
hasEnable("unlock_unlimited_cropping") {
it.result = 0
}
}
} catch (_: Throwable) {
resizeDetector1++
}
}
}
}
}
}

View File

@@ -34,7 +34,7 @@ object ShowBatteryTemperature : HookRegister() {
findMethod("com.miui.powercenter.a") {
name == "b" && parameterTypes[0] == Context::class.java
}
} catch (e : Exception) {
} catch (e: Exception) {
findMethod("com.miui.powercenter.BatteryFragment") {
name == "b" && parameterTypes[0] == Context::class.java
}
@@ -46,58 +46,53 @@ object ShowBatteryTemperature : HookRegister() {
findMethod("com.miui.powercenter.a\$a") {
name == "run"
}
} catch (e : Exception) {
} catch (e: Exception) {
findMethod("com.miui.powercenter.BatteryFragment\$a") {
name == "run"
}
}.hookAfter {
val context = AndroidAppHelper.currentApplication().applicationContext
val isDarkMode =
context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
val currentTemperatureValue = context.resources.getIdentifier(
"current_temperature_value",
"id",
"com.miui.securitycenter"
)
val isDarkMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
val currentTemperatureState = context.resources.getIdentifier("current_temperature_state", "id", "com.miui.securitycenter")
val view = it.thisObject.getObjectAs<View>("a")
val textView = view.findViewById<TextView>(currentTemperatureValue)
val textView = view.findViewById<TextView>(currentTemperatureState)
textView.apply {
(layoutParams as LinearLayout.LayoutParams).marginStart = dp2px(context, 25f)
(layoutParams as LinearLayout.LayoutParams).topMargin = 0
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36.399998f)
setPadding(0, 0, 0, 0)
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36.4f)
setPadding(0, dp2px(context, 4f), 0, 0)
gravity = Gravity.NO_GRAVITY
typeface = Typeface.defaultFromStyle(Typeface.NORMAL)
height = dp2px(context, 49.099983f)
typeface = Typeface.create(null, 700, false)
height = dp2px(context, 49f)
textAlignment = View.TEXT_ALIGNMENT_VIEW_START
}
val tempView = TextView(context)
tempView.apply {
layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
dp2px(context, 49.099983f)
)
(layoutParams as LinearLayout.LayoutParams).marginStart =
dp2px(context, 3.599976f)
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13.099977f)
val temperatureContainer = context.resources.getIdentifier("temperature_container", "id", "com.miui.securitycenter")
val linearL = view.findViewById<LinearLayout>(temperatureContainer).getChildAt(1) as LinearLayout
linearL.orientation = LinearLayout.VERTICAL
val l1 = linearL.getChildAt(0)
val l2 = linearL.getChildAt(1)
val linearLayout = LinearLayout(context)
val linearLayout1 = LinearLayout(context).apply { orientation = LinearLayout.HORIZONTAL }
val tempView = TextView(context).apply {
layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
(layoutParams as LinearLayout.LayoutParams).marginStart = dp2px(context, 3.599976f)
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13.1f)
setTextColor(Color.parseColor(if (isDarkMode) "#e6e6e6" else "#333333"))
setPadding(0, dp2px(context, 25f), 0, 0)
setPadding(0, dp2px(context, 26f), 0, 0)
text = ""
typeface = Typeface.create(null, 500, false)
gravity = Gravity.NO_GRAVITY
typeface = Typeface.create(null, 700, false)
textAlignment = View.TEXT_ALIGNMENT_VIEW_START
}
linearL.removeAllViews()
val tempeValueContainer = context.resources.getIdentifier(
"tempe_value_container",
"id",
"com.miui.securitycenter"
)
linearLayout.addView(l1)
linearLayout1.addView(l2)
linearLayout1.addView(tempView)
val linearLayout = view.findViewById<LinearLayout>(tempeValueContainer)
linearLayout.addView(tempView)
linearL.addView(linearLayout)
linearL.addView(linearLayout1)
}
}