commit 84932594ce14746e74250aad9dc931334549a736 Author: Nathan Freitas nathan@freitas.net Date: Thu Apr 2 23:11:23 2015 -0400
new helper activities for Apps and Bridge setup --- res/layout/layout_diag.xml | 17 ++- res/layout/layout_vpn_setup.xml | 34 ++++++ res/values/strings.xml | 12 ++ src/org/torproject/android/OrbotConstants.java | 1 + src/org/torproject/android/OrbotMainActivity.java | 115 ++++++++++++++++++-- .../torproject/android/ui/BridgeSetupActivity.java | 5 + .../torproject/android/ui/VPNSetupActivity.java | 5 + 7 files changed, 171 insertions(+), 18 deletions(-)
diff --git a/res/layout/layout_diag.xml b/res/layout/layout_diag.xml index 56cd8bb..c19a5b1 100644 --- a/res/layout/layout_diag.xml +++ b/res/layout/layout_diag.xml @@ -4,12 +4,11 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <TextView - android:id="@+id/diaglog" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:paddingTop="15px" - android:paddingLeft="15px" - android:textStyle="bold" - android:textColor="#00ff00" /> - </ScrollView> + <TextView + android:id="@+id/diaglog" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_margin="9dp" + /> +</ScrollView> \ No newline at end of file diff --git a/res/layout/layout_vpn_setup.xml b/res/layout/layout_vpn_setup.xml new file mode 100644 index 0000000..5d2c6dc --- /dev/null +++ b/res/layout/layout_vpn_setup.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> + +<ScrollView android:id="@+id/aboutscrollview" + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="fill_parent"> + <LinearLayout + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <TextView android:text="Apps Mode" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:paddingTop="15px" + android:paddingLeft="15px" + android:textStyle="bold" + android:textColor="#00ff00" /> + <TextView android:text="" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:autoLink="web" + android:textColorLink="#ffffff" + android:paddingLeft="15px" + android:textColor="#ffffff" /> + + <Button android:id="@+id/btnActivateVPN" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Activate" + android:layout_margin="0sp"/> + + </LinearLayout> + </ScrollView> diff --git a/res/values/strings.xml b/res/values/strings.xml index f5a1fe7..3aeb067 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -318,4 +318,16 @@ <string name="restart_orbot_to_use_this_bridge_">"Restart Orbot to use these bridges: "</string>
<string name="menu_qr">QR Codes</string> + + <string name="if_your_mobile_network_actively_blocks_tor_you_can_use_a_tor_bridge_to_access_the_network_another_way_to_get_bridges_is_to_send_an_email_to_bridges_torproject_org_please_note_that_you_must_send_the_email_using_an_address_from_one_of_the_following_email_providers_riseup_gmail_or_yahoo_">If your mobile network actively blocks Tor, you can use a Tor Bridge to access the network.\n\nYou can get a bridge address from https://bridges.torproject.org or scan a bridge QR code from a friend.\n\nAnother way to get bridges is to send an email to bridges@torproject.org. Please note that you must send the email using an address from one of the following email providers: Riseup, Gmail or Yahoo.</string> + + <string name="bridge_mode">Bridge Mode</string> + + <string name="get_bridges">Get Bridges</string> + + <string name="activate">Activate</string> + + <string name="apps_mode">Apps Mode</string> + + <string name="you_can_enable_all_apps_on_your_device_to_run_through_the_tor_network_using_the_vpn_feature_of_android_">You can enable all apps on your device to run through the Tor network using the VPN feature of Android.</string> </resources> diff --git a/src/org/torproject/android/OrbotConstants.java b/src/org/torproject/android/OrbotConstants.java index e400851..745ace4 100644 --- a/src/org/torproject/android/OrbotConstants.java +++ b/src/org/torproject/android/OrbotConstants.java @@ -16,6 +16,7 @@ public interface OrbotConstants { //path to check Tor against public final static String URL_TOR_CHECK = "https://check.torproject.org"; + public final static String URL_TOR_BRIDGES = "https://bridges.torproject.org";
public final static String NEWLINE = "\n";
diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java index 886c222..62e666e 100644 --- a/src/org/torproject/android/OrbotMainActivity.java +++ b/src/org/torproject/android/OrbotMainActivity.java @@ -15,7 +15,6 @@ import org.torproject.android.service.TorServiceUtils; import org.torproject.android.settings.SettingsPreferences; import org.torproject.android.ui.ImageProgressView; import org.torproject.android.ui.Rotate3dAnimation; -import org.torproject.android.ui.wizard.ChooseLocaleWizardActivity; import org.torproject.android.ui.wizard.PromoAppsActivity;
import android.annotation.TargetApi; @@ -267,7 +266,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon public void onClick(View v) {
if (mBtnVPN.isChecked()) - startVpnService(); + promptStartVpnService(); else stopVpnService(); @@ -286,11 +285,8 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon @Override public void onClick(View v) {
- Editor edit = mPrefs.edit(); - edit.putBoolean("pref_bridges_enabled", mBtnBridges.isChecked()); - edit.commit(); + promptSetupBridges (); - updateSettings(); }
@@ -842,10 +838,8 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon setNewBridges(results); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + Log.e(TAG,"unsupported",e); } } @@ -853,6 +847,109 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
}
+ public void promptSetupBridges () + { + LayoutInflater li = LayoutInflater.from(this); + View view = li.inflate(R.layout.layout_diag, null); + + TextView versionName = (TextView)view.findViewById(R.id.diaglog); + versionName.setText(R.string.if_your_mobile_network_actively_blocks_tor_you_can_use_a_tor_bridge_to_access_the_network_another_way_to_get_bridges_is_to_send_an_email_to_bridges_torproject_org_please_note_that_you_must_send_the_email_using_an_address_from_one_of_the_following_email_providers_riseup_gmail_or_yahoo_); + + if (mBtnBridges.isChecked()) + { + new AlertDialog.Builder(this) + .setTitle(R.string.bridge_mode) + .setView(view) + .setNeutralButton(R.string.get_bridges, new Dialog.OnClickListener () + { + + @Override + public void onClick(DialogInterface dialog, int which) { + + openBrowser(URL_TOR_BRIDGES); + + } + + + }) + .setPositiveButton(R.string.activate, new Dialog.OnClickListener () + { + + @Override + public void onClick(DialogInterface dialog, int which) { + + enableBridges (true); + + } + + + }) + .setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() + { + @Override + public void onClick(DialogInterface dialog, int which) { + + mBtnBridges.setChecked(false); + + } + }) + .show(); + } + else + { + enableBridges(false); + } + + } + + private void enableBridges (boolean enable) + { + + Editor edit = mPrefs.edit(); + edit.putBoolean("pref_bridges_enabled", enable); + edit.commit(); + + updateSettings(); + } + + public void promptStartVpnService () + { + LayoutInflater li = LayoutInflater.from(this); + View view = li.inflate(R.layout.layout_diag, null); + + TextView versionName = (TextView)view.findViewById(R.id.diaglog); + versionName.setText(R.string.you_can_enable_all_apps_on_your_device_to_run_through_the_tor_network_using_the_vpn_feature_of_android_); + + new AlertDialog.Builder(this) + .setTitle(R.string.apps_mode) + .setView(view) + .setPositiveButton(R.string.activate, new Dialog.OnClickListener () + { + + @Override + public void onClick(DialogInterface dialog, int which) { + + startVpnService(); + + } + + + }) + .setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener () + { + + @Override + public void onClick(DialogInterface dialog, int which) { + + mBtnVPN.setChecked(false); + + } + + + }) + .show(); + } + @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void startVpnService () { diff --git a/src/org/torproject/android/ui/BridgeSetupActivity.java b/src/org/torproject/android/ui/BridgeSetupActivity.java new file mode 100644 index 0000000..7cabe35 --- /dev/null +++ b/src/org/torproject/android/ui/BridgeSetupActivity.java @@ -0,0 +1,5 @@ +package org.torproject.android.ui; + +public class BridgeSetupActivity { + +} diff --git a/src/org/torproject/android/ui/VPNSetupActivity.java b/src/org/torproject/android/ui/VPNSetupActivity.java new file mode 100644 index 0000000..d8674c0 --- /dev/null +++ b/src/org/torproject/android/ui/VPNSetupActivity.java @@ -0,0 +1,5 @@ +package org.torproject.android.ui; + +public class VPNSetupActivity { + +}
tor-commits@lists.torproject.org