|
|
@ -18,6 +18,7 @@ import io.legado.app.help.AppConfig |
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
import io.legado.app.lib.theme.ATH |
|
|
|
import io.legado.app.lib.theme.ATH |
|
|
|
import io.legado.app.receiver.SharedReceiverActivity |
|
|
|
import io.legado.app.receiver.SharedReceiverActivity |
|
|
|
|
|
|
|
import io.legado.app.service.WebService |
|
|
|
import io.legado.app.ui.filechooser.FileChooserDialog |
|
|
|
import io.legado.app.ui.filechooser.FileChooserDialog |
|
|
|
import io.legado.app.ui.filechooser.FilePicker |
|
|
|
import io.legado.app.ui.filechooser.FilePicker |
|
|
|
import io.legado.app.ui.widget.number.NumberPickerDialog |
|
|
|
import io.legado.app.ui.widget.number.NumberPickerDialog |
|
|
@ -34,12 +35,14 @@ class OtherConfigFragment : PreferenceFragmentCompat(), |
|
|
|
App.INSTANCE, |
|
|
|
App.INSTANCE, |
|
|
|
SharedReceiverActivity::class.java.name |
|
|
|
SharedReceiverActivity::class.java.name |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
private val webPort get() = getPrefInt(PreferKey.webPort, 1122) |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { |
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { |
|
|
|
putPrefBoolean(PreferKey.processText, isProcessTextEnabled()) |
|
|
|
putPrefBoolean(PreferKey.processText, isProcessTextEnabled()) |
|
|
|
addPreferencesFromResource(R.xml.pref_config_other) |
|
|
|
addPreferencesFromResource(R.xml.pref_config_other) |
|
|
|
upPreferenceSummary(PreferKey.downloadPath, BookHelp.downloadPath) |
|
|
|
upPreferenceSummary(PreferKey.downloadPath, BookHelp.downloadPath) |
|
|
|
upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) |
|
|
|
upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) |
|
|
|
|
|
|
|
upPreferenceSummary(PreferKey.webPort, webPort.toString()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
@ -63,6 +66,14 @@ class OtherConfigFragment : PreferenceFragmentCompat(), |
|
|
|
.show { |
|
|
|
.show { |
|
|
|
AppConfig.threadCount = it |
|
|
|
AppConfig.threadCount = it |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
PreferKey.webPort -> NumberPickerDialog(requireContext()) |
|
|
|
|
|
|
|
.setTitle(getString(R.string.web_port_title)) |
|
|
|
|
|
|
|
.setMaxValue(60000) |
|
|
|
|
|
|
|
.setMinValue(1024) |
|
|
|
|
|
|
|
.setValue(webPort) |
|
|
|
|
|
|
|
.show { |
|
|
|
|
|
|
|
putPrefInt(PreferKey.webPort, it) |
|
|
|
|
|
|
|
} |
|
|
|
PreferKey.downloadPath -> selectDownloadPath() |
|
|
|
PreferKey.downloadPath -> selectDownloadPath() |
|
|
|
PreferKey.cleanCache -> { |
|
|
|
PreferKey.cleanCache -> { |
|
|
|
BookHelp.clearCache() |
|
|
|
BookHelp.clearCache() |
|
|
@ -78,9 +89,15 @@ class OtherConfigFragment : PreferenceFragmentCompat(), |
|
|
|
upPreferenceSummary(key, BookHelp.downloadPath) |
|
|
|
upPreferenceSummary(key, BookHelp.downloadPath) |
|
|
|
} |
|
|
|
} |
|
|
|
PreferKey.threadCount -> upPreferenceSummary( |
|
|
|
PreferKey.threadCount -> upPreferenceSummary( |
|
|
|
PreferKey.threadCount, |
|
|
|
key, AppConfig.threadCount.toString() |
|
|
|
AppConfig.threadCount.toString() |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
PreferKey.webPort -> { |
|
|
|
|
|
|
|
upPreferenceSummary(key, webPort.toString()) |
|
|
|
|
|
|
|
if (WebService.isRun) { |
|
|
|
|
|
|
|
WebService.stop(requireContext()) |
|
|
|
|
|
|
|
WebService.start(requireContext()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
PreferKey.recordLog -> LogUtils.upLevel() |
|
|
|
PreferKey.recordLog -> LogUtils.upLevel() |
|
|
|
PreferKey.processText -> sharedPreferences?.let { |
|
|
|
PreferKey.processText -> sharedPreferences?.let { |
|
|
|
setProcessTextEnable(it.getBoolean(key, true)) |
|
|
|
setProcessTextEnable(it.getBoolean(key, true)) |
|
|
@ -93,6 +110,7 @@ class OtherConfigFragment : PreferenceFragmentCompat(), |
|
|
|
val preference = findPreference<Preference>(preferenceKey) ?: return |
|
|
|
val preference = findPreference<Preference>(preferenceKey) ?: return |
|
|
|
when (preferenceKey) { |
|
|
|
when (preferenceKey) { |
|
|
|
PreferKey.threadCount -> preference.summary = getString(R.string.threads_num, value) |
|
|
|
PreferKey.threadCount -> preference.summary = getString(R.string.threads_num, value) |
|
|
|
|
|
|
|
PreferKey.webPort -> preference.summary = getString(R.string.web_port_summary, value) |
|
|
|
else -> if (preference is ListPreference) { |
|
|
|
else -> if (preference is ListPreference) { |
|
|
|
val index = preference.findIndexOfValue(value) |
|
|
|
val index = preference.findIndexOfValue(value) |
|
|
|
// Set the summary to reflect the new value. |
|
|
|
// Set the summary to reflect the new value. |
|
|
|