Skip to content

Commit

Permalink
some improvements on deauthorize confirmation dialog (#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Aug 25, 2019
1 parent b73c900 commit ed7084d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,19 @@ class SettingsFragment : PreferenceFragmentCompat(),
addPreferencesFromResource(R.xml.preferences)

preferenceScreen.findPreference("oauth").setOnPreferenceClickListener {
// 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) { _, _ ->
if (oAuth.isAuthorized) {
context?.let {
AlertDialog.Builder(it)
.setMessage(R.string.oauth_remove_authorization_dialog_message)
.setPositiveButton(R.string.oauth_remove_authorization_confirmation) { _, _ ->
oAuth.saveConsumer(null)
}
.setNegativeButton(android.R.string.cancel, null)
.show()
} ?: fragmentManager?.let { OsmOAuthDialogFragment().show(it, OsmOAuthDialogFragment.TAG) }
}
} else {
fragmentManager?.let { OsmOAuthDialogFragment().show(it, OsmOAuthDialogFragment.TAG) }
}
true
}

Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<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="oauth_remove_authorization_dialog_message">"目前已連結OSM帳號,你想撤消嗎?"</string>
<string name="oauth_remove_authorization_confirmation">"撤消"</string>
<string name="loading">"載入中"</string>
<string name="retry">"重試"</string>
<string name="oauth_cancelled">"取消驗證"</string>
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<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="oauth_remove_authorization_dialog_message">"Do you want to remove the authorization for your OSM account?"</string>
<string name="oauth_remove_authorization_confirmation">"Remove"</string>
<string name="loading">"Loading"</string>
<string name="retry">"Retry"</string>
<string name="oauth_cancelled">"Authorization canceled"</string>
Expand Down

0 comments on commit ed7084d

Please sign in to comment.