summaryrefslogtreecommitdiff
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
parent6738a3f17cb38febfa1c698d6b420aed9e17ad74 (diff)
Progress spinning bar for user session status
Copy changes to xlarge layout.
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java35
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java5
-rw-r--r--app/src/main/res/layout-xlarge/dashboard.xml22
-rw-r--r--app/src/main/res/layout/dashboard.xml32
4 files changed, 77 insertions, 17 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();
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 @@
</LinearLayout>
</LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="32dp">
+ <ProgressBar
+ android:id="@+id/user_session_status_progress"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:indeterminate="true"
+ android:visibility="gone"/>
+ <TextView
+ android:id="@+id/user_session_status"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="18sp"
+ android:layout_marginLeft="10dp"
+ android:ellipsize="marquee"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ />
+ </LinearLayout>
+
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
diff --git a/app/src/main/res/layout/dashboard.xml b/app/src/main/res/layout/dashboard.xml
index 4a9dd502..f4269fe2 100644
--- a/app/src/main/res/layout/dashboard.xml
+++ b/app/src/main/res/layout/dashboard.xml
@@ -33,17 +33,27 @@
</LinearLayout>
- <TextView
- android:id="@+id/user_session_status"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="18sp"
- android:layout_marginLeft="10dp"
- android:ellipsize="marquee"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- />
-
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <ProgressBar
+ android:id="@+id/user_session_status_progress"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:indeterminate="true"
+ android:visibility="gone"/>
+ <TextView
+ android:id="@+id/user_session_status"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="18sp"
+ android:layout_marginLeft="10dp"
+ android:ellipsize="marquee"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ />
+ </LinearLayout>
+
<LinearLayout
android:id="@+id/servicesCollection"
android:layout_width="match_parent"