From 33b04427d54062e9b6871d0d6c96f119a99784be Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 18 Jul 2016 12:58:18 -0500 Subject: [PATCH] Added a startup screen preference option (#395) * Added a startup screen preference option * changed string and keys to be consistent --- .../tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../tachiyomi/data/preference/PreferencesHelper.kt | 2 ++ .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 9 ++++++++- app/src/main/res/values/arrays.xml | 12 ++++++++++++ app/src/main/res/values/keys.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_general.xml | 8 ++++++++ 7 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index b4493e682..28b6fdc09 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -82,6 +82,8 @@ class PreferenceKeys(context: Context) { val automaticUpdateStatus = context.getString(R.string.pref_enable_automatic_updates_key) + val startScreen = context.getString(R.string.pref_start_screen_key) + fun sourceUsername(sourceId: Int) = "pref_source_username_$sourceId" fun sourcePassword(sourceId: Int) = "pref_source_password_$sourceId" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 42385ad44..93a0c8bfd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -32,6 +32,8 @@ class PreferencesHelper(context: Context) { } } + fun startScreen() = prefs.getInt(keys.startScreen, 1) + fun clear() = prefs.edit().clear().apply() fun theme() = prefs.getInt(keys.theme, 1) 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 2fd7e6d55..7c1c98a6c 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 @@ -59,7 +59,14 @@ class MainActivity : BaseActivity() { } if (savedState == null) { - setFragment(LibraryFragment.newInstance()) + + when (preferences.startScreen()) { + 1 -> setFragment(LibraryFragment.newInstance()) + 2 -> setFragment(RecentlyReadFragment.newInstance()) + 3 -> setFragment(RecentChaptersFragment.newInstance()) + else -> setFragment(LibraryFragment.newInstance()) + } + ChangelogDialogFragment.show(preferences, supportFragmentManager) } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 054188238..c21c4f27e 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -144,4 +144,16 @@ remove + + @string/label_library + @string/label_recent_manga + @string/label_recent_updates + + + + 1 + 2 + 3 + + \ No newline at end of file diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index 75b71b6f3..1a8ec63d4 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -1,5 +1,6 @@ + pref_category_general_key pref_category_reader_key pref_category_sync_key @@ -17,6 +18,7 @@ pref_ask_update_manga_sync_key pref_theme_key library_update_restriction + start_screen pref_default_viewer_key pref_image_scale_type_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4cb0c0acd..9f22181da 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -93,6 +93,7 @@ Application theme Main theme Dark theme + Start screen Fullscreen diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 2df9363de..77e5fda3e 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -14,6 +14,14 @@ android:summary="%s" android:title="@string/pref_theme"/> + +