summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2018-01-19 17:34:45 +0100
committerFup Duck <fupduck@sacknagel.com>2018-01-19 17:34:45 +0100
commitb065fa48e802487198ad73915dd017c4464e8c62 (patch)
treedf48491884de8e29c52db4794a3233fa34a4a6ff
parent1ccb2f9e1bcfaf8279ef9576b3bca233e37af61b (diff)
improve layout
* improve layout * gracefully handle orientation changes * respect small devices * set correct colors for buttons, error messages...
-rw-r--r--app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java34
-rw-r--r--app/src/insecure/res/layout/new_provider_dialog.xml2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java9
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java64
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java27
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/LoginActivity.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Provider.java10
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java344
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/SignupActivity.java36
-rw-r--r--app/src/main/res/layout-xlarge/a_provider_detail.xml (renamed from app/src/main/res/layout-xlarge/provider_detail_fragment.xml)0
-rw-r--r--app/src/main/res/layout/a_login.xml38
-rw-r--r--app/src/main/res/layout/a_provider_credentials.xml54
-rw-r--r--app/src/main/res/layout/a_provider_detail.xml (renamed from app/src/main/res/layout/provider_detail_fragment.xml)1
-rw-r--r--app/src/main/res/layout/a_signup.xml38
-rw-r--r--app/src/main/res/layout/provider_credentials.xml (renamed from app/src/main/res/layout/provider_credentials_login.xml)28
-rw-r--r--app/src/main/res/layout/provider_credentials_signup.xml24
-rw-r--r--app/src/main/res/values-v21/styles.xml2
-rw-r--r--app/src/main/res/values-v21/themes.xml2
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java27
19 files changed, 488 insertions, 254 deletions
diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java
index 8a5a6190..3e176fc1 100644
--- a/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -64,10 +64,10 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
public void showAndSelectProvider(String provider_main_url, boolean danger_on) {
try {
- selectedProvider = new Provider(new URL((provider_main_url)));
- adapter.add(selectedProvider);
+ provider = new Provider(new URL((provider_main_url)));
+ adapter.add(provider);
adapter.saveProviders();
- autoSelectProvider(selectedProvider, danger_on);
+ autoSelectProvider(provider, danger_on);
} catch (MalformedURLException e) {
e.printStackTrace();
}
@@ -75,7 +75,7 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
private void autoSelectProvider(Provider provider, boolean danger_on) {
preferences.edit().putBoolean(ProviderItem.DANGER_ON, danger_on).apply();
- selectedProvider = provider;
+ provider = provider;
onItemSelectedLogic();
showProgressBar();
}
@@ -87,24 +87,24 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
*/
public void setUpProvider(boolean danger_on) {
mConfigState.setAction(SETTING_UP_PROVIDER);
- Intent provider_API_command = new Intent(this, ProviderAPI.class);
+ Intent providerAPICommand = new Intent(this, ProviderAPI.class);
Bundle parameters = new Bundle();
- parameters.putString(Provider.MAIN_URL, selectedProvider.getMainUrl().toString());
+ parameters.putString(Provider.MAIN_URL, provider.getMainUrl().toString());
parameters.putBoolean(ProviderItem.DANGER_ON, danger_on);
- if (selectedProvider.hasCertificatePin()){
- parameters.putString(Provider.CA_CERT_FINGERPRINT, selectedProvider.certificatePin());
+ if (provider.hasCertificatePin()){
+ parameters.putString(Provider.CA_CERT_FINGERPRINT, provider.certificatePin());
}
- if (selectedProvider.hasCaCert()) {
- parameters.putString(Provider.CA_CERT, selectedProvider.getCaCert());
+ if (provider.hasCaCert()) {
+ parameters.putString(Provider.CA_CERT, provider.getCaCert());
}
- if (selectedProvider.hasDefinition()) {
- parameters.putString(Provider.KEY, selectedProvider.getDefinition().toString());
+ if (provider.hasDefinition()) {
+ parameters.putString(Provider.KEY, provider.getDefinition().toString());
}
- provider_API_command.setAction(ProviderAPI.SET_UP_PROVIDER);
- provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
+ providerAPICommand.setAction(ProviderAPI.SET_UP_PROVIDER);
+ providerAPICommand.putExtra(ProviderAPI.PARAMETERS, parameters);
- startService(provider_API_command);
+ startService(providerAPICommand);
}
/**
@@ -117,13 +117,13 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
addAndSelectNewProvider(ProviderAPI.lastProviderMainUrl(), ProviderAPI.lastDangerOn());
} else {
showProgressBar();
- adapter.hideAllBut(adapter.indexOf(selectedProvider));
+ adapter.hideAllBut(adapter.indexOf(provider));
Intent providerAPICommand = new Intent(this, ProviderAPI.class);
providerAPICommand.setAction(ProviderAPI.SET_UP_PROVIDER);
Bundle parameters = new Bundle();
- parameters.putString(Provider.MAIN_URL, selectedProvider.getMainUrl().toString());
+ parameters.putString(Provider.MAIN_URL, provider.getMainUrl().toString());
providerAPICommand.putExtra(ProviderAPI.PARAMETERS, parameters);
startService(providerAPICommand);
diff --git a/app/src/insecure/res/layout/new_provider_dialog.xml b/app/src/insecure/res/layout/new_provider_dialog.xml
index 19b8f442..8888a1d9 100644
--- a/app/src/insecure/res/layout/new_provider_dialog.xml
+++ b/app/src/insecure/res/layout/new_provider_dialog.xml
@@ -3,7 +3,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
-
+
<EditText
android:id="@+id/new_provider_url"
android:inputType="textUri"
diff --git a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
index c5a74490..cb5f334b 100644
--- a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
@@ -35,7 +35,7 @@ public abstract class AbstractProviderDetailActivity extends ConfigWizardBaseAct
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.provider_detail_fragment);
+ setContentView(R.layout.a_provider_detail);
try {
JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, ""));
@@ -73,6 +73,7 @@ public abstract class AbstractProviderDetailActivity extends ConfigWizardBaseAct
Log.d(TAG, "use anonymously selected");
intent = new Intent(getApplicationContext(), MainActivity.class);
}
+ intent.putExtra(PROVIDER_KEY, provider);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
}
@@ -82,6 +83,12 @@ public abstract class AbstractProviderDetailActivity extends ConfigWizardBaseAct
}
}
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ provider = intent.getParcelableExtra(PROVIDER_KEY);
+ }
+
private boolean anonAllowed(JSONObject providerJson) {
try {
JSONObject serviceDescription = providerJson.getJSONObject(Provider.SERVICE);
diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
index 8e4f1607..1025a64e 100644
--- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
@@ -80,10 +80,11 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
private ProviderManager providerManager;
protected Intent mConfigState = new Intent(PROVIDER_NOT_SET);
- protected Provider selectedProvider;
final public static String TAG = ConfigurationWizard.class.getSimpleName();
+ final private static String ACTIVITY_STATE = "ACTIVITY STATE";
+
final protected static String PROVIDER_NOT_SET = "PROVIDER NOT SET";
final protected static String SETTING_UP_PROVIDER = "PROVIDER GETS SET";
final private static String SHOWING_PROVIDER_DETAILS = "SHOWING PROVIDER DETAILS";
@@ -91,8 +92,6 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
final private static String REASON_TO_FAIL = "REASON TO FAIL";
final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
- final private static String ACTIVITY_STATE = "ACTIVITY STATE";
-
public ProviderAPIResultReceiver providerAPIResultReceiver;
private ProviderAPIBroadcastReceiver providerAPIBroadcastReceiver;
@@ -119,7 +118,7 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
//if (progressbarDescription != null)
// outState.putString(PROGRESSBAR_TEXT, progressbarDescription.getText().toString());
outState.putString(ACTIVITY_STATE, mConfigState.getAction());
- outState.putParcelable(Provider.KEY, selectedProvider);
+ outState.putParcelable(Provider.KEY, provider);
DialogFragment dialogFragment = (DialogFragment) fragmentManager.findFragmentByTag(DownloadFailedDialog.TAG);
if (dialogFragment != null) {
@@ -147,7 +146,7 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
private void restoreState(Bundle savedInstanceState) {
- selectedProvider = savedInstanceState.getParcelable(Provider.KEY);
+ provider = savedInstanceState.getParcelable(Provider.KEY);
mConfigState.setAction(savedInstanceState.getString(ACTIVITY_STATE, PROVIDER_NOT_SET));
reasonToFail = savedInstanceState.getString(REASON_TO_FAIL);
@@ -170,7 +169,7 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
isActivityShowing = true;
if (SETTING_UP_PROVIDER.equals(mConfigState.getAction())) {
showProgressBar();
- adapter.hideAllBut(adapter.indexOf(selectedProvider));
+ adapter.hideAllBut(adapter.indexOf(provider));
checkProviderSetUp();
} else if (PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())) {
showDownloadFailedDialog();
@@ -212,9 +211,9 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
try {
String providerJsonString = preferences.getString(Provider.KEY, "");
if (!providerJsonString.isEmpty())
- selectedProvider.define(new JSONObject(providerJsonString));
+ provider.define(new JSONObject(providerJsonString));
String caCert = preferences.getString(Provider.CA_CERT, "");
- selectedProvider.setCACert(caCert);
+ provider.setCACert(caCert);
} catch (JSONException e) {
e.printStackTrace();
}
@@ -267,7 +266,7 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
//TODO Code 2 pane view
mConfigState.setAction(SETTING_UP_PROVIDER);
- selectedProvider = adapter.getItem(position);
+ provider = adapter.getItem(position);
showProgressBar();
onItemSelectedLogic();
}
@@ -305,7 +304,7 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
providerAPICommand.setAction(ProviderAPI.UPDATE_PROVIDER_DETAILS);
Bundle parameters = new Bundle();
- parameters.putString(Provider.MAIN_URL, selectedProvider.getMainUrl().toString());
+ parameters.putString(Provider.MAIN_URL, provider.getMainUrl().toString());
providerAPICommand.putExtra(ProviderAPI.PARAMETERS, parameters);
startService(providerAPICommand);
@@ -391,6 +390,7 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
mConfigState.setAction(SHOWING_PROVIDER_DETAILS);
Intent intent = new Intent(this, ProviderDetailActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
+ intent.putExtra(PROVIDER_KEY, provider);
startActivity(intent);
}
}
@@ -417,38 +417,42 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity
public void cancelAndShowAllProviders() {
mConfigState.setAction(PROVIDER_NOT_SET);
- selectedProvider = null;
+ provider = null;
adapter.showAllProviders();
}
public class ProviderAPIBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
+ Log.d(TAG, "received Broadcast");
- if (action == null) {
+ String action = intent.getAction();
+ if (action == null || !action.equalsIgnoreCase(PROVIDER_API_EVENT)) {
return;
}
- // TODO check if correct provider given
- if (action.equalsIgnoreCase(PROVIDER_API_EVENT) && mConfigState.getAction() != null &&
+ if (mConfigState.getAction() != null &&
mConfigState.getAction().equalsIgnoreCase(SETTING_UP_PROVIDER)) {
int resultCode = intent.getIntExtra(RESULT_CODE, -1);
-
- switch (resultCode) {
- case PROVIDER_OK:
- handleProviderSetUp();
- break;
- case PROVIDER_NOK:
- handleProviderSetupFailed((Bundle) intent.getParcelableExtra(RESULT_KEY));
- break;
- case CORRECTLY_DOWNLOADED_CERTIFICATE:
- handleCorrectlyDownloadedCertificate();
- break;
- case INCORRECTLY_DOWNLOADED_CERTIFICATE:
- handleIncorrectlyDownloadedCertificate();
- break;
-
+ Log.d(TAG, "Broadcast resultCode: " + Integer.toString(resultCode));
+
+
+ if (getProviderName().equalsIgnoreCase(provider.getName()) &&
+ getProviderDomain().equalsIgnoreCase(provider.getDomain())) {
+ switch (resultCode) {
+ case PROVIDER_OK:
+ handleProviderSetUp();
+ break;
+ case PROVIDER_NOK:
+ handleProviderSetupFailed((Bundle) intent.getParcelableExtra(RESULT_KEY));
+ break;
+ case CORRECTLY_DOWNLOADED_CERTIFICATE:
+ handleCorrectlyDownloadedCertificate();
+ break;
+ case INCORRECTLY_DOWNLOADED_CERTIFICATE:
+ handleIncorrectlyDownloadedCertificate();
+ break;
+ }
}
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java
index 3e83d9bc..98715c1a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java
@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
+import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
@@ -14,10 +15,14 @@ import android.widget.LinearLayout;
import org.json.JSONException;
import org.json.JSONObject;
+import java.util.Locale;
+
import butterknife.InjectView;
+import se.leap.bitmaskclient.userstatus.SessionDialog;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
+import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
/**
@@ -45,10 +50,14 @@ public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity {
@InjectView(R.id.content)
protected LinearLayout content;
+ protected Provider provider;
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
+
+ provider = getIntent().getParcelableExtra(PROVIDER_KEY);
}
@Override
@@ -84,12 +93,26 @@ public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity {
protected String getProviderName() {
try {
JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, ""));
- return providerJson.getJSONObject(Provider.NAME).getString("en");
+ String lang = Locale.getDefault().getLanguage();
+ return providerJson.getJSONObject(Provider.NAME).getString(lang);
} catch (JSONException e) {
- return null;
+ try {
+ JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, ""));
+ return providerJson.getJSONObject(Provider.NAME).getString("en");
+ } catch (JSONException e2) {
+ return null;
+ }
}
}
+ protected String getProviderDomain() {
+ try {
+ JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, ""));
+ return providerJson.getString(Provider.DOMAIN);
+ } catch (JSONException e) {
+ return null;
+ }
+ }
protected void hideProgressBar() {
loadingScreen.setVisibility(GONE);
content.setVisibility(VISIBLE);
diff --git a/app/src/main/java/se/leap/bitmaskclient/LoginActivity.java b/app/src/main/java/se/leap/bitmaskclient/LoginActivity.java
index 06cf5b89..6ae288c2 100644
--- a/app/src/main/java/se/leap/bitmaskclient/LoginActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/LoginActivity.java
@@ -16,7 +16,6 @@ public class LoginActivity extends ProviderCredentialsBaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.a_login);
setProgressbarText(R.string.logging_in);
setProviderHeaderLogo(R.drawable.mask);
setProviderHeaderText(R.string.login_to_profile);
@@ -30,6 +29,7 @@ public class LoginActivity extends ProviderCredentialsBaseActivity {
@Override
@OnClick(R.id.button)
void handleButton() {
+ super.handleButton();
login(getUsername(), getPassword());
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/Provider.java b/app/src/main/java/se/leap/bitmaskclient/Provider.java
index 60b1b93c..95daccc6 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Provider.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Provider.java
@@ -158,9 +158,13 @@ public final class Provider implements Parcelable {
name = definition.getJSONObject(API_TERM_NAME).getString(lang);
else throw new JSONException("Provider not defined");
} catch (JSONException e) {
- if (mainUrl != null) {
- String host = mainUrl.getDomain();
- name = host.substring(0, host.indexOf("."));
+ try {
+ name = definition.getJSONObject(API_TERM_NAME).getString("en");
+ } catch (JSONException e2) {
+ if (mainUrl != null) {
+ String host = mainUrl.getDomain();
+ name = host.substring(0, host.indexOf("."));
+ }
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java
index c15481e5..1d1908a6 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java
@@ -1,18 +1,36 @@
package se.leap.bitmaskclient;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
-import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.design.widget.TextInputEditText;
+import android.support.design.widget.TextInputLayout;
import android.support.v7.widget.AppCompatButton;
+import android.support.v7.widget.AppCompatTextView;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.widget.TextView;
import butterknife.InjectView;
import butterknife.OnClick;
import se.leap.bitmaskclient.userstatus.SessionDialog;
+import se.leap.bitmaskclient.userstatus.SessionDialog.ERRORS;
import se.leap.bitmaskclient.userstatus.User;
+import static android.view.View.GONE;
+import static android.view.View.VISIBLE;
+import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
+import static se.leap.bitmaskclient.ProviderAPI.PROVIDER_API_EVENT;
+import static se.leap.bitmaskclient.ProviderAPI.RESULT_CODE;
+import static se.leap.bitmaskclient.ProviderAPI.RESULT_KEY;
+import static se.leap.bitmaskclient.userstatus.SessionDialog.USERNAME;
+
/**
* Base Activity for activities concerning a provider interaction
*
@@ -21,56 +39,168 @@ import se.leap.bitmaskclient.userstatus.User;
public abstract class ProviderCredentialsBaseActivity extends ConfigWizardBaseActivity {
- protected ProviderAPIResultReceiver providerAPIResultReceiver;
+ final protected static String TAG = ProviderCredentialsBaseActivity.class.getName();
+
+ final private static String ACTIVITY_STATE = "ACTIVITY STATE";
+
+ final private static String SHOWING_FORM = "SHOWING_FORM";
+ final private static String PERFORMING_ACTION = "PERFORMING_ACTION";
+ final private static String USER_MESSAGE = "USER_MESSAGE";
+ final private static String USERNAME_ERROR = "USERNAME_ERROR";
+ final private static String PASSWORD_ERROR = "PASSWORD_ERROR";
+ final private static String PASSWORD_VERIFICATION_ERROR = "PASSWORD_VERIFICATION_ERROR";
+
+ protected Intent mConfigState = new Intent(SHOWING_FORM);
+ protected ProviderAPIBroadcastReceiver providerAPIBroadcastReceiver;
+
+ @InjectView(R.id.provider_credentials_user_message)
+ AppCompatTextView userMessage;
@InjectView(R.id.provider_credentials_username)
- TextInputEditText providerCredentialsUsername;
+ TextInputEditText usernameField;
@InjectView(R.id.provider_credentials_password)
- TextInputEditText providerCredentialsPassword;
+ TextInputEditText passwordField;
+
+ @InjectView(R.id.provider_credentials_password_verification)
+ TextInputEditText passwordVerificationField;
+
+ @InjectView(R.id.provider_credentials_username_error)
+ TextInputLayout usernameError;
+
+ @InjectView(R.id.provider_credentials_password_error)
+ TextInputLayout passwordError;
+
+ @InjectView(R.id.provider_credentials_password_verification_error)
+ TextInputLayout passwordVerificationError;
@InjectView(R.id.button)
- AppCompatButton providerCredentialsButton;
+ AppCompatButton button;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- providerAPIResultReceiver = new ProviderAPIResultReceiver(new Handler(), new ProviderCredentialsReceiver(this));
+ setContentView(R.layout.a_provider_credentials);
+ providerAPIBroadcastReceiver = new ProviderAPIBroadcastReceiver();
+
+ IntentFilter updateIntentFilter = new IntentFilter(PROVIDER_API_EVENT);
+ updateIntentFilter.addCategory(Intent.CATEGORY_DEFAULT);
+ registerReceiver(providerAPIBroadcastReceiver, updateIntentFilter);
+
+ setUpListeners();
+ if(savedInstanceState != null) {
+ restoreState(savedInstanceState);
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ String action = mConfigState.getAction();
+ if (action == null) {
+ return;
+ }
+
+ if(action.equalsIgnoreCase(PERFORMING_ACTION)) {
+ showProgressBar();
+ }
+ }
+
+ private void restoreState(Bundle savedInstance) {
+ if (savedInstance.getString(USER_MESSAGE) != null) {
+ userMessage.setText(savedInstance.getString(USER_MESSAGE));
+ userMessage.setVisibility(VISIBLE);
+ }
+ usernameError.setError(savedInstance.getString(USERNAME_ERROR));
+ passwordError.setError(savedInstance.getString(PASSWORD_ERROR));
+ passwordVerificationError.setError(savedInstance.getString(PASSWORD_VERIFICATION_ERROR));
+ if (savedInstance.getString(ACTIVITY_STATE) != null) {
+ mConfigState.setAction(savedInstance.getString(ACTIVITY_STATE));
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ outState.putString(ACTIVITY_STATE, mConfigState.getAction());
+ if (userMessage.getText() != null && userMessage.getVisibility() == VISIBLE) {
+ outState.putString(USER_MESSAGE, userMessage.getText().toString());
+ }
+ if (usernameError.getError() != null) {
+ outState.putString(USERNAME_ERROR, usernameError.getError().toString());
+ }
+ if (passwordError.getError() != null) {
+ outState.putString(PASSWORD_ERROR, passwordError.getError().toString());
+ }
+ if (passwordVerificationError.getError() != null) {
+ outState.putString(PASSWORD_VERIFICATION_ERROR, passwordVerificationError.getError().toString());
+ }
+
+ super.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (providerAPIBroadcastReceiver != null)
+ unregisterReceiver(providerAPIBroadcastReceiver);
}
@OnClick(R.id.button)
- abstract void handleButton();
+ void handleButton() {
+ mConfigState.setAction(PERFORMING_ACTION);
+ }
protected void setButtonText(@StringRes int buttonText) {
- providerCredentialsButton.setText(buttonText);
+ button.setText(buttonText);
}
String getUsername() {
- return providerCredentialsUsername.getText().toString();
+ String username = usernameField.getText().toString();
+ String providerDomain = provider.getDomain();
+ if (username.endsWith(providerDomain)) {
+ return username.split("@" + providerDomain)[0];
+ }
+ return username;
}
String getPassword() {
- return providerCredentialsPassword.getText().toString();
+ return passwordField.getText().toString();
+ }
+
+ String getPasswordVerification() {
+ return passwordVerificationField.getText().toString();
}
void login(String username, String password) {
showProgressBar();
+
User.setUserName(username);
- Bundle parameters = bundlePassword(password);
- ProviderAPICommand.execute(parameters, ProviderAPI.LOG_IN, providerAPIResultReceiver);
- }
- void downloadVpnCertificate() {
Intent providerAPICommand = new Intent(this, ProviderAPI.class);
- ProviderAPICommand.execute(Bundle.EMPTY, ProviderAPI.DOWNLOAD_CERTIFICATE, providerAPIResultReceiver);
+ Bundle parameters = bundlePassword(password);
+ providerAPICommand.setAction(ProviderAPI.LOG_IN);
+ providerAPICommand.putExtra(ProviderAPI.PARAMETERS, parameters);
+ startService(providerAPICommand);
}
-
public void signUp(String username, String password) {
showProgressBar();
+
User.setUserName(username);
+
+ Intent providerAPICommand = new Intent(this, ProviderAPI.class);
Bundle parameters = bundlePassword(password);
- ProviderAPICommand.execute(parameters, ProviderAPI.SIGN_UP, providerAPIResultReceiver);
+ providerAPICommand.setAction(ProviderAPI.SIGN_UP);
+ providerAPICommand.putExtra(ProviderAPI.PARAMETERS, parameters);
+ startService(providerAPICommand);
+ }
+
+ void downloadVpnCertificate() {
+ Intent providerAPICommand = new Intent(this, ProviderAPI.class);
+ providerAPICommand.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE);
+ providerAPICommand.putExtra(ProviderAPI.PARAMETERS, Bundle.EMPTY);
+ startService(providerAPICommand);
}
protected Bundle bundlePassword(String password) {
@@ -80,42 +210,162 @@ public abstract class ProviderCredentialsBaseActivity extends ConfigWizardBaseAc
return parameters;
}
- public static class ProviderCredentialsReceiver implements ProviderAPIResultReceiver.Receiver{
+ private void setUpListeners() {
+ usernameField.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
- private ProviderCredentialsBaseActivity activity;
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ if (getUsername().equalsIgnoreCase("")) {
+ usernameError.setError(getString(R.string.username_ask));
+ } else {
+ usernameError.setError(null);
+ }
+ }
+ });
+ usernameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if (actionId == IME_ACTION_DONE
+ || event != null && event.getAction() == KeyEvent.ACTION_DOWN
+ && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
+ passwordField.requestFocus();
+ return true;
+ }
+ return false;
+ }
+ });
+
+ passwordField.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
- ProviderCredentialsReceiver(ProviderCredentialsBaseActivity activity) {
- this.activity = activity;
+ @Override
+ public void afterTextChanged(Editable s) {
+ if(getPassword().length() < 8) {
+ passwordError.setError(getString(R.string.error_not_valid_password_user_message));
+ } else {
+ passwordError.setError(null);
+ }
+ }
+ });
+ passwordField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if (actionId == IME_ACTION_DONE
+ || event != null && event.getAction() == KeyEvent.ACTION_DOWN
+ && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
+ if (passwordVerificationField.getVisibility() == VISIBLE) {
+ passwordVerificationField.requestFocus();
+ } else {
+ button.performClick();
+ }
+ return true;
+ }
+ return false;
+ }
+ });
+
+ passwordVerificationField.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ if(getPassword().equals(getPasswordVerification())) {
+ passwordVerificationError.setError(null);
+ } else {
+ passwordVerificationError.setError(getString(R.string.password_mismatch));
+ }
+ }
+ });
+ passwordVerificationField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if (actionId == IME_ACTION_DONE
+ || event != null && event.getAction() == KeyEvent.ACTION_DOWN
+ && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
+ button.performClick();
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+
+ private void handleReceivedErrors(Bundle arguments) {
+ if (arguments.containsKey(ERRORS.PASSWORD_INVALID_LENGTH.toString()))
+ passwordError.setError(getString(R.string.error_not_valid_password_user_message));
+ else if (arguments.containsKey(ERRORS.RISEUP_WARNING.toString())) {
+ userMessage.setVisibility(VISIBLE);
+ userMessage.setText(R.string.login_riseup_warning);
+ }
+ if (arguments.containsKey(USERNAME)) {
+ String username = arguments.getString(USERNAME);
+ usernameField.setText(username);
}
+ if (arguments.containsKey(ERRORS.USERNAME_MISSING.toString())) {
+ usernameError.setError(getString(R.string.username_ask));
+ }
+ if (arguments.containsKey(getString(R.string.user_message))) {
+ userMessage.setText(arguments.getString(getString(R.string.user_message)));
+ userMessage.setVisibility(VISIBLE);
+ } else if (userMessage.getVisibility() != VISIBLE) {
+ userMessage.setVisibility(GONE);
+ }
+
+ if (!usernameField.getText().toString().isEmpty() && passwordField.isFocusable())
+ passwordField.requestFocus();
+
+ hideProgressBar();
+ }
+ public class ProviderAPIBroadcastReceiver extends BroadcastReceiver {
@Override
- public void onReceiveResult(int resultCode, Bundle resultData) {
- if (resultCode == ProviderAPI.SUCCESSFUL_SIGNUP) {
- activity.downloadVpnCertificate();
- } else if (resultCode == ProviderAPI.FAILED_SIGNUP) {
- //MainActivity.sessionDialog(resultData);
- } else if (resultCode == ProviderAPI.SUCCESSFUL_LOGIN) {
- activity.downloadVpnCertificate();
- } else if (resultCode == ProviderAPI.FAILED_LOGIN) {
- //MainActivity.sessionDialog(resultData);
-// TODO MOVE
-// } else if (resultCode == ProviderAPI.SUCCESSFUL_LOGOUT) {
-// if (switching_provider) activity.switchProvider();
-// } else if (resultCode == ProviderAPI.LOGOUT_FAILED) {
-// activity.setResult(RESULT_CANCELED);
- } else if (resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) {
- Intent intent = new Intent(activity, MainActivity.class);
- activity.startActivity(intent);
- //activity.eip_fragment.updateEipService();
- } else if (resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
- // TODO activity.setResult(RESULT_CANCELED);
-// } else if (resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_EIP_SERVICE) {
-// activity.eip_fragment.updateEipService();
-// activity.setResult(RESULT_OK);
-// } else if (resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_EIP_SERVICE) {
-// activity.setResult(RESULT_CANCELED);
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "received Broadcast");
+
+ String action = intent.getAction();
+ if (action == null || !action.equalsIgnoreCase(PROVIDER_API_EVENT)) {
+ return;
+ }
+
+ int resultCode = intent.getIntExtra(RESULT_CODE, -1);
+ switch (resultCode) {
+ case ProviderAPI.SUCCESSFUL_SIGNUP:
+ case ProviderAPI.SUCCESSFUL_LOGIN:
+ downloadVpnCertificate();
+ break;
+ case ProviderAPI.FAILED_LOGIN:
+ case ProviderAPI.FAILED_SIGNUP:
+ handleReceivedErrors((Bundle) intent.getParcelableExtra(RESULT_KEY));
+ break;
+
+ case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE:
+ intent = new Intent(ProviderCredentialsBaseActivity.this, MainActivity.class);
+ startActivity(intent);
+ //activity.eip_fragment.updateEipService();
+ break;
+ case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE:
+ // TODO activity.setResult(RESULT_CANCELED);
+ break;
}
}
}
-
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/SignupActivity.java b/app/src/main/java/se/leap/bitmaskclient/SignupActivity.java
index 448eba52..151e6cdf 100644
--- a/app/src/main/java/se/leap/bitmaskclient/SignupActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/SignupActivity.java
@@ -2,12 +2,7 @@ package se.leap.bitmaskclient;
import android.os.Bundle;
import android.support.annotation.Nullable;
-import android.support.design.widget.TextInputEditText;
-import android.support.design.widget.TextInputLayout;
-import android.text.Editable;
-import android.text.TextWatcher;
-import butterknife.InjectView;
import butterknife.OnClick;
/**
@@ -16,52 +11,23 @@ import butterknife.OnClick;
public class SignupActivity extends ProviderCredentialsBaseActivity {
- @InjectView(R.id.provider_credentials_password_verification)
- TextInputEditText providerCredentialsPasswordVerification;
-
- @InjectView(R.id.provider_credentials_password_verification_layout)
- TextInputLayout providerCredentialsPasswordVerificationLayout;
-
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.a_signup);
setProviderHeaderLogo(R.drawable.mask);
setProviderHeaderText(R.string.create_profile);
setProgressbarText(R.string.signing_up);
setButtonText(R.string.signup_button);
-
- providerCredentialsPasswordVerification.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- if(getPassword().equals(getPasswordVerification())) {
- providerCredentialsPasswordVerificationLayout.setError(null);
- } else {
- providerCredentialsPasswordVerificationLayout.setError(getString(R.string.password_mismatch));
- }
- }
- });
}
@Override
@OnClick(R.id.button)
void handleButton() {
+ super.handleButton();
if (getPassword().equals(getPasswordVerification())) {
signUp(getUsername(), getPassword());
}
}
-
- private String getPasswordVerification() {
- return providerCredentialsPasswordVerification.getText().toString();
- }
}
diff --git a/app/src/main/res/layout-xlarge/provider_detail_fragment.xml b/app/src/main/res/layout-xlarge/a_provider_detail.xml
index 31538f9f..31538f9f 100644
--- a/app/src/main/res/layout-xlarge/provider_detail_fragment.xml
+++ b/app/src/main/res/layout-xlarge/a_provider_detail.xml
diff --git a/app/src/main/res/layout/a_login.xml b/app/src/main/res/layout/a_login.xml
deleted file mode 100644
index 5b33ec16..00000000
--- a/app/src/main/res/layout/a_login.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
- android:layout_height="match_parent"
- style="@style/BitmaskActivity">
-
- <include layout="@layout/loading_screen" />
-
- <LinearLayout
- android:id="@+id/content"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <include
- layout="@layout/provider_header"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <include layout="@layout/provider_credentials_login"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <android.support.v7.widget.AppCompatButton
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/login_button"
- android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true"/>
-
- </RelativeLayout>
- </LinearLayout>
-</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/a_provider_credentials.xml b/app/src/main/res/layout/a_provider_credentials.xml
new file mode 100644
index 00000000..85d9d3cb
--- /dev/null
+++ b/app/src/main/res/layout/a_provider_credentials.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/BitmaskActivity">
+
+ <include layout="@layout/loading_screen" />
+
+ <LinearLayout
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <include
+ layout="@layout/provider_header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+
+ <ScrollView
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:isScrollContainer="true"
+ >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ <include
+ layout="@layout/provider_credentials"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <android.support.v7.widget.AppCompatButton
+ android:id="@+id/button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentRight="true"
+ android:text="@string/login_button" />
+
+ </RelativeLayout>
+ </LinearLayout>
+ </ScrollView>
+ </LinearLayout>
+</LinearLayout>
diff --git a/app/src/main/res/layout/provider_detail_fragment.xml b/app/src/main/res/layout/a_provider_detail.xml
index e4ee1cca..5f07b87c 100644
--- a/app/src/main/res/layout/provider_detail_fragment.xml
+++ b/app/src/main/res/layout/a_provider_detail.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/provider_detail_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/app/src/main/res/layout/a_signup.xml b/app/src/main/res/layout/a_signup.xml
deleted file mode 100644
index b0c8dc47..00000000
--- a/app/src/main/res/layout/a_signup.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
- android:layout_height="match_parent"
- style="@style/BitmaskActivity">
-
- <include layout="@layout/loading_screen" />
-
- <LinearLayout
- android:id="@+id/content"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <include
- layout="@layout/provider_header"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <include layout="@layout/provider_credentials_signup"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <android.support.v7.widget.AppCompatButton
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/login_button"
- android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true"/>
-
- </RelativeLayout>
- </LinearLayout>
-</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/provider_credentials_login.xml b/app/src/main/res/layout/provider_credentials.xml
index 915ac231..6e4dff95 100644
--- a/app/src/main/res/layout/provider_credentials_login.xml
+++ b/app/src/main/res/layout/provider_credentials.xml
@@ -2,7 +2,16 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
+ <android.support.v7.widget.AppCompatTextView
+ android:id="@+id/provider_credentials_user_message"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/TextAppearance.Design.Error"
+ android:visibility="gone"
+ />
+
<android.support.design.widget.TextInputLayout
+ android:id="@+id/provider_credentials_username_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/auth_username"
@@ -20,6 +29,7 @@
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
+ android:id="@+id/provider_credentials_password_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
@@ -35,4 +45,22 @@
</android.support.design.widget.TextInputLayout>
+ <android.support.design.widget.TextInputLayout
+ android:id="@+id/provider_credentials_password_verification_error"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:passwordToggleEnabled="true"
+ android:hint="@string/password"
+ app:errorEnabled="true"
+ android:visibility="gone">
+
+ <android.support.design.widget.TextInputEditText
+ android:id="@+id/provider_credentials_password_verification"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textPassword"
+ android:visibility="gone"
+ />
+
+ </android.support.design.widget.TextInputLayout>
</merge> \ No newline at end of file
diff --git a/app/src/main/res/layout/provider_credentials_signup.xml b/app/src/main/res/layout/provider_credentials_signup.xml
deleted file mode 100644
index c2e3dcd3..00000000
--- a/app/src/main/res/layout/provider_credentials_signup.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto" >
-
- <include layout="@layout/provider_credentials_login" />
-
- <android.support.design.widget.TextInputLayout
- android:id="@+id/provider_credentials_password_verification_layout"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- app:passwordToggleEnabled="true"
- android:hint="@string/password"
- app:errorEnabled="true">
-
- <android.support.design.widget.TextInputEditText
- android:id="@+id/provider_credentials_password_verification"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="textPassword"
- />
-
- </android.support.design.widget.TextInputLayout>
-
-</merge> \ No newline at end of file
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
index b42c7554..b928a79b 100644
--- a/app/src/main/res/values-v21/styles.xml
+++ b/app/src/main/res/values-v21/styles.xml
@@ -28,7 +28,7 @@
<style name="BitmaskButton" parent="android:Widget.Button">
<item name="android:textAllCaps">true</item>
- <item name="android:backgroundTint">@color/colorPrimaryDark</item>
+ <item name="android:backgroundTint">@color/colorPrimary</item>
</style>
</resources>
diff --git a/app/src/main/res/values-v21/themes.xml b/app/src/main/res/values-v21/themes.xml
index ac62b94c..d6145217 100644
--- a/app/src/main/res/values-v21/themes.xml
+++ b/app/src/main/res/values-v21/themes.xml
@@ -11,7 +11,7 @@
<!-- button and controls -->
<item name="android:buttonStyle">@style/BitmaskButton</item>
- <item name="android:colorButtonNormal">@color/colorPrimaryDark</item>
+ <item name="android:colorButtonNormal">@color/colorPrimary</item>
<item name="android:colorControlHighlight">@color/colorPrimaryDark</item>
</style>
diff --git a/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java
index b1deae67..f7102508 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -40,18 +40,17 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
public void showAndSelectProvider(String provider_main_url) {
try {
- selectedProvider = new Provider(new URL((provider_main_url)));
- adapter.add(selectedProvider);
+ provider = new Provider(new URL((provider_main_url)));
+ adapter.add(provider);
adapter.saveProviders();
- autoSelectProvider(selectedProvider);
+ autoSelectProvider(provider);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
private void autoSelectProvider(Provider provider) {
- selectedProvider = provider;
- onItemSelectedUi();
+ this.provider = provider;
onItemSelectedLogic();
}
@@ -63,15 +62,15 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
mConfigState.setAction(SETTING_UP_PROVIDER);
Intent providerApiCommand = new Intent(this, ProviderAPI.class);
Bundle parameters = new Bundle();
- parameters.putString(Provider.MAIN_URL, selectedProvider.getMainUrl().toString());
- if (selectedProvider.hasCertificatePin()){
- parameters.putString(Provider.CA_CERT_FINGERPRINT, selectedProvider.certificatePin());
+ parameters.putString(Provider.MAIN_URL, provider.getMainUrl().toString());
+ if (provider.hasCertificatePin()){
+ parameters.putString(Provider.CA_CERT_FINGERPRINT, provider.certificatePin());
}
- if (selectedProvider.hasCaCert()) {
- parameters.putString(Provider.CA_CERT, selectedProvider.getCaCert());
+ if (provider.hasCaCert()) {
+ parameters.putString(Provider.CA_CERT, provider.getCaCert());
}
- if (selectedProvider.hasDefinition()) {
- parameters.putString(Provider.KEY, selectedProvider.getDefinition().toString());
+ if (provider.hasDefinition()) {
+ parameters.putString(Provider.KEY, provider.getDefinition().toString());
}
providerApiCommand.setAction(ProviderAPI.SET_UP_PROVIDER);
@@ -87,14 +86,14 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
addAndSelectNewProvider(ProviderAPI.lastProviderMainUrl());
} else {
showProgressBar();
- adapter.hideAllBut(adapter.indexOf(selectedProvider));
+ adapter.hideAllBut(adapter.indexOf(provider));
Intent providerApiCommand = new Intent(this, ProviderAPI.class);
providerApiCommand.setAction(ProviderAPI.SET_UP_PROVIDER);
providerApiCommand.putExtra(ProviderAPI.RECEIVER_KEY, providerAPIResultReceiver);
Bundle parameters = new Bundle();
- parameters.putString(Provider.MAIN_URL, selectedProvider.getMainUrl().toString());
+ parameters.putString(Provider.MAIN_URL, provider.getMainUrl().toString());
providerApiCommand.putExtra(ProviderAPI.PARAMETERS, parameters);
startService(providerApiCommand);