From d3a4e1041b11d007ed9442a09cc6933c71251bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Fri, 13 Mar 2015 14:56:27 +0100 Subject: Progress spinning bar for user session status Copy changes to xlarge layout. --- .../main/java/se/leap/bitmaskclient/Dashboard.java | 35 ++++++++++++++++++---- .../se/leap/bitmaskclient/UserSessionStatus.java | 5 ++++ app/src/main/res/layout-xlarge/dashboard.xml | 22 ++++++++++++++ app/src/main/res/layout/dashboard.xml | 32 +++++++++++++------- 4 files changed, 77 insertions(+), 17 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index c6ac2477..28eb739c 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -63,6 +63,8 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn TextView provider_name; @InjectView(R.id.user_session_status) TextView user_session_status_text_view; + @InjectView(R.id.user_session_status_progress) + ProgressBar user_session_status_progress_bar; EipFragment eip_fragment; private Provider provider; @@ -313,12 +315,16 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn private void handleNewUserSessionStatus(UserSessionStatus status) { user_session_status = status; - if(provider.allowsRegistration()) + if(provider.allowsRegistration()) { + if(user_session_status.inProgress()) + showUserSessionProgressBar(); + else + hideUserSessionProgressBar(); changeSessionStatusMessage(user_session_status.toString()); + } } private void changeSessionStatusMessage(final String message) { - Log.d(TAG, message); runOnUiThread(new Runnable() { @Override public void run() { @@ -327,6 +333,24 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn }); } + private void showUserSessionProgressBar() { + runOnUiThread(new Runnable() { + @Override + public void run() { + user_session_status_progress_bar.setVisibility(ProgressBar.VISIBLE); + } + }); + } + + private void hideUserSessionProgressBar() { + runOnUiThread(new Runnable() { + @Override + public void run() { + user_session_status_progress_bar.setVisibility(ProgressBar.GONE); + } + }); + } + protected void downloadVpnCertificate() { boolean is_authenticated = LeapSRPSession.loggedIn(); boolean allowed_anon = preferences.getBoolean(Constants.ALLOWED_ANON, false); @@ -428,12 +452,11 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn } private void updateViewHidingProgressBar(int resultCode) { - changeStatusMessage(resultCode); - hideProgressBar(); + changeEipStatusMessage(resultCode); invalidateOptionsMenu(); } - private void changeStatusMessage(final int previous_result_code) { + private void changeEipStatusMessage(final int previous_result_code) { ResultReceiver status_receiver = new ResultReceiver(new Handler()){ protected void onReceiveResult(int resultCode, Bundle resultData){ super.onReceiveResult(resultCode, resultData); @@ -480,7 +503,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn startService(intent); } - private void hideProgressBar() { + private void hideEipProgressBar() { if(eip_fragment != null) { eip_fragment.progress_bar.setProgress(0); eip_fragment.progress_bar.setVisibility(ProgressBar.GONE); diff --git a/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java b/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java index bab57d04..f533819b 100644 --- a/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java +++ b/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java @@ -49,6 +49,11 @@ public class UserSessionStatus extends Observable { } public SessionStatus sessionStatus() { return session_status; } + + public boolean inProgress() { + return session_status == SessionStatus.LOGGING_IN + || session_status == SessionStatus.LOGGING_OUT; + } public static void updateStatus(SessionStatus session_status) { current_status = getInstance(); diff --git a/app/src/main/res/layout-xlarge/dashboard.xml b/app/src/main/res/layout-xlarge/dashboard.xml index bd644e1e..268bd3f9 100644 --- a/app/src/main/res/layout-xlarge/dashboard.xml +++ b/app/src/main/res/layout-xlarge/dashboard.xml @@ -52,6 +52,28 @@ + + + + + - - + + + + +