UIPreference: Hide accent color preference on Android 12+ devices

Android 12 and above devices have system based accent color system known as monet
that is highly customizable compared to our offerings.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-05-31 15:14:41 +05:30
parent ac2345254d
commit 358e81e67e
3 changed files with 7 additions and 0 deletions

View File

@@ -4,10 +4,13 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.aurora.extensions.isSAndAbove
import com.aurora.store.data.work.CacheWorker
import com.aurora.store.util.Preferences
import com.aurora.store.util.Preferences.PREFERENCE_INTRO
import com.aurora.store.util.Preferences.PREFERENCE_MIGRATION_VERSION
import com.aurora.store.util.Preferences.PREFERENCE_THEME_ACCENT
import com.aurora.store.util.save
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
@@ -39,6 +42,7 @@ class MigrationReceiver: BroadcastReceiver() {
// 58 -> 59
if (currentVersion == 0) {
CacheWorker.scheduleAutomatedCacheCleanup(context)
if (isSAndAbove()) context.save(PREFERENCE_THEME_ACCENT, 0)
currentVersion++
}

View File

@@ -21,6 +21,7 @@ package com.aurora.store.view.ui.preferences
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.view.View
@@ -77,6 +78,7 @@ class UIPreference : BasePreferenceFragment() {
val accentPreference: ListPreference? = findPreference(Preferences.PREFERENCE_THEME_ACCENT)
accentPreference?.let {
it.isVisible = Build.VERSION.SDK_INT < Build.VERSION_CODES.S
it.setOnPreferenceChangeListener { _, newValue ->
val accentId = Integer.parseInt(newValue.toString())

View File

@@ -33,6 +33,7 @@
app:entries="@array/pref_accent"
app:entryValues="@array/pref_accent_values"
app:iconSpaceReserved="false"
app:isPreferenceVisible="false"
app:key="PREFERENCE_THEME_ACCENT"
app:title="@string/pref_ui_accent_title"
app:useSimpleSummaryProvider="true" />