summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-01-27 18:39:13 +0100
committerParménides GV <parmegv@sdf.org>2014-04-21 17:36:59 +0200
commit365a517ab7571bce056812253cdbb410f3aa8e35 (patch)
treedad7a8e14ae56b25b026d8538f1c55367dd91401 /app/src/main/java
parent0a4162684fe5874f20a4d1e79eae611b93f72a24 (diff)
Launcher and notification reuse existing Activity.
Notifications get mad, we have to fix that.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java39
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EIP.java11
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java11
-rw-r--r--app/src/main/java/se/leap/openvpn/OpenVpnService.java3
4 files changed, 38 insertions, 26 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 27c9f949..b95f319f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -60,6 +60,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
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";
+ final public static String ON_BOOT = "dashboard on boot";
+
private ProgressBar mProgressBar;
private TextView eipStatus;
@@ -88,24 +90,26 @@ 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(getIntent().getBooleanExtra(ON_BOOT, false));
}
@Override
protected void onDestroy() {
super.onDestroy();
}
-
+
+ protected void onPause() {
+ super.onPause();
+ Log.d("Dashboard", "eip_service_fragment.saveEipStatus()");
+ EipServiceFragment eip_service_fragment = (EipServiceFragment) getFragmentManager().findFragmentByTag(TAG_EIP_FRAGMENT);
+ if(eip_service_fragment != null)
+ eip_service_fragment.saveEipStatus();
+ }
+
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) {
@@ -160,7 +164,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
* Inflates permanent UI elements of the View and contains logic for what
* service dependent UI elements to include.
*/
- private void buildDashboard() {
+ private void buildDashboard(boolean hide_and_turn_on_eip) {
provider = Provider.getInstance();
provider.init( this );
@@ -174,18 +178,19 @@ 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)) {
+ if (hide_and_turn_on_eip) {
+ getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().remove(Dashboard.START_ON_BOOT).commit();
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
+ fragMan.beginTransaction().replace(R.id.servicesCollection, eipFragment, EipServiceFragment.TAG).commit();
+
+ if (hide_and_turn_on_eip) {
+ onBackPressed();
+ }
}
}
@@ -482,9 +487,9 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
// TODO validate "action"...how do we get the list of intent-filters for a class via Android API?
Intent eip_intent = new Intent(this, EIP.class);
eip_intent.setAction(EIP.ACTION_STOP_EIP);
- // eip_intent.putExtra(EIP.RECEIVER_TAG, eip_receiver);
+ // eip_intent.putExtra(EIP.RECEIVER_TAG, eip_receiver);fi
startService(eip_intent);
-
+
}
private void eipStart(){
diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java
index 31a06d96..68688b90 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EIP.java
@@ -108,11 +108,12 @@ public final class EIP extends IntentService {
@Override
public void onDestroy() {
- unbindService(mVpnServiceConn);
- mBound = false;
-
- super.onDestroy();
+ unbindService(mVpnServiceConn);
+ mBound = false;
+
+ super.onDestroy();
}
+
@Override
protected void onHandleIntent(Intent intent) {
@@ -245,7 +246,6 @@ 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();
}
/**
@@ -263,7 +263,6 @@ 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().remove(Dashboard.START_ON_BOOT).commit();
}
/**
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
index ff204efc..4cc6be4f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
@@ -111,13 +111,20 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
OpenVPN.removeStateListener(this);
}
-
+
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(IS_EIP_PENDING, mEipStartPending);
}
-
+
+ protected void saveEipStatus() {
+ boolean eip_is_on = false;
+ if(eipSwitch.isChecked()) {
+ eip_is_on = true;
+ }
+ getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit().putBoolean(Dashboard.START_ON_BOOT, eip_is_on).commit();
+ }
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.equals(eipSwitch) && !eipAutoSwitched){
diff --git a/app/src/main/java/se/leap/openvpn/OpenVpnService.java b/app/src/main/java/se/leap/openvpn/OpenVpnService.java
index b5c9c798..11071802 100644
--- a/app/src/main/java/se/leap/openvpn/OpenVpnService.java
+++ b/app/src/main/java/se/leap/openvpn/OpenVpnService.java
@@ -278,10 +278,11 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
@Override
public void onDestroy() {
- if (mProcessThread != null) {
+ if (mProcessThread != null) {
mSocketManager.managmentCommand("signal SIGINT\n");
mProcessThread.interrupt();
+
}
if (mNetworkStateReceiver!= null) {
this.unregisterReceiver(mNetworkStateReceiver);