From adf425a85458168407770a8f8971a153534f825c Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 11 Nov 2020 10:23:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/config/BackupConfigFragment.kt | 24 +++++++++++++++++-- app/src/main/res/menu/backup_restore.xml | 13 ++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/menu/backup_restore.xml diff --git a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt index 887efb63f..e792845bd 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt @@ -4,6 +4,9 @@ import android.content.Intent import android.content.SharedPreferences import android.os.Bundle import android.text.InputType +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import android.view.View import androidx.preference.EditTextPreference import androidx.preference.ListPreference @@ -57,13 +60,30 @@ class BackupConfigFragment : BasePreferenceFragment(), super.onViewCreated(view, savedInstanceState) preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this) ATH.applyEdgeEffectColor(listView) + setHasOptionsMenu(true) if (LocalConfig.isFirstOpenBackup) { - val text = String(requireContext().assets.open("help/webDavHelp.md").readBytes()) - TextDialog.show(childFragmentManager, text, TextDialog.MD) + showHelp() LocalConfig.isFirstOpen = false } } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + super.onCreateOptionsMenu(menu, inflater) + inflater.inflate(R.menu.backup_restore, menu) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.menu_help -> showHelp() + } + return super.onOptionsItemSelected(item) + } + + private fun showHelp() { + val text = String(requireContext().assets.open("help/webDavHelp.md").readBytes()) + TextDialog.show(childFragmentManager, text, TextDialog.MD) + } + override fun onDestroy() { super.onDestroy() preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this) diff --git a/app/src/main/res/menu/backup_restore.xml b/app/src/main/res/menu/backup_restore.xml new file mode 100644 index 000000000..02b6acbd0 --- /dev/null +++ b/app/src/main/res/menu/backup_restore.xml @@ -0,0 +1,13 @@ + + + + + +