Skip to content

Commit

Permalink
Refactor xposed themes and fix freezing issue
Browse files Browse the repository at this point in the history
Signed-off-by: DrDisagree <[email protected]>
  • Loading branch information
Mahmud0808 committed Sep 4, 2024
1 parent f2f752e commit 1afafa8
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 237 deletions.
47 changes: 9 additions & 38 deletions app/src/main/java/com/drdisagree/iconify/xposed/HookEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,18 @@ class HookEntry : ServiceConnection {
}
}
}

private fun connectRootService() {
try {
val intent = Intent().apply {
setComponent(
ComponentName(
BuildConfig.APPLICATION_ID,
"${
BuildConfig.APPLICATION_ID.replace(
".debug",
""
)
}.services.RootProviderProxy"
)
component = ComponentName(
BuildConfig.APPLICATION_ID,
"${
BuildConfig.APPLICATION_ID.replace(
".debug",
""
)
}.services.RootProviderProxy"
)
}

Expand Down Expand Up @@ -255,33 +254,5 @@ class HookEntry : ServiceConnection {
instance!!.forceConnectRootService()
}
}

fun enableOverlay(packageName: String) {
enqueueProxyCommand { proxy ->
proxy?.enableOverlay(packageName)
}
}

fun enableOverlays(vararg packageNames: String) {
enqueueProxyCommand { proxy ->
packageNames.forEach { packageName ->
proxy?.enableOverlay(packageName)
}
}
}

fun disableOverlay(packageName: String) {
enqueueProxyCommand { proxy ->
proxy?.disableOverlay(packageName)
}
}

fun disableOverlays(vararg packageNames: String) {
enqueueProxyCommand { proxy ->
packageNames.forEach { packageName ->
proxy?.disableOverlay(packageName)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
)
)

icon.setImageTintList(ColorStateList.valueOf(Color.WHITE))
icon.imageTintList = ColorStateList.valueOf(Color.WHITE)
} catch (throwable: Throwable) {
log(TAG + throwable)
}
Expand Down Expand Up @@ -272,8 +272,8 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
if (!blackQSHeaderEnabled) return

try {
(getObjectField(param.thisObject, "mIcon") as ImageView)
.setImageTintList(ColorStateList.valueOf(colorText!!))
(getObjectField(param.thisObject, "mIcon") as ImageView).imageTintList =
ColorStateList.valueOf(colorText!!)
} catch (throwable: Throwable) {
log(TAG + throwable)
}
Expand All @@ -286,12 +286,15 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
if (!blackQSHeaderEnabled) return

try {
(getObjectField(param.thisObject, "mIcon") as ImageView)
.setImageTintList(ColorStateList.valueOf(colorText!!))
(getObjectField(param.thisObject, "mIcon") as ImageView).imageTintList =
ColorStateList.valueOf(colorText!!)
} catch (throwable: Throwable) {
try {
(getObjectField(param.thisObject, "mIconView") as ImageView)
.setImageTintList(ColorStateList.valueOf(colorText!!))
(getObjectField(
param.thisObject,
"mIconView"
) as ImageView).imageTintList =
ColorStateList.valueOf(colorText!!)
} catch (throwable1: Throwable) {
log(TAG + throwable1)
}
Expand All @@ -305,8 +308,8 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
if (!blackQSHeaderEnabled) return

try {
(getObjectField(param.thisObject, "mIcon") as ImageView)
.setImageTintList(ColorStateList.valueOf(colorText!!))
(getObjectField(param.thisObject, "mIcon") as ImageView).imageTintList =
ColorStateList.valueOf(colorText!!)
} catch (throwable: Throwable) {
log(TAG + throwable)
}
Expand All @@ -319,8 +322,8 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
try {
if (getIntField(param.args[1], "state") == Tile.STATE_ACTIVE
) {
(param.args[0] as ImageView)
.setImageTintList(ColorStateList.valueOf(colorText!!))
(param.args[0] as ImageView).imageTintList =
ColorStateList.valueOf(colorText!!)
}
} catch (throwable: Throwable) {
log(TAG + throwable)
Expand Down Expand Up @@ -432,7 +435,7 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
mContext.packageName
)
)
customDrawable.setImageTintList(ColorStateList.valueOf(colorText!!))
customDrawable.imageTintList = ColorStateList.valueOf(colorText!!)

val chevron = sideView.findViewById<ImageView>(
mContext.resources.getIdentifier(
Expand All @@ -441,7 +444,7 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
mContext.packageName
)
)
chevron.setImageTintList(ColorStateList.valueOf(colorText!!))
chevron.imageTintList = ColorStateList.valueOf(colorText!!)
} catch (throwable: Throwable) {
log(TAG + throwable)
}
Expand Down Expand Up @@ -477,11 +480,11 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
val mIcon = param.args[0] as ImageView

if (isDisabledState) {
mIcon.setImageTintList(ColorStateList.valueOf(-0x7f000001))
mIcon.imageTintList = ColorStateList.valueOf(-0x7f000001)
} else if (isActiveState && !qsTextAlwaysWhite && !qsTextFollowAccent) {
mIcon.setImageTintList(ColorStateList.valueOf(colorText!!))
mIcon.imageTintList = ColorStateList.valueOf(colorText!!)
} else if (!isActiveState) {
mIcon.setImageTintList(ColorStateList.valueOf(Color.WHITE))
mIcon.imageTintList = ColorStateList.valueOf(Color.WHITE)
}
}
}
Expand Down Expand Up @@ -585,7 +588,7 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
})

try {
val constants: Array<out Any>? = scrimStateEnum.getEnumConstants()
val constants: Array<out Any>? = scrimStateEnum.enumConstants
if (constants != null) {
for (constant in constants) {
when (constant.toString()) {
Expand Down Expand Up @@ -830,7 +833,7 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
mContext.packageName
)
), "mMobileSignal"
) as ImageView).setImageTintList(ColorStateList.valueOf(textColor))
) as ImageView).imageTintList = ColorStateList.valueOf(textColor)

(getObjectField(
mView.findViewById(
Expand All @@ -840,7 +843,7 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {
mContext.packageName
)
), "mMobileRoaming"
) as ImageView).setImageTintList(ColorStateList.valueOf(textColor))
) as ImageView).imageTintList = ColorStateList.valueOf(textColor)
} catch (ignored: Throwable) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {

hookAllMethods(mobileIconBinderClass, "bind", object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
if (param.args[1].javaClass.getName()
if (param.args[1].javaClass.name
.contains("ShadeCarrierGroupMobileIconViewModel")
) {
modernShadeCarrierGroupMobileViews.add(param.result)
Expand Down Expand Up @@ -306,7 +306,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
"id",
mContext.packageName
)
).setImageTintList(ColorStateList.valueOf(Color.WHITE))
).imageTintList = ColorStateList.valueOf(Color.WHITE)

// Power menu button
try {
Expand All @@ -327,7 +327,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
)
}?.apply {
if (this is ImageView) {
setImageTintList(ColorStateList.valueOf(Color.BLACK))
imageTintList = ColorStateList.valueOf(Color.BLACK)
} else if (this is ViewGroup) {
(getChildAt(0) as ImageView).setColorFilter(
Color.WHITE,
Expand Down Expand Up @@ -361,8 +361,8 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
override fun afterHookedMethod(param: MethodHookParam) {
if (!blackQSHeaderEnabled) return

(getObjectField(param.thisObject, "mMobileSignal") as ImageView)
.setImageTintList(ColorStateList.valueOf(Color.WHITE))
(getObjectField(param.thisObject, "mMobileSignal") as ImageView).imageTintList =
ColorStateList.valueOf(Color.WHITE)
}
})

Expand Down Expand Up @@ -479,7 +479,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
}
val mIcon = getObjectField(param.thisObject, "mIcon") as ImageView

mIcon.setImageTintList(ColorStateList.valueOf(iconColor))
mIcon.imageTintList = ColorStateList.valueOf(iconColor)
} catch (throwable: Throwable) {
log(TAG + throwable)
}
Expand All @@ -492,12 +492,15 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
if (!blackQSHeaderEnabled) return

try {
(getObjectField(param.thisObject, "mIcon") as ImageView)
.setImageTintList(ColorStateList.valueOf(colorText!!))
(getObjectField(param.thisObject, "mIcon") as ImageView).imageTintList =
ColorStateList.valueOf(colorText!!)
} catch (throwable: Throwable) {
try {
(getObjectField(param.thisObject, "mIconView") as ImageView)
.setImageTintList(ColorStateList.valueOf(colorText!!))
(getObjectField(
param.thisObject,
"mIconView"
) as ImageView).imageTintList =
ColorStateList.valueOf(colorText!!)
} catch (ignored: Throwable) {
}
}
Expand All @@ -512,7 +515,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {

try {
val mIcon = getObjectField(param.thisObject, "mIcon") as ImageView
mIcon.setImageTintList(ColorStateList.valueOf(colorText!!))
mIcon.imageTintList = ColorStateList.valueOf(colorText!!)
} catch (throwable: Throwable) {
log(TAG + throwable)
}
Expand All @@ -526,8 +529,8 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
try {
if (getIntField(param.args[1], "state") == Tile.STATE_ACTIVE
) {
(param.args[0] as ImageView)
.setImageTintList(ColorStateList.valueOf(colorText!!))
(param.args[0] as ImageView).imageTintList =
ColorStateList.valueOf(colorText!!)
}
} catch (throwable: Throwable) {
log(TAG + throwable)
Expand Down Expand Up @@ -638,7 +641,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
mContext.packageName
)
)
customDrawable.setImageTintList(ColorStateList.valueOf(colorText!!))
customDrawable.imageTintList = ColorStateList.valueOf(colorText!!)

val chevron = sideView.findViewById<ImageView>(
mContext.resources.getIdentifier(
Expand All @@ -647,7 +650,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
mContext.packageName
)
)
chevron.setImageTintList(ColorStateList.valueOf(colorText!!))
chevron.imageTintList = ColorStateList.valueOf(colorText!!)
} catch (throwable: Throwable) {
log(TAG + throwable)
}
Expand Down Expand Up @@ -684,11 +687,11 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
val mIcon = param.args[0] as ImageView

if (isDisabledState) {
mIcon.setImageTintList(ColorStateList.valueOf(-0x7f000001))
mIcon.imageTintList = ColorStateList.valueOf(-0x7f000001)
} else if (isActiveState && !qsTextAlwaysWhite && !qsTextFollowAccent) {
mIcon.setImageTintList(ColorStateList.valueOf(colorText!!))
mIcon.imageTintList = ColorStateList.valueOf(colorText!!)
} else if (!isActiveState) {
mIcon.setImageTintList(ColorStateList.valueOf(Color.WHITE))
mIcon.imageTintList = ColorStateList.valueOf(Color.WHITE)
}
}
}
Expand Down Expand Up @@ -736,7 +739,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
)
)

pmButton.setImageTintList(ColorStateList.valueOf(Color.BLACK))
pmButton.imageTintList = ColorStateList.valueOf(Color.BLACK)
}
} catch (ignored: Throwable) {
}
Expand Down Expand Up @@ -947,7 +950,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
})

try {
val constants: Array<out Any>? = scrimStateEnum.getEnumConstants()
val constants: Array<out Any>? = scrimStateEnum.enumConstants
if (constants != null) {
for (constant in constants) {
when (constant.toString()) {
Expand Down Expand Up @@ -1228,7 +1231,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
mContext.packageName
)
), "mMobileSignal"
) as ImageView).setImageTintList(ColorStateList.valueOf(textColor))
) as ImageView).imageTintList = ColorStateList.valueOf(textColor)

(getObjectField(
mView.findViewById(
Expand All @@ -1238,7 +1241,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
mContext.packageName
)
), "mMobileRoaming"
) as ImageView).setImageTintList(ColorStateList.valueOf(textColor))
) as ImageView).imageTintList = ColorStateList.valueOf(textColor)
} catch (ignored: Throwable) {
}
}
Expand All @@ -1258,7 +1261,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {
)
}

@Suppress("UNCHECKED_CAST")
@Suppress("UNCHECKED_CAST", "SameParameterValue")
private fun setModernSignalTextColor(textColor: Int) {
val res: Resources = mContext.resources
if (shadeCarrierGroupController == null) return
Expand Down
Loading

0 comments on commit 1afafa8

Please sign in to comment.