parent
f63c662275
commit
bb1868fd67
|
@ -79,7 +79,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||||
* views are created. */
|
* views are created. */
|
||||||
String theme = preferences.getString(APP_THEME, ThemeUtils.APP_THEME_DEFAULT);
|
String theme = preferences.getString(APP_THEME, ThemeUtils.APP_THEME_DEFAULT);
|
||||||
Log.d("activeTheme", theme);
|
Log.d("activeTheme", theme);
|
||||||
if (theme.equals("black")) {
|
if (ThemeUtils.isBlack(getResources().getConfiguration(), theme)) {
|
||||||
setTheme(R.style.TuskyBlackTheme);
|
setTheme(R.style.TuskyBlackTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ enum class AppTheme(val value: String) {
|
||||||
DAY("day"),
|
DAY("day"),
|
||||||
BLACK("black"),
|
BLACK("black"),
|
||||||
AUTO("auto"),
|
AUTO("auto"),
|
||||||
AUTO_SYSTEM("auto_system");
|
AUTO_SYSTEM("auto_system"),
|
||||||
|
AUTO_SYSTEM_BLACK("auto_system_black");
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun stringValues() = values().map { it.value }.toTypedArray()
|
fun stringValues() = values().map { it.value }.toTypedArray()
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.keylesspalace.tusky.util
|
package com.keylesspalace.tusky.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
@ -35,6 +36,7 @@ const val THEME_DAY = "day"
|
||||||
const val THEME_BLACK = "black"
|
const val THEME_BLACK = "black"
|
||||||
const val THEME_AUTO = "auto"
|
const val THEME_AUTO = "auto"
|
||||||
const val THEME_SYSTEM = "auto_system"
|
const val THEME_SYSTEM = "auto_system"
|
||||||
|
const val THEME_SYSTEM_BLACK = "auto_system_black"
|
||||||
const val APP_THEME_DEFAULT = THEME_SYSTEM
|
const val APP_THEME_DEFAULT = THEME_SYSTEM
|
||||||
|
|
||||||
fun getDimension(context: Context, @AttrRes attribute: Int): Int {
|
fun getDimension(context: Context, @AttrRes attribute: Int): Int {
|
||||||
|
@ -59,9 +61,21 @@ fun setAppNightMode(flavor: String?) {
|
||||||
THEME_AUTO -> AppCompatDelegate.setDefaultNightMode(
|
THEME_AUTO -> AppCompatDelegate.setDefaultNightMode(
|
||||||
AppCompatDelegate.MODE_NIGHT_AUTO_TIME
|
AppCompatDelegate.MODE_NIGHT_AUTO_TIME
|
||||||
)
|
)
|
||||||
THEME_SYSTEM -> AppCompatDelegate.setDefaultNightMode(
|
THEME_SYSTEM, THEME_SYSTEM_BLACK -> AppCompatDelegate.setDefaultNightMode(
|
||||||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
)
|
)
|
||||||
else -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
else -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isBlack(config: Configuration, theme: String?): Boolean {
|
||||||
|
return when (theme) {
|
||||||
|
THEME_BLACK -> true
|
||||||
|
THEME_SYSTEM_BLACK -> when (config.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
|
||||||
|
Configuration.UI_MODE_NIGHT_NO -> false
|
||||||
|
Configuration.UI_MODE_NIGHT_YES -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<item>@string/app_theme_black</item>
|
<item>@string/app_theme_black</item>
|
||||||
<item>@string/app_theme_auto</item>
|
<item>@string/app_theme_auto</item>
|
||||||
<item>@string/app_theme_system</item>
|
<item>@string/app_theme_system</item>
|
||||||
|
<item>@string/app_theme_system_black</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="post_privacy_names">
|
<string-array name="post_privacy_names">
|
||||||
|
|
|
@ -302,6 +302,7 @@
|
||||||
<string name="app_theme_black">Black</string>
|
<string name="app_theme_black">Black</string>
|
||||||
<string name="app_theme_auto">Automatic at sunset</string>
|
<string name="app_theme_auto">Automatic at sunset</string>
|
||||||
<string name="app_theme_system">Use System Design</string>
|
<string name="app_theme_system">Use System Design</string>
|
||||||
|
<string name="app_theme_system_black">Use System Design (black)</string>
|
||||||
|
|
||||||
<string name="pref_title_browser_settings">Browser</string>
|
<string name="pref_title_browser_settings">Browser</string>
|
||||||
<string name="pref_title_custom_tabs">Use Chrome Custom Tabs</string>
|
<string name="pref_title_custom_tabs">Use Chrome Custom Tabs</string>
|
||||||
|
|
Loading…
Reference in New Issue