|
|
@ -10,6 +10,7 @@ import androidx.preference.Preference |
|
|
|
import androidx.preference.PreferenceFragmentCompat |
|
|
|
import androidx.preference.PreferenceFragmentCompat |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
|
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
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 |
|
|
@ -35,7 +36,7 @@ class ConfigFragment : PreferenceFragmentCompat(), |
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { |
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { |
|
|
|
putPrefBoolean("process_text", isProcessTextEnabled()) |
|
|
|
putPrefBoolean("process_text", isProcessTextEnabled()) |
|
|
|
addPreferencesFromResource(R.xml.pref_config) |
|
|
|
addPreferencesFromResource(R.xml.pref_config) |
|
|
|
bindPreferenceSummaryToValue(findPreference("downloadPath")) |
|
|
|
bindPreferenceSummaryToValue(findPreference(PreferKey.downloadPath)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
@ -55,20 +56,22 @@ class ConfigFragment : PreferenceFragmentCompat(), |
|
|
|
|
|
|
|
|
|
|
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
|
|
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
|
|
|
when (preference?.key) { |
|
|
|
when (preference?.key) { |
|
|
|
"downloadPath" -> fragmentManager?.let { |
|
|
|
PreferKey.downloadPath -> FileChooserDialog.show( |
|
|
|
FileChooserDialog.show( |
|
|
|
childFragmentManager, |
|
|
|
it, |
|
|
|
downloadPath, |
|
|
|
downloadPath, |
|
|
|
mode = FileChooserDialog.DIRECTORY, |
|
|
|
mode = FileChooserDialog.DIRECTORY |
|
|
|
initPath = getPreferenceString(PreferKey.downloadPath) |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
when (key) { |
|
|
|
when (key) { |
|
|
|
"downloadPath" -> BookHelp.upDownloadPath() |
|
|
|
PreferKey.downloadPath -> { |
|
|
|
|
|
|
|
BookHelp.upDownloadPath() |
|
|
|
|
|
|
|
findPreference<Preference>(key)?.summary = getPreferenceString(key) |
|
|
|
|
|
|
|
} |
|
|
|
"recordLog" -> LogUtils.upLevel() |
|
|
|
"recordLog" -> LogUtils.upLevel() |
|
|
|
"process_text" -> sharedPreferences?.let { |
|
|
|
"process_text" -> sharedPreferences?.let { |
|
|
|
setProcessTextEnable(it.getBoolean("process_text", true)) |
|
|
|
setProcessTextEnable(it.getBoolean("process_text", true)) |
|
|
@ -102,7 +105,7 @@ class ConfigFragment : PreferenceFragmentCompat(), |
|
|
|
|
|
|
|
|
|
|
|
private fun getPreferenceString(key: String): String { |
|
|
|
private fun getPreferenceString(key: String): String { |
|
|
|
return when (key) { |
|
|
|
return when (key) { |
|
|
|
"downloadPath" -> getPrefString("downloadPath") |
|
|
|
PreferKey.downloadPath -> getPrefString(PreferKey.downloadPath) |
|
|
|
?: App.INSTANCE.getExternalFilesDir(null)?.absolutePath |
|
|
|
?: App.INSTANCE.getExternalFilesDir(null)?.absolutePath |
|
|
|
?: App.INSTANCE.cacheDir.absolutePath |
|
|
|
?: App.INSTANCE.cacheDir.absolutePath |
|
|
|
else -> getPrefString(key, "") |
|
|
|
else -> getPrefString(key, "") |
|
|
@ -129,6 +132,6 @@ class ConfigFragment : PreferenceFragmentCompat(), |
|
|
|
|
|
|
|
|
|
|
|
override fun onFilePicked(requestCode: Int, currentPath: String) { |
|
|
|
override fun onFilePicked(requestCode: Int, currentPath: String) { |
|
|
|
super.onFilePicked(requestCode, currentPath) |
|
|
|
super.onFilePicked(requestCode, currentPath) |
|
|
|
putPrefString("downloadPath", currentPath) |
|
|
|
putPrefString(PreferKey.downloadPath, currentPath) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |