update VPN to toggle button

This commit is contained in:
Nathan Freitas 2015-02-04 14:55:42 -05:00
parent 17f2a0bdac
commit ec4350ee40
2 changed files with 16 additions and 7 deletions

View File

@ -170,12 +170,12 @@
android:text="Open Browser"
/>
<Button
<ToggleButton
android:id="@+id/btnVPN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start VPN"
android:textOff="VPN Off"
android:textOn="VPN On"
/>
</LinearLayout>

View File

@ -58,6 +58,7 @@ import android.view.animation.AccelerateInterpolator;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
public class OrbotMainActivity extends Activity implements TorConstants, OnLongClickListener, OnTouchListener, OnSharedPreferenceChangeListener
@ -73,8 +74,8 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
private TextView mTxtOrbotLog = null;
private Button mBtnBrowser = null;
private Button mBtnVPN = null;
private ToggleButton mBtnVPN = null;
private DrawerLayout mDrawer;
private ActionBarDrawerToggle mDrawerToggle;
private Toolbar mToolbar;
@ -246,14 +247,17 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
});
mBtnVPN = (Button)findViewById(R.id.btnVPN);
mBtnVPN = (ToggleButton)findViewById(R.id.btnVPN);
mBtnVPN.setOnClickListener(new View.OnClickListener ()
{
@Override
public void onClick(View v) {
startVpnService();
if (mBtnVPN.isChecked())
startVpnService();
else
stopVpnService();
}
@ -807,6 +811,11 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
}
}
public void stopVpnService ()
{
startService(TorServiceConstants.CMD_VPN_CLEAR);
}
private boolean flushTransProxy ()
{