summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-04-30 13:51:43 +0200
committerParménides GV <parmegv@sdf.org>2015-04-30 13:52:04 +0200
commit237e51e09ea7ae13c4cdf7fd9247447f6d75fb9a (patch)
tree955df579d3589ca6a74a7b86fea1ade0e10b2781 /app
parent9a54c425f6d96e1872899eabf78fb60082a8d234 (diff)
Works smoothly, correct texts.
Next step: beautify.
Diffstat (limited to 'app')
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java32
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java17
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java26
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/User.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatus.java (renamed from app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionStatus.java)20
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java (renamed from app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionFragment.java)111
-rw-r--r--app/src/main/res/layout/dashboard.xml2
-rw-r--r--app/src/main/res/layout/eip_service_fragment.xml1
-rw-r--r--app/src/main/res/layout/fragment_user_session.xml63
-rw-r--r--app/src/main/res/menu/client_dashboard.xml10
-rw-r--r--app/src/main/res/values-es/strings.xml2
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java16
14 files changed, 153 insertions, 156 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
index 7551091b..a41a1acf 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
@@ -161,20 +161,25 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
public void testLogInAndOut() {
changeProvider("demo.bitmask.net");
- clickLogIn();
+ clickUserSessionButton();
+ assertLoggedOut();
+ clickUserSessionButton();
logIn("parmegvtest1", " S_Zw3'-");
- assertSuccessfulLogin();
+ assertLoggedIn();
logOut();
}
- private void clickLogIn() {
- solo.clickOnView(getLogInButton());
+ private void clickUserSessionButton() {
+ solo.clickOnView(getUserSessionButton());
}
- private View getLogInButton() {
- return solo.getView(R.id.user_session_button);
+ private View getUserSessionButton() {
+ View view = solo.getView(R.id.user_status_button);
+ assertTrue(view != null);
+ return view;
}
+
private void logIn(String username, String password) {
solo.enterText(0, username);
solo.enterText(1, password);
@@ -182,11 +187,20 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
solo.waitForDialogToClose();
}
- private void assertSuccessfulLogin() {
- assertTrue(solo.waitForText(solo.getString(R.string.logged_in_user_status)));
+ private void assertLoggedIn() {
+ String log_out = solo.getString(R.string.logout_button);
+ solo.waitForText(log_out);
+ }
+
+ private void assertLoggedOut() {
+ String log_in = solo.getString(R.string.login_button);
+ solo.waitForText(log_in);
}
private void logOut() {
+ assertLoggedIn();
+ clickUserSessionButton();
+
solo.clickOnActionBarItem(R.string.logout_button);
assertTrue(solo.waitForDialogToClose());
}
@@ -245,7 +259,7 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
String text = solo.getString(R.string.signup_or_login_button);
clickAndWaitForDashboard(text);
logIn("parmegvtest10", "holahola2");
- assertSuccessfulLogin();
+ assertLoggedIn();
}
private void clickAndWaitForDashboard(String click_text) {
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
index 0896f9ec..2d7e13fe 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -40,7 +40,7 @@ import se.leap.bitmaskclient.ProviderListContent.*;
import se.leap.bitmaskclient.eip.*;
import se.leap.bitmaskclient.userstatus.SessionDialog;
import se.leap.bitmaskclient.userstatus.User;
-import se.leap.bitmaskclient.userstatus.UserSessionStatus;
+import se.leap.bitmaskclient.userstatus.UserStatus;
/**
* Implements HTTP api methods used to manage communications with the provider server.
@@ -148,7 +148,7 @@ public class ProviderAPI extends IntentService {
receiver.send(PROVIDER_NOK, result);
}
} else if (action.equalsIgnoreCase(SIGN_UP)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.SIGNING_UP, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.SIGNING_UP, resources);
Bundle result = tryToRegister(parameters);
if (result.getBoolean(RESULT_KEY)) {
receiver.send(SUCCESSFUL_SIGNUP, result);
@@ -156,23 +156,24 @@ public class ProviderAPI extends IntentService {
receiver.send(FAILED_SIGNUP, result);
}
} else if (action.equalsIgnoreCase(LOG_IN)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_IN, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_IN, resources);
Bundle result = tryToAuthenticate(parameters);
if (result.getBoolean(RESULT_KEY)) {
receiver.send(SUCCESSFUL_LOGIN, result);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_IN, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_IN, resources);
} else {
receiver.send(FAILED_LOGIN, result);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.NOT_LOGGED_IN, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.NOT_LOGGED_IN, resources);
}
} else if (action.equalsIgnoreCase(LOG_OUT)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_OUT, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_OUT, resources);
if (logOut()) {
receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_OUT, resources);
+ android.util.Log.d(TAG, "Logged out, notifying user status");
+ UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_OUT, resources);
} else {
receiver.send(LOGOUT_FAILED, Bundle.EMPTY);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.DIDNT_LOG_OUT, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.DIDNT_LOG_OUT, resources);
}
} else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) {
if (updateVpnCertificate()) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index f87c9f94..bf35d6c3 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -63,7 +63,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
TextView provider_name;
EipFragment eip_fragment;
- UserSessionFragment user_session_fragment;
+ UserStatusFragment user_status_fragment;
private static Provider provider = new Provider();
public ProviderAPIResultReceiver providerAPI_result_receiver;
private boolean switching_provider;
@@ -79,7 +79,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
handleVersion();
- User.init();
+ User.init(getString(R.string.default_username));
ProviderAPICommand.initialize(this);
providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), this);
@@ -89,7 +89,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
startActivityForResult(new Intent(this, ConfigurationWizard.class), CONFIGURE_LEAP);
else {
buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false));
- user_session_fragment.restoreSessionStatus(savedInstanceState);
+ user_status_fragment.restoreSessionStatus(savedInstanceState);
}
}
@@ -199,11 +199,11 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
provider_name.setText(provider.getDomain());
- user_session_fragment = new UserSessionFragment();
+ user_status_fragment = new UserStatusFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(Provider.ALLOW_REGISTRATION, provider.allowsRegistration());
- user_session_fragment.setArguments(bundle);
- fragment_manager.replace(R.id.user_session_fragment, user_session_fragment, UserSessionFragment.TAG);
+ user_status_fragment.setArguments(bundle);
+ fragment_manager.replace(R.id.user_status_fragment, user_status_fragment, UserStatusFragment.TAG);
if (provider.hasEIP()) {
fragment_manager.removePreviousFragment(EipFragment.TAG);
@@ -227,10 +227,6 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
public boolean onPrepareOptionsMenu(Menu menu) {
if (provider.allowsRegistration()) {
menu.findItem(R.id.signup_button).setVisible(true);
-
- boolean logged_in = User.loggedIn();
- menu.findItem(R.id.login_button).setVisible(!logged_in);
- menu.findItem(R.id.logout_button).setVisible(logged_in);
}
return true;
}
@@ -252,15 +248,9 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
return true;
case R.id.switch_provider:
switching_provider = true;
- if (User.loggedIn()) user_session_fragment.logOut();
+ if (User.loggedIn()) user_status_fragment.logOut();
else switchProvider();
return true;
- case R.id.login_button:
- sessionDialog(Bundle.EMPTY);
- return true;
- case R.id.logout_button:
- user_session_fragment.logOut();
- return true;
case R.id.signup_button:
sessionDialog(Bundle.EMPTY);
return true;
@@ -306,7 +296,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
if (resultCode == ProviderAPI.SUCCESSFUL_SIGNUP) {
String username = resultData.getString(SessionDialog.USERNAME);
String password = resultData.getString(SessionDialog.PASSWORD);
- user_session_fragment.logIn(username, password);
+ user_status_fragment.logIn(username, password);
} else if (resultCode == ProviderAPI.FAILED_SIGNUP) {
sessionDialog(resultData);
} else if (resultCode == ProviderAPI.SUCCESSFUL_LOGIN) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java
index 18f16301..f89418ba 100644
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/SessionDialog.java
@@ -167,7 +167,7 @@ public class SessionDialog extends DialogFragment {
super.onAttach(activity);
try {
- interface_with_Dashboard = (SessionDialogInterface) activity.getFragmentManager().findFragmentById(R.id.user_session_fragment);;
+ interface_with_Dashboard = (SessionDialogInterface) activity.getFragmentManager().findFragmentById(R.id.user_status_fragment);;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement LogInDialogListener");
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/User.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/User.java
index 716e2ed6..64ce0629 100644
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/User.java
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/User.java
@@ -19,12 +19,13 @@ package se.leap.bitmaskclient.userstatus;
import se.leap.bitmaskclient.LeapSRPSession;
public class User {
- private static String user_name = "";
+ private static String user_name;
private static User user;
- public static User init() {
+ public static User init(String default_username) {
if (user == null) {
user = new User();
+ user.setUserName(default_username);
}
return user;
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionStatus.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatus.java
index dec0e719..edfed8d6 100644
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionStatus.java
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatus.java
@@ -22,9 +22,9 @@ import java.util.*;
import se.leap.bitmaskclient.R;
-public class UserSessionStatus extends Observable {
- public static String TAG = UserSessionStatus.class.getSimpleName();
- private static UserSessionStatus current_status;
+public class UserStatus extends Observable {
+ public static String TAG = UserStatus.class.getSimpleName();
+ private static UserStatus current_status;
private static Resources resources;
public enum SessionStatus {
@@ -58,17 +58,17 @@ public class UserSessionStatus extends Observable {
}
}
- private static SessionStatus session_status = SessionStatus.NOT_LOGGED_IN;
+ private static SessionStatus session_status = SessionStatus.LOGGED_OUT;
- public static UserSessionStatus getInstance(Resources resources) {
+ public static UserStatus getInstance(Resources resources) {
if (current_status == null) {
- current_status = new UserSessionStatus(resources);
+ current_status = new UserStatus(resources);
}
return current_status;
}
- private UserSessionStatus(Resources resources) {
- UserSessionStatus.resources = resources;
+ private UserStatus(Resources resources) {
+ UserStatus.resources = resources;
}
private void sessionStatus(SessionStatus session_status) {
@@ -85,7 +85,7 @@ public class UserSessionStatus extends Observable {
}
public boolean isLoggedIn() {
- return session_status == SessionStatus.LOGGING_IN;
+ return session_status == SessionStatus.LOGGED_IN;
}
public boolean isLoggedOut() {
@@ -103,7 +103,7 @@ public class UserSessionStatus extends Observable {
public String toString() {
String user_session_status = User.userName();
- String default_username = resources.getString(R.string.default_user, "");
+ String default_username = resources.getString(R.string.default_username, "");
if(user_session_status.isEmpty() && !default_username.equalsIgnoreCase("null")) user_session_status = default_username;
user_session_status += " " + session_status.toString();
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionFragment.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
index dc334c3d..0766dbd5 100644
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserSessionFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
@@ -10,37 +10,38 @@ import org.jetbrains.annotations.NotNull;
import java.util.*;
import butterknife.*;
+import mbanje.kurt.fabbutton.FabButton;
import se.leap.bitmaskclient.*;
import se.leap.bitmaskclient.eip.EipStatus;
-public class UserSessionFragment extends Fragment implements Observer, SessionDialog.SessionDialogInterface {
+public class UserStatusFragment extends Fragment implements Observer, SessionDialog.SessionDialogInterface {
- public static String TAG = UserSessionFragment.class.getSimpleName();
+ public static String TAG = UserStatusFragment.class.getSimpleName();
private static Dashboard dashboard;
private ProviderAPIResultReceiver providerAPI_result_receiver;
- @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;
- @InjectView(R.id.user_session_button)
- Button main_button;
+ @InjectView(R.id.user_status_username)
+ TextView username;
+ @InjectView(R.id.user_status_icon)
+ FabButton icon;
+ @InjectView(R.id.user_status_button)
+ Button button;
- private UserSessionStatus user_session_status;
+ private UserStatus status;
private boolean allows_registration = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- user_session_status = UserSessionStatus.getInstance(getResources());
- user_session_status.addObserver(this);
+ status = UserStatus.getInstance(getResources());
+ status.addObserver(this);
}
@Override
public void onSaveInstanceState(@NotNull Bundle outState) {
- if (user_session_status_text_view != null && user_session_status_text_view.getVisibility() == TextView.VISIBLE)
- outState.putSerializable(UserSessionStatus.TAG, user_session_status.sessionStatus());
+ if (username != null && username.getVisibility() == TextView.VISIBLE)
+ outState.putSerializable(UserStatus.TAG, status.sessionStatus());
super.onSaveInstanceState(outState);
}
@@ -54,7 +55,7 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
Bundle arguments = getArguments();
allows_registration = arguments.getBoolean(Provider.ALLOW_REGISTRATION);
- handleNewUserSessionStatus(user_session_status);
+ handleNewStatus(status);
return view;
}
@@ -62,7 +63,7 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
@Override
public void onDestroyView() {
super.onDestroyView();
- Fragment fragment = (getFragmentManager().findFragmentById(R.id.user_session_fragment));
+ Fragment fragment = (getFragmentManager().findFragmentById(R.id.user_status_fragment));
FragmentTransaction ft = getActivity().getFragmentManager().beginTransaction();
ft.remove(fragment);
ft.commit();
@@ -78,34 +79,40 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
public void restoreSessionStatus(Bundle savedInstanceState) {
if (savedInstanceState != null)
- if (savedInstanceState.containsKey(UserSessionStatus.TAG)) {
- UserSessionStatus.SessionStatus status = (UserSessionStatus.SessionStatus) savedInstanceState.getSerializable(UserSessionStatus.TAG);
- user_session_status.updateStatus(status, getResources());
+ if (savedInstanceState.containsKey(UserStatus.TAG)) {
+ UserStatus.SessionStatus status = (UserStatus.SessionStatus) savedInstanceState.getSerializable(UserStatus.TAG);
+ this.status.updateStatus(status, getResources());
}
}
- @OnClick(R.id.user_session_button)
- public void handleMainButton() {
- if(user_session_status.isLoggedIn())
+ @OnClick(R.id.user_status_button)
+ public void handleButton() {
+ android.util.Log.d(TAG, status.toString());
+ if(status.isLoggedIn())
logOut();
- else if(user_session_status.isLoggedOut())
+ else if(status.isLoggedOut())
dashboard.sessionDialog(Bundle.EMPTY);
- else if(user_session_status.inProgress())
+ else if(status.inProgress())
cancelLoginOrSignup();
}
@Override
public void update(Observable observable, Object data) {
- if (observable instanceof UserSessionStatus) {
- UserSessionStatus status = (UserSessionStatus) observable;
- handleNewUserSessionStatus(status);
+ if (observable instanceof UserStatus) {
+ final UserStatus status = (UserStatus) observable;
+ dashboard.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ handleNewStatus(status);
+ }
+ });
}
}
- private void handleNewUserSessionStatus(UserSessionStatus status) {
- user_session_status = status;
+ private void handleNewStatus(UserStatus status) {
+ this.status = status;
if (allows_registration) {
- if (user_session_status.inProgress())
+ if (this.status.inProgress())
showUserSessionProgressBar();
else
hideUserSessionProgressBar();
@@ -115,48 +122,27 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
}
private void showUserSessionProgressBar() {
- dashboard.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- user_session_status_progress_bar.setVisibility(ProgressBar.VISIBLE);
- }
- });
+ icon.showProgress(true);
}
private void hideUserSessionProgressBar() {
- dashboard.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- user_session_status_progress_bar.setVisibility(ProgressBar.GONE);
- }
- });
+ icon.showProgress(false);
}
private void changeMessage() {
- final String message = user_session_status.toString();
- dashboard.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- user_session_status_text_view.setText(message);
- }
- });
+ final String message = User.userName();
+ username.setText(message);
}
private void updateButton() {
- if(User.loggedIn())
- dashboard.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- main_button.setText(dashboard.getString(R.string.logout_button));
- }
- });
- else if(allows_registration)
- dashboard.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- main_button.setText(dashboard.getString(R.string.login_button));
- }
- });
+ if(status.isLoggedIn())
+ button.setText(dashboard.getString(R.string.logout_button));
+ else if(allows_registration) {
+ if (status.isLoggedOut())
+ button.setText(dashboard.getString(R.string.login_button));
+ else if (status.inProgress())
+ button.setText(dashboard.getString(android.R.string.cancel));
+ }
}
@@ -175,6 +161,7 @@ public class UserSessionFragment extends Fragment implements Observer, SessionDi
}
public void logOut() {
+ android.util.Log.d(TAG, "Log out");
ProviderAPICommand.execute(Bundle.EMPTY, ProviderAPI.LOG_OUT, providerAPI_result_receiver);
}
diff --git a/app/src/main/res/layout/dashboard.xml b/app/src/main/res/layout/dashboard.xml
index 95445d63..6a9bbe97 100644
--- a/app/src/main/res/layout/dashboard.xml
+++ b/app/src/main/res/layout/dashboard.xml
@@ -20,7 +20,7 @@
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
- android:id="@+id/user_session_fragment"
+ android:id="@+id/user.status.fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"/>
diff --git a/app/src/main/res/layout/eip_service_fragment.xml b/app/src/main/res/layout/eip_service_fragment.xml
index 1360b8e0..06b514d3 100644
--- a/app/src/main/res/layout/eip_service_fragment.xml
+++ b/app/src/main/res/layout/eip_service_fragment.xml
@@ -40,7 +40,6 @@
class="mbanje.kurt.fabbutton.FabButton"
android:layout_gravity="center"
android:visibility="visible"
- android:layout_centerInParent="true"
android:indeterminate="true"
android:max="100"
fbb_autoStart="true"
diff --git a/app/src/main/res/layout/fragment_user_session.xml b/app/src/main/res/layout/fragment_user_session.xml
index 0d2a1840..81e68199 100644
--- a/app/src/main/res/layout/fragment_user_session.xml
+++ b/app/src/main/res/layout/fragment_user_session.xml
@@ -1,36 +1,51 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- tools:context="se.leap.bitmaskclient.userstatus.UserSessionFragment">
+ android:layout_marginTop="10dp"
+ tools:context="se.leap.bitmaskclient.userstatus.UserStatusFragment">
+
+ <TextView
+ android:id="@+id/user.status.username"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="18sp"
+ android:layout_marginLeft="10dp"
+ android:layout_marginStart="10dp"
+ android:layout_marginTop="6dp"
+ android:layout_marginBottom="6dp"
+ android:layout_centerHorizontal="true"
+ android:text="@string/default_username"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="wrap_content"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:layout_below="@id/user.status.username"
+ android:layout_centerInParent="true">
- <ProgressBar
- android:id="@+id/user_session_status_progress"
+ <Button
+ android:id="@+id/user.status.button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:indeterminate="true"/>
+ />
- <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:layout_marginStart="10dp"
- android:ellipsize="marquee"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceMedium" />
+ <view
+ android:id="@+id/user.status.icon"
+ android:layout_width="32dp"
+ android:layout_height="32dp"
+ android:layout_marginLeft="3dp"
+ android:layout_marginStart="3dp"
+ android:color="@android:color/holo_blue_dark"
+ class="mbanje.kurt.fabbutton.FabButton"
+ android:layout_gravity="center"
+ android:visibility="visible"
+ android:indeterminate="true"
+ android:max="100"
+ fbb_autoStart="true"
+ fbb_progressColor="#ff170aff"
+ fbb_progressWidthRatio="0.1"
+ />
</LinearLayout>
-
- <Button
- android:id="@+id/user_session_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- />
-</LinearLayout>
+</RelativeLayout>
diff --git a/app/src/main/res/menu/client_dashboard.xml b/app/src/main/res/menu/client_dashboard.xml
index 9bc39d7b..e0336cc0 100644
--- a/app/src/main/res/menu/client_dashboard.xml
+++ b/app/src/main/res/menu/client_dashboard.xml
@@ -15,15 +15,5 @@
android:id="@+id/signup_button"
android:title="@string/signup_button"
android:visible="false"/>
- <item
- android:id="@+id/login_button"
- android:showAsAction="ifRoom"
- android:title="@string/login_button"
- android:visible="false"/>
- <item
- android:id="@+id/logout_button"
- android:showAsAction="ifRoom"
- android:title="@string/logout_button"
- android:visible="false"/>
</menu>
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index c125b8bc..7f0670b8 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -69,7 +69,7 @@
<string name="eip_state_connected">Conexión protegida.</string>
<string name="provider_problem">Parece que hay un problema con el proveedor.</string>
<string name="try_another_provider">Prueba con otro proveedor, o contacta con este.</string>
- <string name="default_user">Anónimo</string>
+ <string name="default_username">Anónimo</string>
<string name="logged_in_user_status">inició sesión.</string>
<string name="logged_out_user_status">cerró la sesión.</string>
<string name="didnt_log_out_user_status">no cerró la sesión.</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 06670aee..7746795e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -67,7 +67,7 @@
<string name="eip_state_connected">Connection Secure.</string>
<string name="provider_problem">It seems there is a problem with the provider.</string>
<string name="try_another_provider">Please try another provider, or contact yours.</string>
- <string name="default_user">Anonymous</string>
+ <string name="default_username">Anonymous</string>
<string name="logged_in_user_status">is logged in.</string>
<string name="logged_out_user_status">logged out.</string>
<string name="didnt_log_out_user_status">didn\'t log out. Try later, it may be a problem in the network or in the provider. If the problem persists, then wipe Bitmask data from the Android settings</string>
diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java
index 917fc966..a3f7db6a 100644
--- a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -39,7 +39,7 @@ import org.thoughtcrime.ssl.pinning.util.*;
import se.leap.bitmaskclient.eip.*;
import se.leap.bitmaskclient.userstatus.SessionDialog;
import se.leap.bitmaskclient.userstatus.User;
-import se.leap.bitmaskclient.userstatus.UserSessionStatus;
+import se.leap.bitmaskclient.userstatus.UserStatus;
/**
* Implements HTTP api methods used to manage communications with the provider server.
@@ -143,7 +143,7 @@ public class ProviderAPI extends IntentService {
}
}
} else if (action.equalsIgnoreCase(SIGN_UP)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.SIGNING_UP, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.SIGNING_UP, resources);
Bundle result = tryToRegister(parameters);
if (result.getBoolean(RESULT_KEY)) {
receiver.send(SUCCESSFUL_SIGNUP, result);
@@ -151,23 +151,23 @@ public class ProviderAPI extends IntentService {
receiver.send(FAILED_SIGNUP, result);
}
} else if (action.equalsIgnoreCase(LOG_IN)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_IN, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_IN, resources);
Bundle result = tryToAuthenticate(parameters);
if (result.getBoolean(RESULT_KEY)) {
receiver.send(SUCCESSFUL_LOGIN, result);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_IN, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_IN, resources);
} else {
receiver.send(FAILED_LOGIN, result);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.NOT_LOGGED_IN, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.NOT_LOGGED_IN, resources);
}
} else if (action.equalsIgnoreCase(LOG_OUT)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_OUT, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_OUT, resources);
if (logOut()) {
receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_OUT, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_OUT, resources);
} else {
receiver.send(LOGOUT_FAILED, Bundle.EMPTY);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.DIDNT_LOG_OUT, resources);
+ UserStatus.updateStatus(UserStatus.SessionStatus.DIDNT_LOG_OUT, resources);
}
} else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) {
if (updateVpnCertificate()) {