Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deauthorize comfirmation dialog #1535

Merged
merged 1 commit into from
Aug 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,21 @@ class SettingsFragment : PreferenceFragmentCompat(),
addPreferencesFromResource(R.xml.preferences)

preferenceScreen.findPreference("oauth").setOnPreferenceClickListener {
fragmentManager?.let { OsmOAuthDialogFragment().show(it, OsmOAuthDialogFragment.TAG) }
// If OSM account is authorized, ask if user want to deauthorize it
// If not, just do OAuth
context?.takeIf { oAuth.isAuthorized }?.let {
val username = prefs.getString(Prefs.OSM_USER_NAME, null)
val message = if (username != null) getString(R.string.oauth_confirm_deauthroize_username, username)
else getString(R.string.oauth_confirm_deauthroize)

AlertDialog.Builder(it)
.setMessage(message)
.setPositiveButton(R.string.oauth_deauthroize_confirmation) { _, _ ->
oAuth.saveConsumer(null)
}
.setNegativeButton(android.R.string.cancel, null)
.show()
} ?: fragmentManager?.let { OsmOAuthDialogFragment().show(it, OsmOAuthDialogFragment.TAG) }
true
}

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<resources>
<string name="action_settings">"設定"</string>
<string name="oauth_communication_error">"無法連接到驗證伺服器"</string>
<string name="oauth_confirm_deauthroize_username">"目前驗證的OSM帳號為:%s,你想撤消嗎?"</string>
<string name="oauth_confirm_deauthroize">"目前已連結OSM帳號,你想撤消嗎?"</string>
<string name="oauth_deauthroize_confirmation">"撤消"</string>
<string name="loading">"載入中"</string>
<string name="retry">"重試"</string>
<string name="oauth_cancelled">"取消驗證"</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<resources>
<string name="action_settings">"Settings"</string>
<string name="oauth_communication_error">"Unable to reach the authorization server"</string>
<string name="oauth_confirm_deauthroize_username">"You are now linked with OSM account: %s, do you want to deauthorize it?"</string>
<string name="oauth_confirm_deauthroize">"You are now linked with an OSM account, do you want to deauthorize it?"</string>
<string name="oauth_deauthroize_confirmation">"deauthorize"</string>
<string name="loading">"Loading"</string>
<string name="retry">"Retry"</string>
<string name="oauth_cancelled">"Authorization canceled"</string>
Expand Down