1
0
mirror of https://github.com/accelforce/Yuito synced 2024-12-22 13:24:46 +01:00

Add system black theme (#3957)

Close #1222
This commit is contained in:
Mylloon 2023-09-13 11:14:20 +02:00 committed by GitHub
parent f63c662275
commit bb1868fd67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 3 deletions

View File

@ -79,7 +79,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
* views are created. */
String theme = preferences.getString(APP_THEME, ThemeUtils.APP_THEME_DEFAULT);
Log.d("activeTheme", theme);
if (theme.equals("black")) {
if (ThemeUtils.isBlack(getResources().getConfiguration(), theme)) {
setTheme(R.style.TuskyBlackTheme);
}

View File

@ -5,7 +5,8 @@ enum class AppTheme(val value: String) {
DAY("day"),
BLACK("black"),
AUTO("auto"),
AUTO_SYSTEM("auto_system");
AUTO_SYSTEM("auto_system"),
AUTO_SYSTEM_BLACK("auto_system_black");
companion object {
fun stringValues() = values().map { it.value }.toTypedArray()

View File

@ -17,6 +17,7 @@
package com.keylesspalace.tusky.util
import android.content.Context
import android.content.res.Configuration
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
@ -35,6 +36,7 @@ const val THEME_DAY = "day"
const val THEME_BLACK = "black"
const val THEME_AUTO = "auto"
const val THEME_SYSTEM = "auto_system"
const val THEME_SYSTEM_BLACK = "auto_system_black"
const val APP_THEME_DEFAULT = THEME_SYSTEM
fun getDimension(context: Context, @AttrRes attribute: Int): Int {
@ -59,9 +61,21 @@ fun setAppNightMode(flavor: String?) {
THEME_AUTO -> AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_AUTO_TIME
)
THEME_SYSTEM -> AppCompatDelegate.setDefaultNightMode(
THEME_SYSTEM, THEME_SYSTEM_BLACK -> AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
)
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
}
}

View File

@ -7,6 +7,7 @@
<item>@string/app_theme_black</item>
<item>@string/app_theme_auto</item>
<item>@string/app_theme_system</item>
<item>@string/app_theme_system_black</item>
</string-array>
<string-array name="post_privacy_names">

View File

@ -302,6 +302,7 @@
<string name="app_theme_black">Black</string>
<string name="app_theme_auto">Automatic at sunset</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_custom_tabs">Use Chrome Custom Tabs</string>