Dynamic colors [1/2]

This commit is contained in:
Rahul Patel
2024-08-31 02:33:07 +05:30
parent 4107eed2d9
commit 3546ed8a54
119 changed files with 676 additions and 2321 deletions

View File

@@ -38,11 +38,9 @@ import android.view.LayoutInflater
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.app.ActivityCompat
import androidx.core.app.ActivityOptionsCompat
import androidx.core.content.ContextCompat
import com.aurora.Constants
import com.aurora.gplayapi.data.models.App
import com.aurora.store.R
import com.aurora.store.util.Preferences
private const val TAG = "Context"
@@ -115,44 +113,6 @@ fun Context.getStyledAttributeColor(id: Int): Int {
return styledAttr
}
fun Context.accentColor(): Int {
val color = when (Preferences.getInteger(this, Preferences.PREFERENCE_THEME_ACCENT)) {
0 -> R.color.colorAccent
1 -> R.color.colorAccent01
2 -> R.color.colorAccent02
3 -> R.color.colorAccent03
4 -> R.color.colorAccent04
5 -> R.color.colorAccent05
6 -> R.color.colorAccent06
7 -> R.color.colorAccent07
8 -> R.color.colorAccent08
9 -> R.color.colorAccent09
10 -> R.color.colorAccent10
11 -> R.color.colorAccent11
12 -> R.color.colorAccent12
13 -> R.color.colorAccent13
else -> if (isSAndAbove()) R.color.colorAccent else R.color.colorAccent01
}
return ContextCompat.getColor(this, color)
}
fun Context.backgroundColor(): Int {
val color = when (Preferences.getInteger(this, Preferences.PREFERENCE_THEME_TYPE)) {
1 -> R.color.colorWhite
2 -> R.color.colorDarkBackground
3 -> R.color.colorBlack
4 -> R.color.colorDarkXBackground
5 -> R.color.colorDarkordBackground
else -> null
}
if (color == null) {
return getStyledAttributeColor(com.google.android.material.R.attr.colorSurface)
}
return ContextCompat.getColor(this, color)
}
fun Context.isIgnoringBatteryOptimizations(): Boolean {
return if (isMAndAbove()) {
(getSystemService(Context.POWER_SERVICE) as PowerManager).isIgnoringBatteryOptimizations(