diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d030dd40..99ed8599 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -7,7 +7,6 @@ plugins { android { compileSdk = 33 - buildToolsVersion = "33.0.0" defaultConfig { applicationId = "com.lt2333.simplicitytools" minSdk = 31 @@ -52,7 +51,7 @@ android { dependencies { //API compileOnly("de.robv.android.xposed:api:82") - implementation("com.github.kyuubiran:EzXHelper:0.9.2") + implementation("com.github.kyuubiran:EzXHelper:1.0.3") //UI implementation(project(":blockmiui")) implementation("androidx.constraintlayout:constraintlayout:2.1.3") diff --git a/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt b/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt index 950fe56a..4e75f0ec 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt @@ -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) { diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/MaxWallpaperScale.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/MaxWallpaperScale.kt index ddd0508a..403b17c7 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/MaxWallpaperScale.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/MaxWallpaperScale.kt @@ -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) } } diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/mediaeditor/UnlockUnlimitedCropping.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/mediaeditor/UnlockUnlimitedCropping.kt index 2e4a996f..b46497e8 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/mediaeditor/UnlockUnlimitedCropping.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/mediaeditor/UnlockUnlimitedCropping.kt @@ -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++ + } } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/securitycenter/ShowBatteryTemperature.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/securitycenter/ShowBatteryTemperature.kt index 3c3d7b24..14f251a8 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/securitycenter/ShowBatteryTemperature.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/securitycenter/ShowBatteryTemperature.kt @@ -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("a") - val textView = view.findViewById(currentTemperatureValue) + val textView = view.findViewById(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(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(tempeValueContainer) - linearLayout.addView(tempView) + linearL.addView(linearLayout) + linearL.addView(linearLayout1) } } diff --git a/build.gradle.kts b/build.gradle.kts index 354d41ca..796068f3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,8 +5,8 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:7.2.1") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0") + classpath("com.android.tools.build:gradle:7.4.0") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle.kts files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 10814e93..37afa672 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat Apr 23 16:13:18 CST 2022 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 zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME