diff options
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/EipFragment.java')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/EipFragment.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index 414b1f2a..c0e2c21e 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -53,6 +53,7 @@ import de.blinkt.openvpn.core.VpnStatus; import se.leap.bitmaskclient.eip.EIP; import se.leap.bitmaskclient.eip.EipStatus; import se.leap.bitmaskclient.eip.VoidVpnService; +import se.leap.bitmaskclient.userstatus.SessionDialog; import static android.view.View.GONE; import static android.view.View.VISIBLE; @@ -73,10 +74,12 @@ import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; public class EipFragment extends Fragment implements Observer { - public static String TAG = EipFragment.class.getSimpleName(); + public final static String TAG = EipFragment.class.getSimpleName(); protected static final String IS_CONNECTED = TAG + ".is_connected"; public static final String START_EIP_ON_BOOT = "start on boot"; + public static final String ASK_TO_CANCEL_VPN = "ask_to_cancel_vpn"; + private SharedPreferences preferences; @@ -121,6 +124,7 @@ public class EipFragment extends Fragment implements Observer { }; + @Override public void onAttach(Context context) { super.onAttach(context); downloadEIPServiceConfig(); @@ -130,19 +134,23 @@ public class EipFragment extends Fragment implements Observer { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); eipStatus = EipStatus.getInstance(); - eipStatus.addObserver(this); eipReceiver = new EIPReceiver(new Handler()); preferences = getActivity().getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + eipStatus.addObserver(this); View view = inflater.inflate(R.layout.eip_service_fragment, container, false); ButterKnife.inject(this, view); Bundle arguments = getArguments(); - if (arguments != null && arguments.containsKey(START_EIP_ON_BOOT) && arguments.getBoolean(START_EIP_ON_BOOT)) { - startEipFromScratch(); + if (arguments != null) { + if (arguments.containsKey(START_EIP_ON_BOOT) && arguments.getBoolean(START_EIP_ON_BOOT)) { + startEipFromScratch(); + } else if (arguments.containsKey(ASK_TO_CANCEL_VPN) && arguments.getBoolean(ASK_TO_CANCEL_VPN)) { + askToStopEIP(); + } } return view; } @@ -163,6 +171,12 @@ public class EipFragment extends Fragment implements Observer { } @Override + public void onDestroyView() { + super.onDestroyView(); + eipStatus.deleteObserver(this); + } + + @Override public void onSaveInstanceState(Bundle outState) { outState.putBoolean(IS_CONNECTED, eipStatus.isConnected()); super.onSaveInstanceState(outState); @@ -199,8 +213,10 @@ public class EipFragment extends Fragment implements Observer { startEipFromScratch(); else if (canLogInToStartEIP()) { wantsToConnect = true; - Bundle bundle = new Bundle(); - MainActivity.sessionDialog(bundle); + /*Bundle bundle = new Bundle(); + seionDialogCallback.onSessionDialog(bundle);*/ + Log.w(TAG, "TODO: implement login from here"); + //FIXME: implement login from here } else { Log.d(TAG, "WHAT IS GOING ON HERE?!"); // TODO: implement a fallback: check if vpncertificate was not downloaded properly or give |