theming fixes

This commit is contained in:
X1nto 2021-02-15 19:29:36 +04:00
parent 0c2b9805e4
commit b6c01333b0
2 changed files with 19 additions and 7 deletions

View File

@ -9,6 +9,8 @@ import com.vanced.manager.R
import com.vanced.manager.databinding.ViewSponsorBinding
import com.vanced.manager.model.SponsorModel
import com.vanced.manager.ui.viewmodels.HomeViewModel
import com.vanced.manager.utils.LIGHT
import com.vanced.manager.utils.currentTheme
import com.vanced.manager.utils.defPrefs
import com.vanced.manager.utils.managerTheme
@ -18,7 +20,7 @@ class SponsorAdapter(
) : RecyclerView.Adapter<SponsorAdapter.LinkViewHolder>() {
private val brave = SponsorModel(
if (context.defPrefs.managerTheme == "Light") AppCompatResources.getDrawable(context, R.drawable.ic_brave_light) else AppCompatResources.getDrawable(context, R.drawable.ic_brave),
if (currentTheme == LIGHT) AppCompatResources.getDrawable(context, R.drawable.ic_brave_light) else AppCompatResources.getDrawable(context, R.drawable.ic_brave),
"Brave",
BRAVE
)

View File

@ -7,20 +7,30 @@ import androidx.lifecycle.MutableLiveData
import com.vanced.manager.R
const val defAccentColor: Int = -13732865
const val LIGHT = "Light"
const val DARK = "Dark"
const val SYSTEM_DEFAULT = "System Default"
val mutableAccentColor = MutableLiveData<Int>()
val accentColor: LiveData<Int> = mutableAccentColor
var currentTheme = ""
fun Activity.setFinalTheme() {
when (defPrefs.managerTheme) {
"Light" -> setTheme(R.style.LightTheme)
"Dark" -> setTheme(R.style.DarkTheme)
"System Default" -> {
LIGHT -> setTheme(R.style.LightTheme, LIGHT)
DARK -> setTheme(R.style.DarkTheme, DARK)
SYSTEM_DEFAULT -> {
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> setTheme(R.style.DarkTheme)
Configuration.UI_MODE_NIGHT_NO -> setTheme(R.style.LightTheme)
Configuration.UI_MODE_NIGHT_YES -> setTheme(R.style.DarkTheme, DARK)
Configuration.UI_MODE_NIGHT_NO -> setTheme(R.style.LightTheme, LIGHT)
}
}
else -> setTheme(R.style.LightTheme)
else -> setTheme(R.style.LightTheme, LIGHT)
}
}
fun Activity.setTheme(resId: Int, themeValue: String) {
setTheme(resId)
currentTheme = themeValue
}