This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Also add WIP Dock Blur
- Loading branch information
Showing
9 changed files
with
261 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.yuk.hyperOS_XXL.blur | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.view.View | ||
import cn.fkj233.ui.activity.dp2px | ||
import com.yuk.hyperOS_XXL.blur.MiBlurUtilities.mSupportedMiBlur | ||
import com.yuk.hyperOS_XXL.utils.AppUtils.isDarkMode | ||
|
||
@SuppressLint("ViewConstructor") | ||
class BlurView(context: Context, private val radius: Int) : View(context) { | ||
|
||
private fun setBlur() { | ||
//MiBlurUtilities.resetBlurColor(this.parent as View) | ||
MiBlurUtilities.setPassWindowBlurEnable(this.parent as View, true) | ||
MiBlurUtilities.setViewBlur(this.parent as View, 1) | ||
MiBlurUtilities.setBlurRoundRect(this.parent as View, dp2px(context, radius.toFloat())) | ||
//MiBlurUtilities.setBlurColor(this.parent as View, if (isDarkMode(this.context)) 0x14ffffff else 0x14000000, 3) | ||
} | ||
|
||
override fun onAttachedToWindow() { | ||
super.onAttachedToWindow() | ||
if (mSupportedMiBlur) { | ||
setBlur() | ||
} | ||
} | ||
|
||
override fun onDetachedFromWindow() { | ||
super.onDetachedFromWindow() | ||
MiBlurUtilities.clearAllBlur(this.parent as View) | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
app/src/main/kotlin/com/yuk/hyperOS_XXL/blur/MiBlurUtilities.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package com.yuk.hyperOS_XXL.blur | ||
|
||
import android.graphics.Outline | ||
import android.util.Log | ||
import android.view.View | ||
import android.view.ViewOutlineProvider | ||
import com.yuk.hyperOS_XXL.utils.AppUtils.isDarkMode | ||
import org.lsposed.hiddenapibypass.HiddenApiBypass | ||
|
||
object MiBlurUtilities { | ||
var mSupportedMiBlur: Boolean = true | ||
|
||
fun setViewBackgroundBlur(view: View?, i: Int) { | ||
HiddenApiBypass.invoke(View::class.java, view, "setMiBackgroundBlurMode", i) | ||
} | ||
|
||
fun setViewBlur(view: View, i: Int) { | ||
HiddenApiBypass.invoke(View::class.java, view, "setMiViewBlurMode", i) | ||
} | ||
|
||
fun setBlurRadius(view: View, i: Int) { | ||
if (i < 0 || i > 200) { | ||
Log.e("MiBlurUtilities", "setMiBackgroundBlurRadius error radius is " + i + " " + view.javaClass.getName() + " hashcode " + view.hashCode()) | ||
return | ||
} | ||
HiddenApiBypass.invoke(View::class.java, view, "setMiBackgroundBlurRadius", i) | ||
} | ||
|
||
fun setPassWindowBlurEnable(view: View, z: Boolean) { | ||
Log.d("Launcher.BlurUtilities", "setViewBlur: view $view") | ||
HiddenApiBypass.invoke(View::class.java, view, "setPassWindowBlurEnabled", z) | ||
} | ||
|
||
fun disableMiBackgroundContainBelow(view: View, z: Boolean) { | ||
HiddenApiBypass.invoke(View::class.java, view, "disableMiBackgroundContainBelow", z) | ||
} | ||
|
||
fun setBlurColor(view: View, i: Int, i2: Int) { | ||
HiddenApiBypass.invoke(View::class.java, view, "addMiBackgroundBlendColor", i, i2) | ||
} | ||
|
||
fun resetBlurColor(view: View) { | ||
HiddenApiBypass.invoke(View::class.java, view, "clearMiBackgroundBlendColor") | ||
} | ||
|
||
fun setBlurRoundRect(view: View, i: Int, i2: Int, i3: Int, i4: Int, i5: Int) { | ||
view.setClipToOutline(false) | ||
val outlineProvider = object : ViewOutlineProvider() { | ||
override fun getOutline(view: View, outline: Outline) { | ||
outline.setRoundRect( | ||
i2, i3, i4, i5, i.toFloat() | ||
) | ||
} | ||
} | ||
view.outlineProvider = outlineProvider | ||
} | ||
|
||
fun setBlurRoundRect(view: View, i: Int) { | ||
view.setClipToOutline(true) | ||
val outlineProvider = object : ViewOutlineProvider() { | ||
override fun getOutline(view: View, outline: Outline) { | ||
outline.setRoundRect( | ||
0, 0, view.width, view.height, i.toFloat() | ||
) | ||
} | ||
} | ||
view.outlineProvider = outlineProvider | ||
} | ||
|
||
|
||
fun clearAllBlur(view: View) { | ||
resetBlurColor(view) | ||
setViewBackgroundBlur(view, 0) | ||
setViewBlur(view, 0) | ||
setBlurRadius(view, 0) | ||
setPassWindowBlurEnable(view, false) | ||
} | ||
|
||
fun setElementBlur(view: View, i: Int, i2: Int, i3: Int, i4: Int, i5: Int, i6: Int, i7: Int, i8: Int, i9: Int, i10: Int) { | ||
resetBlurColor(view) | ||
setViewBlur(view, i) | ||
setBlurRoundRect(view, i2) | ||
if (isDarkMode(view.context)) { | ||
setBlurColor(view, i3, i4) | ||
setBlurColor(view, i7, i8) | ||
return | ||
} | ||
setBlurColor(view, i5, i6) | ||
setBlurColor(view, i9, i10) | ||
} | ||
|
||
fun setContainerBlur(view: View, i: Int, z: Boolean, i2: Int, i3: Int, i4: Int, i5: Int, i6: Int) { | ||
resetBlurColor(view) | ||
setViewBackgroundBlur(view, i) | ||
if (z) { | ||
setPassWindowBlurEnable(view, true) | ||
} | ||
setBlurRadius(view, i2) | ||
if (isDarkMode(view.context)) { | ||
setBlurColor(view, i3, i4) | ||
} else { | ||
setBlurColor(view, i5, i6) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
app/src/main/kotlin/com/yuk/hyperOS_XXL/hooks/modules/miuihome/DockBlur.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.yuk.hyperOS_XXL.hooks.modules.miuihome | ||
|
||
import android.animation.ValueAnimator | ||
import android.app.Application | ||
import android.content.Context | ||
import android.os.Bundle | ||
import android.view.Gravity | ||
import android.view.View | ||
import android.widget.FrameLayout | ||
import cn.fkj233.ui.activity.dp2px | ||
import com.github.kyuubiran.ezxhelper.EzXHelper | ||
import com.github.kyuubiran.ezxhelper.EzXHelper.appContext | ||
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks | ||
import com.yuk.hyperOS_XXL.blur.BlurView | ||
import com.yuk.hyperOS_XXL.hooks.modules.BaseHook | ||
import com.yuk.hyperOS_XXL.utils.KotlinXposedHelper.callMethod | ||
import com.yuk.hyperOS_XXL.utils.KotlinXposedHelper.findClass | ||
import com.yuk.hyperOS_XXL.utils.KotlinXposedHelper.hookAfterMethod | ||
import com.yuk.hyperOS_XXL.utils.KotlinXposedHelper.hookBeforeMethod | ||
import com.yuk.hyperOS_XXL.utils.XSharedPreferences.getBoolean | ||
import de.robv.android.xposed.XposedHelpers | ||
|
||
object DockBlur : BaseHook() { | ||
override fun init() { | ||
|
||
if (!getBoolean("miuihome_add_dock_blur", false)) return | ||
|
||
var isShowEditPanel = false | ||
val launcherClass = "com.miui.home.launcher.Launcher".findClass() | ||
val folderInfo = "com.miui.home.launcher.FolderInfo".findClass() | ||
|
||
Application::class.java.hookBeforeMethod("attach", Context::class.java) { hookParam -> | ||
EzXHelper.initAppContext(hookParam.args[0] as Context) | ||
|
||
val mDockHeight = dp2px(appContext, 93f) | ||
val mDockMargin = dp2px(appContext, 10f) | ||
val mDockBottomMargin = dp2px(appContext, 13f) | ||
|
||
// DockBlur WIP | ||
"com.miui.home.launcher.Launcher".findClass().declaredConstructors.createHooks { | ||
after { | ||
var mDockBlurParent = XposedHelpers.getAdditionalInstanceField(it.thisObject, "mDockBlurParent") | ||
var mDockBlur = XposedHelpers.getAdditionalInstanceField(it.thisObject, "mDockBlur") | ||
if (mDockBlurParent != null && mDockBlur != null) return@after | ||
mDockBlurParent = FrameLayout(appContext) | ||
mDockBlur = BlurView(appContext, 30) | ||
XposedHelpers.setAdditionalInstanceField(it.thisObject, "mDockBlur", mDockBlur) | ||
XposedHelpers.setAdditionalInstanceField(it.thisObject, "mDockBlurParent", mDockBlurParent) | ||
} | ||
launcherClass.hookAfterMethod("onCreate", Bundle::class.java) { | ||
val mSearchBarContainer = it.thisObject.callMethod("getSearchBarContainer") as FrameLayout | ||
val mSearchEdgeLayout = mSearchBarContainer.parent as FrameLayout | ||
val mDockBlurParent = XposedHelpers.getAdditionalInstanceField(it.thisObject, "mDockBlurParent") as FrameLayout | ||
val mDockBlur = XposedHelpers.getAdditionalInstanceField(it.thisObject, "mDockBlur") as BlurView | ||
val lp = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mDockHeight) | ||
lp.gravity = Gravity.BOTTOM | ||
lp.setMargins(mDockMargin, 0, mDockMargin, mDockBottomMargin) | ||
mDockBlurParent.layoutParams = lp | ||
mDockBlur.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT) | ||
mSearchEdgeLayout.addView(mDockBlurParent, 0) | ||
mDockBlurParent.addView(mDockBlur, 0) | ||
launcherClass.hookAfterMethod("showEditPanel", Boolean::class.java) { hookParam -> | ||
isShowEditPanel = hookParam.args[0] as Boolean | ||
if (isShowEditPanel) { | ||
val valueAnimator = ValueAnimator.ofFloat(mDockBlurParent.alpha, 0f) | ||
valueAnimator.addUpdateListener { animator -> | ||
val value = animator.animatedValue as Float | ||
mDockBlurParent.alpha = value | ||
} | ||
valueAnimator.duration = 150 | ||
valueAnimator.start() | ||
} else { | ||
val valueAnimator = ValueAnimator.ofFloat(mDockBlurParent.alpha, 1f) | ||
valueAnimator.addUpdateListener { animator -> | ||
val value = animator.animatedValue as Float | ||
mDockBlurParent.alpha = value | ||
} | ||
valueAnimator.duration = 150 | ||
valueAnimator.start() | ||
} | ||
} | ||
launcherClass.hookAfterMethod("openFolder", folderInfo, View::class.java) { | ||
if (!isShowEditPanel) { | ||
val valueAnimator = ValueAnimator.ofFloat(mDockBlurParent.alpha, 0f) | ||
valueAnimator.addUpdateListener { animator -> | ||
val value = animator.animatedValue as Float | ||
mDockBlurParent.alpha = value | ||
} | ||
valueAnimator.duration = 150 | ||
valueAnimator.start() | ||
} | ||
} | ||
launcherClass.hookAfterMethod("closeFolder", Boolean::class.java) { | ||
if (!isShowEditPanel) { | ||
val valueAnimator = ValueAnimator.ofFloat(mDockBlurParent.alpha, 1f) | ||
valueAnimator.addUpdateListener { animator -> | ||
val value = animator.animatedValue as Float | ||
mDockBlurParent.alpha = value | ||
} | ||
valueAnimator.duration = 150 | ||
valueAnimator.start() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters