Added a startup screen preference option (#395)

* Added a startup screen preference option

* changed string and keys to be consistent
This commit is contained in:
Josh
2016-07-18 12:58:18 -05:00
committed by inorichi
parent f7bb356abd
commit 33b04427d5
7 changed files with 35 additions and 1 deletions

View File

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

View File

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

View File

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