Dark amoled theme

pull/26/head
Koitharu 6 years ago
parent 5190ec3e98
commit 908baebb62

@ -1,6 +1,7 @@
<component name="ProjectDictionaryState"> <component name="ProjectDictionaryState">
<dictionary name="admin"> <dictionary name="admin">
<words> <words>
<w>amoled</w>
<w>chucker</w> <w>chucker</w>
<w>desu</w> <w>desu</w>
<w>failsafe</w> <w>failsafe</w>

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

@ -1,13 +1,23 @@
package org.koitharu.kotatsu.ui.base package org.koitharu.kotatsu.ui.base
import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import moxy.MvpAppCompatActivity import moxy.MvpAppCompatActivity
import org.koin.android.ext.android.get
import org.koitharu.kotatsu.R import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.prefs.AppSettings
abstract class BaseActivity : MvpAppCompatActivity() { 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) { override fun setContentView(layoutResID: Int) {
super.setContentView(layoutResID) super.setContentView(layoutResID)
setupToolbar() setupToolbar()

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

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

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

@ -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>

@ -168,4 +168,7 @@
<string name="zoom_mode_fit_height">Подогнать по высоте</string> <string name="zoom_mode_fit_height">Подогнать по высоте</string>
<string name="zoom_mode_fit_width">Подогнать по ширине</string> <string name="zoom_mode_fit_width">Подогнать по ширине</string>
<string name="zoom_mode_keep_start">Исходный размер</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> </resources>

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

@ -170,4 +170,7 @@
<string name="zoom_mode_fit_height">Fit to height</string> <string name="zoom_mode_fit_height">Fit to height</string>
<string name="zoom_mode_fit_width">Fit to width</string> <string name="zoom_mode_fit_width">Fit to width</string>
<string name="zoom_mode_keep_start">Keep at start</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> </resources>

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

@ -13,6 +13,13 @@
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" /> 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 <Preference
android:key="list_mode" android:key="list_mode"
android:persistent="false" android:persistent="false"
@ -74,6 +81,7 @@
android:entries="@array/zoom_modes" android:entries="@array/zoom_modes"
android:key="zoom_mode" android:key="zoom_mode"
android:title="@string/scale_mode" android:title="@string/scale_mode"
app:useSimpleSummaryProvider="true"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreference <SwitchPreference

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

Loading…
Cancel
Save