From 3c186a3c8d3fd74f489a7aa2a27906d29502e0f6 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Mon, 24 May 2021 20:09:35 +0700 Subject: [PATCH 1/7] Fix incognito mode disabled after the app kicked out of memory (#5167) The application class onCreate will also be called when user navigates to an activity after the app process is killed by the system. So make sure the incognito is disabled only when the entry point of the app is created from scratch (e.g. after being force closed by the user). --- app/src/main/java/eu/kanade/tachiyomi/App.kt | 3 --- app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 7292b81b8..370e5199b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -74,9 +74,6 @@ open class App : Application(), LifecycleObserver, ImageLoaderFactory { ProcessLifecycleOwner.get().lifecycle.addObserver(this) - // Reset Incognito Mode on relaunch - preferences.incognitoMode().set(false) - // Show notification to disable Incognito Mode when it's enabled preferences.incognitoMode().asFlow() .onEach { enabled -> diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 501bb0113..7529b561e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -224,6 +224,9 @@ class MainActivity : BaseViewBindingActivity() { syncActivityViewWithController(router.backstack.lastOrNull()?.controller()) if (savedInstanceState == null) { + // Reset Incognito Mode on relaunch + preferences.incognitoMode().set(false) + // Show changelog prompt on update if (Migrations.upgrade(preferences) && !BuildConfig.DEBUG) { WhatsNewDialogController().showDialog(router) From b5a700276a00f5b630d35d1b902bd624905c6c01 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Mon, 24 May 2021 20:10:13 +0700 Subject: [PATCH 2/7] Remove top margin of PreferenceCategory if no title set (#5168) --- .../util/preference/PreferenceDSL.kt | 3 ++- .../AdaptiveTitlePreferenceCategory.kt | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/widget/preference/AdaptiveTitlePreferenceCategory.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/preference/PreferenceDSL.kt b/app/src/main/java/eu/kanade/tachiyomi/util/preference/PreferenceDSL.kt index 148b91ae2..03a74b48d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/preference/PreferenceDSL.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/preference/PreferenceDSL.kt @@ -16,6 +16,7 @@ import androidx.preference.PreferenceScreen import androidx.preference.SwitchPreferenceCompat import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.getResourceColor +import eu.kanade.tachiyomi.widget.preference.AdaptiveTitlePreferenceCategory import eu.kanade.tachiyomi.widget.preference.IntListPreference import eu.kanade.tachiyomi.widget.preference.SwitchPreferenceCategory import eu.kanade.tachiyomi.widget.preference.SwitchSettingsPreference @@ -77,7 +78,7 @@ inline fun PreferenceGroup.multiSelectListPreference(block: (@DSL MultiSelectLis } inline fun PreferenceScreen.preferenceCategory(block: (@DSL PreferenceCategory).() -> Unit): PreferenceCategory { - return addThenInit(PreferenceCategory(context), block) + return addThenInit(AdaptiveTitlePreferenceCategory(context), block) } inline fun PreferenceScreen.preferenceScreen(block: (@DSL PreferenceScreen).() -> Unit): PreferenceScreen { diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/AdaptiveTitlePreferenceCategory.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/AdaptiveTitlePreferenceCategory.kt new file mode 100644 index 000000000..d0448549d --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/AdaptiveTitlePreferenceCategory.kt @@ -0,0 +1,22 @@ +package eu.kanade.tachiyomi.widget.preference + +import android.content.Context +import androidx.core.view.updateLayoutParams +import androidx.preference.PreferenceCategory +import androidx.preference.PreferenceViewHolder +import androidx.recyclerview.widget.RecyclerView + +/** + * PreferenceCategory that hides the title placeholder layout if the title is unset + */ +class AdaptiveTitlePreferenceCategory(context: Context) : PreferenceCategory(context) { + override fun onBindViewHolder(holder: PreferenceViewHolder) { + super.onBindViewHolder(holder) + if (title.isNullOrBlank()) { + holder.itemView.updateLayoutParams { + height = 0 + topMargin = 0 + } + } + } +} From 176e984b56d66d1e47bd367d7dde03e4a024152c Mon Sep 17 00:00:00 2001 From: Soitora Date: Mon, 24 May 2021 17:16:32 +0200 Subject: [PATCH 3/7] Add "Midnight Dusk" and "Hot Pink" themes (#5161) * Organize and clarify themes file Increases clarification with better commenting, should make it easier to add or modify current themes. * Make AMOLED its own theme category * Tweak ripples for AMOLED * Add "Midnight Dusk" theme Ports it from jobobby04/TachiyomiSY. Co-Authored-By: CrepeTF <70870719+CrepeTF@users.noreply.github.com> * Add "Hot Pink" theme Ports it from jobobby04/TachiyomiSY. Co-Authored-By: OncePunchedMan <64155117+OncePunchedMan@users.noreply.github.com> * Make AMOLED a base theme * Final tweaks Rename "Toolbar.Light" to "Custom.PopupTheme" Changes placing of backgroundDusk Removes HotPink and MidnightDusk custom Toolbars, I believe they are unnecessary. * Rename a Midnight Dusk color * Make AMOLED independent from Dark as a theme Co-authored-by: CrepeTF <70870719+CrepeTF@users.noreply.github.com> Co-authored-by: OncePunchedMan <64155117+OncePunchedMan@users.noreply.github.com> --- .../data/preference/PreferenceValues.kt | 2 + .../ui/base/activity/BaseThemedActivity.kt | 4 +- .../ui/setting/SettingsGeneralController.kt | 8 +- app/src/main/res/values/colors.xml | 38 +++ app/src/main/res/values/strings.xml | 2 + app/src/main/res/values/styles.xml | 18 +- app/src/main/res/values/themes.xml | 226 +++++++++++++++--- 7 files changed, 256 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt index 13cda3269..bdd11acc5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt @@ -24,7 +24,9 @@ object PreferenceValues { enum class DarkThemeVariant { default, blue, + midnightdusk, amoled, + hotpink, } /* ktlint-enable experimental:enum-entry-name-case */ diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt index 11ddee568..90283f20b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt @@ -25,7 +25,9 @@ abstract class BaseThemedActivity : AppCompatActivity() { when (preferences.themeDark().get()) { DarkThemeVariant.default -> R.style.Theme_Tachiyomi_Dark DarkThemeVariant.blue -> R.style.Theme_Tachiyomi_Dark_Blue - DarkThemeVariant.amoled -> R.style.Theme_Tachiyomi_Dark_Amoled + DarkThemeVariant.midnightdusk -> R.style.Theme_Tachiyomi_Dark_MidnightDusk + DarkThemeVariant.amoled -> R.style.Theme_Tachiyomi_Amoled + DarkThemeVariant.hotpink -> R.style.Theme_Tachiyomi_Amoled_HotPink } } else { when (preferences.themeLight().get()) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index 5c53a1e35..4c871d072 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -141,12 +141,16 @@ class SettingsGeneralController : SettingsController() { entriesRes = arrayOf( R.string.theme_dark_default, R.string.theme_dark_blue, - R.string.theme_dark_amoled + R.string.theme_dark_midnightdusk, + R.string.theme_dark_amoled, + R.string.theme_dark_amoled_hotpink ) entryValues = arrayOf( Values.DarkThemeVariant.default.name, Values.DarkThemeVariant.blue.name, - Values.DarkThemeVariant.amoled.name + Values.DarkThemeVariant.midnightdusk.name, + Values.DarkThemeVariant.amoled.name, + Values.DarkThemeVariant.hotpink.name ) defaultValue = Values.DarkThemeVariant.default.name summary = "%s" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4c43322e9..90b4a280f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -8,8 +8,11 @@ #242529 #202125 + + @color/md_black_1000 + @color/colorPrimary @@ -38,6 +41,38 @@ @color/colorDarkPrimary @color/md_blue_A200_50 + + #F02475 + @color/md_white_1000 + @color/md_white_1000_70 + @color/md_white_1000_50 + #12ffffff + #0FF02475 + #16151D + #201F27 + #80F02475 + + + #3399FF + @color/md_white_1000 + @color/md_white_1000_70 + @color/md_white_1000_50 + @android:color/transparent + @color/md_white_1000_8 + #0A3399FF + @color/rippleColorAmoled + @color/colorAmoledPrimary + @color/colorAmoledPrimary + @color/md_blue_A200_50 + + + #FF3399 + @color/md_white_1000 + @color/md_white_1000_70 + @color/md_white_1000_50 + #0AFF3399 + #80FF69B4 + @color/colorDarkPrimary @color/md_grey_50_75 @@ -45,12 +80,14 @@ #FFC107 #FFEB3B + #FFEB3B #DE000000 #8A000000 #61000000 #1F000000 + #14000000 #0F000000 #FFFFFFFF @@ -59,6 +96,7 @@ #80FFFFFF #33FFFFFF #1FFFFFFF + #14FFFFFF #0FFFFFFF diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 45c1b1cbe..af36ed751 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -159,7 +159,9 @@ Dark theme Default Dark blue + Midnight dusk AMOLED black + Hot pink Start screen Language Default diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 2f7d92a3e..f09c42891 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -6,11 +6,7 @@ - - @@ -18,6 +14,14 @@ ?attr/rippleToolbarColor + + + + @@ -68,6 +72,10 @@ @color/colorAccentDark + + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 859335eef..890bff4cf 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -4,16 +4,16 @@ - - - - + + + + + + + @@ -118,6 +135,8 @@ + + + - - - - - + + + + + + + + + + + + -