Show a button to disconnect the VPN once it is established
This commit is contained in:
@@ -72,6 +72,17 @@
|
|||||||
</TextView>
|
</TextView>
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/action"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:text="@string/disconnect"
|
||||||
|
style="?android:attr/borderlessButtonStyle" >
|
||||||
|
</Button>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="2dp"
|
android:layout_height="2dp"
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
<!-- VPN state fragment -->
|
<!-- VPN state fragment -->
|
||||||
<string name="state_label">Status:</string>
|
<string name="state_label">Status:</string>
|
||||||
<string name="profile_label">Profile:</string>
|
<string name="profile_label">Profile:</string>
|
||||||
|
<string name="disconnect">Disconnect</string>
|
||||||
<string name="state_connecting">Connecting…</string>
|
<string name="state_connecting">Connecting…</string>
|
||||||
<string name="state_connected">Connected</string>
|
<string name="state_connected">Connected</string>
|
||||||
<string name="state_disconnecting">Disconnecting…</string>
|
<string name="state_disconnecting">Disconnecting…</string>
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ import android.os.Bundle;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class VpnStateFragment extends Fragment implements VpnStateListener
|
public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||||
@@ -45,6 +47,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||||||
private TextView mProfileView;
|
private TextView mProfileView;
|
||||||
private TextView mStateView;
|
private TextView mStateView;
|
||||||
private int stateBaseColor;
|
private int stateBaseColor;
|
||||||
|
private Button mActionButton;
|
||||||
private ProgressDialog mProgressDialog;
|
private ProgressDialog mProgressDialog;
|
||||||
private State mState;
|
private State mState;
|
||||||
private VpnStateService mService;
|
private VpnStateService mService;
|
||||||
@@ -81,6 +84,19 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||||||
{
|
{
|
||||||
View view = inflater.inflate(R.layout.vpn_state_fragment, null);
|
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);
|
mStateView = (TextView)view.findViewById(R.id.vpn_state);
|
||||||
stateBaseColor = mStateView.getCurrentTextColor();
|
stateBaseColor = mStateView.getCurrentTextColor();
|
||||||
mProfileView = (TextView)view.findViewById(R.id.vpn_profile_label);
|
mProfileView = (TextView)view.findViewById(R.id.vpn_profile_label);
|
||||||
@@ -144,6 +160,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
hideProgressDialog();
|
hideProgressDialog();
|
||||||
|
enableActionButton(false);
|
||||||
mProfileNameView.setText(name);
|
mProfileNameView.setText(name);
|
||||||
mState = state;
|
mState = state;
|
||||||
|
|
||||||
@@ -162,6 +179,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||||||
break;
|
break;
|
||||||
case CONNECTED:
|
case CONNECTED:
|
||||||
showProfile(true);
|
showProfile(true);
|
||||||
|
enableActionButton(true);
|
||||||
mStateView.setText(R.string.state_connected);
|
mStateView.setText(R.string.state_connected);
|
||||||
mStateView.setTextColor(Color.GREEN);
|
mStateView.setTextColor(Color.GREEN);
|
||||||
break;
|
break;
|
||||||
@@ -180,6 +198,12 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||||||
mProfileNameView.setVisibility(show ? View.VISIBLE : View.GONE);
|
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()
|
private void hideProgressDialog()
|
||||||
{
|
{
|
||||||
if (mProgressDialog != null)
|
if (mProgressDialog != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user