summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-01-22 20:50:53 +0100
committerParménides GV <parmegv@sdf.org>2014-04-21 17:36:59 +0200
commitb9a190335150e458099d81b70c16462fbe9e3cdd (patch)
tree6c22baaf605992cc294f3776cbc072366e2571bb /app/src
parentf85ff9f79376ca56c62c17e3f9c5968113b44565 (diff)
Always restore last eip status on boot.
Next step: don't restore off status!
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java22
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EIP.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java14
-rw-r--r--app/src/main/java/se/leap/openvpn/ProfileManager.java3
4 files changed, 34 insertions, 7 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 292434c7..27c9f949 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -57,7 +57,9 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
final public static String SHARED_PREFERENCES = "LEAPPreferences";
final public static String ACTION_QUIT = "quit";
- public static final String REQUEST_CODE = "request_code";
+ public static final String REQUEST_CODE = "request_code";
+ public static final String PARAMETERS = "dashboard parameters";
+ public static final String START_ON_BOOT = "dashboard start on boot";
private ProgressBar mProgressBar;
private TextView eipStatus;
@@ -86,11 +88,17 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
+<<<<<<< HEAD:app/src/main/java/se/leap/bitmaskclient/Dashboard.java
authed_eip = preferences.getBoolean(EIP.AUTHED_EIP, false);
if (preferences.getString(Provider.KEY, "").isEmpty())
startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
+=======
+ authed_eip = ConfigHelper.getBoolFromSharedPref(EIP.AUTHED_EIP);
+ if (ConfigHelper.getStringFromSharedPref(Provider.KEY).isEmpty())
+ startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
+>>>>>>> Always restore last eip status on boot.:src/se/leap/bitmaskclient/Dashboard.java
else
- buildDashboard();
+ buildDashboard();
}
@Override
@@ -166,8 +174,18 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
FragmentManager fragMan = getFragmentManager();
if ( provider.hasEIP()){
+<<<<<<< HEAD:app/src/main/java/se/leap/bitmaskclient/Dashboard.java
EipServiceFragment eipFragment = new EipServiceFragment();
fragMan.beginTransaction().replace(R.id.servicesCollection, eipFragment, EipServiceFragment.TAG).commit();
+=======
+ EipServiceFragment eipFragment = new EipServiceFragment();
+ if (getSharedPreferences(Dashboard.SHARED_PREFERENCES, Context.MODE_PRIVATE).getBoolean(Dashboard.START_ON_BOOT, false)) {
+ Bundle arguments = new Bundle();
+ arguments.putBoolean(EipServiceFragment.START_ON_BOOT, true);
+ eipFragment.setArguments(arguments);
+ }
+ fragMan.beginTransaction().replace(R.id.servicesCollection, eipFragment, TAG_EIP_FRAGMENT).commit();
+>>>>>>> Always restore last eip status on boot.:src/se/leap/bitmaskclient/Dashboard.java
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java
index e773e3b9..49243ffc 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EIP.java
@@ -245,6 +245,7 @@ public final class EIP extends IntentService {
intent.putExtra(RECEIVER_TAG, mReceiver);
startActivity(intent);
mPending = ACTION_START_EIP;
+ getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(Dashboard.START_ON_BOOT, true).commit();
}
/**
@@ -262,6 +263,7 @@ public final class EIP extends IntentService {
resultData.putString(REQUEST_TAG, ACTION_STOP_EIP);
mReceiver.send(Activity.RESULT_OK, resultData);
}
+ getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(Dashboard.START_ON_BOOT, false).commit();
}
/**
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
index b4cb541a..ff204efc 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
@@ -27,6 +27,7 @@ import android.widget.TextView;
public class EipServiceFragment extends Fragment implements StateListener, OnCheckedChangeListener {
protected static final String IS_EIP_PENDING = "is_eip_pending";
+ public static final String START_ON_BOOT = "start on boot";
private View eipFragment;
private static Switch eipSwitch;
@@ -73,6 +74,8 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
});
eipSwitch.setOnCheckedChangeListener(this);
+ if(getArguments() != null && getArguments().containsKey(START_ON_BOOT) && getArguments().getBoolean(START_ON_BOOT))
+ startEipFromScratch();
return eipFragment;
}
@@ -122,10 +125,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
String certificate = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).getString(EIP.CERTIFICATE, "");
if(allowed_anon || !certificate.isEmpty()) {
if (isChecked){
- mEipStartPending = true;
- eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE);
- ((TextView) eipFragment.findViewById(R.id.eipStatus)).setText(R.string.eip_status_start_pending);
- eipCommand(EIP.ACTION_START_EIP);
+ startEipFromScratch();
} else {
if (mEipStartPending){
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
@@ -168,6 +168,12 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
}
+ public void startEipFromScratch() {
+ mEipStartPending = true;
+ eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE);
+ ((TextView) eipFragment.findViewById(R.id.eipStatus)).setText(R.string.eip_status_start_pending);
+ eipCommand(EIP.ACTION_START_EIP);
+ }
/**
* Send a command to EIP
diff --git a/app/src/main/java/se/leap/openvpn/ProfileManager.java b/app/src/main/java/se/leap/openvpn/ProfileManager.java
index b9eb3ab6..07a4087a 100644
--- a/app/src/main/java/se/leap/openvpn/ProfileManager.java
+++ b/app/src/main/java/se/leap/openvpn/ProfileManager.java
@@ -71,7 +71,8 @@ public class ProfileManager {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
Editor prefsedit = prefs.edit();
- prefsedit.putString(ONBOOTPROFILE, connectedrofile.getUUIDString());
+ //prefsedit.putString(ONBOOTPROFILE, connectedrofile.getUUIDString());
+ prefsedit.putString(ONBOOTPROFILE, VpnProfile.EXTRA_PROFILEUUID);
prefsedit.apply();
mLastConnectedVpn=connectedrofile;