summaryrefslogtreecommitdiff
path: root/app/src/main/java/se
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-12-16 16:58:07 +0100
committerParménides GV <parmegv@sdf.org>2014-12-16 16:58:07 +0100
commit132b62695b021b61d1774944a7bfa6e9166d3ea0 (patch)
tree6c451f16af153d0f7a72971ef3625da7f736cbe3 /app/src/main/java/se
parent9f146deb3448815fccc1637c00588e0dfb23293e (diff)
Update eip-service.json each EipFragment.onAttach
Diffstat (limited to 'app/src/main/java/se')
-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);