壁纸缩放功能

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

@@ -23,14 +23,6 @@
public void *(de.robv.android.xposed.callbacks.XC_LoadPackage$LoadPackageParam);
}
-keep class * implements de.robv.android.xposed.IXposedHookInitPackageResources {
public void *(de.robv.android.xposed.callbacks.XC_InitPackageResources$InitPackageResourcesParam);
}
-keep class * implements de.robv.android.xposed.IXposedHookZygoteInit {
public void *(de.robv.android.xposed.IXposedHookZygoteInit$StartupParam);
}
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
public static void check*(...);
public static void throw*(...);

View File

@@ -2,15 +2,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lt2333.simplicitytools">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:supportsRtl="true" >
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activity.SettingsActivity"
android:exported="true"
@@ -27,8 +26,8 @@
android:exported="true"
android:targetActivity=".activity.SettingsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
@@ -52,7 +51,7 @@
android:label="@string/lock_max"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
@@ -63,7 +62,7 @@
android:label="@string/allow_screenshots"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>

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) {

View File

@@ -1,4 +1,4 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.NoActionBar">
<!-- Customize your theme here. -->
@@ -10,10 +10,8 @@
<item name="android:textColor">@color/white</item>
<item name="android:colorBackground">@color/black</item>
<item name="android:statusBarColor">@color/black</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
<item name="android:forceDarkAllowed" tools:targetApi="Q">true</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:forceDarkAllowed">true</item>
</style>
<!-- 定义dialog的样式-->
</resources>

View File

@@ -151,4 +151,7 @@
<string name="remove_thememanager_ads">移除主题壁纸的广告</string>
<string name="battery_life_function">电池页面显示当前温度</string>
<string name="enable_wave_charge_animation">启用Alpha充电动画</string>
<string name="max_wallpaper_scale">壁纸缩放比例</string>
<string name="def">默认值:</string>
<string name="current">当前值:</string>
</resources>

View File

@@ -151,4 +151,7 @@
<string name="remove_thememanager_ads">拿掉主題壁紙的廣告</string>
<string name="battery_life_function">電池頁面展示當前溫度</string>
<string name="enable_wave_charge_animation">啟用Alpha充電動畫</string>
<string name="max_wallpaper_scale">壁紙縮放比例</string>
<string name="def">默認值:</string>
<string name="current">當前值:</string>
</resources>

View File

@@ -151,4 +151,7 @@
<string name="remove_thememanager_ads">拿掉主題壁紙的廣告</string>
<string name="battery_life_function">電池頁面展示當前溫度</string>
<string name="enable_wave_charge_animation">啟用Alpha充電動畫</string>
<string name="max_wallpaper_scale">壁紙縮放比例</string>
<string name="def">默認值:</string>
<string name="current">當前值:</string>
</resources>

View File

@@ -151,4 +151,7 @@
<string name="remove_thememanager_ads">Remove ads for theme manager</string>
<string name="battery_life_function">Battery page shows the current temperature</string>
<string name="enable_wave_charge_animation">Enable wave charge animation</string>
<string name="max_wallpaper_scale">Max wallpaper scale</string>
<string name="def">"Default: "</string>
<string name="current">Current:</string>
</resources>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
<!-- Customize your theme here. -->
@@ -10,11 +10,8 @@
<item name="android:textAllCaps">false</item>
<item name="android:textColor">@color/black</item>
<item name="android:statusBarColor">@color/white</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
<item name="android:forceDarkAllowed" tools:targetApi="Q">true</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:forceDarkAllowed">true</item>
</style>
<!-- 定义dialog的样式-->
</resources>

View File

@@ -1,6 +1,6 @@
#Sun Feb 13 16:53:34 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME