Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #231 from wesleywiser/master

Issue #147 - Log out confirmation
  • Loading branch information...
commit 9619a651b7167ad43c06d1e61dc5597076114034 2 parents 5774a3b + af14961
@talklittle authored
View
4 res/values/strings.xml
@@ -27,6 +27,8 @@
<string name="no">No</string>
<string name="quit">Quit</string>
<string name="really_quit">Really quit?</string>
+ <string name="confirm_logout_title">Logout</string>
+ <string name="confirm_logout">Are you sure you want to logout?</string>
<string name="noThreads">No threads here</string>
<string name="noComments">No comments here</string>
@@ -147,7 +149,7 @@
<string name="pref_use_external_browser">Use external browser</string>
- <string name="pref_confirm_quit">Quit confirmation</string>
+ <string name="pref_confirm_quit">Quit/logout confirmation</string>
<string name="pref_save_history">Save browsing history</string>
View
14 src/com/andrewshu/android/reddit/settings/RedditSettings.java
@@ -52,7 +52,7 @@
private String homepage = Constants.FRONTPAGE_STRING;
private boolean useExternalBrowser = false;
private boolean showCommentGuideLines = true;
- private boolean confirmQuit = true;
+ private boolean confirmQuitOrLogout = true;
private boolean saveHistory = true;
private boolean alwaysShowNextPrevious = true;
@@ -135,7 +135,7 @@ public void saveRedditPreferences(Context context) {
editor.putBoolean(Constants.PREF_USE_EXTERNAL_BROWSER, this.useExternalBrowser);
// Show confirmation dialog when backing out of root Activity
- editor.putBoolean(Constants.PREF_CONFIRM_QUIT, this.confirmQuit);
+ editor.putBoolean(Constants.PREF_CONFIRM_QUIT, this.confirmQuitOrLogout);
// Save reddit history to Browser history
editor.putBoolean(Constants.PREF_SAVE_HISTORY, this.saveHistory);
@@ -205,7 +205,7 @@ public void loadRedditPreferences(Context context, HttpClient client) {
this.setUseExternalBrowser(sessionPrefs.getBoolean(Constants.PREF_USE_EXTERNAL_BROWSER, false));
// Show confirmation dialog when backing out of root Activity
- this.setConfirmQuit(sessionPrefs.getBoolean(Constants.PREF_CONFIRM_QUIT, true));
+ this.setConfirmQuitOrLogout(sessionPrefs.getBoolean(Constants.PREF_CONFIRM_QUIT, true));
// Save reddit history to Browser history
this.setSaveHistory(sessionPrefs.getBoolean(Constants.PREF_SAVE_HISTORY, true));
@@ -290,16 +290,16 @@ public void setShowCommentGuideLines(boolean showCommentGuideLines) {
this.showCommentGuideLines = showCommentGuideLines;
}
- public boolean isConfirmQuit() {
- return confirmQuit;
+ public boolean isConfirmQuitOrLogout() {
+ return confirmQuitOrLogout;
}
public boolean isSaveHistory() {
return saveHistory;
}
- public void setConfirmQuit(boolean confirmQuit) {
- this.confirmQuit = confirmQuit;
+ public void setConfirmQuitOrLogout(boolean confirmQuitOrLogout) {
+ this.confirmQuitOrLogout = confirmQuitOrLogout;
}
public void setSaveHistory(boolean saveHistory) {
View
30 src/com/andrewshu/android/reddit/threads/ThreadsListActivity.java
@@ -289,7 +289,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//Handle the back button
- if(mSettings.isConfirmQuit() && keyCode == KeyEvent.KEYCODE_BACK && isTaskRoot()) {
+ if(mSettings.isConfirmQuitOrLogout() && keyCode == KeyEvent.KEYCODE_BACK && isTaskRoot()) {
//Ask the user if they want to quit
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
@@ -1118,10 +1118,23 @@ public boolean onOptionsItemSelected(MenuItem item) {
showDialog(Constants.DIALOG_LOGIN);
break;
case R.id.logout_menu_id:
- Common.doLogout(mSettings, mClient, getApplicationContext());
- Toast.makeText(this, "You have been logged out.", Toast.LENGTH_SHORT).show();
- new MyDownloadThreadsTask(mSubreddit).execute();
- break;
+ if (mSettings.isConfirmQuitOrLogout()) {
+ // Ask the user if they want to logout
+ new AlertDialog.Builder(this)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setTitle(R.string.confirm_logout_title)
+ .setMessage(R.string.confirm_logout)
+ .setPositiveButton(R.string.yes,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int which) {
+ ThreadsListActivity.this.logout();
+ }
+ }).setNegativeButton(R.string.no, null).show();
+ } else {
+ logout();
+ }
+ break;
case R.id.refresh_menu_id:
CacheInfo.invalidateCachedSubreddit(getApplicationContext());
new MyDownloadThreadsTask(mSubreddit).execute();
@@ -1172,6 +1185,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
}
+
+ private void logout() {
+ Common.doLogout(mSettings, mClient, getApplicationContext());
+ Toast.makeText(this, "You have been logged out.", Toast.LENGTH_SHORT)
+ .show();
+ new MyDownloadThreadsTask(mSubreddit).execute();
+ }
@Override
protected Dialog onCreateDialog(int id) {
Please sign in to comment.
Something went wrong with that request. Please try again.