summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/User.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java27
-rw-r--r--app/src/main/res/values-es/arrays.xml18
-rw-r--r--app/src/main/res/values/arrays.xml17
6 files changed, 62 insertions, 18 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index ee64a1b3..4207872d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -78,7 +78,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
super.onCreate(savedInstanceState);
app = this;
- user_session_status = UserSessionStatus.getInstance();
+ user_session_status = UserSessionStatus.getInstance(getResources());
user_session_status.addObserver(this);
PRNGFixes.apply();
@@ -86,6 +86,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
handleVersion();
+ User.init();
restoreProvider(savedInstanceState);
if (provider == null || provider.getName().isEmpty())
@@ -109,7 +110,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
if (savedInstanceState != null)
if (savedInstanceState.containsKey(UserSessionStatus.TAG)) {
UserSessionStatus.SessionStatus status = (UserSessionStatus.SessionStatus) savedInstanceState.getSerializable(UserSessionStatus.TAG);
- user_session_status.updateStatus(status);
+ user_session_status.updateStatus(status, getResources());
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
index b961350e..1ced6d60 100644
--- a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
+++ b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
@@ -42,7 +42,6 @@ public class LeapSRPSession {
final public static String AUTHORIZATION_HEADER = "Authorization";
final public static String TAG = "Leap SRP session class tag";
- private User user;
private SRPParameters params;
private String username;
private String password;
diff --git a/app/src/main/java/se/leap/bitmaskclient/User.java b/app/src/main/java/se/leap/bitmaskclient/User.java
index 4bbd9a91..5b0bab47 100644
--- a/app/src/main/java/se/leap/bitmaskclient/User.java
+++ b/app/src/main/java/se/leap/bitmaskclient/User.java
@@ -17,12 +17,15 @@
package se.leap.bitmaskclient;
public class User {
- private static String user_name = "You";
+ private static String user_name;
private static User user;
+ public static int DEFAULT_CONJUGATION_PERSON = 1;
- public static User getInstance() {
+ public static User init() {
if (user == null) {
- user = new User();
+ String[] personal_pronouns = Dashboard.getContext().getResources().getStringArray(R.array.personal_pronouns);
+ String default_username = personal_pronouns[DEFAULT_CONJUGATION_PERSON];
+ user = new User(default_username);
}
return user;
}
@@ -31,7 +34,8 @@ public class User {
User.user_name = user_name;
}
- private User() {
+ private User(String user_name) {
+ User.user_name = user_name;
}
public static String userName() {
diff --git a/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java b/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java
index e43c8a25..ee818635 100644
--- a/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java
+++ b/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java
@@ -16,13 +16,14 @@
*/
package se.leap.bitmaskclient;
-import android.os.*;
+import android.content.res.*;
import java.util.*;
public class UserSessionStatus extends Observable {
public static String TAG = UserSessionStatus.class.getSimpleName();
private static UserSessionStatus current_status;
+ private static Resources resources;
public enum SessionStatus {
LOGGED_IN,
@@ -36,14 +37,15 @@ public class UserSessionStatus extends Observable {
private static SessionStatus session_status = SessionStatus.NOT_LOGGED_IN;
- public static UserSessionStatus getInstance() {
+ public static UserSessionStatus getInstance(Resources resources) {
if (current_status == null) {
- current_status = new UserSessionStatus();
+ current_status = new UserSessionStatus(resources);
}
return current_status;
}
- private UserSessionStatus() {
+ private UserSessionStatus(Resources resources) {
+ UserSessionStatus.resources = resources;
}
private void sessionStatus(SessionStatus session_status) {
@@ -59,8 +61,8 @@ public class UserSessionStatus extends Observable {
|| session_status == SessionStatus.LOGGING_OUT;
}
- public static void updateStatus(SessionStatus session_status) {
- current_status = getInstance();
+ public static void updateStatus(SessionStatus session_status, Resources resources) {
+ current_status = getInstance(resources);
current_status.sessionStatus(session_status);
current_status.setChanged();
current_status.notifyObservers();
@@ -76,11 +78,14 @@ public class UserSessionStatus extends Observable {
private String conjugateToBe(String subject) {
String conjugation = "";
- if(subject.equalsIgnoreCase("I"))
- conjugation = "am";
- else if(subject.equalsIgnoreCase("you") || subject.equalsIgnoreCase("we")|| subject.equalsIgnoreCase("they"))
- conjugation = "are";
- else conjugation = "is";
+ String[] personal_pronouns = resources.getStringArray(R.array.personal_pronouns);
+ String[] verb_to_be = resources.getStringArray(R.array.verb_to_be);
+ for (int i = 0; i < personal_pronouns.length ; i++)
+ if(subject.equalsIgnoreCase(personal_pronouns[i])) {
+ conjugation = verb_to_be[i];
+ break;
+ }
+ if(conjugation.isEmpty()) conjugation = verb_to_be[User.DEFAULT_CONJUGATION_PERSON];
return conjugation;
}
diff --git a/app/src/main/res/values-es/arrays.xml b/app/src/main/res/values-es/arrays.xml
index 045e125f..731330b2 100644
--- a/app/src/main/res/values-es/arrays.xml
+++ b/app/src/main/res/values-es/arrays.xml
@@ -1,3 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
+ <!-- Keep the order the same as the TYPE_ constants in VPNProfile -->
+ <string-array name="verb_to_be">
+ <item>soy</item>
+ <item>estás</item>
+ <item>está</item>
+ <item>estamos</item>
+ <item>estáis</item>
+ <item>están</item>
+ </string-array>
+
+ <string-array name="personal_pronouns">
+ <item>Yo</item>
+ <item>Tú</item>
+ <item>Él</item>
+ <item>Nosotros</item>
+ <item>Vosotros</item>
+ <item>Ellos</item>
+ </string-array>
</resources>
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 66f07a87..3c960442 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Keep the order the same as the TYPE_ constants in VPNProfile -->
+ <string-array name="verb_to_be">
+ <item>am</item>
+ <item>are</item>
+ <item>is</item>
+ <item>are</item>
+ <item>are</item>
+ <item>are</item>
+ </string-array>
+
+ <string-array name="personal_pronouns">
+ <item>I</item>
+ <item>You</item>
+ <item>He</item>
+ <item>We</item>
+ <item>You</item>
+ <item>They</item>
+ </string-array>
</resources>