|
|
@ -1,5 +1,6 @@ |
|
|
|
package io.legado.app.ui.config |
|
|
|
package io.legado.app.ui.config |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
import android.app.Activity.RESULT_OK |
|
|
|
import android.app.Activity.RESULT_OK |
|
|
|
import android.content.ComponentName |
|
|
|
import android.content.ComponentName |
|
|
|
import android.content.Intent |
|
|
|
import android.content.Intent |
|
|
@ -29,7 +30,9 @@ import io.legado.app.service.WebService |
|
|
|
import io.legado.app.ui.main.MainActivity |
|
|
|
import io.legado.app.ui.main.MainActivity |
|
|
|
import io.legado.app.ui.widget.image.CoverImageView |
|
|
|
import io.legado.app.ui.widget.image.CoverImageView |
|
|
|
import io.legado.app.ui.widget.number.NumberPickerDialog |
|
|
|
import io.legado.app.ui.widget.number.NumberPickerDialog |
|
|
|
|
|
|
|
import io.legado.app.ui.widget.text.AutoCompleteTextView |
|
|
|
import io.legado.app.utils.* |
|
|
|
import io.legado.app.utils.* |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.dialog_edit_text.view.* |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -48,6 +51,7 @@ class OtherConfigFragment : BasePreferenceFragment(), |
|
|
|
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.userAgent, AppConfig.userAgent) |
|
|
|
upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) |
|
|
|
upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) |
|
|
|
upPreferenceSummary(PreferKey.webPort, webPort.toString()) |
|
|
|
upPreferenceSummary(PreferKey.webPort, webPort.toString()) |
|
|
|
upPreferenceSummary(PreferKey.defaultCover, getPrefString(PreferKey.defaultCover)) |
|
|
|
upPreferenceSummary(PreferKey.defaultCover, getPrefString(PreferKey.defaultCover)) |
|
|
@ -66,6 +70,7 @@ class OtherConfigFragment : BasePreferenceFragment(), |
|
|
|
|
|
|
|
|
|
|
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
|
|
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
|
|
|
when (preference?.key) { |
|
|
|
when (preference?.key) { |
|
|
|
|
|
|
|
PreferKey.userAgent -> showUserAgentDialog() |
|
|
|
PreferKey.threadCount -> NumberPickerDialog(requireContext()) |
|
|
|
PreferKey.threadCount -> NumberPickerDialog(requireContext()) |
|
|
|
.setTitle(getString(R.string.threads_num_title)) |
|
|
|
.setTitle(getString(R.string.threads_num_title)) |
|
|
|
.setMaxValue(999) |
|
|
|
.setMaxValue(999) |
|
|
@ -117,8 +122,7 @@ class OtherConfigFragment : BasePreferenceFragment(), |
|
|
|
} |
|
|
|
} |
|
|
|
PreferKey.showRss -> postEvent(EventBus.SHOW_RSS, "") |
|
|
|
PreferKey.showRss -> postEvent(EventBus.SHOW_RSS, "") |
|
|
|
PreferKey.defaultCover -> upPreferenceSummary( |
|
|
|
PreferKey.defaultCover -> upPreferenceSummary( |
|
|
|
key, |
|
|
|
key, getPrefString(PreferKey.defaultCover) |
|
|
|
getPrefString(PreferKey.defaultCover) |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
PreferKey.language -> listView.postDelayed({ |
|
|
|
PreferKey.language -> listView.postDelayed({ |
|
|
|
LanguageUtils.setConfiguration(App.INSTANCE) |
|
|
|
LanguageUtils.setConfiguration(App.INSTANCE) |
|
|
@ -127,6 +131,9 @@ class OtherConfigFragment : BasePreferenceFragment(), |
|
|
|
App.INSTANCE.startActivity(intent) |
|
|
|
App.INSTANCE.startActivity(intent) |
|
|
|
Process.killProcess(Process.myPid()) |
|
|
|
Process.killProcess(Process.myPid()) |
|
|
|
}, 1000) |
|
|
|
}, 1000) |
|
|
|
|
|
|
|
PreferKey.userAgent -> listView.post { |
|
|
|
|
|
|
|
upPreferenceSummary(PreferKey.userAgent, AppConfig.userAgent) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -145,6 +152,28 @@ class OtherConfigFragment : BasePreferenceFragment(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("InflateParams") |
|
|
|
|
|
|
|
private fun showUserAgentDialog() { |
|
|
|
|
|
|
|
alert("UserAgent") { |
|
|
|
|
|
|
|
var editText: AutoCompleteTextView? = null |
|
|
|
|
|
|
|
customView { |
|
|
|
|
|
|
|
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { |
|
|
|
|
|
|
|
edit_view.setText(AppConfig.userAgent) |
|
|
|
|
|
|
|
editText = edit_view |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
okButton { |
|
|
|
|
|
|
|
val userAgent = editText?.text?.toString() |
|
|
|
|
|
|
|
if (userAgent.isNullOrBlank()) { |
|
|
|
|
|
|
|
removePref(PreferKey.userAgent) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
putPrefString(PreferKey.userAgent, userAgent) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
noButton() |
|
|
|
|
|
|
|
}.show() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun clearCache() { |
|
|
|
private fun clearCache() { |
|
|
|
requireContext().alert( |
|
|
|
requireContext().alert( |
|
|
|
titleResource = R.string.clear_cache, |
|
|
|
titleResource = R.string.clear_cache, |
|
|
|