壁纸缩放功能

This commit is contained in:
YuKongA
2022-03-12 15:39:20 +08:00
parent 8ba9132d4e
commit 0a8b43c344
16 changed files with 110 additions and 37 deletions

View File

@@ -12,6 +12,7 @@ import android.view.View
import android.widget.Switch
import android.widget.Toast
import cn.fkj233.ui.activity.MIUIActivity
import cn.fkj233.ui.activity.OwnSP
import cn.fkj233.ui.activity.view.*
import cn.fkj233.ui.dialog.MIUIDialog
import com.lt2333.simplicitytools.BuildConfig
@@ -436,6 +437,23 @@ class SettingsActivity : MIUIActivity() {
SwitchV("remove_small_window_restrictions")
)
)
add(TextSummaryArrowV(TextSummaryV(textId = R.string.max_wallpaper_scale, onClickListener = {
MIUIDialog(activity).apply {
setTitle(R.string.max_wallpaper_scale)
setEditText("", "${activity.getString(R.string.def)}1.1, ${activity.getString(R.string.current)}${OwnSP.ownSP.getFloat("max_wallpaper_scale", 1.1f)}")
setLButton(textId = R.string.cancel) {
dismiss()
}
setRButton(textId = R.string.Done) {
OwnSP.ownSP.edit().run {
putFloat("max_wallpaper_scale", getEditText().toFloat())
apply()
}
dismiss()
}
show()
}
})))
}
}
@@ -677,7 +695,12 @@ class SettingsActivity : MIUIActivity() {
SwitchV("hide_battery_charging_icon")
)
)
add(TextWithSwitchV(TextV(resId = R.string.hide_gps_icon), SwitchV("hide_gps_icon")))
add(
TextWithSwitchV(
TextV(resId = R.string.hide_gps_icon),
SwitchV("hide_gps_icon")
)
)
add(
TextWithSwitchV(
TextV(resId = R.string.hide_bluetooth_icon),
@@ -732,7 +755,12 @@ class SettingsActivity : MIUIActivity() {
SwitchV("hide_mobile_type_icon")
)
)
add(TextWithSwitchV(TextV(resId = R.string.hide_wifi_icon), SwitchV("hide_wifi_icon")))
add(
TextWithSwitchV(
TextV(resId = R.string.hide_wifi_icon),
SwitchV("hide_wifi_icon")
)
)
add(
TextWithSwitchV(
TextV(resId = R.string.hide_wifi_activity_icon),
@@ -757,7 +785,12 @@ class SettingsActivity : MIUIActivity() {
SwitchV("hide_hotspot_icon")
)
)
add(TextWithSwitchV(TextV(resId = R.string.hide_vpn_icon), SwitchV("hide_vpn_icon")))
add(
TextWithSwitchV(
TextV(resId = R.string.hide_vpn_icon),
SwitchV("hide_vpn_icon")
)
)
add(
TextWithSwitchV(
TextV(resId = R.string.hide_airplane_icon),
@@ -941,7 +974,8 @@ class SettingsActivity : MIUIActivity() {
intent.component = comp
startActivity(intent)
} catch (e: Exception) {
Toast.makeText(activity, "启动失败,可能是不支持", Toast.LENGTH_LONG).show()
Toast.makeText(activity, "启动失败,可能是不支持", Toast.LENGTH_LONG)
.show()
}
})
)

View File

@@ -2,6 +2,7 @@ package com.lt2333.simplicitytools.hook.app
import com.lt2333.simplicitytools.hook.app.android.DeleteOnPostNotification
import com.lt2333.simplicitytools.hook.app.android.DisableFlagSecure
import com.lt2333.simplicitytools.hook.app.android.MaxWallpaperScale
import com.lt2333.simplicitytools.hook.app.android.RemoveSmallWindowRestrictions
import com.lt2333.simplicitytools.hook.app.android.corepatch.CorePatch
import de.robv.android.xposed.IXposedHookLoadPackage
@@ -19,5 +20,7 @@ class Android : IXposedHookLoadPackage {
DeleteOnPostNotification().handleLoadPackage(lpparam)
//解除小窗限制
RemoveSmallWindowRestrictions().handleLoadPackage(lpparam)
//壁纸缩放比例
MaxWallpaperScale().handleLoadPackage(lpparam)
}
}

View File

@@ -5,7 +5,7 @@ import com.lt2333.simplicitytools.util.hookBeforeMethod
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.callbacks.XC_LoadPackage
class DisableFlagSecure :IXposedHookLoadPackage {
class DisableFlagSecure : IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
"com.android.server.wm.WindowState".hookBeforeMethod(lpparam.classLoader, "isSecureLocked") {
hasEnable("disable_flag_secure") {

View File

@@ -0,0 +1,23 @@
package com.lt2333.simplicitytools.hook.app.android
import android.app.Service
import android.icu.text.DisplayContext
import com.lt2333.simplicitytools.util.XSPUtils
import com.lt2333.simplicitytools.util.hookAfterMethod
import com.lt2333.simplicitytools.util.hookBeforeMethod
import com.lt2333.simplicitytools.util.setFloatField
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.callbacks.XC_LoadPackage
class MaxWallpaperScale : IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
val value = XSPUtils.getFloat("max_wallpaper_scale", 1.1f)
"com.android.server.wm.WallpaperController".hookAfterMethod(lpparam.classLoader, "WallpaperController", Service::class.java, DisplayContext::class.java
) {
it.thisObject.setFloatField("mMaxWallpaperScale", value)
}
"com.android.server.wm.WallpaperController".hookBeforeMethod(lpparam.classLoader, "zoomOutToScale", Float::class.java) {
it.thisObject.setFloatField("mMaxWallpaperScale", value)
}
}
}

View File

@@ -13,7 +13,10 @@ import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import cn.fkj233.ui.activity.dp2px
import com.lt2333.simplicitytools.util.*
import com.lt2333.simplicitytools.util.XSPUtils
import com.lt2333.simplicitytools.util.findClass
import com.lt2333.simplicitytools.util.hookAfterMethod
import com.lt2333.simplicitytools.util.hookBeforeMethod
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.callbacks.XC_LoadPackage
import java.lang.reflect.Field
@@ -36,6 +39,7 @@ class ShowBatteryTemperature: IXposedHookLoadPackage {
val textView = view.findViewById<TextView>(currentTemperatureValue)
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36.399998f)
textView.gravity = Gravity.NO_GRAVITY
textView.typeface = Typeface.create(null, 400, false)
textView.setPadding(0, 0, 0, 0)
textView.height = dp2px(context, 49.099983f)
textView.textAlignment = View.TEXT_ALIGNMENT_VIEW_START
@@ -48,7 +52,7 @@ class ShowBatteryTemperature: IXposedHookLoadPackage {
tempView.setPadding(0, dp2px(context, 25f), 0, 0)
tempView.text = ""
tempView.setTextColor(Color.parseColor(if (isDarkMode) "#e6e6e6" else "#333333"))
tempView.typeface = Typeface.create(null, 500, false)
tempView.typeface = Typeface.create(null, 400, false)
tempView.textAlignment = View.TEXT_ALIGNMENT_VIEW_START
val tempeValueContainer = context.resources.getIdentifier("tempe_value_container", "id", "com.miui.securitycenter")
val linearLayout = view.findViewById<LinearLayout>(tempeValueContainer)

View File

@@ -395,6 +395,10 @@ fun <T> T.setLongField(field: String?, value: Long) = apply {
XposedHelpers.setLongField(this, field, value)
}
fun <T> T.setFloatField(field: String?, value: Float) = apply {
XposedHelpers.setFloatField(this, field, value)
}
fun <T> T.setObjectField(field: String?, value: Any?) = apply {
XposedHelpers.setObjectField(this, field, value)
}

View File

@@ -4,7 +4,7 @@ import com.lt2333.simplicitytools.BuildConfig
import de.robv.android.xposed.XSharedPreferences
object XSPUtils {
var prefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "config")
private var prefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "config")
fun getBoolean(key: String, defValue: Boolean): Boolean {
if (prefs.hasFileChanged()) {
@@ -18,6 +18,13 @@ object XSPUtils {
}
return prefs.getInt(key, defValue)
}
fun getFloat(key: String, defValue: Float): Float {
if (prefs.hasFileChanged()) {
prefs.reload()
}
return prefs.getFloat(key, defValue)
}
}
inline fun hasEnable(key: String, default: Boolean = false, noinline extraCondition: (() -> Boolean)? = null, crossinline block: () -> Unit) {