From f0c42391501aa646c5d65df5e19dbbd36b19b970 Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Fri, 19 Jul 2013 14:11:29 -0600 Subject: Add logic to only trigger EIP control events if switch changed by a touch event. Fixes VPN reconnection when framework rebuilds view, triggering onCheckedChangeListener --- src/se/leap/leapclient/EipServiceFragment.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/se/leap') diff --git a/src/se/leap/leapclient/EipServiceFragment.java b/src/se/leap/leapclient/EipServiceFragment.java index 51284bc0..c18f83da 100644 --- a/src/se/leap/leapclient/EipServiceFragment.java +++ b/src/se/leap/leapclient/EipServiceFragment.java @@ -12,6 +12,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.ResultReceiver; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -30,7 +31,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli private View eipDetail; private TextView eipStatus; - private boolean eipAutoSwitched = false; + private boolean eipAutoSwitched = true; private boolean mEipStartPending = false; @@ -55,6 +56,13 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli eipStatus.setOnClickListener(this); eipSwitch = (Switch) eipFragment.findViewById(R.id.eipSwitch); + eipSwitch.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + eipAutoSwitched = false; + return false; + } + }); eipSwitch.setOnCheckedChangeListener(this); return eipFragment; @@ -139,6 +147,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli } } } + eipAutoSwitched = true; } /** -- cgit v1.2.3