diff --git a/app/src/main/java/com/vanced/manager/core/App.kt b/app/src/main/java/com/vanced/manager/core/App.kt index ac3993d1..9fa489ad 100644 --- a/app/src/main/java/com/vanced/manager/core/App.kt +++ b/app/src/main/java/com/vanced/manager/core/App.kt @@ -10,6 +10,8 @@ import com.crowdin.platform.data.remote.NetworkType import com.vanced.manager.BuildConfig.* import com.vanced.manager.utils.AppUtils.log import com.vanced.manager.utils.loadJson +import com.vanced.manager.utils.managerAccent +import com.vanced.manager.utils.mutableAccentColor import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob @@ -23,7 +25,7 @@ open class App: Application() { override fun onCreate() { scope.launch { loadJson(this@App) } super.onCreate() - + mutableAccentColor.value = prefs.managerAccent Crowdin.init(this, CrowdinConfig.Builder().apply { withDistributionHash(CROWDIN_HASH) diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedAppCard.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedAppCard.kt index 929e2217..cabfb2c6 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedAppCard.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedAppCard.kt @@ -4,8 +4,7 @@ import android.content.Context import android.content.res.ColorStateList import android.util.AttributeSet import com.google.android.material.card.MaterialCardView -import com.vanced.manager.utils.defPrefs -import com.vanced.manager.utils.managerAccent +import com.vanced.manager.utils.accentColor class ThemedAppCard @JvmOverloads constructor( context: Context, @@ -14,7 +13,7 @@ class ThemedAppCard @JvmOverloads constructor( ) : MaterialCardView(context, attributeSet, defStyleAttr) { init { - setCardBackgroundColor(ColorStateList.valueOf(context.defPrefs.managerAccent).withAlpha(35)) + setCardBackgroundColor(ColorStateList.valueOf(accentColor.value!!).withAlpha(35)) } } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedImageButton.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedImageButton.kt index 2af9dcec..f5623ed1 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedImageButton.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedImageButton.kt @@ -4,8 +4,7 @@ import android.content.Context import android.content.res.ColorStateList import android.util.AttributeSet import androidx.appcompat.widget.AppCompatImageButton -import com.vanced.manager.utils.defPrefs -import com.vanced.manager.utils.managerAccent +import com.vanced.manager.utils.accentColor class ThemedImageButton @JvmOverloads constructor( context: Context, @@ -14,7 +13,7 @@ class ThemedImageButton @JvmOverloads constructor( ) : AppCompatImageButton(context, attributeSet, defStyleAttr) { init { - imageTintList = ColorStateList.valueOf(context.defPrefs.managerAccent) + imageTintList = ColorStateList.valueOf(accentColor.value!!) } } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialButton.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialButton.kt index 511eed07..dacb450f 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialButton.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialButton.kt @@ -7,9 +7,7 @@ import androidx.core.graphics.ColorUtils import com.google.android.material.button.MaterialButton import com.vanced.manager.R import com.vanced.manager.utils.accentColor -import com.vanced.manager.utils.defPrefs import com.vanced.manager.utils.lifecycleOwner -import com.vanced.manager.utils.managerAccent class ThemedMaterialButton @JvmOverloads constructor( context: Context, @@ -18,7 +16,6 @@ class ThemedMaterialButton @JvmOverloads constructor( ) : MaterialButton(context, attributeSet, defStyleAttr) { init { - setBgColor(context.defPrefs.managerAccent) context.lifecycleOwner()?.let { owner -> accentColor.observe(owner) { color -> setBgColor(color.toInt()) diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialCheckbox.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialCheckbox.kt index eea3ee3d..4b8001bf 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialCheckbox.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialCheckbox.kt @@ -5,14 +5,13 @@ import android.content.res.ColorStateList import android.util.AttributeSet import com.google.android.material.checkbox.MaterialCheckBox import com.vanced.manager.R -import com.vanced.manager.utils.defPrefs -import com.vanced.manager.utils.managerAccent +import com.vanced.manager.utils.accentColor class ThemedMaterialCheckbox @JvmOverloads constructor( context: Context, attributeSet: AttributeSet? = null, ) : MaterialCheckBox(context, attributeSet, R.attr.checkboxStyle) { init { - buttonTintList = ColorStateList.valueOf(context.defPrefs.managerAccent) + buttonTintList = ColorStateList.valueOf(accentColor.value!!) } } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialRadioButton.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialRadioButton.kt index 6022a426..895bcf51 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialRadioButton.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialRadioButton.kt @@ -5,14 +5,13 @@ import android.content.res.ColorStateList import android.util.AttributeSet import com.google.android.material.radiobutton.MaterialRadioButton import com.vanced.manager.R -import com.vanced.manager.utils.defPrefs -import com.vanced.manager.utils.managerAccent +import com.vanced.manager.utils.accentColor class ThemedMaterialRadioButton @JvmOverloads constructor( context: Context, attributeSet: AttributeSet? = null, ) : MaterialRadioButton(context, attributeSet, R.attr.radioButtonStyle) { init { - buttonTintList = ColorStateList.valueOf(context.defPrefs.managerAccent) + buttonTintList = ColorStateList.valueOf(accentColor.value!!) } } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialSlider.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialSlider.kt index a2ad82d0..8653121b 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialSlider.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedMaterialSlider.kt @@ -4,8 +4,7 @@ import android.content.Context import android.content.res.ColorStateList import android.util.AttributeSet import com.google.android.material.slider.Slider -import com.vanced.manager.utils.defPrefs -import com.vanced.manager.utils.managerAccent +import com.vanced.manager.utils.accentColor class ThemedMaterialSlider @JvmOverloads constructor( context: Context, @@ -14,7 +13,7 @@ class ThemedMaterialSlider @JvmOverloads constructor( ) : Slider(context, attributeSet, defStyleAttr) { init { - val accentValue = ColorStateList.valueOf(context.defPrefs.managerAccent) + val accentValue = ColorStateList.valueOf(accentColor.value!!) thumbTintList = accentValue trackActiveTintList = accentValue trackInactiveTintList = accentValue.withAlpha(70) diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedOutlinedMaterialButton.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedOutlinedMaterialButton.kt index a1dd5bb5..107182a6 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedOutlinedMaterialButton.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedOutlinedMaterialButton.kt @@ -6,10 +6,7 @@ import android.util.AttributeSet import androidx.core.graphics.ColorUtils import com.google.android.material.button.MaterialButton import com.vanced.manager.utils.accentColor -import com.vanced.manager.utils.defPrefs import com.vanced.manager.utils.lifecycleOwner -import com.vanced.manager.utils.managerAccent - class ThemedOutlinedMaterialButton @JvmOverloads constructor( context: Context, @@ -17,7 +14,6 @@ class ThemedOutlinedMaterialButton @JvmOverloads constructor( defStyleAttr: Int = 0 ) : MaterialButton(context, attributeSet, defStyleAttr) { init { - applyAccent(context.defPrefs.managerAccent) context.lifecycleOwner()?.let { owner -> accentColor.observe(owner) { color -> applyAccent(color.toInt()) diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedSwipeRefreshlayout.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedSwipeRefreshlayout.kt index 0cd37b7d..e3996e63 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedSwipeRefreshlayout.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedSwipeRefreshlayout.kt @@ -4,15 +4,14 @@ import android.content.Context import android.util.AttributeSet import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.vanced.manager.R -import com.vanced.manager.utils.defPrefs -import com.vanced.manager.utils.managerAccent +import com.vanced.manager.utils.accentColor class ThemedSwipeRefreshlayout @JvmOverloads constructor( context: Context, attributeSet: AttributeSet? = null ) : SwipeRefreshLayout(context, attributeSet) { init { - setColorSchemeColors(context.defPrefs.managerAccent) + setColorSchemeColors(accentColor.value!!) initAttrs(context, attributeSet) } private fun initAttrs(context: Context, attributeSet: AttributeSet?) { diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedSwitchCompat.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedSwitchCompat.kt index 7d51ef62..2eafc0b1 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedSwitchCompat.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedSwitchCompat.kt @@ -9,9 +9,7 @@ import androidx.core.graphics.ColorUtils import androidx.core.graphics.drawable.DrawableCompat import com.vanced.manager.R import com.vanced.manager.utils.accentColor -import com.vanced.manager.utils.defPrefs import com.vanced.manager.utils.lifecycleOwner -import com.vanced.manager.utils.managerAccent class ThemedSwitchCompat @JvmOverloads constructor( context: Context, @@ -21,7 +19,6 @@ class ThemedSwitchCompat @JvmOverloads constructor( private val states = arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)) init { - setSwitchColors(context.defPrefs.managerAccent) context.lifecycleOwner()?.let { owner -> accentColor.observe(owner) { color -> setSwitchColors(color.toInt()) diff --git a/app/src/main/java/com/vanced/manager/ui/core/ThemedTextView.kt b/app/src/main/java/com/vanced/manager/ui/core/ThemedTextView.kt index 6ec2189f..a6e4297b 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/ThemedTextView.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/ThemedTextView.kt @@ -4,9 +4,7 @@ import android.content.Context import android.util.AttributeSet import androidx.appcompat.widget.AppCompatTextView import com.vanced.manager.utils.accentColor -import com.vanced.manager.utils.defPrefs import com.vanced.manager.utils.lifecycleOwner -import com.vanced.manager.utils.managerAccent class ThemedTextView @JvmOverloads constructor( context: Context, @@ -14,7 +12,6 @@ class ThemedTextView @JvmOverloads constructor( defStyleAttr: Int = 0 ) : AppCompatTextView(context, attributeSet, defStyleAttr) { init { - setTextColor(context.defPrefs.managerAccent) context.lifecycleOwner()?.let { owner -> accentColor.observe(owner) { color -> setTextColor(color.toInt()) diff --git a/app/src/main/java/com/vanced/manager/utils/ThemeHelper.kt b/app/src/main/java/com/vanced/manager/utils/ThemeHelper.kt index 8bbf5d8d..3713f6f9 100644 --- a/app/src/main/java/com/vanced/manager/utils/ThemeHelper.kt +++ b/app/src/main/java/com/vanced/manager/utils/ThemeHelper.kt @@ -11,7 +11,7 @@ const val LIGHT = "Light" const val DARK = "Dark" const val SYSTEM_DEFAULT = "System Default" -val mutableAccentColor = MutableLiveData() +val mutableAccentColor = MutableLiveData(defAccentColor) val accentColor: LiveData = mutableAccentColor var currentTheme = ""