diff --git a/mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt b/mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt index 85a4e91136..19ee2477b1 100644 --- a/mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt +++ b/mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt @@ -30,6 +30,7 @@ import android.view.MenuItem import androidx.appcompat.app.AlertDialog import androidx.core.content.getSystemService import androidx.core.os.bundleOf +import androidx.preference.EditTextPreferenceDialogFragmentCompat import androidx.preference.Preference import androidx.preference.PreferenceDataStore import androidx.preference.SwitchPreference @@ -152,13 +153,17 @@ class ProfileConfigFragment : PreferenceFragmentCompat(), } override fun onDisplayPreferenceDialog(preference: Preference) { - if (preference.key == Key.pluginConfigure) { - val intent = PluginManager.buildIntent(pluginConfiguration.selected, PluginContract.ACTION_CONFIGURE) - if (intent.resolveActivity(requireContext().packageManager) == null) showPluginEditor() else - startActivityForResult(intent - .putExtra(PluginContract.EXTRA_OPTIONS, pluginConfiguration.selectedOptions.toString()), - REQUEST_CODE_PLUGIN_CONFIGURE) - } else super.onDisplayPreferenceDialog(preference) + when (preference.key) { + Key.password -> displayPreferenceDialog(EditTextPreferenceDialogFragmentCompat(), preference.key) + Key.pluginConfigure -> { + val intent = PluginManager.buildIntent(pluginConfiguration.selected, PluginContract.ACTION_CONFIGURE) + if (intent.resolveActivity(requireContext().packageManager) == null) showPluginEditor() else + startActivityForResult(intent + .putExtra(PluginContract.EXTRA_OPTIONS, pluginConfiguration.selectedOptions.toString()), + REQUEST_CODE_PLUGIN_CONFIGURE) + } + else -> super.onDisplayPreferenceDialog(preference) + } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { diff --git a/mobile/src/main/res/layout/preference_dialog_password.xml b/mobile/src/main/res/layout/preference_dialog_password.xml new file mode 100644 index 0000000000..1e77685b4a --- /dev/null +++ b/mobile/src/main/res/layout/preference_dialog_password.xml @@ -0,0 +1,40 @@ + + + + + + + + + + diff --git a/mobile/src/main/res/xml/pref_profile.xml b/mobile/src/main/res/xml/pref_profile.xml index b6265f69a1..68e038a13a 100644 --- a/mobile/src/main/res/xml/pref_profile.xml +++ b/mobile/src/main/res/xml/pref_profile.xml @@ -23,11 +23,10 @@ android:title="@string/remote_port"/>