summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java140
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java3
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java4
-rw-r--r--app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java107
-rw-r--r--gradle/wrapper/gradle-wrapper.properties4
5 files changed, 161 insertions, 97 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
index 38084493..7c79c7c7 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -18,9 +18,7 @@ package se.leap.bitmaskclient;
import android.app.*;
import android.content.*;
-import android.content.res.AssetManager;
import android.os.*;
-import android.util.Log;
import android.view.*;
import android.widget.*;
import java.io.*;
@@ -33,9 +31,7 @@ import se.leap.bitmaskclient.NewProviderDialog.NewProviderDialogInterface;
import se.leap.bitmaskclient.ProviderAPIResultReceiver.Receiver;
import se.leap.bitmaskclient.ProviderDetailFragment.ProviderDetailFragmentInterface;
import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
-import se.leap.bitmaskclient.FragmentManagerEnhanced;
import se.leap.bitmaskclient.eip.Constants;
-import se.leap.bitmaskclient.R;
/**
* Activity that builds and shows the list of known available providers.
@@ -52,6 +48,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
private TextView progressbar_description;
private ProviderListFragment provider_list_fragment;
private Intent mConfigState = new Intent();
+ private ProviderItem selected_provider;
final public static String TAG = ConfigurationWizard.class.getSimpleName();
final public static String TYPE_OF_CERTIFICATE = "type_of_certificate";
@@ -61,6 +58,9 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
final protected static String PROVIDER_SET = "PROVIDER SET";
final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
final protected static String ASSETS_URL_FOLDER = "urls";
+
+ final private static String PROGRESSBAR_TEXT = TAG + "PROGRESSBAR_TEXT";
+ final private static String PROGRESSBAR_NUMBER = TAG + "PROGRESSBAR_NUMBER";
public ProviderAPIResultReceiver providerAPI_result_receiver;
private ProviderAPIBroadcastReceiver_Update providerAPI_broadcast_receiver_update;
@@ -68,32 +68,62 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
private static SharedPreferences preferences;
FragmentManagerEnhanced fragment_manager;
private static boolean setting_up_provider = false;
-
+ private String progressbar_text = "";
+ private String provider_name = "";
+ private int progress = -1;
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ if(mProgressBar != null)
+ outState.putInt(PROGRESSBAR_NUMBER, mProgressBar.getProgress());
+ if(progressbar_description != null)
+ outState.putString(PROGRESSBAR_TEXT, progressbar_description.getText().toString());
+ if(selected_provider != null)
+ outState.putString(Provider.NAME, selected_provider.name());
+ outState.putParcelable(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+ super.onSaveInstanceState(outState);
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
- fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
+ preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
+ fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
+
+ setUpInitialUI();
- setUpInitialUI();
+ loadPreseededProviders();
- loadPreseededProviders();
+ setUpProviderAPIResultReceiver();
- setUpProviderAPIResultReceiver();
-
- // Only create our fragments if we're not restoring a saved instance
- if ( savedInstanceState == null ){
- // TODO Some welcome screen?
- // We will need better flow control when we have more Fragments (e.g. user auth)
- setUpProviderList();
+ setUpProviderList();
+
+ if(savedInstanceState != null) {
+ progressbar_text = savedInstanceState.getString(PROGRESSBAR_TEXT, "");
+ provider_name = savedInstanceState.getString(Provider.NAME, "");
+ selected_provider = getProvider(provider_name);
+ progress = savedInstanceState.getInt(PROGRESSBAR_NUMBER, -1);
+ providerAPI_result_receiver = savedInstanceState.getParcelable(ProviderAPI.RECEIVER_KEY);
+ providerAPI_result_receiver.setReceiver(this);
}
+ }
- // TODO: If exposing deep links into your app, handle intents here.
+ @Override
+ protected void onPostResume() {
+ super.onPostResume();
+ if(!progressbar_text.isEmpty() && !provider_name.isEmpty() && progress != -1) {
+ progressbar_description.setText(progressbar_text);
+ onItemSelectedUi(getProvider(provider_name));
+ mProgressBar.setProgress(progress);
+
+ progressbar_text = "";
+ provider_name = "";
+ progress = -1;
+ }
}
private void setUpInitialUI() {
- setContentView(R.layout.configuration_wizard_activity);
-
+ setContentView(R.layout.configuration_wizard_activity);
hideProgressBar();
}
@@ -119,15 +149,15 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
private void putProviderListFragment(ProviderListFragment fragment) {
-
fragment_manager.replace(R.id.configuration_wizard_layout, provider_list_fragment, ProviderListFragment.TAG);
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- unregisterReceiver(providerAPI_broadcast_receiver_update);
- }
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if(providerAPI_broadcast_receiver_update != null)
+ unregisterReceiver(providerAPI_broadcast_receiver_update);
+ }
private void setUpProviderAPIResultReceiver() {
providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
@@ -153,12 +183,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
hideProgressBar();
setResult(RESULT_OK);
-
+
showProviderDetails();
}
} else if(resultCode == ProviderAPI.PROVIDER_NOK) {
hideProgressBar();
- preferences.edit().remove(Provider.KEY).commit();
+ preferences.edit().remove(Provider.KEY).apply();
setting_up_provider = false;
setResult(RESULT_CANCELED, mConfigState);
@@ -169,10 +199,10 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) {
mProgressBar.incrementProgressBy(1);
hideProgressBar();
-
- setResult(RESULT_OK);
-
+
showProviderDetails();
+
+ setResult(RESULT_OK);
} else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
hideProgressBar();
@@ -190,17 +220,20 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
@Override
public void onItemSelected(String id) {
//TODO Code 2 pane view
- ProviderItem selected_provider = getProvider(id);
- int provider_index = getProviderIndex(id);
-
- startProgressBar(provider_index+1);
- provider_list_fragment.hideAllBut(provider_index);
+ selected_provider = getProvider(id);
+ onItemSelectedUi(selected_provider);
boolean danger_on = true;
if(preferences.contains(ProviderItem.DANGER_ON))
danger_on = preferences.getBoolean(ProviderItem.DANGER_ON, false);
setUpProvider(selected_provider.providerMainUrl(), danger_on);
}
+
+ private void onItemSelectedUi(ProviderItem provider) {
+ startProgressBar();
+ int provider_index = getProviderIndex(provider.name());
+ provider_list_fragment.hideAllBut(provider_index);
+ }
@Override
public void onBackPressed() {
@@ -216,7 +249,8 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
mProgressBar.setVisibility(ProgressBar.GONE);
mProgressBar.setProgress(0);
progressbar_description.setVisibility(TextView.GONE);
- preferences.edit().remove(Provider.KEY).commit();
+
+ preferences.edit().remove(Provider.KEY).apply();
setting_up_provider = false;
showAllProviders();
}
@@ -254,19 +288,16 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
return null;
}
- private void startProgressBar() {
- mProgressBar.setVisibility(ProgressBar.VISIBLE);
- progressbar_description.setVisibility(TextView.VISIBLE);
- mProgressBar.setProgress(0);
- mProgressBar.setMax(3);
- }
-
- private void startProgressBar(int list_item_index) {
- startProgressBar();
- int measured_height = listItemHeight(list_item_index);
- mProgressBar.setTranslationY(measured_height);
- progressbar_description.setTranslationY(measured_height + mProgressBar.getHeight());
- }
+ private void startProgressBar() {
+ mProgressBar.setVisibility(ProgressBar.VISIBLE);
+ progressbar_description.setVisibility(TextView.VISIBLE);
+ mProgressBar.setProgress(0);
+ mProgressBar.setMax(3);
+
+ int measured_height = listItemHeight();
+ mProgressBar.setTranslationY(measured_height);
+ progressbar_description.setTranslationY(measured_height + mProgressBar.getHeight());
+ }
private int getProviderIndex(String id) {
int index = 0;
@@ -280,7 +311,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
return index;
}
- private int listItemHeight(int list_item_index) {
+ private int listItemHeight() {
ListView provider_list_view = (ListView)findViewById(android.R.id.list);
ListAdapter provider_list_adapter = provider_list_view.getAdapter();
View listItem = provider_list_adapter.getView(0, null, provider_list_view);
@@ -433,7 +464,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail);
newFragment.show(fragment_transaction, DownloadFailedDialog.TAG);
}
-
+
/**
* Once selected a provider, this fragment offers the user to log in,
* use it anonymously (if possible)
@@ -450,11 +481,11 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
public void showAndSelectProvider(String provider_main_url, boolean danger_on) {
if(getId(provider_main_url).isEmpty())
- showProvider(provider_main_url, danger_on);
+ showProvider(provider_main_url);
autoSelectProvider(provider_main_url, danger_on);
}
- private void showProvider(final String provider_main_url, final boolean danger_on) {
+ private void showProvider(final String provider_main_url) {
String provider_name = provider_main_url.replaceFirst("http[s]?://", "").replaceFirst("\\/", "_");
ProviderItem added_provider = new ProviderItem(provider_name, provider_main_url);
provider_list_fragment.addItem(added_provider);
@@ -467,8 +498,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
/**
* Asks ProviderAPI to download a new provider.json file
- * @param provider_name
- * @param provider_main_url
+n * @param provider_main_url
* @param danger_on tells if HTTPS client should bypass certificate errors
*/
public void setUpProvider(String provider_main_url, boolean danger_on) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 8143d8d6..94de2fe8 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -86,7 +86,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
handleVersion();
-
boolean provider_configured = preferences.getString(Constants.KEY, "").isEmpty();
if (provider_configured)
startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
@@ -136,7 +135,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
preferences.edit().putInt(Constants.PARSED_SERIAL, 0).apply();
preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply();
updateEipService();
- buildDashboard(false);
invalidateOptionsMenu();
if(data != null && data.hasExtra(LogInDialog.TAG)) {
logInDialog(Bundle.EMPTY);
@@ -205,7 +203,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
eip_fragment.setArguments(arguments);
}
- fragment_manager.removePreviousFragment(EipServiceFragment.TAG);
fragment_manager.replace(R.id.servicesCollection, eip_fragment, EipServiceFragment.TAG);
if (hide_and_turn_on_eip) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java b/app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java
index c4844be9..49af9274 100644
--- a/app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java
+++ b/app/src/main/java/se/leap/bitmaskclient/FragmentManagerEnhanced.java
@@ -45,6 +45,10 @@ public class FragmentManagerEnhanced {
transaction.replace(containerViewId, fragment, tag).commit();
}
+ public FragmentTransaction beginTransaction() {
+ return generic_fragment_manager.beginTransaction();
+ }
+
public Fragment findFragmentByTag(String tag) {
return generic_fragment_manager.findFragmentByTag(tag);
}
diff --git a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java
index d3203ab3..9afcf8a1 100644
--- a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -18,9 +18,7 @@ package se.leap.bitmaskclient;
import android.app.*;
import android.content.*;
-import android.content.res.AssetManager;
import android.os.*;
-import android.util.Log;
import android.view.*;
import android.widget.*;
import java.io.*;
@@ -52,6 +50,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
private TextView progressbar_description;
private ProviderListFragment provider_list_fragment;
private Intent mConfigState = new Intent();
+ private ProviderItem selected_provider;
final public static String TAG = ConfigurationWizard.class.getSimpleName();
final public static String TYPE_OF_CERTIFICATE = "type_of_certificate";
@@ -61,6 +60,9 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
final protected static String PROVIDER_SET = "PROVIDER SET";
final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
final protected static String ASSETS_URL_FOLDER = "urls";
+
+ final private static String PROGRESSBAR_TEXT = TAG + "PROGRESSBAR_TEXT";
+ final private static String PROGRESSBAR_NUMBER = TAG + "PROGRESSBAR_NUMBER";
public ProviderAPIResultReceiver providerAPI_result_receiver;
private ProviderAPIBroadcastReceiver_Update providerAPI_broadcast_receiver_update;
@@ -68,6 +70,21 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
private static SharedPreferences preferences;
FragmentManagerEnhanced fragment_manager;
private static boolean setting_up_provider = false;
+ private String progressbar_text = "";
+ private String provider_name = "";
+ private int progress = -1;
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ if(mProgressBar != null)
+ outState.putInt(PROGRESSBAR_NUMBER, mProgressBar.getProgress());
+ if(progressbar_description != null)
+ outState.putString(PROGRESSBAR_TEXT, progressbar_description.getText().toString());
+ if(selected_provider != null)
+ outState.putString(Provider.NAME, selected_provider.name());
+ outState.putParcelable(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+ super.onSaveInstanceState(outState);
+ }
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -80,16 +97,32 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
loadPreseededProviders();
setUpProviderAPIResultReceiver();
-
- // Only create our fragments if we're not restoring a saved instance
- if ( savedInstanceState == null ) {
- // TODO Some welcome screen?
- // We will need better flow control when we have more Fragments (e.g. user auth)
- setUpProviderList();
+
+ setUpProviderList();
+
+ if ( savedInstanceState != null ) {
+ progressbar_text = savedInstanceState.getString(PROGRESSBAR_TEXT, "");
+ provider_name = savedInstanceState.getString(Provider.NAME, "");
+ selected_provider = getProvider(provider_name);
+ progress = savedInstanceState.getInt(PROGRESSBAR_NUMBER, -1);
+ providerAPI_result_receiver = savedInstanceState.getParcelable(ProviderAPI.RECEIVER_KEY);
+ providerAPI_result_receiver.setReceiver(this);
}
+ }
- // TODO: If exposing deep links into your app, handle intents here.
- }
+ @Override
+ protected void onPostResume() {
+ super.onPostResume();
+ if(!progressbar_text.isEmpty() && !provider_name.isEmpty() && progress != -1) {
+ progressbar_description.setText(progressbar_text);
+ onItemSelectedUi(getProvider(provider_name));
+ mProgressBar.setProgress(progress);
+
+ progressbar_text = "";
+ provider_name = "";
+ progress = -1;
+ }
+ }
private void setUpInitialUI() {
setContentView(R.layout.configuration_wizard_activity);
@@ -122,11 +155,11 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
fragment_manager.replace(R.id.configuration_wizard_layout, provider_list_fragment, ProviderListFragment.TAG);
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- unregisterReceiver(providerAPI_broadcast_receiver_update);
- }
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ unregisterReceiver(providerAPI_broadcast_receiver_update);
+ }
private void setUpProviderAPIResultReceiver() {
providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
@@ -169,9 +202,9 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
mProgressBar.incrementProgressBy(1);
hideProgressBar();
- setResult(RESULT_OK);
-
showProviderDetails();
+
+ setResult(RESULT_OK);
} else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
hideProgressBar();
@@ -189,14 +222,16 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
@Override
public void onItemSelected(String id) {
//TODO Code 2 pane view
- ProviderItem selected_provider = getProvider(id);
- int provider_index = getProviderIndex(id);
-
- startProgressBar(provider_index+1);
- provider_list_fragment.hideAllBut(provider_index);
-
+ selected_provider = getProvider(id);
+ onItemSelectedUi(selected_provider);
setUpProvider(selected_provider.providerMainUrl());
}
+
+ private void onItemSelectedUi(ProviderItem provider) {
+ startProgressBar();
+ int provider_index = getProviderIndex(provider.name());
+ provider_list_fragment.hideAllBut(provider_index);
+ }
@Override
public void onBackPressed() {
@@ -212,6 +247,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
mProgressBar.setVisibility(ProgressBar.GONE);
mProgressBar.setProgress(0);
progressbar_description.setVisibility(TextView.GONE);
+
preferences.edit().remove(Provider.KEY).commit();
setting_up_provider = false;
showAllProviders();
@@ -250,19 +286,16 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
return null;
}
- private void startProgressBar() {
- mProgressBar.setVisibility(ProgressBar.VISIBLE);
- progressbar_description.setVisibility(TextView.VISIBLE);
- mProgressBar.setProgress(0);
- mProgressBar.setMax(3);
- }
-
- private void startProgressBar(int list_item_index) {
- startProgressBar();
- int measured_height = listItemHeight(list_item_index);
- mProgressBar.setTranslationY(measured_height);
- progressbar_description.setTranslationY(measured_height + mProgressBar.getHeight());
- }
+ private void startProgressBar() {
+ mProgressBar.setVisibility(ProgressBar.VISIBLE);
+ progressbar_description.setVisibility(TextView.VISIBLE);
+ mProgressBar.setProgress(0);
+ mProgressBar.setMax(3);
+
+ int measured_height = listItemHeight();
+ mProgressBar.setTranslationY(measured_height);
+ progressbar_description.setTranslationY(measured_height + mProgressBar.getHeight());
+ }
private int getProviderIndex(String id) {
int index = 0;
@@ -276,7 +309,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
return index;
}
- private int listItemHeight(int list_item_index) {
+ private int listItemHeight() {
ListView provider_list_view = (ListView)findViewById(android.R.id.list);
ListAdapter provider_list_adapter = provider_list_view.getAdapter();
View listItem = provider_list_adapter.getView(0, null, provider_list_view);
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 170d65de..c8e43f9e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Nov 04 16:20:08 CET 2014
+#Wed Dec 03 00:07:42 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip