commit 345aea9ad2e93e9724bdb503b44664aa58215fc8 Author: Nathan Freitas nathan@freitas.net Date: Mon Oct 24 16:50:59 2016 -0400
move the controls to the left sidebar; improve VPN mode more --- .../org/torproject/android/OrbotMainActivity.java | 54 +++---- .../java/org/torproject/android/ui/AppManager.java | 17 +- app/src/main/res/layout/layout_diag.xml | 2 +- app/src/main/res/layout/layout_main.xml | 171 ++------------------- app/src/main/res/layout/layout_orbot_control.xml | 124 +++++++++++++++ app/src/main/res/values/arrays.xml | 2 - 6 files changed, 184 insertions(+), 186 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java index d95e0f2..93e79b2 100644 --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java @@ -322,17 +322,9 @@ public class OrbotMainActivity extends AppCompatActivity @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + enableVPN(isChecked);
- Prefs.putUseVpn(isChecked);
- if (isChecked) { - if (mIsLollipop) //let the user choose the apps - startActivityForResult(new Intent(OrbotMainActivity.this, AppManager.class),REQUEST_VPN_APPS_SELECT); - else - startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class)); - } - else - stopVpnService(); } });
@@ -550,6 +542,19 @@ public class OrbotMainActivity extends AppCompatActivity
} + + private void enableVPN (boolean enable) + { + Prefs.putUseVpn(enable); + + if (enable) { + if (mIsLollipop) //let the user choose the apps + startActivityForResult(new Intent(OrbotMainActivity.this, AppManager.class), REQUEST_VPN_APPS_SELECT); + else + startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class)); + } else + stopVpnService(); + } private void enableHiddenServicePort (int hsPort) throws RemoteException, InterruptedException { @@ -758,7 +763,6 @@ public class OrbotMainActivity extends AppCompatActivity else { AlertDialog aDialog = new AlertDialog.Builder(OrbotMainActivity.this) - .setIcon(R.drawable.onion32) .setTitle(R.string.install_apps_) .setMessage(R.string.it_doesn_t_seem_like_you_have_orweb_installed_want_help_with_that_or_should_we_just_open_the_browser_) .setPositiveButton(R.string.install_orweb, new Dialog.OnClickListener () @@ -777,6 +781,13 @@ public class OrbotMainActivity extends AppCompatActivity } }) + .setNeutralButton(R.string.apps_mode, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // enableVPN(true); + mBtnVPN.setChecked(true); + } + }) .setNegativeButton(R.string.standard_browser, new Dialog.OnClickListener () {
@@ -864,8 +875,9 @@ public class OrbotMainActivity extends AppCompatActivity } else if (request == REQUEST_VPN) { - if (response == RESULT_OK) - sendIntentToService(TorServiceConstants.CMD_VPN); + if (response == RESULT_OK) { + sendIntentToService(TorServiceConstants.CMD_VPN); + } else { Prefs.putUseVpn(false); @@ -949,27 +961,17 @@ public class OrbotMainActivity extends AppCompatActivity enableBridges(true);
break; - case 1: //obfs3 - setupBridgeType("obfs3"); - enableBridges(true); - - break; - case 2: //scramblesuit - setupBridgeType("scramblesuit"); - enableBridges(true); - - break; - case 3: //azure + case 1: //azure Prefs.setBridgesList("2"); enableBridges(true); break; - case 4: //amazon + case 2: //amazon Prefs.setBridgesList("1"); enableBridges(true); break; - case 5: + case 3: showGetBridgePrompt("obfs4"); break; @@ -1224,7 +1226,7 @@ public class OrbotMainActivity extends AppCompatActivity } else if (torStatus == TorServiceConstants.STATUS_OFF) {
imgStatus.setImageResource(R.drawable.toroff); - lblStatus.setText(getString(R.string.press_to_start)); + // lblStatus.setText(getString(R.string.press_to_start)); mBtnBrowser.setEnabled(false);
mBtnStart.setText(R.string.menu_start); diff --git a/app/src/main/java/org/torproject/android/ui/AppManager.java b/app/src/main/java/org/torproject/android/ui/AppManager.java index 84af48d..85fe4b3 100644 --- a/app/src/main/java/org/torproject/android/ui/AppManager.java +++ b/app/src/main/java/org/torproject/android/ui/AppManager.java @@ -27,6 +27,7 @@ import android.support.v7.app.ActionBarActivity; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.LayoutInflater; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -127,7 +128,21 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList loadApps(prefs); } } - + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + setResult(RESULT_OK); + finish(); + return true; + + + } + + return false; + } + @Override protected void onResume() { super.onResume(); diff --git a/app/src/main/res/layout/layout_diag.xml b/app/src/main/res/layout/layout_diag.xml index df38971..5b4ce21 100644 --- a/app/src/main/res/layout/layout_diag.xml +++ b/app/src/main/res/layout/layout_diag.xml @@ -9,6 +9,6 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_margin="3dp" + android:layout_margin="6dp" /> </ScrollView> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_main.xml b/app/src/main/res/layout/layout_main.xml index 3dfd15a..ab566ec 100644 --- a/app/src/main/res/layout/layout_main.xml +++ b/app/src/main/res/layout/layout_main.xml @@ -33,9 +33,10 @@ android:layout_height="400dp" android:id="@+id/frameMain" android:visibility="visible" - android:orientation="vertical" - android:gravity="center_horizontal|center_vertical" - > + android:orientation="vertical" + android:layout_centerVertical="true" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true"> <org.torproject.android.ui.ImageProgressView android:id="@+id/imgStatus" android:layout_width="match_parent" @@ -76,166 +77,14 @@
</LinearLayout>
- <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:gravity="bottom" - android:layout_gravity="bottom" - android:padding="3dp" - android:background="#454545" - android:layout_alignParentBottom="true" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true"> - - <LinearLayout android:gravity="center_horizontal" - android:orientation="horizontal" android:layout_width="match_parent" - android:layout_height="wrap_content" - - >
- - <android.support.v7.widget.SwitchCompat - android:id="@+id/btnVPN" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/menu_vpn" - android:layout_margin="3dp" - android:singleLine="true" - app:switchPadding="9dp" - - /> - - - <android.support.v7.widget.SwitchCompat - android:id="@+id/btnBridges" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/bridges" - android:layout_marginTop="3dp" - android:layout_marginLeft="5dp" - android:layout_marginBottom="3dp" - android:singleLine="true" - app:switchPadding="9dp" - /> - <Spinner - android:id="@+id/spinnerCountry" - android:layout_width="140dp" - android:layout_height="wrap_content" - android:layout_weight="1" - - android:layout_marginTop="3dp" - android:layout_marginLeft="5dp" - android:layout_marginBottom="3dp" - /> - - </LinearLayout> - - - - <TextView - android:id="@+id/lblStatus" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textSize="14sp" - android:gravity="center_horizontal" - android:fontFamily="sans-serif-light" - android:text="" - android:lines="2" - android:maxLines="2" - android:layout_gravity="center_horizontal" - android:layout_margin="0dp" - android:layout_marginLeft="5dp" - android:layout_marginRight="5dp" - android:visibility="gone" - /> - - <!-- - <TextView android:id="@+id/lblStatus" - android:text="status status status" - android:gravity="center_horizontal" - android:textSize="20sp" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="10dp" - android:layout_marginTop="10dp" - android:layout_marginLeft="40dp" - android:layout_marginRight="40dp" - android:textColor="#ffffff" - android:maxLines="1" - android:orientation="vertical" - android:fontFamily="sans-serif-light" - /> - --> - - <RelativeLayout - android:id="@+id/rowTrafficDown" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:paddingLeft="3sp" - android:paddingRight="3sp" - - > - <TextView - android:id="@+id/trafficLabelDown" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:textSize="15sp" - android:text="@string/main_layout_download" - android:gravity="center_vertical" - android:fontFamily="sans-serif-light" /> - <TextView - android:id="@+id/trafficLabelUp" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:text="@string/main_layout_upload" - android:textSize="15sp" - android:gravity="center_vertical" - android:fontFamily="sans-serif-light" /> - - </RelativeLayout> - <RelativeLayout - android:id="@+id/rowTrafficUp" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:paddingLeft="3sp" - android:paddingRight="3sp" - android:paddingBottom="3sp" - - > - <TextView - android:id="@+id/trafficDown" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:textSize="15sp" - android:gravity="center_vertical" - android:fontFamily="sans-serif-light" - /> - - <TextView - android:id="@+id/trafficUp" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:textSize="15sp" - android:gravity="center_vertical" - android:fontFamily="sans-serif-light" - /> - </RelativeLayout> - </LinearLayout> - - </RelativeLayout>
<LinearLayout - android:layout_width="320dp" + android:layout_width="250dp" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/left_drawer" @@ -243,6 +92,9 @@ android:background="#333333" >
+ <include layout="@layout/layout_orbot_control"/> + + </LinearLayout> <LinearLayout @@ -252,7 +104,14 @@ android:id="@+id/right_drawer" android:layout_gravity="end" android:background="#333333" + android:padding="6dp" > + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/menu_log" + android:textAppearance="?android:attr/textAppearanceMedium" + /> <TextView android:id="@+id/orbotLog" android:textSize="12sp" diff --git a/app/src/main/res/layout/layout_orbot_control.xml b/app/src/main/res/layout/layout_orbot_control.xml new file mode 100644 index 0000000..870eda4 --- /dev/null +++ b/app/src/main/res/layout/layout_orbot_control.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="match_parent"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="3dp"> + + + <android.support.v7.widget.SwitchCompat + android:id="@+id/btnVPN" + android:layout_width="200dp" + android:layout_height="wrap_content" + android:text="@string/apps_mode" + android:layout_margin="12dp" + android:singleLine="true" + app:switchPadding="9dp" + /> + + + <android.support.v7.widget.SwitchCompat + android:id="@+id/btnBridges" + android:layout_width="200dp" + android:layout_height="wrap_content" + android:text="@string/bridges" + android:layout_margin="12dp" + android:singleLine="true" + app:switchPadding="9dp" + /> + + + <Spinner + android:id="@+id/spinnerCountry" + android:layout_width="220dp" + android:layout_height="wrap_content" + android:layout_margin="12dp" + android:layout_marginLeft="9dp" + /> + + + + + <RelativeLayout + android:id="@+id/rowTrafficDown" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingLeft="3sp" + android:paddingRight="3sp" + android:layout_margin="12dp" + > + <TextView + android:id="@+id/trafficLabelDown" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:textSize="15sp" + android:text="@string/main_layout_download" + android:gravity="center_vertical" + android:fontFamily="sans-serif-light" /> + + + <TextView + android:id="@+id/trafficDown" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:textSize="15sp" + android:gravity="center_vertical" + android:fontFamily="sans-serif-light" + /> + </RelativeLayout> + <RelativeLayout + android:id="@+id/rowTrafficUp" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:paddingLeft="3sp" + android:paddingRight="3sp" + android:paddingBottom="3sp" + android:layout_margin="12dp" + + > + + <TextView + android:id="@+id/trafficLabelUp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:text="@string/main_layout_upload" + android:textSize="15sp" + android:gravity="center_vertical" + android:fontFamily="sans-serif-light" /> + + <TextView + android:id="@+id/trafficUp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:textSize="15sp" + android:gravity="center_vertical" + android:fontFamily="sans-serif-light" + /> + </RelativeLayout> + + <TextView + android:id="@+id/lblStatus" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="14sp" + android:fontFamily="sans-serif-light" + android:text="" + android:lines="2" + android:maxLines="2" + android:layout_margin="12dp" + /> + + </LinearLayout> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 7defef0..795a419 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -4,8 +4,6 @@
<string-array name="bridge_options"> <item>Obfs4 (Best)</item> - <item>Obfs3</item> - <item>ScrambleSuit</item> <item>Tunnel through Azure</item> <item>Tunnel through Amazon</item> <item>Get New Bridges</item>
tor-commits@lists.torproject.org