diff options
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/User.java | 10 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java | 37 | ||||
-rw-r--r-- | app/src/main/res/values-es/strings.xml | 8 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 8 |
4 files changed, 51 insertions, 12 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/User.java b/app/src/main/java/se/leap/bitmaskclient/User.java index 5b0bab47..f3d3b8b1 100644 --- a/app/src/main/java/se/leap/bitmaskclient/User.java +++ b/app/src/main/java/se/leap/bitmaskclient/User.java @@ -17,15 +17,13 @@ package se.leap.bitmaskclient; public class User { - private static String user_name; + private static String user_name = ""; private static User user; public static int DEFAULT_CONJUGATION_PERSON = 1; public static User init() { if (user == null) { - String[] personal_pronouns = Dashboard.getContext().getResources().getStringArray(R.array.personal_pronouns); - String default_username = personal_pronouns[DEFAULT_CONJUGATION_PERSON]; - user = new User(default_username); + user = new User(); } return user; } @@ -34,9 +32,7 @@ public class User { User.user_name = user_name; } - private User(String user_name) { - User.user_name = user_name; - } + private User() { } public static String userName() { return user_name; diff --git a/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java b/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java index ee818635..d5d53b6f 100644 --- a/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java +++ b/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java @@ -32,7 +32,26 @@ public class UserSessionStatus extends Observable { DIDNT_LOG_OUT, LOGGING_IN, LOGGING_OUT, - SIGNING_UP + SIGNING_UP; + + @Override + public String toString() { + int id = 0; + if(this == SessionStatus.LOGGED_IN) + id = R.string.logged_in_user_status; + else if(this == SessionStatus.LOGGED_OUT) + id = R.string.logged_out_user_status; + else if(this == SessionStatus.NOT_LOGGED_IN) + id = R.string.not_logged_in_user_status; + else if(this == SessionStatus.DIDNT_LOG_OUT) + id = R.string.didnt_log_out_user_status; + else if(this == SessionStatus.LOGGING_IN) + id = R.string.logging_in_user_status; + else if(this == SessionStatus.LOGGING_OUT) + id = R.string.logging_out_user_status; + + return resources.getString(id); + } } private static SessionStatus session_status = SessionStatus.NOT_LOGGED_IN; @@ -70,10 +89,20 @@ public class UserSessionStatus extends Observable { @Override public String toString() { - String username = User.userName(); + String user_session_status = User.userName(); + + String default_username = resources.getString(R.string.default_user, ""); + if(user_session_status.isEmpty() && !default_username.equalsIgnoreCase("null")) user_session_status = default_username; + user_session_status += " " + session_status.toString(); + + user_session_status = user_session_status.trim(); + if(User.userName().isEmpty()) + user_session_status = capitalize(user_session_status); + return user_session_status; + } - return username + " " + conjugateToBe(username) + " " - + session_status.toString().toLowerCase().replaceAll("_", " "); + private String capitalize(String to_be_capitalized) { + return to_be_capitalized.substring(0,1).toUpperCase() + to_be_capitalized.substring(1); } private String conjugateToBe(String subject) { diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index b9c01afa..47dc2bc8 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -74,4 +74,12 @@ <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"></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> + <string name="not_logged_in_user_status">no has iniciado sesión.</string> + <string name="logging_in_user_status">está iniciando sesión.</string> + <string name="logging_out_user_status">está cerrando sesión.</string> + </resources> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 47ff2832..ea2d74ae 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,7 +58,6 @@ <string name="signingup_message">Signing up</string> <string name="logout_message">Logging out from this session.</string> <string name="logged_out_message">Logged out.</string> - <string name="log_out_failed_message">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> <string name="login.riseup.warning">"Riseup users: You need to create a separate account to use the VPN service"</string> <string name="succesful_authentication_message">Authentication succeeded.</string> <string name="authentication_failed_message">Authentication failed.</string> @@ -73,4 +72,11 @@ <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">You</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> + <string name="not_logged_in_user_status">have not logged in.</string> + <string name="logging_in_user_status">is logging in.</string> + <string name="logging_out_user_status">is logging out.</string> </resources> |