summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-04-10 10:39:51 +0200
committerParménides GV <parmegv@sdf.org>2015-04-10 10:39:51 +0200
commitf8f636d90a1110554eda858420e5052e88a250b4 (patch)
tree33ef55c923771a791e8a018d5a951c5393276694 /app/src/main/java/se/leap
parentc8d84fb5fdf1bc834c3ef26eacb4eb1df9ed3668 (diff)
Seems to work.
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/User.java10
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java37
2 files changed, 36 insertions, 11 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) {