From 9787e857bca4dca056d9e55cc9c8eaa1756eb990 Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Tue, 27 Feb 2018 19:04:18 +0100 Subject: 8865 - disconnect without internet * move function to dialog --- .../java/se/leap/bitmaskclient/EipFragment.java | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'app') diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index 1a6ad8d2..cb98aaac 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -258,21 +258,10 @@ public class EipFragment extends Fragment implements Observer { } private void handleSwitchOff() { - if (eipStatus.isConnecting()) { + if (isOpenVpnRunningWithoutNetwork() || eipStatus.isConnecting()) { askPendingStartCancellation(); } else if (eipStatus.isConnected()) { askToStopEIP(); - } else if (isOpenVpnRunningWithoutNetwork()) { - // TODO move to EIP - // TODO see stopEIP function - Bundle resultData = new Bundle(); - resultData.putString(EIP_REQUEST, EIP_ACTION_STOP); - Intent intentUpdate = new Intent(BROADCAST_EIP_EVENT); - intentUpdate.addCategory(Intent.CATEGORY_DEFAULT); - intentUpdate.putExtra(BROADCAST_RESULT_CODE, Activity.RESULT_OK); - intentUpdate.putExtra(BROADCAST_RESULT_KEY, resultData); - Log.d(TAG, "sending broadcast"); - LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intentUpdate); } } @@ -293,7 +282,20 @@ public class EipFragment extends Fragment implements Observer { protected void stopEipIfPossible() { Context context = getContext(); if (context != null) { - EipCommand.stopVPN(getContext()); + if (isOpenVpnRunningWithoutNetwork()) { + // TODO move to EIP + // TODO see stopEIP function + Bundle resultData = new Bundle(); + resultData.putString(EIP_REQUEST, EIP_ACTION_STOP); + Intent intentUpdate = new Intent(BROADCAST_EIP_EVENT); + intentUpdate.addCategory(Intent.CATEGORY_DEFAULT); + intentUpdate.putExtra(BROADCAST_RESULT_CODE, Activity.RESULT_OK); + intentUpdate.putExtra(BROADCAST_RESULT_KEY, resultData); + Log.d(TAG, "sending broadcast"); + LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intentUpdate); + } else { + EipCommand.stopVPN(getContext()); + } } else { Log.e(TAG, "context is null when trying to stop EIP"); } -- cgit v1.2.3