From dbc1295be6f159e12b23f1f44b6b2b50959ddc37 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Fri, 7 Aug 2020 12:42:14 -0400 Subject: [PATCH] logout optimization --- .../main/java/awais/instagrabber/dialogs/SettingsDialog.java | 5 +++-- app/src/main/java/awais/instagrabber/utils/Utils.java | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java b/app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java index 519444c1..54f4feb6 100755 --- a/app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java +++ b/app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java @@ -185,11 +185,12 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V if (v == btnLogin) { startActivity(new Intent(v.getContext(), Login.class)); somethingChanged = true; + this.dismiss(); } else if (v == btnLogout) { Utils.setupCookies("LOGOUT"); - settingsHelper.putString(Constants.COOKIE, null); + settingsHelper.putString(Constants.COOKIE, ""); + somethingChanged = true; this.dismiss(); - activity.recreate(); } else if (v == btnImportExport) { if (ContextCompat.checkSelfPermission(activity, Utils.PERMS[0]) == PackageManager.PERMISSION_DENIED) requestPermissions(Utils.PERMS, 6007); diff --git a/app/src/main/java/awais/instagrabber/utils/Utils.java b/app/src/main/java/awais/instagrabber/utils/Utils.java index 1cc08efd..27a02fdd 100755 --- a/app/src/main/java/awais/instagrabber/utils/Utils.java +++ b/app/src/main/java/awais/instagrabber/utils/Utils.java @@ -123,12 +123,11 @@ public final class Utils { public static SimpleDateFormat datetimeParser; public static void setupCookies(final String cookieRaw) { + final CookieStore cookieStore = NET_COOKIE_MANAGER.getCookieStore(); if (cookieRaw == "LOGOUT") { - final CookieStore cookieStore = NET_COOKIE_MANAGER.getCookieStore(); cookieStore.removeAll(); } else if (cookieRaw != null && !isEmpty(cookieRaw)) { - final CookieStore cookieStore = NET_COOKIE_MANAGER.getCookieStore(); try { final URI uri1 = new URI("https://instagram.com"); final URI uri2 = new URI("https://instagram.com/");