testing with themes

This commit is contained in:
X1nto 2020-05-02 18:39:47 +04:00
parent 22f8af9984
commit 85e40c8ba4
8 changed files with 23 additions and 29 deletions

File diff suppressed because one or more lines are too long

View File

@ -53,7 +53,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.fragment:fragment-ktx:1.2.4'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

View File

@ -31,7 +31,8 @@
</activity>
<activity
android:name=".ui.MainActivity"
android:label="@string/app_name" />
android:label="@string/app_name"
android:theme="@style/LightTheme"/>
<meta-data
android:name="preloaded_fonts"

View File

@ -54,15 +54,15 @@ open class ThemeActivity : AppCompatActivity() {
private fun setFinalTheme(currentTheme: String) {
when (currentTheme) {
"LIGHT" -> setTheme(R.style.LightTheme_Blue)
"DARK" -> setTheme(R.style.DarkTheme_Blue)
"LIGHT" -> setTheme(R.style.LightTheme)
"DARK" -> setTheme(R.style.DarkTheme)
"FOLLOW" -> {
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> setTheme(R.style.DarkTheme_Blue)
Configuration.UI_MODE_NIGHT_NO -> setTheme(R.style.LightTheme_Blue)
Configuration.UI_MODE_NIGHT_YES -> setTheme(R.style.DarkTheme)
Configuration.UI_MODE_NIGHT_NO -> setTheme(R.style.LightTheme)
}
}
else -> setTheme(R.style.LightTheme_Blue)
else -> setTheme(R.style.LightTheme)
}
}

View File

@ -31,27 +31,27 @@ class SettingsFragment : PreferenceFragmentCompat() {
when (themeSwitch.value){
"LIGHT" -> {
activity?.setTheme(R.style.LightTheme_Blue)
activity?.setTheme(R.style.LightTheme)
activity?.recreate()
}
"DARK" -> {
activity?.setTheme(R.style.DarkTheme_Blue)
activity?.setTheme(R.style.DarkTheme)
activity?.recreate()
}
"FOLLOW" -> {
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES ->{
activity?.setTheme(R.style.DarkTheme_Blue)
activity?.setTheme(R.style.DarkTheme)
activity?.recreate()
}
Configuration.UI_MODE_NIGHT_NO -> {
activity?.setTheme(R.style.LightTheme_Blue)
activity?.setTheme(R.style.LightTheme)
activity?.recreate()
}
}
}
else -> {
activity?.setTheme(R.style.LightTheme_Blue)
activity?.setTheme(R.style.LightTheme)
activity?.recreate()
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="DarkTheme.Blue">
<style name="DarkTheme" parent="Theme.MaterialComponents.NoActionBar">
<item name="colorPrimary">#1490D7</item>
<item name="colorPrimaryVariant">#804EAFF5</item>
@ -23,6 +23,9 @@
<item name="iconColor">?colorPrimaryVariant</item>
<item name="toolbarIconColor">?colorOnPrimary</item>
<item name="DialogBG">#111111</item>
<item name="colorBackgroundFloating">#111111</item>
<item name="android:windowBackground">?colorSurface</item>
<item name="android:statusBarColor">#000000</item>
</style>

View File

@ -6,16 +6,4 @@
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="LightTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">?colorSurface</item>
<item name="android:statusBarColor">#787777</item>
</style>
<style name="DarkTheme" parent="Theme.MaterialComponents.NoActionBar">
<item name="colorBackgroundFloating">#111111</item>
<item name="android:windowBackground">?colorSurface</item>
<item name="android:statusBarColor">#000000</item>
</style>
</resources>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LightTheme.Blue">
<style name="LightTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#1490D7</item>
<item name="colorPrimaryVariant">#2C7EB9</item>
@ -23,6 +23,9 @@
<item name="iconColor">?colorPrimaryVariant</item>
<item name="toolbarIconColor">#111111</item>
<item name="DialogBG">#ffffff</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">?colorSurface</item>
<item name="android:statusBarColor">#787777</item>
</style>