Fixed Preference title tint for MD3
This commit is contained in:
parent
480d66cc24
commit
8ce6cf58fa
9 changed files with 27 additions and 11 deletions
|
@ -72,7 +72,7 @@
|
|||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_begin="@dimen/list_pref_guideline_begin" />
|
||||
|
||||
<code.name.monkey.retromusic.views.ATESwitch
|
||||
<code.name.monkey.appthemehelper.common.views.ATESwitch
|
||||
android:id="@android:id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_begin="@dimen/list_pref_guideline_begin" />
|
||||
|
||||
<code.name.monkey.retromusic.views.ATESwitch
|
||||
<code.name.monkey.appthemehelper.common.views.ATESwitch
|
||||
android:id="@android:id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -299,5 +299,9 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun isMD3Enabled(context: Context): Boolean {
|
||||
return prefs(context).getBoolean(ThemeStorePrefKeys.KEY_MATERIAL_YOU, false)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,5 +27,7 @@ internal interface ThemeStorePrefKeys {
|
|||
const val KEY_APPLY_PRIMARYDARK_STATUSBAR = "apply_primarydark_statusbar"
|
||||
const val KEY_APPLY_PRIMARY_NAVBAR = "apply_primary_navbar"
|
||||
const val KEY_AUTO_GENERATE_PRIMARYDARK = "auto_generate_primarydark"
|
||||
|
||||
const val KEY_MATERIAL_YOU = "material_you"
|
||||
}
|
||||
}
|
|
@ -16,9 +16,11 @@ package code.name.monkey.appthemehelper.common.views
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
|
||||
class ATEAccentTextView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -27,6 +29,13 @@ class ATEAccentTextView @JvmOverloads constructor(
|
|||
) : AppCompatTextView(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
setTextColor(ThemeStore.accentColor(context))
|
||||
setTextColor(
|
||||
// Set MD3 accent if MD3 is enabled or in-app accent otherwise
|
||||
if (ThemeStore.isMD3Enabled(context) && VersionUtils.hasS()) {
|
||||
ContextCompat.getColor(context, R.color.m3_accent_color)
|
||||
} else {
|
||||
ThemeStore.accentColor(context)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package code.name.monkey.retromusic.views
|
||||
package code.name.monkey.appthemehelper.common.views
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.SwitchCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import code.name.monkey.appthemehelper.ATH
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
|
@ -31,8 +32,8 @@ class ATESwitch : SwitchCompat {
|
|||
}
|
||||
|
||||
private fun init(context: Context) {
|
||||
if (PreferenceUtil.materialYou) {
|
||||
ATH.setTint(this, RetroColorUtil.getMD3AccentColor(context))
|
||||
if (ThemeStore.isMD3Enabled(context) && VersionUtils.hasS()) {
|
||||
ATH.setTint(this, ContextCompat.getColor(context, R.color.m3_accent_color))
|
||||
} else {
|
||||
ATH.setTint(this, ThemeStore.accentColor(context))
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<code.name.monkey.retromusic.views.ATESwitch xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ATESwitch xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
0
app/src/main/res/values-v31/colors.xml → appthemehelper/src/main/res/values-v31/colors.xml
Normal file → Executable file
0
app/src/main/res/values-v31/colors.xml → appthemehelper/src/main/res/values-v31/colors.xml
Normal file → Executable file
Loading…
Reference in a new issue