diff --git a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt index 040a04da0..5c5c27aac 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt @@ -34,7 +34,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } override fun primaryColorAttr(@AttrRes colorAttr: Int): ThemeStore { - return primaryColor(ATHUtils.resolveColor(mContext, colorAttr)) + return primaryColor(ThemeUtils.resolveColor(mContext, colorAttr)) } override fun primaryColorDark(@ColorInt color: Int): ThemeStore { @@ -47,7 +47,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } override fun primaryColorDarkAttr(@AttrRes colorAttr: Int): ThemeStore { - return primaryColorDark(ATHUtils.resolveColor(mContext, colorAttr)) + return primaryColorDark(ThemeUtils.resolveColor(mContext, colorAttr)) } override fun accentColor(@ColorInt color: Int): ThemeStore { @@ -60,7 +60,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } override fun accentColorAttr(@AttrRes colorAttr: Int): ThemeStore { - return accentColor(ATHUtils.resolveColor(mContext, colorAttr)) + return accentColor(ThemeUtils.resolveColor(mContext, colorAttr)) } override fun statusBarColor(@ColorInt color: Int): ThemeStore { @@ -73,7 +73,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } override fun statusBarColorAttr(@AttrRes colorAttr: Int): ThemeStore { - return statusBarColor(ATHUtils.resolveColor(mContext, colorAttr)) + return statusBarColor(ThemeUtils.resolveColor(mContext, colorAttr)) } override fun navigationBarColor(@ColorInt color: Int): ThemeStore { @@ -86,7 +86,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } override fun navigationBarColorAttr(@AttrRes colorAttr: Int): ThemeStore { - return navigationBarColor(ATHUtils.resolveColor(mContext, colorAttr)) + return navigationBarColor(ThemeUtils.resolveColor(mContext, colorAttr)) } override fun textColorPrimary(@ColorInt color: Int): ThemeStore { @@ -99,7 +99,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } override fun textColorPrimaryAttr(@AttrRes colorAttr: Int): ThemeStore { - return textColorPrimary(ATHUtils.resolveColor(mContext, colorAttr)) + return textColorPrimary(ThemeUtils.resolveColor(mContext, colorAttr)) } override fun textColorPrimaryInverse(@ColorInt color: Int): ThemeStore { @@ -112,7 +112,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } override fun textColorPrimaryInverseAttr(@AttrRes colorAttr: Int): ThemeStore { - return textColorPrimaryInverse(ATHUtils.resolveColor(mContext, colorAttr)) + return textColorPrimaryInverse(ThemeUtils.resolveColor(mContext, colorAttr)) } override fun textColorSecondary(@ColorInt color: Int): ThemeStore { @@ -125,7 +125,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } override fun textColorSecondaryAttr(@AttrRes colorAttr: Int): ThemeStore { - return textColorSecondary(ATHUtils.resolveColor(mContext, colorAttr)) + return textColorSecondary(ThemeUtils.resolveColor(mContext, colorAttr)) } override fun textColorSecondaryInverse(@ColorInt color: Int): ThemeStore { @@ -138,7 +138,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } override fun textColorSecondaryInverseAttr(@AttrRes colorAttr: Int): ThemeStore { - return textColorSecondaryInverse(ATHUtils.resolveColor(mContext, colorAttr)) + return textColorSecondaryInverse(ThemeUtils.resolveColor(mContext, colorAttr)) } override fun backgroundColor(color: Int): ThemeStore { @@ -189,7 +189,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun primaryColor(context: Context = appCtx): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_PRIMARY_COLOR, - ATHUtils.resolveColor(context, R.attr.colorPrimary, Color.parseColor("#455A64")) + ThemeUtils.resolveColor(context, R.attr.colorPrimary, Color.parseColor("#455A64")) ) } @@ -198,7 +198,11 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun primaryColorDark(context: Context): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_PRIMARY_COLOR_DARK, - ATHUtils.resolveColor(context, R.attr.colorPrimaryDark, Color.parseColor("#37474F")) + ThemeUtils.resolveColor( + context, + R.attr.colorPrimaryDark, + Color.parseColor("#37474F") + ) ) } @@ -207,7 +211,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun accentColor(context: Context = appCtx): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_ACCENT_COLOR, - ATHUtils.resolveColor(context, R.attr.colorAccent, Color.parseColor("#263238")) + ThemeUtils.resolveColor(context, R.attr.colorAccent, Color.parseColor("#263238")) ) } @@ -241,7 +245,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun textColorPrimary(context: Context): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_TEXT_COLOR_PRIMARY, - ATHUtils.resolveColor(context, android.R.attr.textColorPrimary) + ThemeUtils.resolveColor(context, android.R.attr.textColorPrimary) ) } @@ -250,7 +254,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun textColorPrimaryInverse(context: Context): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_TEXT_COLOR_PRIMARY_INVERSE, - ATHUtils.resolveColor(context, android.R.attr.textColorPrimaryInverse) + ThemeUtils.resolveColor(context, android.R.attr.textColorPrimaryInverse) ) } @@ -259,7 +263,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun textColorSecondary(context: Context): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_TEXT_COLOR_SECONDARY, - ATHUtils.resolveColor(context, android.R.attr.textColorSecondary) + ThemeUtils.resolveColor(context, android.R.attr.textColorSecondary) ) } @@ -268,7 +272,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun textColorSecondaryInverse(context: Context): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_TEXT_COLOR_SECONDARY_INVERSE, - ATHUtils.resolveColor(context, android.R.attr.textColorSecondaryInverse) + ThemeUtils.resolveColor(context, android.R.attr.textColorSecondaryInverse) ) } @@ -277,7 +281,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun backgroundColor(context: Context = appCtx): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_BACKGROUND_COLOR, - ATHUtils.resolveColor(context, android.R.attr.colorBackground) + ThemeUtils.resolveColor(context, android.R.attr.colorBackground) ) } @@ -286,7 +290,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun elevation(context: Context): Float { return prefs(context).getFloat( ThemeStorePrefKeys.KEY_ELEVATION, - ATHUtils.resolveFloat( + ThemeUtils.resolveFloat( context, android.R.attr.elevation, context.resources.getDimension(R.dimen.design_appbar_elevation) @@ -299,7 +303,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun bottomBackground(context: Context = appCtx): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_BOTTOM_BACKGROUND, - ATHUtils.resolveColor(context, android.R.attr.colorBackground) + ThemeUtils.resolveColor(context, android.R.attr.colorBackground) ) } diff --git a/app/src/main/java/io/legado/app/lib/theme/ATHUtils.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeUtils.kt similarity index 97% rename from app/src/main/java/io/legado/app/lib/theme/ATHUtils.kt rename to app/src/main/java/io/legado/app/lib/theme/ThemeUtils.kt index ddd6fc816..fe8b3f988 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATHUtils.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeUtils.kt @@ -6,7 +6,7 @@ import androidx.annotation.AttrRes /** * @author Aidan Follestad (afollestad) */ -object ATHUtils { +object ThemeUtils { @JvmOverloads fun resolveColor(context: Context, @AttrRes attr: Int, fallback: Int = 0): Int {