From: Tobias Brunner Date: Thu, 9 Aug 2012 09:27:34 +0000 (+0200) Subject: Show a button to disconnect the VPN once it is established X-Git-Tag: 5.0.1~210^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8062f973e1481d51b69a619212b752ab95abf8fe;p=thirdparty%2Fstrongswan.git Show a button to disconnect the VPN once it is established --- diff --git a/src/frontends/android/res/layout/vpn_state_fragment.xml b/src/frontends/android/res/layout/vpn_state_fragment.xml index 12d890a90d..6353f32897 100644 --- a/src/frontends/android/res/layout/vpn_state_fragment.xml +++ b/src/frontends/android/res/layout/vpn_state_fragment.xml @@ -72,6 +72,17 @@ + + Status: Profile: + Disconnect Connecting… Connected Disconnecting… diff --git a/src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java b/src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java index fc250f18d5..94475a3c9b 100644 --- a/src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java +++ b/src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java @@ -36,7 +36,9 @@ import android.os.Bundle; import android.os.IBinder; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.widget.Button; import android.widget.TextView; public class VpnStateFragment extends Fragment implements VpnStateListener @@ -45,6 +47,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener private TextView mProfileView; private TextView mStateView; private int stateBaseColor; + private Button mActionButton; private ProgressDialog mProgressDialog; private State mState; private VpnStateService mService; @@ -81,6 +84,19 @@ public class VpnStateFragment extends Fragment implements VpnStateListener { View view = inflater.inflate(R.layout.vpn_state_fragment, null); + mActionButton = (Button)view.findViewById(R.id.action); + mActionButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) + { + if (mService != null) + { + mService.disconnect(); + } + } + }); + enableActionButton(false); + mStateView = (TextView)view.findViewById(R.id.vpn_state); stateBaseColor = mStateView.getCurrentTextColor(); mProfileView = (TextView)view.findViewById(R.id.vpn_profile_label); @@ -144,6 +160,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener } hideProgressDialog(); + enableActionButton(false); mProfileNameView.setText(name); mState = state; @@ -162,6 +179,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener break; case CONNECTED: showProfile(true); + enableActionButton(true); mStateView.setText(R.string.state_connected); mStateView.setTextColor(Color.GREEN); break; @@ -180,6 +198,12 @@ public class VpnStateFragment extends Fragment implements VpnStateListener mProfileNameView.setVisibility(show ? View.VISIBLE : View.GONE); } + private void enableActionButton(boolean enable) + { + mActionButton.setEnabled(enable); + mActionButton.setVisibility(enable ? View.VISIBLE : View.GONE); + } + private void hideProgressDialog() { if (mProgressDialog != null)