Skip to content

Commit

Permalink
Xposed Themes: Simplify getting color resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmud0808 committed Apr 25, 2024
1 parent c42dec1 commit f9863a3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 84 deletions.
Expand Up @@ -784,15 +784,7 @@ class QSBlackThemeA13(context: Context?) : ModPack(context!!) {

private fun calculateColors() {
try {
val res = mContext.resources

colorText = res.getColor(
res.getIdentifier(
"android:color/system_neutral1_900",
"color",
mContext.packageName
), mContext.theme
)
colorText = mContext.getColor(android.R.color.system_neutral1_900)

colorTextAlpha = colorText!! and 0xFFFFFF or (Math.round(
Color.alpha(
Expand Down
Expand Up @@ -1082,15 +1082,7 @@ class QSBlackThemeA14(context: Context?) : ModPack(context!!) {

private fun calculateColors() {
try {
val res = mContext.resources

colorText = res.getColor(
res.getIdentifier(
"android:color/system_neutral1_900",
"color",
mContext.packageName
), mContext.theme
)
colorText = mContext.getColor(android.R.color.system_neutral1_900)

colorTextAlpha = colorText!! and 0xFFFFFF or (Math.round(
Color.alpha(
Expand Down
Expand Up @@ -50,13 +50,7 @@ import kotlin.math.min
class QSFluidThemeA13(context: Context?) : ModPack(context!!) {

val colorActive = intArrayOf(
mContext.resources.getColor(
mContext.resources.getIdentifier(
"android:color/system_accent1_400",
"color",
mContext.packageName
), mContext.theme
)
mContext.getColor(android.R.color.system_accent1_400)
)
val colorActiveAlpha = intArrayOf(
Color.argb(
Expand Down Expand Up @@ -735,13 +729,7 @@ class QSFluidThemeA13(context: Context?) : ModPack(context!!) {
wasDark = isDark
}

colorActive[0] = mContext.resources.getColor(
mContext.resources.getIdentifier(
"android:color/system_accent1_400",
"color",
mContext.packageName
), mContext.theme
)
colorActive[0] = mContext.getColor(android.R.color.system_accent1_400)

colorActiveAlpha[0] = Color.argb(
(ACTIVE_ALPHA * 255).toInt(), Color.red(
Expand Down
Expand Up @@ -52,13 +52,7 @@ class QSFluidThemeA14(context: Context?) : ModPack(context!!) {
private var wasDark: Boolean = SystemUtil.isDarkMode
private var mSlider: SeekBar? = null
val colorActive = intArrayOf(
mContext.resources.getColor(
mContext.resources.getIdentifier(
"android:color/system_accent1_400",
"color",
mContext.packageName
), mContext.theme
)
mContext.getColor(android.R.color.system_accent1_400)
)
val colorActiveAlpha = intArrayOf(
Color.argb(
Expand Down Expand Up @@ -870,13 +864,7 @@ class QSFluidThemeA14(context: Context?) : ModPack(context!!) {
wasDark = isDark
}

colorActive[0] = mContext.resources.getColor(
mContext.resources.getIdentifier(
"android:color/system_accent1_400",
"color",
mContext.packageName
), mContext.theme
)
colorActive[0] = mContext.getColor(android.R.color.system_accent1_400)

colorActiveAlpha[0] = Color.argb(
(ACTIVE_ALPHA * 255).toInt(), Color.red(
Expand Down
Expand Up @@ -168,14 +168,7 @@ class QSLightThemeA12(context: Context?) : ModPack(context!!) {
if (!lightQSHeaderEnabled) return

try {
val res = mContext.resources
val iconColor = mContext.getColor(
res.getIdentifier(
"android:color/system_neutral1_900",
"color",
mContext.packageName
)
)
val iconColor = mContext.getColor(android.R.color.system_neutral1_900)

setObjectField(param.thisObject, "iconColor", iconColor)
} catch (throwable: Throwable) {
Expand Down
Expand Up @@ -796,15 +796,8 @@ class QSLightThemeA13(context: Context?) : ModPack(context!!) {
}

if (!isDark) {
val res = mContext.resources
colorActive = mContext.getColor(android.R.color.system_accent1_600)
colorInactive = res.getColor(
res.getIdentifier(
"android:color/system_neutral1_10",
"color",
mContext.packageName
), mContext.theme
)
colorInactive = mContext.getColor(android.R.color.system_neutral1_10)
}
} catch (throwable: Throwable) {
log(TAG + throwable)
Expand Down
Expand Up @@ -1069,31 +1069,15 @@ class QSLightThemeA14(context: Context?) : ModPack(context!!) {
setObjectField(unlockedScrimState, "mBehindTint", Color.TRANSPARENT)
}

val res = mContext.resources

if (!isDark) {
colorInactive = res.getColor(
res.getIdentifier(
"android:color/system_neutral1_10",
"color",
mContext.packageName
), mContext.theme
)
colorInactive = mContext.getColor(android.R.color.system_neutral1_10)
}

mScrimBehindTint = if (isDark) res.getColor(
res.getIdentifier(
"android:color/system_neutral1_1000",
"color",
mContext.packageName
), mContext.theme
) else res.getColor(
res.getIdentifier(
"android:color/system_neutral1_100",
"color",
mContext.packageName
), mContext.theme
)
mScrimBehindTint = if (isDark) {
mContext.getColor(android.R.color.system_neutral1_1000)
} else {
mContext.getColor(android.R.color.system_neutral1_100)
}
} catch (throwable: Throwable) {
log(TAG + throwable)
}
Expand Down

0 comments on commit f9863a3

Please sign in to comment.