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 @@ + +