Skip to content

Commit

Permalink
HomeHandle & Wallpaper: support custom home_handle opacity ctrl & ada…
Browse files Browse the repository at this point in the history
…pt U for WallpaperZoom

Signed-off-by: Art_Chen <[email protected]>
  • Loading branch information
Art-Chen committed Nov 4, 2023
1 parent f5e0751 commit 0ac93a2
Show file tree
Hide file tree
Showing 10 changed files with 508 additions and 458 deletions.
634 changes: 313 additions & 321 deletions app/src/main/java/moe/chenxy/miuiextra/hooker/entity/MiWallpaperHook.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package moe.chenxy.miuiextra.hooker.entity

import android.util.Log
import androidx.dynamicanimation.animation.SpringAnimation
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.method
import com.highcapable.yukihookapi.hook.type.android.ViewClass
Expand Down Expand Up @@ -48,13 +49,17 @@ object MiuiHomeHook : YukiBaseHooker() {
}.hook {
after {
val springAnimation = this.result
val springAnimationReal = XposedHelpers.getObjectField(springAnimation, "mSpringAnimation") as SpringAnimation
if (this.args[2] == -1500.0f) {
XposedHelpers.callMethod(
springAnimation,
"setDampingResponse",
0.68f,
0.55f
)
// XposedHelpers.callMethod(
// springAnimation,
// "setDampingResponse",
// 0.68f,
// 0.55f
// )
springAnimationReal.spring.stiffness = 100f
springAnimationReal.spring.dampingRatio = 1.5f
springAnimationReal.setStartVelocity(5f)
}
this.result = springAnimation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ object AnimationEnhanceHooker : YukiBaseHooker() {
override fun onHook() {
// Force enable breakable anim support
"com.miui.home.launcher.common.DeviceLevelUtils".toClass().apply {
method {
name = "supportBreakOpenAnim"
}.hook {
replaceToTrue()
}

method {
name = "isUseSimpleAnim"
}.hook {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ object HomeHandleAnimatorHooker : YukiBaseHooker() {
var mLightColor = -1
var mDarkColor = -1
var mNavigationHandle : Any? = null
var currentIntensity = 0f
fun animateHomeHandleZoom(zoomType: ZoomType) {
if (zoomValueAnimator == null) {
zoomValueAnimator = ValueAnimator()
Expand Down Expand Up @@ -174,6 +173,7 @@ object HomeHandleAnimatorHooker : YukiBaseHooker() {
mainPrefs.reload()
val autoTransparent = mainPrefs.getBoolean("chen_home_handle_auto_transparent", false)
val useScaleEffect = mainPrefs.getBoolean("home_handle_scale_on_full_transparent", false)
val transDegree = mainPrefs.getInt("home_handle_auto_trans_alpha_val", 30)
useMiBlur = mainPrefs.getBoolean("chen_home_handle_blur_effect", false)
val isHome = mIsInHome
if (!autoTransparent && needOpacity && !needToTransparent && !useMiBlur) {
Expand Down Expand Up @@ -244,7 +244,7 @@ object HomeHandleAnimatorHooker : YukiBaseHooker() {
if (needToTransparent)
0f
else if (needOpacity)
0.7f
1 - (transDegree.toFloat() / 100)
else
1.0f
)
Expand Down Expand Up @@ -569,7 +569,6 @@ object HomeHandleAnimatorHooker : YukiBaseHooker() {
XposedHelpers.setIntField(this.instance, "mDarkColor", mDarkColor)
XposedHelpers.setIntField(this.instance, "mLightColor", mLightColor)
}
currentIntensity = this.args[0] as Float
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class SettingsActivity : AppCompatActivity() {
}

bindAnimationSeekBarNoEditText(findPreference("blur_scale_val"), 1)
bindAnimationSeekBarNoEditText(findPreference("home_handle_auto_trans_alpha_val"), 1)
}

private val setColorFadeSettings : Runnable = Runnable {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@
<string name="shift_and_stretch">位移 + 拉伸</string>
<string name="scale">缩放</string>
<string name="shift_and_scale">位移 + 缩放</string>
<string name="home_handle_auto_trans_alphaval_title">自动透明程度</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,5 @@
<string name="shift_and_stretch">Shift and Stretch</string>
<string name="scale">Scale</string>
<string name="shift_and_scale">Shift and Scale</string>
<string name="home_handle_auto_trans_alphaval_title">Auto Transparent Degree</string>
</resources>
43 changes: 26 additions & 17 deletions app/src/main/res/xml/chen_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,28 @@
app:key="wallpaper_zoom"
app:title="@string/wallpaper_scale_title" />

<rikka.material.preference.MaterialSwitchPreference
app:key="use_chen_screen_on_anim"
app:title="@string/use_chen_screen_on_anim_title"
app:summary="@string/use_chen_screen_on_anim_summary"/>
<!-- <rikka.material.preference.MaterialSwitchPreference-->
<!-- app:key="use_chen_screen_on_anim"-->
<!-- app:title="@string/use_chen_screen_on_anim_title"-->
<!-- app:summary="@string/use_chen_screen_on_anim_summary"/>-->

<rikka.material.preference.MaterialSwitchPreference
app:key="disable_wallpaper_auto_darken"
app:title="@string/disable_wallpaper_auto_darken_title"/>

<rikka.material.preference.MaterialSwitchPreference
app:key="miui_unlock_wallpaper_anim_fade"
app:title="@string/miui_unlock_wallpaper_anim_fade_title"
app:summary="@string/miui_unlock_wallpaper_anim_fade_summary"/>

<SeekBarPreference
android:max="1000"
app:key="miui_unlock_wallpaper_anim_fade_anim_val"
app:dependency="miui_unlock_wallpaper_anim_fade"
app:defaultValue="450"
app:min="1"
app:updatesContinuously="true"
app:title="@string/miui_unlock_wallpaper_anim_fade_anim_val_title" />
<!-- <rikka.material.preference.MaterialSwitchPreference-->
<!-- app:key="miui_unlock_wallpaper_anim_fade"-->
<!-- app:title="@string/miui_unlock_wallpaper_anim_fade_title"-->
<!-- app:summary="@string/miui_unlock_wallpaper_anim_fade_summary"/>-->

<!-- <SeekBarPreference-->
<!-- android:max="1000"-->
<!-- app:key="miui_unlock_wallpaper_anim_fade_anim_val"-->
<!-- app:dependency="miui_unlock_wallpaper_anim_fade"-->
<!-- app:defaultValue="450"-->
<!-- app:min="1"-->
<!-- app:updatesContinuously="true"-->
<!-- app:title="@string/miui_unlock_wallpaper_anim_fade_anim_val_title" />-->
</PreferenceCategory>

<PreferenceCategory app:title="@string/home_handle_header" app:key="home_handle">
Expand Down Expand Up @@ -147,6 +147,15 @@
app:title="@string/chen_home_handle_auto_transparent_title"
app:summary="@string/chen_home_handle_auto_transparent_summary"/>

<SeekBarPreference
android:max="100"
app:key="home_handle_auto_trans_alpha_val"
app:dependency="chen_home_handle_auto_transparent"
app:defaultValue="30"
app:min="1"
app:updatesContinuously="true"
app:title="@string/home_handle_auto_trans_alphaval_title" />

<rikka.material.preference.MaterialSwitchPreference
app:key="chen_home_handle_full_transparent_at_miuihome"
app:dependency="chen_home_handle_anim"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/wallpaper_zoom_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<SeekBarPreference
android:max="10"
app:key="wallpaper_zoomOut_val"
app:defaultValue="4"
app:defaultValue="1"
app:min="1"
app:updatesContinuously="true"
app:title="@string/wallpaper_zoomOut_summary" />
Expand Down

0 comments on commit 0ac93a2

Please sign in to comment.