commit ec4350ee40da84a54db0b3e5d6eb62ed8cf45293 Author: Nathan Freitas nathan@freitas.net Date: Wed Feb 4 14:55:42 2015 -0500
update VPN to toggle button --- res/layout/layout_main.xml | 6 +++--- src/org/torproject/android/OrbotMainActivity.java | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/res/layout/layout_main.xml b/res/layout/layout_main.xml index b060ce9..7abd037 100644 --- a/res/layout/layout_main.xml +++ b/res/layout/layout_main.xml @@ -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> diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java index e10c89c..2b4e9d3 100644 --- a/src/org/torproject/android/OrbotMainActivity.java +++ b/src/org/torproject/android/OrbotMainActivity.java @@ -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 () {
tor-commits@lists.torproject.org