Dark amoled theme

This commit is contained in:
Koitharu
2020-11-09 19:43:01 +02:00
parent 5190ec3e98
commit 908baebb62
13 changed files with 46 additions and 3 deletions

View File

@@ -36,6 +36,8 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
)
val isAmoledTheme by BoolPreferenceDelegate(KEY_THEME_AMOLED, defaultValue = false)
val gridSize by IntPreferenceDelegate(KEY_GRID_SIZE, defaultValue = 100)
val readerPageSwitch by StringSetPreferenceDelegate(
@@ -126,6 +128,7 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :
const val KEY_LIST_MODE = "list_mode"
const val KEY_APP_SECTION = "app_section"
const val KEY_THEME = "theme"
const val KEY_THEME_AMOLED = "amoled_theme"
const val KEY_SOURCES_ORDER = "sources_order"
const val KEY_SOURCES_HIDDEN = "sources_hidden"
const val KEY_TRAFFIC_WARNING = "traffic_warning"

View File

@@ -1,13 +1,23 @@
package org.koitharu.kotatsu.ui.base
import android.os.Bundle
import android.view.MenuItem
import android.view.View
import androidx.appcompat.widget.Toolbar
import moxy.MvpAppCompatActivity
import org.koin.android.ext.android.get
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.prefs.AppSettings
abstract class BaseActivity : MvpAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
if (get<AppSettings>().isAmoledTheme) {
setTheme(R.style.AppTheme_Amoled)
}
super.onCreate(savedInstanceState)
}
override fun setContentView(layoutResID: Int) {
super.setContentView(layoutResID)
setupToolbar()

View File

@@ -65,7 +65,6 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
findPreference<ListPreference>(AppSettings.KEY_ZOOM_MODE)?.let {
it.entryValues = ZoomMode.values().names()
it.setDefaultValue(ZoomMode.FIT_CENTER.name)
it.summaryProvider = ListPreference.SimpleSummaryProvider.getInstance()
}
findPreference<SwitchPreference>(AppSettings.KEY_PROTECT_APP)?.isChecked =
!settings.appPassword.isNullOrEmpty()
@@ -88,6 +87,9 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
AppSettings.KEY_THEME -> {
AppCompatDelegate.setDefaultNightMode(settings.theme)
}
AppSettings.KEY_THEME_AMOLED -> {
findPreference<Preference>(key)?.setSummary(R.string.restart_required)
}
AppSettings.KEY_LOCAL_STORAGE -> {
findPreference<Preference>(key)?.run {
summary = settings.getStorageDir(context)?.getStorageName(context)

View File

@@ -25,7 +25,6 @@ class ReaderSettingsFragment : BasePreferenceFragment(R.string.reader_settings)
findPreference<ListPreference>(AppSettings.KEY_ZOOM_MODE)?.let {
it.entryValues = ZoomMode.values().names()
it.setDefaultValue(ZoomMode.FIT_CENTER.name)
it.summaryProvider = ListPreference.SimpleSummaryProvider.getInstance()
}
}
}

View File

@@ -2,6 +2,7 @@
<resources>
<color name="blue_primary">#1565C0</color>
<color name="blue_primary_dark">#283593</color>
<color name="blue_primary_darker">#1A237E</color>
<color name="red_accent">#FF8A65</color>
<color name="dim">#99000000</color>
<color name="error">#E57373</color>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.Amoled">
<item name="colorPrimary">@color/blue_primary_dark</item>
<item name="colorPrimaryDark">@color/blue_primary_darker</item>
<item name="android:windowBackground">@android:color/black</item>
</style>
</resources>

View File

@@ -168,4 +168,7 @@
<string name="zoom_mode_fit_height">Подогнать по высоте</string>
<string name="zoom_mode_fit_width">Подогнать по ширине</string>
<string name="zoom_mode_keep_start">Исходный размер</string>
<string name="black_dark_theme">Чёрная тёмная тема</string>
<string name="black_dark_theme_summary">Полезно для AMOLED экранов</string>
<string name="restart_required">Требуется перезапуск</string>
</resources>

View File

@@ -2,6 +2,7 @@
<resources>
<color name="blue_primary">#1976D2</color>
<color name="blue_primary_dark">#1565C0</color>
<color name="blue_primary_darker">#283593</color>
<color name="red_accent">#EF5350</color>
<color name="grey">#424242</color>
<color name="grey_dark">#212121</color>

View File

@@ -170,4 +170,7 @@
<string name="zoom_mode_fit_height">Fit to height</string>
<string name="zoom_mode_fit_width">Fit to width</string>
<string name="zoom_mode_keep_start">Keep at start</string>
<string name="black_dark_theme">Black dark theme</string>
<string name="black_dark_theme_summary">Useful for AMOLED screens</string>
<string name="restart_required">Restart required</string>
</resources>

View File

@@ -6,9 +6,12 @@
<item name="actionModeStyle">@style/AppActionMode</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
</style>
<style name="AppTheme" parent="BaseAppTheme">
<item name="colorPrimary">@color/blue_primary</item>
<item name="colorPrimaryDark">@color/blue_primary_dark</item>
<item name="colorAccent">@color/red_accent</item>
</style>
<style name="AppTheme.Amoled" />
</resources>

View File

@@ -13,6 +13,13 @@
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreference
android:defaultValue="false"
android:key="amoled_theme"
app:iconSpaceReserved="false"
android:title="@string/black_dark_theme"
android:summary="@string/black_dark_theme_summary" />
<Preference
android:key="list_mode"
android:persistent="false"
@@ -74,6 +81,7 @@
android:entries="@array/zoom_modes"
android:key="zoom_mode"
android:title="@string/scale_mode"
app:useSimpleSummaryProvider="true"
app:iconSpaceReserved="false" />
<SwitchPreference

View File

@@ -21,7 +21,8 @@
android:entries="@array/zoom_modes"
android:key="zoom_mode"
android:title="@string/scale_mode"
app:iconSpaceReserved="false" />
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />
<SwitchPreference
android:defaultValue="false"