diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/AppPreferences.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/AppPreferences.kt index c45a9981..6996168d 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/AppPreferences.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/AppPreferences.kt @@ -158,14 +158,14 @@ class AppPreferences { } var themePref: Int - get() = sharedPreferences.getInt(APP_THEME, 2) + get() = sharedPreferences.getInt(APP_THEME, FOLLOW_SYSTEM_THEME) set(value) = sharedPreferences.edit().putInt(APP_THEME, value).apply() @NightMode val nightMode: Int get() = when (themePref) { - 0 -> AppCompatDelegate.MODE_NIGHT_NO - 1 -> AppCompatDelegate.MODE_NIGHT_YES - 2 -> { + LIGHT_THEME -> AppCompatDelegate.MODE_NIGHT_NO + DARK_THEME, JUST_BLACK_THEME -> AppCompatDelegate.MODE_NIGHT_YES + FOLLOW_SYSTEM_THEME -> { if (supportSystemNightMode) AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM else AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY } @@ -239,6 +239,10 @@ class AppPreferences { const val TRANSLUCENT = 2 const val LIGHT = 1 const val DARK = 2 + const val LIGHT_THEME = 0 + const val DARK_THEME = 1 + const val FOLLOW_SYSTEM_THEME = 2 + const val JUST_BLACK_THEME = 3 val TIME_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm") val DATE_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofLocalizedDate(MEDIUM) diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/base/BaseActivity.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/base/BaseActivity.kt index 3e50e565..119c7c47 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/base/BaseActivity.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/base/BaseActivity.kt @@ -4,11 +4,13 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.lifecycleScope import androidx.viewbinding.ViewBinding +import com.github.premnirmal.ticker.AppPreferences import com.github.premnirmal.ticker.analytics.Analytics import com.github.premnirmal.ticker.components.Injector import com.github.premnirmal.ticker.model.IStocksProvider import com.github.premnirmal.ticker.model.IStocksProvider.FetchState import com.github.premnirmal.ticker.showDialog +import com.github.premnirmal.tickerwidget.R import com.google.android.material.color.DynamicColors import kotlinx.coroutines.delay import kotlinx.coroutines.isActive @@ -32,6 +34,9 @@ abstract class BaseActivity : AppCompatActivity() { ) { super.onCreate(savedInstanceState) DynamicColors.applyToActivityIfAvailable(this) + if (holder.appPreferences.themePref == AppPreferences.JUST_BLACK_THEME) { + theme.applyStyle(R.style.AppTheme_Overlay_JustBlack, true) + } setContentView(binding.root) savedInstanceState?.let { isErrorDialogShowing = it.getBoolean(IS_ERROR_DIALOG_SHOWING, false) } } @@ -87,6 +92,7 @@ abstract class BaseActivity : AppCompatActivity() { class InjectionHolder { @Inject internal lateinit var analytics: Analytics @Inject internal lateinit var stocksProvider: IStocksProvider + @Inject internal lateinit var appPreferences: AppPreferences init { Injector.appComponent.inject(this) diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/settings/SettingsFragment.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/settings/SettingsFragment.kt index ea59c9ac..585f2a0d 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/settings/SettingsFragment.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/settings/SettingsFragment.kt @@ -177,6 +177,9 @@ class SettingsFragment : PreferenceFragmentCompat(), ChildFragment, val index = listPreference.findIndexOfValue(stringValue) appPreferences.themePref = index themePref.summary = listPreference.entries[index] + if (index == AppPreferences.JUST_BLACK_THEME) { + requireActivity().recreate() + } AppCompatDelegate.setDefaultNightMode(appPreferences.nightMode) InAppMessage.showMessage(requireView(), R.string.theme_updated_message) return true diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/widget/WidgetData.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/widget/WidgetData.kt index 1af984b1..4a92851d 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/widget/WidgetData.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/widget/WidgetData.kt @@ -98,7 +98,11 @@ class WidgetData { @ColorRes get() { return when (textColorPref()) { SYSTEM -> { - R.color.text_widget_positive + if (appPreferences.themePref == AppPreferences.JUST_BLACK_THEME || nightMode) { + R.color.text_widget_positive_light + } else { + R.color.text_widget_positive + } } DARK -> { R.color.text_widget_positive_dark diff --git a/app/src/main/res/values-de/settings.xml b/app/src/main/res/values-de/settings.xml index 2eace6ac..45d9d6a8 100644 --- a/app/src/main/res/values-de/settings.xml +++ b/app/src/main/res/values-de/settings.xml @@ -11,6 +11,7 @@ Hell Dunkel Systemstandardeinstellung + Nur schwarz diff --git a/app/src/main/res/values-es/settings.xml b/app/src/main/res/values-es/settings.xml index 27532daa..abf16276 100644 --- a/app/src/main/res/values-es/settings.xml +++ b/app/src/main/res/values-es/settings.xml @@ -11,6 +11,7 @@ Clara Oscura Seguir sistema + Solo negra diff --git a/app/src/main/res/values-fr/settings.xml b/app/src/main/res/values-fr/settings.xml index e807b775..d7787f66 100644 --- a/app/src/main/res/values-fr/settings.xml +++ b/app/src/main/res/values-fr/settings.xml @@ -11,6 +11,7 @@ Clair Sombre Selon le système + Juste noir diff --git a/app/src/main/res/values-it/settings.xml b/app/src/main/res/values-it/settings.xml index 4af64c9c..c84033b2 100644 --- a/app/src/main/res/values-it/settings.xml +++ b/app/src/main/res/values-it/settings.xml @@ -16,11 +16,7 @@ Chiaro Scuro Come da sistema - - - 0 - 1 - 2 + Solo nero diff --git a/app/src/main/res/values-night/base_themes.xml b/app/src/main/res/values-night/base_themes.xml index f3f537b9..89bc1389 100644 --- a/app/src/main/res/values-night/base_themes.xml +++ b/app/src/main/res/values-night/base_themes.xml @@ -30,4 +30,12 @@ @color/md_theme_dark_inversePrimary + + diff --git a/app/src/main/res/values-pt-rBR/settings.xml b/app/src/main/res/values-pt-rBR/settings.xml index fe01c796..ded2f693 100644 --- a/app/src/main/res/values-pt-rBR/settings.xml +++ b/app/src/main/res/values-pt-rBR/settings.xml @@ -16,11 +16,7 @@ Claro Escuro Como o sistema - - - 0 - 1 - 2 + Apenas preto diff --git a/app/src/main/res/values/base_themes.xml b/app/src/main/res/values/base_themes.xml index fa4fbe63..109773eb 100644 --- a/app/src/main/res/values/base_themes.xml +++ b/app/src/main/res/values/base_themes.xml @@ -39,4 +39,12 @@ #62e04f true + + diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index beecee0e..01e958b5 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -16,11 +16,13 @@ Light Dark Follow system + Just black 0 1 2 + 3