From e112720efcec91b354acd0e4fbe48e62860b0e8b Mon Sep 17 00:00:00 2001 From: Tryton Van Meer Date: Fri, 5 May 2017 12:19:11 -0400 Subject: [PATCH 1/2] logout() now creates a dialog asking the user if they wish to logout. --- .../com/keylesspalace/tusky/MainActivity.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index c93bb5ed..c9ad6b85 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -16,6 +16,7 @@ package com.keylesspalace.tusky; import android.app.NotificationManager; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; @@ -30,6 +31,7 @@ import android.support.design.widget.TabLayout; import android.support.graphics.drawable.VectorDrawableCompat; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; +import android.support.v7.app.AlertDialog; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; @@ -337,16 +339,26 @@ public class MainActivity extends BaseActivity implements SFragment.OnUserRemove } private void logout() { - if (arePushNotificationsEnabled()) disablePushNotifications(); + new AlertDialog.Builder(this) + .setTitle(R.string.action_logout) + .setMessage(R.string.action_logout_confirm) + .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (arePushNotificationsEnabled()) disablePushNotifications(); - getPrivatePreferences().edit() - .remove("domain") - .remove("accessToken") - .apply(); + getPrivatePreferences().edit() + .remove("domain") + .remove("accessToken") + .apply(); - Intent intent = new Intent(MainActivity.this, LoginActivity.class); - startActivity(intent); - finish(); + Intent intent = new Intent(MainActivity.this, LoginActivity.class); + startActivity(intent); + finish(); + } + }) + .setNegativeButton(android.R.string.no, null) + .show(); } private void setupSearchView() { From ff88e6c280c1ff0b32cfbfa6aa5c3c09c714d653 Mon Sep 17 00:00:00 2001 From: Tryton Van Meer Date: Fri, 5 May 2017 12:19:34 -0400 Subject: [PATCH 2/2] Added string 'action_logout_confirm' --- app/src/main/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5a8f3573..53a75910 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -59,6 +59,7 @@ Compose Login with Mastodon Log Out + Do you wish to logout Follow Unfollow Block