summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-12-16 17:43:14 +0100
committerParménides GV <parmegv@sdf.org>2014-12-16 17:43:14 +0100
commit31bd970bbc888e5fe21a1396a8365504decf8d7e (patch)
treeaec0a8134aaeb29e75ade251ff17237517065559 /app/src/main
parent14692f1ad6ae6f6d3b07400c743352e4aed3f23a (diff)
parentdbd6f2c57e4565d4e7a76b4ae2a5520aa877f121 (diff)
Merge branch 'develop' into release-0.8.1
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java19
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java (renamed from app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java)17
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/SessionDialog.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java5
4 files changed, 24 insertions, 19 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 862086eb..cca9c63c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -77,7 +77,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
@InjectView(R.id.providerName)
TextView provider_name;
- EipServiceFragment eip_fragment;
+ EipFragment eip_fragment;
private Provider provider;
private static boolean authed_eip;
public ProviderAPIResultReceiver providerAPI_result_receiver;
@@ -220,17 +220,17 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
provider_name.setText(provider.getDomain());
if ( provider.hasEIP()){
- fragment_manager.removePreviousFragment(EipServiceFragment.TAG);
- eip_fragment = new EipServiceFragment();
+ fragment_manager.removePreviousFragment(EipFragment.TAG);
+ eip_fragment = new EipFragment();
if (hide_and_turn_on_eip) {
preferences.edit().remove(Dashboard.START_ON_BOOT).apply();
Bundle arguments = new Bundle();
- arguments.putBoolean(EipServiceFragment.START_ON_BOOT, true);
+ arguments.putBoolean(EipFragment.START_ON_BOOT, true);
if(eip_fragment != null) eip_fragment.setArguments(arguments);
}
- fragment_manager.replace(R.id.servicesCollection, eip_fragment, EipServiceFragment.TAG);
+ fragment_manager.replace(R.id.servicesCollection, eip_fragment, EipFragment.TAG);
if (hide_and_turn_on_eip) {
onBackPressed();
@@ -312,7 +312,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
}
- private Intent prepareProviderAPICommand() {
+ protected Intent prepareProviderAPICommand() {
providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
providerAPI_result_receiver.setReceiver(this);
@@ -474,6 +474,13 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
hideProgressBar();
setResult(RESULT_CANCELED);
}
+ else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_EIP_SERVICE) {
+ setResult(RESULT_OK);
+
+ updateEipService();
+ } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_EIP_SERVICE) {
+ setResult(RESULT_CANCELED);
+ }
}
private void updateEipService() {
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index 1b40c94c..92d2a8bd 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -27,9 +27,9 @@ import se.leap.bitmaskclient.eip.Constants;
import se.leap.bitmaskclient.eip.EIP;
import se.leap.bitmaskclient.eip.EipStatus;
-public class EipServiceFragment extends Fragment implements Observer {
+public class EipFragment extends Fragment implements Observer {
- public static String TAG = "se.leap.bitmask.EipServiceFragment";
+ public static String TAG = EipFragment.class.getSimpleName();
protected static final String IS_PENDING = TAG + ".is_pending";
protected static final String IS_CONNECTED = TAG + ".is_connected";
@@ -53,6 +53,11 @@ public class EipServiceFragment extends Fragment implements Observer {
public void onAttach(Activity activity) {
super.onAttach(activity);
parent_activity = activity;
+
+ Dashboard dashboard = (Dashboard) parent_activity;
+ Intent provider_API_command = dashboard.prepareProviderAPICommand();
+ provider_API_command.setAction(ProviderAPI.DOWNLOAD_EIP_SERVICE);
+ parent_activity.startService(provider_API_command);
}
@Override
@@ -332,14 +337,8 @@ public class EipServiceFragment extends Fragment implements Observer {
if(LeapSRPSession.getToken().isEmpty() && !Dashboard.preferences.getBoolean(Constants.ALLOWED_ANON, false)) {
dashboard.logInDialog(Bundle.EMPTY);
} else {
- Intent provider_API_command = new Intent(parent_activity, ProviderAPI.class);
- if(dashboard.providerAPI_result_receiver == null) {
- dashboard.providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
- dashboard.providerAPI_result_receiver.setReceiver(dashboard);
- }
-
+ Intent provider_API_command = dashboard.prepareProviderAPICommand();
provider_API_command.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, dashboard.providerAPI_result_receiver);
parent_activity.startService(provider_API_command);
}
break;
diff --git a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java
index 60382cf0..22e0f128 100644
--- a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java
@@ -72,7 +72,7 @@ public class SessionDialog extends DialogFragment{
Bundle arguments = getArguments();
if (arguments != null) {
- is_eip_pending = arguments.getBoolean(EipServiceFragment.IS_PENDING, false);
+ is_eip_pending = arguments.getBoolean(EipFragment.IS_PENDING, false);
if (arguments.containsKey(PASSWORD_INVALID_LENGTH))
password_field.setError(getString(R.string.error_not_valid_password_user_message));
if (arguments.containsKey(USERNAME)) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
index 7db35c17..7017e874 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -22,7 +22,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
-import android.os.Handler;
import android.os.ResultReceiver;
import android.util.Log;
@@ -38,7 +37,7 @@ import de.blinkt.openvpn.LaunchVPN;
import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.core.ProfileManager;
import se.leap.bitmaskclient.Dashboard;
-import se.leap.bitmaskclient.EipServiceFragment;
+import se.leap.bitmaskclient.EipFragment;
import static se.leap.bitmaskclient.eip.Constants.ACTION_CHECK_CERT_VALIDITY;
import static se.leap.bitmaskclient.eip.Constants.ACTION_IS_EIP_RUNNING;
@@ -121,7 +120,7 @@ public final class EIP extends IntentService {
GatewaySelector gateway_selector = new GatewaySelector(gateways);
gateway = gateway_selector.select();
if(gateway != null && gateway.getProfile() != null) {
- mReceiver = EipServiceFragment.getReceiver();
+ mReceiver = EipFragment.getReceiver();
launchActiveGateway();
}
tellToReceiver(ACTION_START_EIP, Activity.RESULT_OK);