mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Add: System Amoled Theme
Fix: Use similar switches in Settings
This commit is contained in:
parent
59ebd3394f
commit
ac79953c7c
@ -173,7 +173,7 @@ object Preferences {
|
|||||||
|
|
||||||
sealed class Theme(override val valueString: String) : Enumeration<Theme> {
|
sealed class Theme(override val valueString: String) : Enumeration<Theme> {
|
||||||
override val values: List<Theme>
|
override val values: List<Theme>
|
||||||
get() = if (Android.sdk(29)) listOf(System, Light, Dark, Amoled)
|
get() = if (Android.sdk(29)) listOf(System, AmoledSystem, Light, Dark, Amoled)
|
||||||
else listOf(Light, Dark, Amoled)
|
else listOf(Light, Dark, Amoled)
|
||||||
|
|
||||||
abstract fun getResId(configuration: Configuration): Int
|
abstract fun getResId(configuration: Configuration): Int
|
||||||
@ -185,6 +185,13 @@ object Preferences {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object AmoledSystem : Theme("system-amoled") {
|
||||||
|
override fun getResId(configuration: Configuration): Int {
|
||||||
|
return if ((configuration.uiMode and Configuration.UI_MODE_NIGHT_YES) != 0)
|
||||||
|
R.style.Theme_Main_Amoled else R.style.Theme_Main_Light
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
object Light : Theme("light") {
|
object Light : Theme("light") {
|
||||||
override fun getResId(configuration: Configuration): Int = R.style.Theme_Main_Light
|
override fun getResId(configuration: Configuration): Int = R.style.Theme_Main_Light
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import androidx.appcompat.widget.Toolbar
|
|||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||||
import com.looker.droidify.BuildConfig
|
import com.looker.droidify.BuildConfig
|
||||||
import com.looker.droidify.R
|
import com.looker.droidify.R
|
||||||
import com.looker.droidify.content.Preferences
|
import com.looker.droidify.content.Preferences
|
||||||
@ -105,6 +106,9 @@ class SettingsFragment : ScreenFragment() {
|
|||||||
addEnumeration(Preferences.Key.Theme, getString(R.string.theme)) {
|
addEnumeration(Preferences.Key.Theme, getString(R.string.theme)) {
|
||||||
when (it) {
|
when (it) {
|
||||||
is Preferences.Theme.System -> getString(R.string.system)
|
is Preferences.Theme.System -> getString(R.string.system)
|
||||||
|
is Preferences.Theme.AmoledSystem -> getString(R.string.system) + " " + getString(
|
||||||
|
R.string.amoled
|
||||||
|
)
|
||||||
is Preferences.Theme.Light -> getString(R.string.light)
|
is Preferences.Theme.Light -> getString(R.string.light)
|
||||||
is Preferences.Theme.Dark -> getString(R.string.dark)
|
is Preferences.Theme.Dark -> getString(R.string.dark)
|
||||||
is Preferences.Theme.Amoled -> getString(R.string.amoled)
|
is Preferences.Theme.Amoled -> getString(R.string.amoled)
|
||||||
@ -316,7 +320,7 @@ class SettingsFragment : ScreenFragment() {
|
|||||||
val view = parent.inflate(R.layout.preference_item)
|
val view = parent.inflate(R.layout.preference_item)
|
||||||
val title = view.findViewById<TextView>(R.id.title)!!
|
val title = view.findViewById<TextView>(R.id.title)!!
|
||||||
val summary = view.findViewById<TextView>(R.id.summary)!!
|
val summary = view.findViewById<TextView>(R.id.summary)!!
|
||||||
val check = view.findViewById<Switch>(R.id.check)!!
|
val check = view.findViewById<SwitchMaterial>(R.id.check)!!
|
||||||
|
|
||||||
private var callback: (() -> Unit)? = null
|
private var callback: (() -> Unit)? = null
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Switch
|
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||||
android:id="@+id/check"
|
android:id="@+id/check"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user