Skip to content
Snippets Groups Projects
Commit e3f5ed87 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Implement support for global DayNight mode (on Android P through developer...

Implement support for global DayNight mode (on Android P through developer settings or on LineageOS devices)
parent 7daf7343
No related branches found
No related tags found
No related merge requests found
Pipeline #284 failed
......@@ -40,13 +40,17 @@ data class AppearanceSettings(
}
enum class Theme(@StyleRes val style: Int) {
MATERIAL_DAYNIGHT(R.style.Theme_ChatTheme_Material_DayNight),
MATERIAL_LIGHT(R.style.Theme_ChatTheme_Material_Light),
MATERIAL_DARK(R.style.Theme_ChatTheme_Material_Dark),
QUASSEL_DAYNIGHT(R.style.Theme_ChatTheme_Quassel_DayNight),
QUASSEL_LIGHT(R.style.Theme_ChatTheme_Quassel_Light),
QUASSEL_DARK(R.style.Theme_ChatTheme_Quassel_Dark),
AMOLED(R.style.Theme_ChatTheme_Amoled),
SOLARIZED_DAYNIGHT(R.style.Theme_ChatTheme_Solarized_DayNight),
SOLARIZED_LIGHT(R.style.Theme_ChatTheme_Solarized_Light),
SOLARIZED_DARK(R.style.Theme_ChatTheme_Solarized_Dark),
GRUVBOX_DAYNIGHT(R.style.Theme_ChatTheme_Gruvbox_DayNight),
GRUVBOX_LIGHT(R.style.Theme_ChatTheme_Gruvbox_Light),
GRUVBOX_DARK(R.style.Theme_ChatTheme_Gruvbox_Dark),
DRACULA(R.style.Theme_ChatTheme_Dracula);
......
......@@ -19,8 +19,10 @@
package de.kuschku.quasseldroid.util.service
import android.app.UiModeManager
import android.content.Context
import android.content.SharedPreferences
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.view.WindowManager
......@@ -51,6 +53,9 @@ abstract class ServiceBoundActivity :
protected val backend: BehaviorSubject<Optional<Backend>>
get() = connection.backend
private var uiModeManager: UiModeManager? = null
private var nightMode: Int? = null
protected fun runInBackground(f: () -> Unit) {
connection.backend.value.ifPresent {
it.sessionManager().handlerService.backend(f)
......@@ -92,6 +97,8 @@ abstract class ServiceBoundActivity :
if (appearanceSettings.keepScreenOn) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
nightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
}
fun updateRecentsHeader() {
......@@ -106,7 +113,8 @@ abstract class ServiceBoundActivity :
}
override fun onStart() {
if (Settings.appearance(this) != appearanceSettings) {
if (Settings.appearance(this) != appearanceSettings ||
(resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) != nightMode) {
recreate()
}
sharedPreferences(Keys.Status.NAME, Context.MODE_PRIVATE) {
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ChatTheme.Material_DayNight" parent="Theme.ChatTheme.Material_Dark" />
<style name="Theme.ChatTheme.Quassel_DayNight" parent="Theme.ChatTheme.Quassel_Dark" />
<style name="Theme.ChatTheme.Solarized_DayNight" parent="Theme.ChatTheme.Solarized_Dark" />
<style name="Theme.ChatTheme.Gruvbox_DayNight" parent="Theme.ChatTheme.Gruvbox_Dark" />
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?><!--
Quasseldroid - Quassel client for Android
Copyright (c) 2018 Janne Koschinski
Copyright (c) 2018 The Quassel Project
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License version 3 as published
by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string-array name="preference_theme_entries" translatable="false">
<item>@string/preference_theme_entry_material_daynight</item>
<item>@string/preference_theme_entry_material_light</item>
<item>@string/preference_theme_entry_material_dark</item>
<item>@string/preference_theme_entry_quassel_daynight</item>
<item>@string/preference_theme_entry_quassel_light</item>
<item>@string/preference_theme_entry_quassel_dark</item>
<item>@string/preference_theme_entry_amoled</item>
<item>@string/preference_theme_entry_solarized_daynight</item>
<item>@string/preference_theme_entry_solarized_light</item>
<item>@string/preference_theme_entry_solarized_dark</item>
<item>@string/preference_theme_entry_gruvbox_daynight</item>
<item>@string/preference_theme_entry_gruvbox_light</item>
<item>@string/preference_theme_entry_gruvbox_dark</item>
<item>@string/preference_theme_entry_dracula</item>
</string-array>
<string-array name="preference_theme_entryvalues" translatable="false">
<item>MATERIAL_DAYNIGHT</item>
<item>MATERIAL_LIGHT</item>
<item>MATERIAL_DARK</item>
<item>QUASSEL_DAYNIGHT</item>
<item>QUASSEL_LIGHT</item>
<item>QUASSEL_DARK</item>
<item>AMOLED</item>
<item>SOLARIZED_DAYNIGHT</item>
<item>SOLARIZED_LIGHT</item>
<item>SOLARIZED_DARK</item>
<item>GRUVBOX_DAYNIGHT</item>
<item>GRUVBOX_LIGHT</item>
<item>GRUVBOX_DARK</item>
<item>DRACULA</item>
</string-array>
</resources>
......@@ -22,13 +22,17 @@
<string name="preference_theme_key" translatable="false">theme</string>
<string name="preference_theme_title">Theme</string>
<string name="preference_theme_entry_material_daynight">Material (Auto)</string>
<string name="preference_theme_entry_material_light">Material (Light)</string>
<string name="preference_theme_entry_material_dark">Material (Dark)</string>
<string name="preference_theme_entry_quassel_daynight">Quassel (Auto)</string>
<string name="preference_theme_entry_quassel_light">Quassel (Light)</string>
<string name="preference_theme_entry_quassel_dark">Quassel (Dark)</string>
<string name="preference_theme_entry_amoled">AMOLED</string>
<string name="preference_theme_entry_solarized_daynight">Solarized (Auto)</string>
<string name="preference_theme_entry_solarized_light">Solarized (Light)</string>
<string name="preference_theme_entry_solarized_dark">Solarized (Dark)</string>
<string name="preference_theme_entry_gruvbox_daynight">Gruvbox (Auto)</string>
<string name="preference_theme_entry_gruvbox_light">Gruvbox (Light)</string>
<string name="preference_theme_entry_gruvbox_dark">Gruvbox (Dark)</string>
<string name="preference_theme_entry_dracula">Dracula</string>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ChatTheme.Material_DayNight" parent="Theme.ChatTheme.Material_Light" />
<style name="Theme.ChatTheme.Quassel_DayNight" parent="Theme.ChatTheme.Quassel_Light" />
<style name="Theme.ChatTheme.Solarized_DayNight" parent="Theme.ChatTheme.Solarized_Light" />
<style name="Theme.ChatTheme.Gruvbox_DayNight" parent="Theme.ChatTheme.Gruvbox_Light" />
</resources>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment