summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-03-13 14:56:27 +0100
committerParménides GV <parmegv@sdf.org>2015-03-13 14:56:27 +0100
commitd3a4e1041b11d007ed9442a09cc6933c71251bc3 (patch)
tree4c12ce7fb287d619e8738bfb114796d872d9c321 /app/src/main/java
parent6738a3f17cb38febfa1c698d6b420aed9e17ad74 (diff)
Progress spinning bar for user session status
Copy changes to xlarge layout.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java35
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java5
2 files changed, 34 insertions, 6 deletions
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();