feat: 优化代码

pull/149/head
kunfei 5 years ago
parent e05a451314
commit 7f1add2b31
  1. 3
      app/src/main/java/io/legado/app/help/AppConfig.kt
  2. 7
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
  3. 2
      app/src/main/res/values/arrays.xml
  4. 2
      app/src/main/res/values/pref_key_value.xml
  5. 8
      app/src/main/res/xml/pref_config_other.xml

@ -32,6 +32,9 @@ object AppConfig {
App.INSTANCE.putPrefBoolean("transparentStatusBar", value) App.INSTANCE.putPrefBoolean("transparentStatusBar", value)
} }
val requestedDirection: String?
get() = App.INSTANCE.getPrefString(R.string.pk_requested_direction)
var backupPath: String? var backupPath: String?
get() = App.INSTANCE.getPrefString(PreferKey.backupPath) get() = App.INSTANCE.getPrefString(PreferKey.backupPath)
set(value) { set(value) {

@ -43,6 +43,10 @@ class OtherConfigFragment : PreferenceFragmentCompat(),
upPreferenceSummary(getString(R.string.pk_download_path), BookHelp.downloadPath) upPreferenceSummary(getString(R.string.pk_download_path), BookHelp.downloadPath)
upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString())
upPreferenceSummary(PreferKey.webPort, webPort.toString()) upPreferenceSummary(PreferKey.webPort, webPort.toString())
upPreferenceSummary(
getString(R.string.pk_requested_direction),
AppConfig.requestedDirection
)
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -103,6 +107,9 @@ class OtherConfigFragment : PreferenceFragmentCompat(),
setProcessTextEnable(it.getBoolean(key, true)) setProcessTextEnable(it.getBoolean(key, true))
} }
PreferKey.showRss -> postEvent(EventBus.SHOW_RSS, "unused") PreferKey.showRss -> postEvent(EventBus.SHOW_RSS, "unused")
getString(R.string.pk_requested_direction) -> {
upPreferenceSummary(key, AppConfig.requestedDirection)
}
} }
} }

@ -67,7 +67,7 @@
<item>@string/app_folder_picker</item> <item>@string/app_folder_picker</item>
</string-array> </string-array>
<string-array name="screen_direction_list_title"> <string-array name="screen_direction_title">
<item>@string/screen_unspecified</item> <item>@string/screen_unspecified</item>
<item>@string/screen_portrait</item> <item>@string/screen_portrait</item>
<item>@string/screen_landscape</item> <item>@string/screen_landscape</item>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pk_auto_refresh">auto_refresh</string> <string name="pk_auto_refresh">auto_refresh</string>
<string name="pk_screen_direction">list_screen_direction</string> <string name="pk_requested_direction">list_screen_direction</string>
<string name="pk_full_screen">full_screen</string> <string name="pk_full_screen">full_screen</string>
<string name="pk_threads_num">threads_num</string> <string name="pk_threads_num">threads_num</string>
<string name="pk_user_agent">user_agent</string> <string name="pk_user_agent">user_agent</string>

@ -6,6 +6,14 @@
android:title="@string/main_activity" android:title="@string/main_activity"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<ListPreference
android:key="@string/pk_requested_direction"
android:defaultValue="@string/screen_unspecified"
android:title="@string/screen_direction"
android:entries="@array/screen_direction_title"
android:entryValues="@array/screen_direction_title"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/pk_auto_refresh" android:key="@string/pk_auto_refresh"

Loading…
Cancel
Save