mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 17:48:52 -06:00
Rename night mode to dark theme; abide by system-wide settings (API 29)
Closes issue #513
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities
|
||||
|
||||
import android.content.res.Configuration.*
|
||||
import android.os.Build.VERSION.*
|
||||
import android.support.v4.content.*
|
||||
import org.isoron.androidbase.activities.*
|
||||
import org.isoron.uhabits.*
|
||||
@@ -33,6 +35,16 @@ class AndroidThemeSwitcher
|
||||
preferences: Preferences
|
||||
) : ThemeSwitcher(preferences) {
|
||||
|
||||
override fun getSystemTheme(): Int {
|
||||
if(SDK_INT < 29) return THEME_LIGHT;
|
||||
val uiMode = activity.resources.configuration.uiMode
|
||||
return if ((uiMode and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES) {
|
||||
THEME_DARK;
|
||||
} else {
|
||||
THEME_LIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
override fun applyDarkTheme() {
|
||||
activity.setTheme(R.style.AppBaseThemeDark)
|
||||
activity.window.navigationBarColor =
|
||||
|
||||
@@ -27,14 +27,14 @@ import android.provider.*;
|
||||
import android.support.annotation.*;
|
||||
import android.support.v7.preference.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.R;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.preferences.*;
|
||||
import org.isoron.uhabits.core.ui.*;
|
||||
import org.isoron.uhabits.notifications.*;
|
||||
|
||||
import static android.media.RingtoneManager.*;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static android.os.Build.VERSION.*;
|
||||
import static org.isoron.uhabits.activities.habits.list.ListHabitsScreenKt.*;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragmentCompat
|
||||
|
||||
@@ -169,9 +169,9 @@
|
||||
<string name="troubleshooting">Troubleshooting</string>
|
||||
|
||||
<string name="help_translate">Help translate this app</string>
|
||||
<string name="night_mode">Night mode</string>
|
||||
<string name="use_pure_black">Use pure black in night mode</string>
|
||||
<string name="pure_black_description">Replaces gray backgrounds with pure black in night mode. Reduces battery usage in phones with AMOLED display.</string>
|
||||
<string name="night_mode">Dark theme</string>
|
||||
<string name="use_pure_black">Use pure black in dark theme</string>
|
||||
<string name="pure_black_description">Replaces gray backgrounds with pure black in dark theme. Reduces battery usage in phones with AMOLED display.</string>
|
||||
<string name="interface_preferences">Interface</string>
|
||||
<string name="reverse_days">Reverse order of days</string>
|
||||
<string name="reverse_days_description">Show days in reverse order on the main screen.</string>
|
||||
|
||||
Reference in New Issue
Block a user