From 47e0180aaaaa5ba2cd921ebd28221ab27fd51b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 1 Jun 2015 11:15:40 +0200 Subject: Update user session button correctly on failure --- .../main/java/se/leap/bitmaskclient/userstatus/UserStatus.java | 8 ++++++++ .../java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatus.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatus.java index edfed8d6..90ad0ffd 100644 --- a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatus.java +++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatus.java @@ -92,6 +92,14 @@ public class UserStatus extends Observable { return session_status == SessionStatus.LOGGED_OUT; } + public boolean notLoggedIn() { + return session_status == SessionStatus.NOT_LOGGED_IN; + } + + public boolean didntLogOut() { + return session_status == SessionStatus.DIDNT_LOG_OUT; + } + public static void updateStatus(SessionStatus session_status, Resources resources) { current_status = getInstance(resources); current_status.sessionStatus(session_status); diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java index f670553f..20189904 100644 --- a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java @@ -138,10 +138,10 @@ public class UserStatusFragment extends Fragment implements Observer, SessionDia } private void updateButton() { - if(status.isLoggedIn()) + if(status.isLoggedIn() || status.didntLogOut()) button.setText(dashboard.getString(R.string.logout_button)); else if(allows_registration) { - if (status.isLoggedOut()) + if (status.isLoggedOut() || status.notLoggedIn()) button.setText(dashboard.getString(R.string.login_button)); else if (status.inProgress()) button.setText(dashboard.getString(android.R.string.cancel)); -- cgit v1.2.3