summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java17
-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
-rw-r--r--app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java16
8 files changed, 81 insertions, 32 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
index 0b24e1c9..b0df5ab8 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -18,6 +18,7 @@ package se.leap.bitmaskclient;
import android.app.*;
import android.content.*;
+import android.content.res.*;
import android.os.*;
import android.util.*;
@@ -87,6 +88,7 @@ public class ProviderAPI extends IntentService {
private static boolean go_ahead = true;
private static SharedPreferences preferences;
private static String provider_api_url;
+ private Resources resources;
public static void stop() {
go_ahead = false;
@@ -101,6 +103,7 @@ public class ProviderAPI extends IntentService {
super.onCreate();
preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
+ resources = getResources();
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ORIGINAL_SERVER));
}
@@ -141,7 +144,7 @@ public class ProviderAPI extends IntentService {
}
}
} else if (action.equalsIgnoreCase(SIGN_UP)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.SIGNING_UP);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.SIGNING_UP, resources);
Bundle result = tryToRegister(parameters);
if (result.getBoolean(RESULT_KEY)) {
receiver.send(SUCCESSFUL_SIGNUP, result);
@@ -149,23 +152,23 @@ public class ProviderAPI extends IntentService {
receiver.send(FAILED_SIGNUP, result);
}
} else if (action.equalsIgnoreCase(LOG_IN)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_IN);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_IN, resources);
Bundle result = tryToAuthenticate(parameters);
if (result.getBoolean(RESULT_KEY)) {
receiver.send(SUCCESSFUL_LOGIN, result);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_IN);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_IN, resources);
} else {
receiver.send(FAILED_LOGIN, result);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.NOT_LOGGED_IN);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.NOT_LOGGED_IN, resources);
}
} else if (action.equalsIgnoreCase(LOG_OUT)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_OUT);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_OUT, resources);
if (logOut()) {
receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_OUT);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_OUT, resources);
} else {
receiver.send(LOGOUT_FAILED, Bundle.EMPTY);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.DIDNT_LOG_OUT);
+ UserSessionStatus.updateStatus(UserSessionStatus.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 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>
diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java
index 7cf80a4f..24e7df20 100644
--- a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -18,6 +18,7 @@ package se.leap.bitmaskclient;
import android.app.*;
import android.content.*;
+import android.content.res.*;
import android.os.*;
import android.util.*;
@@ -86,6 +87,7 @@ public class ProviderAPI extends IntentService {
private static boolean go_ahead = true;
private static SharedPreferences preferences;
private static String provider_api_url;
+ private Resources resources;
public static void stop() {
go_ahead = false;
@@ -137,7 +139,7 @@ public class ProviderAPI extends IntentService {
}
}
} else if (action.equalsIgnoreCase(SIGN_UP)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.SIGNING_UP);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.SIGNING_UP, resources);
Bundle result = tryToRegister(parameters);
if (result.getBoolean(RESULT_KEY)) {
receiver.send(SUCCESSFUL_SIGNUP, result);
@@ -145,23 +147,23 @@ public class ProviderAPI extends IntentService {
receiver.send(FAILED_SIGNUP, result);
}
} else if (action.equalsIgnoreCase(LOG_IN)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_IN);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_IN, resources);
Bundle result = tryToAuthenticate(parameters);
if (result.getBoolean(RESULT_KEY)) {
receiver.send(SUCCESSFUL_LOGIN, result);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_IN);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_IN, resources);
} else {
receiver.send(FAILED_LOGIN, result);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.NOT_LOGGED_IN);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.NOT_LOGGED_IN, resources);
}
} else if (action.equalsIgnoreCase(LOG_OUT)) {
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_OUT);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGING_OUT, resources);
if (logOut()) {
receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_OUT);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.LOGGED_OUT, resources);
} else {
receiver.send(LOGOUT_FAILED, Bundle.EMPTY);
- UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.DIDNT_LOG_OUT);
+ UserSessionStatus.updateStatus(UserSessionStatus.SessionStatus.DIDNT_LOG_OUT, resources);
}
} else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) {
if (updateVpnCertificate()) {