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

@@ -7,7 +7,6 @@ plugins {
android { android {
compileSdk = 33 compileSdk = 33
buildToolsVersion = "33.0.0"
defaultConfig { defaultConfig {
applicationId = "com.lt2333.simplicitytools" applicationId = "com.lt2333.simplicitytools"
minSdk = 31 minSdk = 31
@@ -52,7 +51,7 @@ android {
dependencies { dependencies {
//API //API
compileOnly("de.robv.android.xposed:api:82") compileOnly("de.robv.android.xposed:api:82")
implementation("com.github.kyuubiran:EzXHelper:0.9.2") implementation("com.github.kyuubiran:EzXHelper:1.0.3")
//UI //UI
implementation(project(":blockmiui")) implementation(project(":blockmiui"))
implementation("androidx.constraintlayout:constraintlayout:2.1.3") implementation("androidx.constraintlayout:constraintlayout:2.1.3")

View File

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

View File

@@ -1,6 +1,7 @@
package com.lt2333.simplicitytools.hook.app.android package com.lt2333.simplicitytools.hook.app.android
import com.github.kyuubiran.ezxhelper.utils.findMethod 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.hookBefore
import com.github.kyuubiran.ezxhelper.utils.putObject import com.github.kyuubiran.ezxhelper.utils.putObject
import com.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.util.XSPUtils
@@ -11,7 +12,11 @@ object MaxWallpaperScale : HookRegister() {
findMethod("com.android.server.wm.WallpaperController") { findMethod("com.android.server.wm.WallpaperController") {
name == "zoomOutToScale" && parameterTypes[0] == Float::class.java name == "zoomOutToScale" && parameterTypes[0] == Float::class.java
}.hookBefore { }.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) 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.findMethod
import com.github.kyuubiran.ezxhelper.utils.hookBefore 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.hasEnable
import com.lt2333.simplicitytools.util.xposed.base.HookRegister import com.lt2333.simplicitytools.util.xposed.base.HookRegister
@@ -9,21 +10,57 @@ object UnlockUnlimitedCropping : HookRegister() {
override fun init() { override fun init() {
//解锁图库裁切最小值 //解锁图库裁切最小值
findMethod("com.miui.gallery.editor.photo.core.imports.obsoletes.Crop\$ResizeDetector") { val resizeDetectorClass = loadClassOrNull("com.miui.gallery.editor.photo.core.imports.obsoletes.Crop\$ResizeDetector")
name == "calculateMinSize" if (resizeDetectorClass != null) {
}.hookBefore { findMethod("com.miui.gallery.editor.photo.core.imports.obsoletes.Crop\$ResizeDetector") {
hasEnable("unlock_unlimited_cropping") { name == "calculateMinSize"
it.result = 0 }.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") { val resizeDetectorClass1 = loadClassOrNull("com.miui.gallery.editor.photo.screen.crop.ScreenCropView\$ResizeDetector")
name == "calculateMinSize" if (resizeDetectorClass1 != null) {
}.hookBefore { findMethod("com.miui.gallery.editor.photo.screen.crop.ScreenCropView\$ResizeDetector") {
hasEnable("unlock_unlimited_cropping") { name == "calculateMinSize"
it.result = 0 }.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") { findMethod("com.miui.powercenter.a") {
name == "b" && parameterTypes[0] == Context::class.java name == "b" && parameterTypes[0] == Context::class.java
} }
} catch (e : Exception) { } catch (e: Exception) {
findMethod("com.miui.powercenter.BatteryFragment") { findMethod("com.miui.powercenter.BatteryFragment") {
name == "b" && parameterTypes[0] == Context::class.java name == "b" && parameterTypes[0] == Context::class.java
} }
@@ -46,58 +46,53 @@ object ShowBatteryTemperature : HookRegister() {
findMethod("com.miui.powercenter.a\$a") { findMethod("com.miui.powercenter.a\$a") {
name == "run" name == "run"
} }
} catch (e : Exception) { } catch (e: Exception) {
findMethod("com.miui.powercenter.BatteryFragment\$a") { findMethod("com.miui.powercenter.BatteryFragment\$a") {
name == "run" name == "run"
} }
}.hookAfter { }.hookAfter {
val context = AndroidAppHelper.currentApplication().applicationContext val context = AndroidAppHelper.currentApplication().applicationContext
val isDarkMode = val isDarkMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
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 currentTemperatureValue = context.resources.getIdentifier(
"current_temperature_value",
"id",
"com.miui.securitycenter"
)
val view = it.thisObject.getObjectAs<View>("a") val view = it.thisObject.getObjectAs<View>("a")
val textView = view.findViewById<TextView>(currentTemperatureValue) val textView = view.findViewById<TextView>(currentTemperatureState)
textView.apply { textView.apply {
(layoutParams as LinearLayout.LayoutParams).marginStart = dp2px(context, 25f)
(layoutParams as LinearLayout.LayoutParams).topMargin = 0 (layoutParams as LinearLayout.LayoutParams).topMargin = 0
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36.399998f) setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36.4f)
setPadding(0, 0, 0, 0) setPadding(0, dp2px(context, 4f), 0, 0)
gravity = Gravity.NO_GRAVITY gravity = Gravity.NO_GRAVITY
typeface = Typeface.defaultFromStyle(Typeface.NORMAL) typeface = Typeface.create(null, 700, false)
height = dp2px(context, 49.099983f) height = dp2px(context, 49f)
textAlignment = View.TEXT_ALIGNMENT_VIEW_START textAlignment = View.TEXT_ALIGNMENT_VIEW_START
} }
val tempView = TextView(context) val temperatureContainer = context.resources.getIdentifier("temperature_container", "id", "com.miui.securitycenter")
tempView.apply { val linearL = view.findViewById<LinearLayout>(temperatureContainer).getChildAt(1) as LinearLayout
layoutParams = LinearLayout.LayoutParams( linearL.orientation = LinearLayout.VERTICAL
LinearLayout.LayoutParams.MATCH_PARENT, val l1 = linearL.getChildAt(0)
dp2px(context, 49.099983f) val l2 = linearL.getChildAt(1)
) val linearLayout = LinearLayout(context)
(layoutParams as LinearLayout.LayoutParams).marginStart = val linearLayout1 = LinearLayout(context).apply { orientation = LinearLayout.HORIZONTAL }
dp2px(context, 3.599976f) val tempView = TextView(context).apply {
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13.099977f) 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")) setTextColor(Color.parseColor(if (isDarkMode) "#e6e6e6" else "#333333"))
setPadding(0, dp2px(context, 25f), 0, 0) setPadding(0, dp2px(context, 26f), 0, 0)
text = "" text = ""
typeface = Typeface.create(null, 500, false) gravity = Gravity.NO_GRAVITY
typeface = Typeface.create(null, 700, false)
textAlignment = View.TEXT_ALIGNMENT_VIEW_START textAlignment = View.TEXT_ALIGNMENT_VIEW_START
} }
linearL.removeAllViews()
val tempeValueContainer = context.resources.getIdentifier( linearLayout.addView(l1)
"tempe_value_container", linearLayout1.addView(l2)
"id", linearLayout1.addView(tempView)
"com.miui.securitycenter"
)
val linearLayout = view.findViewById<LinearLayout>(tempeValueContainer) linearL.addView(linearLayout)
linearLayout.addView(tempView) linearL.addView(linearLayout1)
} }
} }

View File

@@ -5,8 +5,8 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath("com.android.tools.build:gradle:7.2.1") classpath("com.android.tools.build:gradle:7.4.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0")
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files // in the individual module build.gradle.kts files

View File

@@ -1,6 +1,6 @@
#Sat Apr 23 16:13:18 CST 2022 #Sat Apr 23 16:13:18 CST 2022
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME