summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java4
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/TestProviderListActivity.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestConfigurationWizard.java)8
-rw-r--r--app/src/insecure/java/se/leap/bitmaskclient/ProviderListActivity.java (renamed from app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java)38
-rw-r--r--app/src/insecure/java/se/leap/bitmaskclient/ProviderListContent.java2
-rw-r--r--app/src/insecure/res/layout/new_provider_dialog.xml2
-rw-r--r--app/src/main/AndroidManifest.xml8
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java59
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java83
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java104
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java10
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/LoginActivity.java14
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/MainActivity.java19
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Provider.java21
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java369
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java (renamed from app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java)187
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/SignupActivity.java43
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/StartActivity.java33
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java6
-rw-r--r--app/src/main/res/drawable/action_history.xml9
-rw-r--r--app/src/main/res/layout-xlarge/a_provider_detail.xml32
-rw-r--r--app/src/main/res/layout-xlarge/configuration_wizard_activity.xml3
-rw-r--r--app/src/main/res/layout-xlarge/provider_detail_fragment.xml48
-rw-r--r--app/src/main/res/layout/a_login.xml29
-rw-r--r--app/src/main/res/layout/a_provider_credentials.xml54
-rw-r--r--app/src/main/res/layout/a_provider_detail.xml40
-rw-r--r--app/src/main/res/layout/a_signup.xml29
-rw-r--r--app/src/main/res/layout/configuration_wizard_activity.xml40
-rw-r--r--app/src/main/res/layout/loading_screen.xml41
-rw-r--r--app/src/main/res/layout/provider_credentials.xml66
-rw-r--r--app/src/main/res/layout/provider_credentials_login.xml36
-rw-r--r--app/src/main/res/layout/provider_credentials_signup.xml24
-rw-r--r--app/src/main/res/layout/provider_detail_fragment.xml46
-rw-r--r--app/src/main/res/layout/provider_header.xml15
-rw-r--r--app/src/main/res/values-v21/styles.xml5
-rw-r--r--app/src/main/res/values-v21/themes.xml24
-rw-r--r--app/src/main/res/values/dimens.xml4
-rw-r--r--app/src/main/res/values/strings.xml5
-rw-r--r--app/src/main/res/values/styles.xml5
-rw-r--r--app/src/main/res/values/themes.xml8
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java (renamed from app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java)30
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderListContent.java2
43 files changed, 1045 insertions, 563 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java
index 956049dc..e187d424 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java
@@ -7,7 +7,7 @@ import android.view.View;
import com.robotium.solo.Solo;
-import se.leap.bitmaskclient.ConfigurationWizard;
+import se.leap.bitmaskclient.ProviderListActivity;
import se.leap.bitmaskclient.Dashboard;
import se.leap.bitmaskclient.R;
@@ -43,7 +43,7 @@ public abstract class BaseTestDashboardFragment extends ActivityInstrumentationT
void tapSwitchProvider() {
solo.clickOnMenuItem(solo.getString(R.string.switch_provider_menu_option));
- solo.waitForActivity(ConfigurationWizard.class);
+ solo.waitForActivity(ProviderListActivity.class);
}
private void useRegistered() {
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestConfigurationWizard.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestProviderListActivity.java
index c0d3aab1..4ab705e7 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestConfigurationWizard.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestProviderListActivity.java
@@ -7,15 +7,15 @@ import com.robotium.solo.Solo;
import java.io.IOException;
-import se.leap.bitmaskclient.ConfigurationWizard;
+import se.leap.bitmaskclient.ProviderListActivity;
import se.leap.bitmaskclient.R;
-public class TestConfigurationWizard extends ActivityInstrumentationTestCase2<ConfigurationWizard> {
+public class TestProviderListActivity extends ActivityInstrumentationTestCase2<ProviderListActivity> {
private Solo solo;
- public TestConfigurationWizard() {
- super(ConfigurationWizard.class);
+ public TestProviderListActivity() {
+ super(ProviderListActivity.class);
}
diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderListActivity.java
index dc65665c..034c9752 100644
--- a/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderListActivity.java
@@ -34,7 +34,7 @@ import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
* @author parmegv
* @author cyberta
*/
-public class ConfigurationWizard extends BaseConfigurationWizard {
+public class ProviderListActivity extends ProviderListBaseActivity {
@Override
protected void onItemSelectedLogic() {
@@ -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,9 +75,9 @@ public class ConfigurationWizard extends BaseConfigurationWizard {
private void autoSelectProvider(Provider provider, boolean danger_on) {
preferences.edit().putBoolean(ProviderItem.DANGER_ON, danger_on).apply();
- selectedProvider = provider;
+ this.provider = provider;
onItemSelectedLogic();
- onItemSelectedUi();
+ 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/java/se/leap/bitmaskclient/ProviderListContent.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderListContent.java
index c8dfc092..88e31c9a 100644
--- a/app/src/insecure/java/se/leap/bitmaskclient/ProviderListContent.java
+++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderListContent.java
@@ -20,7 +20,7 @@ import java.util.*;
import java.net.*;
/**
- * Models the provider list shown in the ConfigurationWizard.
+ * Models the provider list shown in the ProviderListActivity.
*
* @author parmegv
*/
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/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 0a10b13c..2ffb54f4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -78,7 +78,6 @@
android:name=".StartActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
- android:noHistory="true"
android:theme="@style/SplashTheme"
>
@@ -94,7 +93,7 @@
android:label="@string/title_activity_main" />
<activity
- android:name=".ConfigurationWizard"
+ android:name=".ProviderListActivity"
android:label="@string/configuration_wizard_title" />
<activity
@@ -102,9 +101,10 @@
android:label="@string/provider_details_title"
android:launchMode="singleTop" />
- <activity android:name=".LoginActivity" />
+ <activity android:name=".LoginActivity"
+ android:noHistory="true" />
<activity android:name=".SignupActivity"
- android:theme="@style/BitmaskTheme"/>
+ android:noHistory="true" />
<service
android:name=".eip.EIP"
diff --git a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
index d521a3a9..fbb27b58 100644
--- a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
@@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
+import android.support.v7.widget.AppCompatTextView;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
@@ -20,22 +21,14 @@ import butterknife.InjectView;
import static se.leap.bitmaskclient.Constants.PROVIDER_ALLOW_ANONYMOUS;
import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
-import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
-import static se.leap.bitmaskclient.MainActivity.ACTION_SHOW_VPN_FRAGMENT;
+import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
-public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity {
+public abstract class AbstractProviderDetailActivity extends ConfigWizardBaseActivity {
final public static String TAG = "providerDetailActivity";
- protected SharedPreferences preferences;
-
- @InjectView(R.id.provider_detail_domain)
- TextView domain;
-
- @InjectView(R.id.provider_detail_name)
- TextView name;
@InjectView(R.id.provider_detail_description)
- TextView description;
+ AppCompatTextView description;
@InjectView(R.id.provider_detail_options)
ListView options;
@@ -43,22 +36,18 @@ public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.provider_detail_fragment);
+ setContentView(R.layout.a_provider_detail);
- preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
try {
JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, ""));
- domain.setText(providerJson.getString(Provider.DOMAIN));
- name.setText(providerJson.getJSONObject(Provider.NAME).getString("en"));
- description.setText(providerJson.getJSONObject(Provider.DESCRIPTION).getString("en"));
-
- setTitle(R.string.provider_details_title);
+ setProviderHeaderText(ConfigHelper.getProviderName(preferences));
+ description.setText(ConfigHelper.getDescription(preferences));
// Show only the options allowed by the provider
ArrayList<String> optionsList = new ArrayList<>();
if (registrationAllowed(providerJson)) {
- optionsList.add(getString(R.string.login_button));
- optionsList.add(getString(R.string.signup_button));
+ optionsList.add(getString(R.string.login_to_profile));
+ optionsList.add(getString(R.string.create_profile));
}
if (anonAllowed(providerJson)) {
optionsList.add(getString(R.string.use_anonymously_button));
@@ -75,19 +64,23 @@ public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String text = ((TextView) view).getText().toString();
Intent intent;
- if (text.equals(getString(R.string.login_button))) {
+ if (text.equals(getString(R.string.login_to_profile))) {
Log.d(TAG, "login selected");
intent = new Intent(getApplicationContext(), LoginActivity.class);
- } else if (text.equals(getString(R.string.signup_button))) {
+ } else if (text.equals(getString(R.string.create_profile))) {
Log.d(TAG, "signup selected");
intent = new Intent(getApplicationContext(), SignupActivity.class);
} else {
Log.d(TAG, "use anonymously selected");
- intent = new Intent(getApplicationContext(), MainActivity.class);
- intent.setAction(ACTION_SHOW_VPN_FRAGMENT);
+ intent = new Intent();
+ intent.putExtra(Provider.KEY, provider);
+ setResult(RESULT_OK, intent);
+ finish();
+ return;
}
+ intent.putExtra(PROVIDER_KEY, provider);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent);
+ startActivityForResult(intent, REQUEST_CODE_CONFIGURE_LEAP);
}
});
} catch (JSONException e) {
@@ -95,6 +88,22 @@ public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity
}
}
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ provider = intent.getParcelableExtra(PROVIDER_KEY);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_CODE_CONFIGURE_LEAP) {
+ if (resultCode == RESULT_OK) {
+ setResult(resultCode, data);
+ finish();
+ }
+ }
+ }
+
private boolean anonAllowed(JSONObject providerJson) {
try {
JSONObject serviceDescription = providerJson.getJSONObject(Provider.SERVICE);
diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
index ccdf5064..741a6f56 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
@@ -18,8 +18,10 @@ package se.leap.bitmaskclient;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.util.Log;
+import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;
import org.spongycastle.util.encoders.Base64;
@@ -45,6 +47,7 @@ import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPrivateKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
+import java.util.Locale;
import static android.R.attr.name;
import static se.leap.bitmaskclient.Constants.PROVIDER_CONFIGURED;
@@ -261,16 +264,6 @@ public class ConfigHelper {
}
- public static String getCurrentProviderName(@NonNull SharedPreferences preferences) {
- try {
- JSONObject providerDefintion = new JSONObject(preferences.getString(Provider.KEY, ""));
- return providerDefintion.getString(Provider.DOMAIN);
- } catch (JSONException e) {
- e.printStackTrace();
- }
- return null;
- }
-
public static boolean providerInSharedPreferences(@NonNull SharedPreferences preferences) {
return preferences.getBoolean(PROVIDER_CONFIGURED, false);
}
@@ -288,4 +281,74 @@ public class ConfigHelper {
return provider;
}
+ public static String getProviderName(String provider) {
+ return getProviderName(null, provider);
+ }
+
+ public static String getProviderName(@Nullable SharedPreferences preferences) {
+ return getProviderName(preferences,null);
+ }
+
+ public static String getProviderName(@Nullable SharedPreferences preferences, @Nullable String provider) {
+ if (provider == null && preferences != null) {
+ provider = preferences.getString(Provider.KEY, "");
+ }
+ try {
+ JSONObject providerJson = new JSONObject(provider);
+ String lang = Locale.getDefault().getLanguage();
+ return providerJson.getJSONObject(Provider.NAME).getString(lang);
+ } catch (JSONException e) {
+ try {
+ JSONObject providerJson = new JSONObject(provider);
+ return providerJson.getJSONObject(Provider.NAME).getString("en");
+ } catch (JSONException e2) {
+ return null;
+ }
+ } catch (NullPointerException npe) {
+ return null;
+ }
+ }
+
+ public static String getProviderDomain(SharedPreferences preferences) {
+ return getProviderDomain(preferences, null);
+ }
+
+ public static String getProviderDomain(String provider) {
+ return getProviderDomain(null, provider);
+ }
+
+ public static String getProviderDomain(@Nullable SharedPreferences preferences, @Nullable String provider) {
+ if (provider == null && preferences != null) {
+ provider = preferences.getString(Provider.KEY, "");
+ }
+ try {
+ JSONObject providerJson = new JSONObject(provider);
+ return providerJson.getString(Provider.DOMAIN);
+ } catch (JSONException | NullPointerException e) {
+ return null;
+ }
+ }
+
+ public static String getDescription(SharedPreferences preferences) {
+ try {
+ JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, ""));
+ String lang = Locale.getDefault().getLanguage();
+ return providerJson.getJSONObject(Provider.DESCRIPTION).getString(lang);
+ } catch (JSONException e) {
+ try {
+ JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, ""));
+ return providerJson.getJSONObject(Provider.DESCRIPTION).getString("en");
+ } catch (JSONException e1) {
+ return null;
+ }
+ }
+ }
+
+ public static void storeProviderInPreferences(SharedPreferences preferences, Provider provider) {
+ preferences.edit().putBoolean(PROVIDER_CONFIGURED, true).
+ putString(Provider.MAIN_URL, provider.getMainUrlString()).
+ putString(Provider.KEY, provider.getDefinitionString()).
+ putString(Provider.CA_CERT, provider.getCaCert()).
+ apply();
+ }
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java
new file mode 100644
index 00000000..79a78fe1
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/ConfigWizardBaseActivity.java
@@ -0,0 +1,104 @@
+package se.leap.bitmaskclient;
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.support.annotation.DrawableRes;
+import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
+import android.support.v7.widget.AppCompatImageView;
+import android.support.v7.widget.AppCompatTextView;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+import butterknife.InjectView;
+
+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;
+
+/**
+ * Base Activity for configuration wizard activities
+ *
+ * Created by fupduck on 09.01.18.
+ */
+
+public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity {
+
+ protected SharedPreferences preferences;
+
+ @InjectView(R.id.provider_header_logo)
+ AppCompatImageView providerHeaderLogo;
+
+ @InjectView(R.id.provider_header_text)
+ AppCompatTextView providerHeaderText;
+
+ @InjectView(R.id.loading_screen)
+ protected LinearLayout loadingScreen;
+
+ @InjectView(R.id.progressbar_description)
+ protected AppCompatTextView progressbarText;
+
+ @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
+ public void setContentView(View view) {
+ super.setContentView(view);
+ setProviderHeaderText(ConfigHelper.getProviderName(preferences));
+ }
+
+ @Override
+ public void setContentView(int layoutResID) {
+ super.setContentView(layoutResID);
+ setProviderHeaderText(ConfigHelper.getProviderName(preferences));
+ }
+
+ @Override
+ public void setContentView(View view, ViewGroup.LayoutParams params) {
+ super.setContentView(view, params);
+ setProviderHeaderText(ConfigHelper.getProviderName(preferences));
+ }
+
+ protected void setProviderHeaderLogo(@DrawableRes int providerHeaderLogo) {
+ this.providerHeaderLogo.setImageResource(providerHeaderLogo);
+ }
+
+ protected void setProviderHeaderText(String providerHeaderText) {
+ this.providerHeaderText.setText(providerHeaderText);
+ }
+
+ protected void setProviderHeaderText(@StringRes int providerHeaderText) {
+ this.providerHeaderText.setText(providerHeaderText);
+ }
+
+ protected void hideProgressBar() {
+ loadingScreen.setVisibility(GONE);
+ content.setVisibility(VISIBLE);
+ }
+
+ protected void showProgressBar() {
+ content.setVisibility(GONE);
+ loadingScreen.setVisibility(VISIBLE);
+ }
+
+ protected void setProgressbarText(String progressbarText) {
+ this.progressbarText.setText(progressbarText);
+ }
+
+ protected void setProgressbarText(@StringRes int progressbarText) {
+ this.progressbarText.setText(progressbarText);
+ }
+
+}
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index a14b7d2f..a4db5f84 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -232,7 +232,7 @@ public class Dashboard extends ButterKnifeActivity {
private void handleConfigureAlwaysOn(Intent intent) {
intent.removeExtra(APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE);
Log.d(TAG, "start Configuration wizard!");
- startActivityForResult(new Intent(this, ConfigurationWizard.class), REQUEST_CODE_CONFIGURE_LEAP);
+ startActivityForResult(new Intent(this, ProviderListActivity.class), REQUEST_CODE_CONFIGURE_LEAP);
}
private void prepareEIP(Bundle savedInstanceState) {
@@ -255,7 +255,7 @@ public class Dashboard extends ButterKnifeActivity {
if (getIntent().hasExtra(APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE)) {
getIntent().removeExtra(APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE);
}
- startActivityForResult(new Intent(this, ConfigurationWizard.class), REQUEST_CODE_CONFIGURE_LEAP);
+ startActivityForResult(new Intent(this, ProviderListActivity.class), REQUEST_CODE_CONFIGURE_LEAP);
}
@SuppressLint("CommitPrefEdits")
private void providerToPreferences(Provider provider) {
@@ -273,7 +273,7 @@ public class Dashboard extends ButterKnifeActivity {
.setPositiveButton(getResources().getString(R.string.setup_error_configure_button), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- startActivityForResult(new Intent(Dashboard.this, ConfigurationWizard.class), REQUEST_CODE_CONFIGURE_LEAP);
+ startActivityForResult(new Intent(Dashboard.this, ProviderListActivity.class), REQUEST_CODE_CONFIGURE_LEAP);
}
})
.setNegativeButton(getResources().getString(R.string.setup_error_close_button), new DialogInterface.OnClickListener() {
@@ -416,7 +416,7 @@ public class Dashboard extends ButterKnifeActivity {
clearDataOfLastProvider();
switching_provider = false;
- startActivityForResult(new Intent(this, ConfigurationWizard.class), REQUEST_CODE_SWITCH_PROVIDER);
+ startActivityForResult(new Intent(this, ProviderListActivity.class), REQUEST_CODE_SWITCH_PROVIDER);
}
private void clearDataOfLastProvider() {
@@ -441,7 +441,7 @@ public class Dashboard extends ButterKnifeActivity {
preferenceEditor.apply();
switching_provider = false;
- startActivityForResult(new Intent(this, ConfigurationWizard.class), REQUEST_CODE_SWITCH_PROVIDER);
+ startActivityForResult(new Intent(this, ProviderListActivity.class), REQUEST_CODE_SWITCH_PROVIDER);
}
private static class DashboardReceiver implements ProviderAPIResultReceiver.Receiver{
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index cf2f0eff..414b1f2a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -360,7 +360,7 @@ public class EipFragment extends Fragment implements Observer {
key.setImageResource(R.drawable.vpn_connected);
routedText.setVisibility(VISIBLE);
vpnRoute.setVisibility(VISIBLE);
- vpnRoute.setText(ConfigHelper.getCurrentProviderName(preferences));
+ vpnRoute.setText(ConfigHelper.getProviderName(preferences));
colorBackground();
} else {
mainButton.setText(activity.getString(R.string.vpn_button_turn_on));
diff --git a/app/src/main/java/se/leap/bitmaskclient/LoginActivity.java b/app/src/main/java/se/leap/bitmaskclient/LoginActivity.java
index a5cbf5f5..a407b0a9 100644
--- a/app/src/main/java/se/leap/bitmaskclient/LoginActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/LoginActivity.java
@@ -2,11 +2,12 @@ package se.leap.bitmaskclient;
import android.os.Bundle;
import android.support.annotation.Nullable;
-import android.util.Log;
import butterknife.OnClick;
/**
+ * Activity to login to chosen Provider
+ *
* Created by fupduck on 09.01.18.
*/
@@ -15,20 +16,15 @@ public class LoginActivity extends ProviderCredentialsBaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.a_login);
-
- setProviderHeaderText("providerNAME");
+ setProgressbarText(R.string.logging_in);
setProviderHeaderLogo(R.drawable.mask);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
+ setProviderHeaderText(R.string.login_to_profile);
}
@Override
@OnClick(R.id.button)
void handleButton() {
+ super.handleButton();
login(getUsername(), getPassword());
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
index 4fd16a8b..7629f0b7 100644
--- a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
@@ -2,6 +2,7 @@ package se.leap.bitmaskclient;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
@@ -12,11 +13,15 @@ import android.support.v7.widget.Toolbar;
import se.leap.bitmaskclient.drawer.NavigationDrawerFragment;
import se.leap.bitmaskclient.userstatus.SessionDialog;
+import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
+import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
+
public class MainActivity extends AppCompatActivity {
private static Provider provider = new Provider();
private static FragmentManagerEnhanced fragmentManager;
+ private SharedPreferences preferences;
public final static String ACTION_SHOW_VPN_FRAGMENT = "action_show_vpn_fragment";
@@ -34,6 +39,7 @@ public class MainActivity extends AppCompatActivity {
NavigationDrawerFragment navigationDrawerFragment = (NavigationDrawerFragment)
getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
+ preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
fragmentManager = new FragmentManagerEnhanced(getSupportFragmentManager());
// Set up the drawer.
navigationDrawerFragment.setUp(
@@ -81,5 +87,18 @@ public class MainActivity extends AppCompatActivity {
}
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (data == null) {
+ return;
+ }
+
+ if (requestCode == REQUEST_CODE_CONFIGURE_LEAP) {
+ if (resultCode == RESULT_OK && data.hasExtra(Provider.KEY)) {
+ Provider provider = data.getParcelableExtra(Provider.KEY);
+ ConfigHelper.storeProviderInPreferences(preferences, provider);
+ }
+ }
+ }
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/Provider.java b/app/src/main/java/se/leap/bitmaskclient/Provider.java
index 60b1b93c..ae329cd1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Provider.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Provider.java
@@ -16,6 +16,7 @@
*/
package se.leap.bitmaskclient;
+import android.content.SharedPreferences;
import android.os.*;
import com.google.gson.Gson;
@@ -26,6 +27,8 @@ import java.io.Serializable;
import java.net.*;
import java.util.*;
+import static se.leap.bitmaskclient.Constants.PROVIDER_CONFIGURED;
+
/**
* @author Sean Leonard <meanderingcode@aetherislands.net>
* @author Parménides GV <parmegv@sdf.org>
@@ -118,10 +121,18 @@ public final class Provider implements Parcelable {
return definition;
}
+ String getDefinitionString() {
+ return getDefinition().toString();
+ }
+
protected String getDomain() {
return mainUrl.getDomain();
}
+ String getMainUrlString() {
+ return getMainUrl().toString();
+ }
+
protected DefaultedURL getMainUrl() {
return mainUrl;
}
@@ -158,9 +169,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/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
index da2e4c8b..cfc6e49d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
@@ -96,7 +96,6 @@ import static se.leap.bitmaskclient.R.string.error_io_exception_user_message;
import static se.leap.bitmaskclient.R.string.error_json_exception_user_message;
import static se.leap.bitmaskclient.R.string.error_no_such_algorithm_exception_user_message;
import static se.leap.bitmaskclient.R.string.malformed_url;
-import static se.leap.bitmaskclient.R.string.routes_info_excl;
import static se.leap.bitmaskclient.R.string.server_unreachable_message;
import static se.leap.bitmaskclient.R.string.service_is_down_error;
import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_cert;
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java
index 1ed64559..25dca4e0 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderCredentialsBaseActivity.java
@@ -1,91 +1,207 @@
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.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.design.widget.TextInputEditText;
-import android.widget.Button;
-import android.widget.ImageView;
+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.view.inputmethod.InputMethodManager;
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 se.leap.bitmaskclient.MainActivity.ACTION_SHOW_VPN_FRAGMENT;
+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
+ *
* Created by fupduck on 09.01.18.
*/
-public abstract class ProviderCredentialsBaseActivity extends ButterKnifeActivity {
+public abstract class ProviderCredentialsBaseActivity extends ConfigWizardBaseActivity {
- protected ProviderAPIResultReceiver providerAPIResultReceiver;
+ final protected static String TAG = ProviderCredentialsBaseActivity.class.getName();
- @InjectView(R.id.provider_header_logo)
- ImageView providerHeaderLogo;
+ final private static String ACTIVITY_STATE = "ACTIVITY STATE";
- @InjectView(R.id.provider_header_text)
- TextView providerHeaderText;
+ 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)
- Button 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);
+ }
}
- @OnClick(R.id.button)
- abstract void handleButton();
+ @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));
+ }
+ }
- protected void setProviderHeaderLogo(@DrawableRes int providerHeaderLogo) {
- this.providerHeaderLogo.setImageResource(providerHeaderLogo);
+ @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);
}
- protected void setProviderHeaderText(String providerHeaderText) {
- this.providerHeaderText.setText(providerHeaderText);
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (providerAPIBroadcastReceiver != null)
+ unregisterReceiver(providerAPIBroadcastReceiver);
}
- protected void setProviderHeaderText(@StringRes int providerHeaderText) {
- this.providerHeaderText.setText(providerHeaderText);
+ @OnClick(R.id.button)
+ void handleButton() {
+ mConfigState.setAction(PERFORMING_ACTION);
+ hideKeyboard();
+ showProgressBar();
}
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) {
User.setUserName(username);
+
+ Intent providerAPICommand = new Intent(this, ProviderAPI.class);
Bundle parameters = bundlePassword(password);
- ProviderAPICommand.execute(parameters, ProviderAPI.LOG_IN, providerAPIResultReceiver);
+ providerAPICommand.setAction(ProviderAPI.LOG_IN);
+ providerAPICommand.putExtra(ProviderAPI.PARAMETERS, parameters);
+ startService(providerAPICommand);
}
public void signUp(String username, String password) {
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) {
Bundle parameters = new Bundle();
if (!password.isEmpty())
@@ -93,45 +209,176 @@ public abstract class ProviderCredentialsBaseActivity extends ButterKnifeActivit
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) {
+ }
+
+ @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;
+ }
+ });
- ProviderCredentialsReceiver(ProviderCredentialsBaseActivity activity) {
- this.activity = activity;
+ 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 hideKeyboard() {
+ InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(passwordField.getWindowToken(), 0);
}
+ }
+ 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();
+
+ mConfigState.setAction(SHOWING_FORM);
+ hideProgressBar();
+ }
+
+ private void successfullyFinished() {
+ Intent resultData = new Intent();
+ resultData.putExtra(Provider.KEY, provider);
+ setResult(RESULT_OK, resultData);
+ finish();
+ }
+
+ public class ProviderAPIBroadcastReceiver extends BroadcastReceiver {
@Override
- public void onReceiveResult(int resultCode, Bundle resultData) {
- if (resultCode == ProviderAPI.SUCCESSFUL_SIGNUP) {
- String username = resultData.getString(SessionDialog.USERNAME);
- String password = resultData.getString(SessionDialog.PASSWORD);
- activity.login(username, password);
- } else if (resultCode == ProviderAPI.FAILED_SIGNUP) {
- //MainActivity.sessionDialog(resultData);
- } else if (resultCode == ProviderAPI.SUCCESSFUL_LOGIN) {
- Intent intent = new Intent(activity, MainActivity.class);
- intent.setAction(ACTION_SHOW_VPN_FRAGMENT);
- activity.startActivity(intent);
- } 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) {
-// activity.eip_fragment.updateEipService();
-// activity.setResult(RESULT_OK);
-// } else if (resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
-// 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:
+ successfullyFinished();
+ //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/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
index d0868437..2b0c72db 100644
--- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
@@ -21,21 +21,14 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
-import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.View;
-import android.view.WindowManager;
import android.widget.ListView;
-import android.widget.ProgressBar;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
import com.pedrogomez.renderers.Renderer;
@@ -53,12 +46,10 @@ import butterknife.OnItemClick;
import se.leap.bitmaskclient.fragments.AboutFragment;
import static android.view.View.GONE;
-import static android.view.View.INVISIBLE;
-import static android.view.View.VISIBLE;
import static se.leap.bitmaskclient.Constants.APP_ACTION_QUIT;
import static se.leap.bitmaskclient.Constants.PROVIDER_ALLOW_ANONYMOUS;
import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
-import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
+import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
import static se.leap.bitmaskclient.ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE;
import static se.leap.bitmaskclient.ProviderAPI.ERRORS;
import static se.leap.bitmaskclient.ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE;
@@ -68,11 +59,10 @@ import static se.leap.bitmaskclient.ProviderAPI.PROVIDER_OK;
import static se.leap.bitmaskclient.ProviderAPI.PROVIDER_SET_UP;
import static se.leap.bitmaskclient.ProviderAPI.RESULT_CODE;
import static se.leap.bitmaskclient.ProviderAPI.RESULT_KEY;
-import static se.leap.bitmaskclient.ProviderAPI.UPDATE_PROGRESSBAR;
/**
* abstract base Activity that builds and shows the list of known available providers.
- * The implementation of BaseConfigurationWizard differ in that they may or may not allow to bypass
+ * The implementation of ProviderListBaseActivity differ in that they may or may not allow to bypass
* secure download mechanisms including certificate validation.
* <p/>
* It also allows the user to enter custom providers with a button.
@@ -81,12 +71,8 @@ import static se.leap.bitmaskclient.ProviderAPI.UPDATE_PROGRESSBAR;
* @author cyberta
*/
-public abstract class BaseConfigurationWizard extends ButterKnifeActivity
+public abstract class ProviderListBaseActivity extends ConfigWizardBaseActivity
implements NewProviderDialog.NewProviderDialogInterface, DownloadFailedDialog.DownloadFailedDialogInterface, ProviderAPIResultReceiver.Receiver {
- @InjectView(R.id.progressbar_configuration_wizard)
- protected ProgressBar mProgressBar;
- @InjectView(R.id.progressbar_description)
- protected TextView progressbarDescription;
@InjectView(R.id.provider_list)
protected ListView providerListView;
@@ -95,9 +81,10 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
private ProviderManager providerManager;
protected Intent mConfigState = new Intent(PROVIDER_NOT_SET);
- protected Provider selectedProvider;
- final public static String TAG = ConfigurationWizard.class.getSimpleName();
+ final public static String TAG = ProviderListActivity.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";
@@ -106,16 +93,10 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
final private static String REASON_TO_FAIL = "REASON TO FAIL";
final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
- final private static String PROGRESSBAR_TEXT = TAG + "PROGRESSBAR_TEXT";
- final private static String PROGRESSBAR_NUMBER = TAG + "PROGRESSBAR_NUMBER";
- final private static String ACTIVITY_STATE = "ACTIVITY STATE";
-
public ProviderAPIResultReceiver providerAPIResultReceiver;
private ProviderAPIBroadcastReceiver providerAPIBroadcastReceiver;
- protected static SharedPreferences preferences;
FragmentManagerEnhanced fragmentManager;
- //TODO: add some states (values for progressbarText) about ongoing setup or remove that field
private boolean isActivityShowing;
private String reasonToFail;
@@ -135,12 +116,8 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
@Override
protected void onSaveInstanceState(@NotNull Bundle outState) {
- if (mProgressBar != null)
- outState.putInt(PROGRESSBAR_NUMBER, mProgressBar.getProgress());
- 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) {
@@ -154,7 +131,6 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
fragmentManager = new FragmentManagerEnhanced(getSupportFragmentManager());
providerManager = ProviderManager.getInstance(getAssets(), getExternalFilesDir(null));
@@ -169,7 +145,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
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);
@@ -180,7 +156,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
if (SETTING_UP_PROVIDER.equals(mConfigState.getAction()) ||
PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())
) {
- onItemSelectedUi();
+ showProgressBar();
}
}
@@ -192,7 +168,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
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();
@@ -203,22 +179,10 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
private void setUpInitialUI() {
setContentView(R.layout.configuration_wizard_activity);
+ setProviderHeaderText(R.string.setup_provider);
hideProgressBar();
}
- private void hideProgressBar() {
- //needs to be "INVISIBLE" instead of GONE b/c the progressbarDescription gets translated
- // by the height of mProgressbar (and the height of the first list item)
- mProgressBar.setVisibility(INVISIBLE);
- progressbarDescription.setVisibility(INVISIBLE);
- mProgressBar.setProgress(0);
- }
-
- protected void showProgressBar() {
- mProgressBar.setVisibility(VISIBLE);
- progressbarDescription.setVisibility(VISIBLE);
- }
-
@Override
protected void onPause() {
super.onPause();
@@ -233,12 +197,21 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
providerAPIResultReceiver = null;
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_CODE_CONFIGURE_LEAP) {
+ if (resultCode == RESULT_OK) {
+ setResult(resultCode, data);
+ finish();
+ }
+ }
+ }
+
private void setUpProviderAPIResultReceiver() {
providerAPIResultReceiver = new ProviderAPIResultReceiver(new Handler(), this);
providerAPIBroadcastReceiver = new ProviderAPIBroadcastReceiver();
- IntentFilter updateIntentFilter = new IntentFilter(UPDATE_PROGRESSBAR);
- updateIntentFilter.addAction(PROVIDER_API_EVENT);
+ IntentFilter updateIntentFilter = new IntentFilter(PROVIDER_API_EVENT);
updateIntentFilter.addCategory(Intent.CATEGORY_DEFAULT);
registerReceiver(providerAPIBroadcastReceiver, updateIntentFilter);
}
@@ -247,9 +220,9 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
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();
}
@@ -259,9 +232,6 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
downloadVpnCertificate();
} else {
- mProgressBar.incrementProgressBy(1);
- hideProgressBar();
-
showProviderDetails();
}
}
@@ -277,8 +247,6 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
}
void handleCorrectlyDownloadedCertificate() {
- mProgressBar.incrementProgressBy(1);
- hideProgressBar();
showProviderDetails();
}
@@ -307,16 +275,11 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
//TODO Code 2 pane view
mConfigState.setAction(SETTING_UP_PROVIDER);
- selectedProvider = adapter.getItem(position);
- onItemSelectedUi();
+ provider = adapter.getItem(position);
+ showProgressBar();
onItemSelectedLogic();
}
- protected void onItemSelectedUi() {
- adapter.hideAllBut(adapter.indexOf(selectedProvider));
- startProgressBar();
- }
-
@Override
public void onBackPressed() {
if (SETTING_UP_PROVIDER.equals(mConfigState.getAction()) ||
@@ -330,9 +293,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
private void stopSettingUpProvider() {
ProviderAPI.stop();
- mProgressBar.setVisibility(GONE);
- mProgressBar.setProgress(0);
- progressbarDescription.setVisibility(GONE);
+ loadingScreen.setVisibility(GONE);
cancelSettingUpProvider();
}
@@ -352,7 +313,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
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);
@@ -371,34 +332,6 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
setResult(RESULT_CANCELED, askQuit);
}
- private void startProgressBar() {
- showProgressBar();
- mProgressBar.setProgress(0);
- mProgressBar.setMax(3);
-
- int measured_height = listItemHeight();
- mProgressBar.setTranslationY(measured_height);
- progressbarDescription.setTranslationY(measured_height + mProgressBar.getHeight());
- }
-
- private int listItemHeight() {
- View listItem = adapter.getView(0, null, providerListView);
- listItem.setLayoutParams(new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT));
- WindowManager wm = (WindowManager) getApplicationContext()
- .getSystemService(Context.WINDOW_SERVICE);
- Display display = wm.getDefaultDisplay();
- int screenWidth = display.getWidth(); // deprecated
-
- int listViewWidth = screenWidth - 10 - 10;
- int widthSpec = View.MeasureSpec.makeMeasureSpec(listViewWidth,
- View.MeasureSpec.AT_MOST);
- listItem.measure(widthSpec, 0);
-
- return listItem.getMeasuredHeight();
- }
-
/**
* Asks ProviderApiService to download an anonymous (anon) VPN certificate.
*/
@@ -461,11 +394,13 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
*/
public void showProviderDetails() {
// show only if current activity is shown
- if (isActivityShowing && !mConfigState.getAction().equalsIgnoreCase(SHOWING_PROVIDER_DETAILS)) {
+ if (isActivityShowing && mConfigState.getAction() != null &&
+ !mConfigState.getAction().equalsIgnoreCase(SHOWING_PROVIDER_DETAILS)) {
mConfigState.setAction(SHOWING_PROVIDER_DETAILS);
Intent intent = new Intent(this, ProviderDetailActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent);
+ intent.putExtra(PROVIDER_KEY, provider);
+ startActivityForResult(intent, REQUEST_CODE_CONFIGURE_LEAP);
}
}
@@ -491,39 +426,57 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity
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;
}
- if (action.equalsIgnoreCase(UPDATE_PROGRESSBAR)) {
- int update = intent.getIntExtra(ProviderAPI.CURRENT_PROGRESS, 0);
- mProgressBar.setProgress(update);
- } else if (action.equalsIgnoreCase(PROVIDER_API_EVENT)) {
+ if (mConfigState.getAction() != null &&
+ mConfigState.getAction().equalsIgnoreCase(SETTING_UP_PROVIDER)) {
int resultCode = intent.getIntExtra(RESULT_CODE, -1);
+ Log.d(TAG, "Broadcast resultCode: " + Integer.toString(resultCode));
- 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;
+ Bundle resultData = intent.getParcelableExtra(RESULT_KEY);
+ String handledProvider = resultData.getString(Provider.KEY);
+
+ String providerName = ConfigHelper.getProviderName(handledProvider);
+ String providerDomain = ConfigHelper.getProviderDomain(handledProvider);
+
+ //FIXME: remove that lines as soon as Provider gets sent via broadcast
+ if (resultCode == PROVIDER_OK && handledProvider == null) {
+ providerName = ConfigHelper.getProviderName(preferences);
+ providerDomain = ConfigHelper.getProviderDomain(preferences);
+ }
+ if (providerName != null && providerName.equalsIgnoreCase(provider.getName()) &&
+ providerDomain != null &&
+ providerDomain.equalsIgnoreCase(provider.getDomain())) {
+ switch (resultCode) {
+ case PROVIDER_OK:
+ handleProviderSetUp();
+ break;
+ case PROVIDER_NOK:
+ handleProviderSetupFailed(resultData);
+ break;
+ }
+ } else {
+ switch (resultCode) {
+ case CORRECTLY_DOWNLOADED_CERTIFICATE:
+ handleCorrectlyDownloadedCertificate();
+ break;
+ case INCORRECTLY_DOWNLOADED_CERTIFICATE:
+ handleIncorrectlyDownloadedCertificate();
+ break;
+ }
}
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/SignupActivity.java b/app/src/main/java/se/leap/bitmaskclient/SignupActivity.java
index f6344065..0ff792bb 100644
--- a/app/src/main/java/se/leap/bitmaskclient/SignupActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/SignupActivity.java
@@ -2,65 +2,38 @@ 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 android.view.View;
-import butterknife.InjectView;
import butterknife.OnClick;
+import static android.view.View.VISIBLE;
+
/**
* Create an account with a provider
*/
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);
- setProviderHeaderText("providerNAME");
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));
- }
- }
- });
+ passwordVerificationField.setVisibility(VISIBLE);
+ passwordVerificationError.setVisibility(VISIBLE);
}
@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/java/se/leap/bitmaskclient/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
index bb01ddc0..f5991538 100644
--- a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
@@ -55,7 +55,7 @@ public class StartActivity extends Activity {
case FIRST:
storeAppVersion();
// TODO start ProfileCreation & replace below code
- // (new Intent(getActivity(), ConfigurationWizard.class), Constants.REQUEST_CODE_SWITCH_PROVIDER);
+ // (new Intent(getActivity(), ProviderListActivity.class), Constants.REQUEST_CODE_SWITCH_PROVIDER);
break;
case UPGRADE:
@@ -153,9 +153,7 @@ public class StartActivity extends Activity {
//buildDashboard(getIntent().getBooleanExtra(EIP_RESTART_ON_BOOT, false));
// user_status_fragment.restoreSessionStatus(savedInstanceState);
- Intent intent = new Intent(this, MainActivity.class);
- intent.setAction(MainActivity.ACTION_SHOW_VPN_FRAGMENT);
- startActivity(intent);
+ showMainActivity();
}
} else {
configureLeapProvider();
@@ -166,7 +164,32 @@ public class StartActivity extends Activity {
if (getIntent().hasExtra(APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE)) {
getIntent().removeExtra(APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE);
}
- startActivityForResult(new Intent(this, ConfigurationWizard.class), REQUEST_CODE_CONFIGURE_LEAP);
+ startActivityForResult(new Intent(this, ProviderListActivity.class), REQUEST_CODE_CONFIGURE_LEAP);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (data == null) {
+ return;
+ }
+
+ if (requestCode == REQUEST_CODE_CONFIGURE_LEAP) {
+ if (resultCode == RESULT_OK && data.hasExtra(Provider.KEY)) {
+ Provider provider = data.getParcelableExtra(Provider.KEY);
+ ConfigHelper.storeProviderInPreferences(preferences, provider);
+
+ showMainActivity();
+ } else if (resultCode == RESULT_CANCELED) {
+ finish();
+ }
+ }
+ }
+
+ private void showMainActivity() {
+ Intent intent = new Intent(this, MainActivity.class);
+ intent.setAction(MainActivity.ACTION_SHOW_VPN_FRAGMENT);
+ startActivity(intent);
+ finish();
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
index 4f2d0744..090e8d26 100644
--- a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
@@ -27,7 +27,7 @@ import android.widget.ListView;
import android.widget.Toast;
import se.leap.bitmaskclient.ConfigHelper;
-import se.leap.bitmaskclient.ConfigurationWizard;
+import se.leap.bitmaskclient.ProviderListActivity;
import se.leap.bitmaskclient.EipFragment;
import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.fragments.AboutFragment;
@@ -143,7 +143,7 @@ public class NavigationDrawerFragment extends Fragment {
android.R.layout.simple_list_item_activated_1,
android.R.id.text1);
- String providerName = ConfigHelper.getCurrentProviderName(preferences);
+ String providerName = ConfigHelper.getProviderName(preferences);
if (providerName == null) {
//TODO: ADD A header to the ListView containing a useful message.
//TODO 2: disable switchProvider
@@ -304,7 +304,7 @@ public class NavigationDrawerFragment extends Fragment {
// TODO STOP VPN
// if (provider.hasEIP()) eip_fragment.stopEipIfPossible();
preferences.edit().clear().apply();
- startActivityForResult(new Intent(getActivity(), ConfigurationWizard.class), REQUEST_CODE_SWITCH_PROVIDER);
+ startActivityForResult(new Intent(getActivity(), ProviderListActivity.class), REQUEST_CODE_SWITCH_PROVIDER);
break;
case 1:
mTitle = getString(R.string.log_fragment_title);
diff --git a/app/src/main/res/drawable/action_history.xml b/app/src/main/res/drawable/action_history.xml
new file mode 100644
index 00000000..97c7c6dc
--- /dev/null
+++ b/app/src/main/res/drawable/action_history.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+android:width="24dp"
+android:height="24dp"
+android:viewportWidth="24.0"
+android:viewportHeight="24.0">
+<path
+ android:fillColor="#FF000000"
+ android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"/>
+</vector> \ No newline at end of file
diff --git a/app/src/main/res/layout-xlarge/a_provider_detail.xml b/app/src/main/res/layout-xlarge/a_provider_detail.xml
new file mode 100644
index 00000000..31538f9f
--- /dev/null
+++ b/app/src/main/res/layout-xlarge/a_provider_detail.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ style="@style/BitmaskActivity" >
+
+ <include layout="@layout/loading_screen" />
+
+ <android.support.v7.widget.AppCompatTextView
+ android:id="@+id/provider_detail_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="24sp"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <android.support.v7.widget.AppCompatTextView
+ android:id="@+id/provider_detail_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="18sp"
+ android:textStyle="normal"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <ListView
+ android:id="@+id/provider_detail_options"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/standard_margin"
+ />
+
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout-xlarge/configuration_wizard_activity.xml b/app/src/main/res/layout-xlarge/configuration_wizard_activity.xml
index 50bb5d0b..581b0c9a 100644
--- a/app/src/main/res/layout-xlarge/configuration_wizard_activity.xml
+++ b/app/src/main/res/layout-xlarge/configuration_wizard_activity.xml
@@ -3,7 +3,8 @@
android:id="@+id/configuration_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".ConfigurationWizard" >
+ tools:context=".ProviderListActivity"
+ style="@style/BitmaskActivity" >
<ListView
android:id="@+id/provider_list"
diff --git a/app/src/main/res/layout-xlarge/provider_detail_fragment.xml b/app/src/main/res/layout-xlarge/provider_detail_fragment.xml
deleted file mode 100644
index 860f99d9..00000000
--- a/app/src/main/res/layout-xlarge/provider_detail_fragment.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/provider_detail_domain"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:layout_marginTop="16dp"
- android:textSize="32sp"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/provider_detail_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
- android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:layout_marginBottom="4dp"
- android:textSize="24sp"
- android:textStyle="italic"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <TextView
- android:id="@+id/provider_detail_description"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
- android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:layout_marginBottom="4dp"
- android:textSize="18sp"
- android:textStyle="normal"
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
- <ListView
- android:id="@+id/provider_detail_options"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
-</LinearLayout> \ No newline at end of file
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 5ecb807c..00000000
--- a/app/src/main/res/layout/a_login.xml
+++ /dev/null
@@ -1,29 +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">
-
- <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">
-
- <Button
- 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> \ 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/a_provider_detail.xml b/app/src/main/res/layout/a_provider_detail.xml
new file mode 100644
index 00000000..5f07b87c
--- /dev/null
+++ b/app/src/main/res/layout/a_provider_detail.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/provider_detail_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ style="@style/BitmaskActivity" >
+
+ <include layout="@layout/loading_screen" />
+
+ <LinearLayout
+ android:id="@+id/content"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <include
+ layout="@layout/provider_header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <android.support.v7.widget.AppCompatTextView
+ android:id="@+id/provider_detail_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textStyle="normal"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:layout_marginTop="@dimen/standard_margin"
+ android:layout_marginBottom="@dimen/standard_margin"
+ />
+
+ <ListView
+ android:id="@+id/provider_detail_options"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/standard_margin"
+ android:drawSelectorOnTop="false"/>
+
+ </LinearLayout>
+</LinearLayout> \ No newline at end of file
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 edcaea45..00000000
--- a/app/src/main/res/layout/a_signup.xml
+++ /dev/null
@@ -1,29 +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">
-
- <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">
-
- <Button
- 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> \ No newline at end of file
diff --git a/app/src/main/res/layout/configuration_wizard_activity.xml b/app/src/main/res/layout/configuration_wizard_activity.xml
index 71cd5314..e22d9047 100644
--- a/app/src/main/res/layout/configuration_wizard_activity.xml
+++ b/app/src/main/res/layout/configuration_wizard_activity.xml
@@ -3,29 +3,27 @@
android:id="@+id/configuration_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".ConfigurationWizard" >
+ tools:context=".ProviderListActivity"
+ style="@style/BitmaskActivity" >
- <ListView
- android:id="@+id/provider_list"
+ <include layout="@layout/loading_screen" />
+
+ <LinearLayout
+ android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:drawSelectorOnTop="false" />
+ android:orientation="vertical">
+
+ <include layout="@layout/provider_header" />
+
+ <ListView
+ android:id="@+id/provider_list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:drawSelectorOnTop="false"
+ android:layout_marginTop="@dimen/standard_margin"
+ />
+
+ </LinearLayout>
- <ProgressBar
- android:id="@+id/progressbar_configuration_wizard"
- style="?android:attr/progressBarStyleHorizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:max="3" />
-
- <TextView
- android:id="@+id/progressbar_description"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:fadingEdge="horizontal"
- android:singleLine="true"
- android:text="@string/configuring_provider"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_centerHorizontal="true"
- android:textColor="@android:color/holo_blue_bright" />
</RelativeLayout>
diff --git a/app/src/main/res/layout/loading_screen.xml b/app/src/main/res/layout/loading_screen.xml
new file mode 100644
index 00000000..f4c7eb95
--- /dev/null
+++ b/app/src/main/res/layout/loading_screen.xml
@@ -0,0 +1,41 @@
+<?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/loading_screen"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:visibility="gone">
+
+ <android.support.v7.widget.AppCompatImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:adjustViewBounds="true"
+ app:tint="@color/colorPrimary"
+ app:srcCompat="@drawable/action_history"
+ android:layout_marginTop="@dimen/loading_screen_icon_vertical_margin"
+ android:layout_marginBottom="@dimen/loading_screen_icon_vertical_margin"
+ />
+
+ <android.support.v7.widget.AppCompatTextView
+ android:id="@+id/progressbar_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fadingEdge="horizontal"
+ android:singleLine="true"
+ android:text="@string/configuring_provider"
+ android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
+ android:layout_marginTop="@dimen/standard_margin"
+ android:layout_marginBottom="@dimen/standard_margin"
+ />
+
+ <ProgressBar
+ android:id="@+id/progressbar"
+ style="@style/Widget.AppCompat.ProgressBar.Horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:indeterminate="true"
+ android:layout_marginTop="@dimen/standard_margin"
+ />
+
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/provider_credentials.xml b/app/src/main/res/layout/provider_credentials.xml
new file mode 100644
index 00000000..6e4dff95
--- /dev/null
+++ b/app/src/main/res/layout/provider_credentials.xml
@@ -0,0 +1,66 @@
+<?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">
+
+ <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"
+ app:errorEnabled="true"
+ android:layout_marginTop="@dimen/standard_margin"
+ >
+
+ <android.support.design.widget.TextInputEditText
+ android:id="@+id/provider_credentials_username"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:inputType="text" />
+
+ </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"
+ android:hint="@string/password"
+ app:errorEnabled="true">
+
+ <android.support.design.widget.TextInputEditText
+ android:id="@+id/provider_credentials_password"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textPassword"
+ />
+
+ </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_login.xml b/app/src/main/res/layout/provider_credentials_login.xml
deleted file mode 100644
index 9c52b9b5..00000000
--- a/app/src/main/res/layout/provider_credentials_login.xml
+++ /dev/null
@@ -1,36 +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" >
-
- <android.support.design.widget.TextInputLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="@string/auth_username"
- app:errorEnabled="true">
-
- <android.support.design.widget.TextInputEditText
- android:id="@+id/provider_credentials_username"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="text" />
-
- </android.support.design.widget.TextInputLayout>
-
- <android.support.design.widget.TextInputLayout
- 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"
- 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/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/layout/provider_detail_fragment.xml b/app/src/main/res/layout/provider_detail_fragment.xml
deleted file mode 100644
index 3db32b2c..00000000
--- a/app/src/main/res/layout/provider_detail_fragment.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/provider_detail_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/provider_detail_domain"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:layout_marginTop="16dp"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/provider_detail_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
- android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:layout_marginBottom="4dp"
- android:textStyle="italic"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <TextView
- android:id="@+id/provider_detail_description"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
- android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:layout_marginBottom="4dp"
- android:textStyle="normal"
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
- <ListView
- android:id="@+id/provider_detail_options"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/provider_header.xml b/app/src/main/res/layout/provider_header.xml
index 89cbd7b2..8a757181 100644
--- a/app/src/main/res/layout/provider_header.xml
+++ b/app/src/main/res/layout/provider_header.xml
@@ -2,16 +2,21 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
- <ImageView
+ <android.support.v7.widget.AppCompatImageView
android:id="@+id/provider_header_logo"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_width="@dimen/round_button_diameter"
+ android:layout_height="@dimen/round_button_diameter"
+ android:adjustViewBounds="true"
app:srcCompat="@drawable/mask" />
- <TextView
+ <android.support.v7.widget.AppCompatTextView
android:id="@+id/provider_header_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="" />
+ android:text=""
+ android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
+ android:layout_marginTop="@dimen/standard_margin"
+ android:layout_marginBottom="@dimen/standard_margin"
+ />
</merge>
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
index 09c44fb2..9f36e474 100644
--- a/app/src/main/res/values-v21/styles.xml
+++ b/app/src/main/res/values-v21/styles.xml
@@ -26,6 +26,11 @@
<item name="android:colorAccent">@color/accent</item>
</style>
+ <style name="BitmaskButton" parent="android:Widget.Button">
+ <item name="android:textAllCaps">true</item>
+ <item name="android:backgroundTint">@color/colorPrimary</item>
+ </style>
+
<style name="BitmaskButtonBlack" parent="android:Widget.Button">
<item name="android:textAllCaps">true</item>
<item name="android:backgroundTint">@color/black800</item>
diff --git a/app/src/main/res/values-v21/themes.xml b/app/src/main/res/values-v21/themes.xml
new file mode 100644
index 00000000..d6145217
--- /dev/null
+++ b/app/src/main/res/values-v21/themes.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="BitmaskTheme" parent="Theme.AppCompat.Light.NoActionBar">
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+
+ <item name="textColorError">@color/colorError</item>
+
+ <!-- progressBar color -->
+ <item name="colorAccent">@color/colorPrimary</item>
+
+ <!-- button and controls -->
+ <item name="android:buttonStyle">@style/BitmaskButton</item>
+ <item name="android:colorButtonNormal">@color/colorPrimary</item>
+ <item name="android:colorControlHighlight">@color/colorPrimaryDark</item>
+ </style>
+
+ <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
+ <item name="android:colorPrimary">@color/colorPrimary</item>
+ <item name="android:colorPrimaryDark">@color/colorPrimary</item>
+ <item name="android:windowBackground">@drawable/splash_page</item>
+ </style>
+
+</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 3e06cbe2..a6afc8bc 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -6,6 +6,7 @@
<resources>
<dimen name="paddingItemsSidebarLog">20dp</dimen>
<dimen name="stdpadding">8dp</dimen>
+ <dimen name="standard_margin">8dp</dimen>
<bool name="logSildersAlwaysVisible">false</bool>
<dimen name="diameter">48dp</dimen>
@@ -21,8 +22,11 @@
<dimen name="activity_margin">16dp</dimen>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
+ <dimen name="list_view_margin_top">24dp</dimen>
<!-- Per the design guidelines, navigation drawers should be between 240dp and 320dp:
https://developer.android.com/design/patterns/navigation-drawer.html -->
<dimen name="navigation_drawer_width">300dp</dimen>
+
+ <dimen name="loading_screen_icon_vertical_margin">16dp</dimen>
</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5205a628..c1443138 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -42,8 +42,11 @@
<string name="error_no_such_algorithm_exception_user_message">Encryption algorithm not found. Please upgrade Android!</string>
<string name="signup_or_login_button">Sign Up/Log In</string>
<string name="login_button">Log In</string>
+ <string name="login_to_profile">Log in to profile</string>
<string name="logout_button">Log Out</string>
<string name="signup_button">Sign Up</string>
+ <string name="create_profile">Create profile</string>
+ <string name="setup_provider">Set up provider</string>
<string name="setup_error_title">Configuration Error</string>
<string name="setup_error_configure_button">Configure</string>
<string name="setup_error_close_button">Exit</string>
@@ -75,6 +78,8 @@
<string name="didnt_log_out_user_status">didn\'t log out. Try later, it may be a problem in the network or with the provider. Should it persist, wipe the Bitmask data from the Android settings.</string>
<string name="not_logged_in_user_status">have not logged in.</string>
<string name="logging_in_user_status">is logging in.</string>
+ <string name="logging_in">Logging in</string>
+ <string name="signing_up">Signing up</string>
<string name="logging_out_user_status">is logging out.</string>
<string name="signingup_message">is being registered.</string>
<string name="vpn.button.turn.on">Turn on</string>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 0f41ea86..867fa54f 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -62,7 +62,10 @@
<style name="BitmaskButton" parent="android:Widget.Button">
<item name="android:textAllCaps">true</item>
- <item name="android:color">@color/colorPrimary</item>
+ </style>
+
+ <style name="BitmaskActivity">
+ <item name="android:padding">@dimen/activity_margin</item>
</style>
<style name="BitmaskButtonBlack" parent="android:Widget.Button">
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 76cfd866..70bc3e16 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -3,10 +3,16 @@
<style name="BitmaskTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimary</item>
+
<item name="textColorError">@color/colorError</item>
- <item name="android:buttonStyle">@style/BitmaskButton</item>
+ <!-- progressBar color -->
+ <item name="colorAccent">@color/colorPrimary</item>
+ <!-- button and controls -->
+ <item name="android:buttonStyle">@style/BitmaskButton</item>
+ <item name="colorButtonNormal">@color/colorPrimaryDark</item>
+ <item name="colorControlHighlight">@color/colorPrimaryDark</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
diff --git a/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java
index b1deae67..8c008024 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java
@@ -30,7 +30,7 @@ import java.net.URL;
* @author parmegv
* @author cyberta
*/
-public class ConfigurationWizard extends BaseConfigurationWizard {
+public class ProviderListActivity extends ProviderListBaseActivity {
@Override
@@ -40,19 +40,19 @@ 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();
+ showProgressBar();
}
/**
@@ -63,15 +63,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 +87,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);
diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderListContent.java b/app/src/production/java/se/leap/bitmaskclient/ProviderListContent.java
index 6466e769..d9e1d1a9 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderListContent.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderListContent.java
@@ -20,7 +20,7 @@ import java.util.*;
import java.net.*;
/**
- * Models the provider list shown in the ConfigurationWizard.
+ * Models the provider list shown in the ProviderListActivity.
*
* @author parmegv
*/