Skip to content

Commit

Permalink
Home & Animations: add another effect params for unlock anim
Browse files Browse the repository at this point in the history
* Only deny overridePendingTransition if enter and exit both overrided

Signed-off-by: Art_Chen <[email protected]>
  • Loading branch information
Art-Chen committed Nov 4, 2023
1 parent 0ac93a2 commit ce18b99
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 23 deletions.
Binary file modified app/release/app-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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
import com.highcapable.yukihookapi.hook.type.java.BooleanType
import com.highcapable.yukihookapi.hook.type.java.FloatType
import com.highcapable.yukihookapi.hook.type.java.IntType
import de.robv.android.xposed.XSharedPreferences
Expand Down Expand Up @@ -42,24 +43,36 @@ object MiuiHomeHook : YukiBaseHooker() {
loadHooker(WallpaperZoomOptimizeHooker)
}

if (mainPrefs.getBoolean("miui_unlock_anim_enhance", false)) {
"com.miui.home.launcher.compat.UserPresentAnimationCompatV12Phone".toClass().method {

"com.miui.home.launcher.compat.UserPresentAnimationCompatV12Phone".toClass().apply {
method {
name = "getSpringAnimator"
param(ViewClass, IntType, FloatType, FloatType, FloatType, FloatType)
}.hook {
after {
mainPrefs.reload()
val mode = mainPrefs.getString("miui_unlock_anim_enhance_menu", "0")?.toInt()
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
// )
springAnimationReal.spring.stiffness = 100f
springAnimationReal.spring.dampingRatio = 1.5f
springAnimationReal.setStartVelocity(5f)
var dumping = 0.78f
var response = 0.35f
when (mode) {
1 -> {
dumping = 0.68f
response = 0.6f
}
2 -> {
dumping = 1.5f
response = 0.3f
}
}
XposedHelpers.callMethod(
springAnimation,
"setDampingResponse",
dumping,
response
)

}
this.result = springAnimation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,15 @@ object SystemHooker : YukiBaseHooker() {
"com.android.server.wm.ActivityClientController".toClass().method {
name = "overridePendingTransition"
param(IBinderClass, StringClass, IntType, IntType, IntType)
}.hook { intercept() }
}.hook {
before {
Log.v("Art_Chen", "overridePendingTransition pkgName ${this.args[1]} enterAnim ${this.args[2]} exit ${this.args[3]}")
// Skip if exit Anim is not null.
if (this.args[2] != 0 && this.args[3] != 0) {
this.result = null
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import moe.chenxy.miuiextra.R
import moe.chenxy.miuiextra.utils.ChenUtils
import rikka.preference.SimpleMenuPreference
import kotlin.system.exitProcess

private var isActivated = false
Expand Down Expand Up @@ -139,11 +140,6 @@ class SettingsActivity : AppCompatActivity() {
return@setOnPreferenceChangeListener true
}

findPreference<SwitchPreferenceCompat>("miui_unlock_anim_enhance")?.setOnPreferenceChangeListener { _, _ ->
showRebootSnackBar(R.string.may_need_reboot_miui_home, SHELL_RESTART_MIUI_HOME)
return@setOnPreferenceChangeListener true
}

findPreference<SwitchPreferenceCompat>("miui_unlock_wallpaper_anim_fade")?.setOnPreferenceChangeListener { _, newValue ->
showRebootSnackBar(null, SHELL_RESTART_MI_WALLPAPER)
return@setOnPreferenceChangeListener true
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<string name="wallpaper_zoomIn_start_velocity_summary">放大动画开始速度</string>
<string name="wallpaper_zoomOut_summary">缩小动画程度</string>
<string name="wallpaper_auto_zoom_on_lockscreen_title">锁屏时自动缩放壁纸</string>
<string name="miui_unlock_anim_enhance_title">优化解锁时的图标飞入动画</string>
<string name="miui_unlock_anim_enhance_title">解锁时的图标飞入动画</string>
<string name="wallpaper_auto_zoom_on_lockscreen_summary">仅在锁屏和桌面壁纸使用同一壁纸的情况下支持</string>
<string name="miui_unlock_wallpaper_anim_fade_title">解锁到桌面壁纸时使用淡入动画</string>
<string name="miui_unlock_wallpaper_anim_fade_summary">如果锁屏壁纸和桌面壁纸不同时,使用淡入动画而不是缩放动画来切换到桌面壁纸</string>
Expand Down Expand Up @@ -113,4 +113,5 @@
<string name="scale">缩放</string>
<string name="shift_and_scale">位移 + 缩放</string>
<string name="home_handle_auto_trans_alphaval_title">自动透明程度</string>
<string name="defaults">默认</string>
</resources>
10 changes: 10 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@
<item>1</item>
<item>2</item>
</string-array>
<string-array name="miui_unlock_anim_enhance_entries">
<item>@string/defaults</item>
<item>Effect 1</item>
<item>Effect 2</item>
</string-array>
<string-array name="miui_unlock_anim_enhance_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<string name="wallpaper_zoomIn_stiffness_summary">Zoom In Animation Stiffness</string>
<string name="wallpaper_zoomOut_summary">Zoom Out Animation Degree</string>
<string name="wallpaper_auto_zoom_on_lockscreen_title">Auto Zoom on LockScreen</string>
<string name="miui_unlock_anim_enhance_title">Unlock Anim Optimize</string>
<string name="miui_unlock_anim_enhance_title">Unlock Anim</string>
<string name="wallpaper_auto_zoom_on_lockscreen_summary">Only Support if the desktop wallpaper same as the keyguard</string>
<string name="miui_unlock_wallpaper_anim_fade_title">Use Fade Effect For Desktop Wallpaper</string>
<string name="miui_unlock_wallpaper_anim_fade_summary">Replace the scale animation to fade animation when unlock if the keyguard wallpaper differ than desktop used</string>
Expand Down Expand Up @@ -115,4 +115,5 @@
<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>
<string name="defaults">Default</string>
</resources>
11 changes: 8 additions & 3 deletions app/src/main/res/xml/chen_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
app:title="@string/miui_home_anim_enhance_title"
app:summary="@string/miui_home_anim_enhance_summary"/>

<rikka.material.preference.MaterialSwitchPreference
app:key="miui_unlock_anim_enhance"
app:title="@string/miui_unlock_anim_enhance_title" />
<rikka.preference.SimpleMenuPreference
app:key="miui_unlock_anim_enhance_menu"
app:title="@string/miui_unlock_anim_enhance_title"
app:entries="@array/miui_unlock_anim_enhance_entries"
app:defaultValue="0"
app:summary="%s"
app:entryValues="@array/miui_unlock_anim_enhance_values" />

<!-- <rikka.material.preference.MaterialSwitchPreference-->
<!-- app:key="not_hide_icon_when_enter_recent"-->
Expand Down Expand Up @@ -80,6 +84,7 @@
app:dependency="use_chen_volume_animation"
app:title="@string/chen_volume_animation_effect_title"
app:entries="@array/volume_animation_effect_entries"
app:defaultValue="0"
app:summary="%s"
app:entryValues="@array/volume_animation_effect_values" />
</PreferenceCategory>
Expand Down

0 comments on commit ce18b99

Please sign in to comment.