summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java38
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/SessionDialog.java20
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java3
3 files changed, 35 insertions, 26 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index a8f6e110..7c5e5421 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -1,6 +1,6 @@
/**
* Copyright (c) 2013 LEAP Encryption Access Project and contributers
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -37,7 +37,7 @@ import se.leap.bitmaskclient.eip.*;
/**
* The main user facing Activity of Bitmask Android, consisting of status, controls,
* and access to preferences.
- *
+ *
* @author Sean Leonard <meanderingcode@aetherislands.net>
* @author parmegv
*/
@@ -202,7 +202,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
})
.show();
}
-
+
/**
* Inflates permanent UI elements of the View and contains logic for what
* service dependent UI elements to include.
@@ -248,7 +248,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
getMenuInflater().inflate(R.menu.client_dashboard, menu);
return true;
}
-
+
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()){
@@ -279,7 +279,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
public void showAbout() {
Intent intent = new Intent(this, AboutActivity.class);
- startActivity(intent);
+ startActivity(intent);
}
public void showLog() {
@@ -291,20 +291,20 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
public void signUp(String username, String password) {
User.setUserName(username);
Bundle parameters = bundlePassword(password);
- providerApiCommand(parameters, R.string.signingup_message, ProviderAPI.SIGN_UP);
+ providerApiCommand(parameters, 0, ProviderAPI.SIGN_UP);
}
@Override
public void logIn(String username, String password) {
User.setUserName(username);
Bundle parameters = bundlePassword(password);
- providerApiCommand(parameters, R.string.authenticating_message, ProviderAPI.LOG_IN);
+ providerApiCommand(parameters, 0, ProviderAPI.LOG_IN);
}
-
+
public void logOut() {
- providerApiCommand(Bundle.EMPTY, R.string.logout_message, ProviderAPI.LOG_OUT);
+ providerApiCommand(Bundle.EMPTY, 0, ProviderAPI.LOG_OUT);
}
-
+
@Override
public void update (Observable observable, Object data) {
if(observable instanceof UserSessionStatus) {
@@ -374,7 +374,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE);
setStatusMessage(progressbar_message_resId);
}
-
+
Intent command = prepareProviderAPICommand(parameters, providerApi_action);
startService(command);
}
@@ -382,9 +382,9 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
private Intent prepareProviderAPICommand(Bundle parameters, String action) {
providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
providerAPI_result_receiver.setReceiver(this);
-
+
Intent command = new Intent(this, ProviderAPI.class);
-
+
command.putExtra(ProviderAPI.PARAMETERS, parameters);
command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
command.setAction(action);
@@ -394,12 +394,16 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
public void cancelLoginOrSignup() {
EipStatus.getInstance().setConnectedOrDisconnected();
}
-
+
public void sessionDialog(Bundle resultData) {
-
+
FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG);
DialogFragment newFragment = new SessionDialog();
+ if(provider.getName().equalsIgnoreCase("riseup")) {
+ resultData = resultData == Bundle.EMPTY ? new Bundle() : resultData;
+ resultData.putBoolean(SessionDialog.ERRORS.RISEUP_WARNING.toString(), true);
+ }
if(resultData != null && !resultData.isEmpty()) {
newFragment.setArguments(resultData);
}
@@ -408,7 +412,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
private void switchProvider() {
if (provider.hasEIP()) eip_fragment.stopEipIfPossible();
-
+
preferences.edit().clear().apply();
switching_provider = false;
startActivityForResult(new Intent(this, ConfigurationWizard.class), SWITCH_PROVIDER);
@@ -454,7 +458,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
public static Context getContext() {
return app;
}
-
+
@Override
public void startActivityForResult(Intent intent, int requestCode) {
intent.putExtra(Dashboard.REQUEST_CODE, requestCode);
diff --git a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java
index 9025564b..91e56330 100644
--- a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java
@@ -26,8 +26,6 @@ import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
-import org.jetbrains.annotations.NotNull;
-
import butterknife.ButterKnife;
import butterknife.InjectView;
@@ -48,8 +46,11 @@ public class SessionDialog extends DialogFragment{
final public static String USERNAME = "username";
final public static String PASSWORD = "password";
- final public static String USERNAME_MISSING = "username missing";
- final public static String PASSWORD_INVALID_LENGTH = "password_invalid_length";
+ public static enum ERRORS {
+ USERNAME_MISSING,
+ PASSWORD_INVALID_LENGTH,
+ RISEUP_WARNING
+ }
@InjectView(R.id.user_message)
TextView user_message;
@@ -105,18 +106,21 @@ public class SessionDialog extends DialogFragment{
private void setUp(Bundle arguments) {
is_eip_pending = arguments.getBoolean(EipFragment.IS_PENDING, false);
- if (arguments.containsKey(PASSWORD_INVALID_LENGTH))
+ if (arguments.containsKey(ERRORS.PASSWORD_INVALID_LENGTH.toString()))
password_field.setError(getString(R.string.error_not_valid_password_user_message));
- if (arguments.containsKey(USERNAME)) {
+ else if(arguments.containsKey(ERRORS.RISEUP_WARNING.toString())) {
+ user_message.setVisibility(TextView.VISIBLE);
+ user_message.setText(R.string.login_riseup_warning);
+ } if (arguments.containsKey(USERNAME)) {
String username = arguments.getString(USERNAME);
username_field.setText(username);
}
- if (arguments.containsKey(USERNAME_MISSING)) {
+ if (arguments.containsKey(ERRORS.USERNAME_MISSING.toString())) {
username_field.setError(getString(R.string.username_ask));
}
if(arguments.containsKey(getString(R.string.user_message)))
user_message.setText(arguments.getString(getString(R.string.user_message)));
- else
+ else if(user_message.getVisibility() != TextView.VISIBLE)
user_message.setVisibility(View.GONE);
if(!username_field.getText().toString().isEmpty() && password_field.isFocusable())
diff --git a/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java b/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java
index f533819b..db432a82 100644
--- a/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java
+++ b/app/src/main/java/se/leap/bitmaskclient/UserSessionStatus.java
@@ -30,7 +30,8 @@ public class UserSessionStatus extends Observable {
NOT_LOGGED_IN,
DIDNT_LOG_OUT,
LOGGING_IN,
- LOGGING_OUT
+ LOGGING_OUT,
+ SIGNING_UP
}
private static SessionStatus session_status = SessionStatus.NOT_LOGGED_IN;