summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-04-07 17:45:20 +0200
committerParménides GV <parmegv@sdf.org>2015-04-07 17:45:20 +0200
commitc8d84fb5fdf1bc834c3ef26eacb4eb1df9ed3668 (patch)
treebe47b6b6b7740c8a8ac83bbe08736812e9513ab6 /app/src/main/java
parentfe85613a73d48ebeadc7d35e8d346d68bd0b4fc0 (diff)
Trying to conjugate the Spanish verbs programmatically.
Diffstat (limited to 'app/src/main/java')
-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
4 files changed, 27 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;
}