tor-commits
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
October 2011
- 18 participants
- 1256 discussions
commit 0eb64792bf5911412758d0b73eff486c27172bb8
Author: Sathyanarayanan Gunasekaran <gsathya.ceg(a)gmail.com>
Date: Sat Jun 11 02:32:39 2011 +0530
Fixed wizard restart on rotation
Added a SharedPreference - "wizardscreen1" which when set to true
shows stepOne()(Intro screen) and shows stepTwo()(Warning screen)
when set to palse
---
src/org/torproject/android/LotsaText.java | 40 +++++++++++++++++---------
src/org/torproject/android/Orbot.java | 7 +++…
[View More]+-
src/org/torproject/android/Permissions.java | 2 +-
src/org/torproject/android/WizardHelper.java | 4 +-
4 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/src/org/torproject/android/LotsaText.java b/src/org/torproject/android/LotsaText.java
index e9fc556..43e6d16 100644
--- a/src/org/torproject/android/LotsaText.java
+++ b/src/org/torproject/android/LotsaText.java
@@ -3,7 +3,10 @@ package org.torproject.android;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
@@ -12,12 +15,14 @@ import android.widget.TextView;
public class LotsaText extends Activity implements TorConstants{
private Context context;
- private int step = -1;
protected void onCreate(Bundle savedInstanceState)
- {
+ {
+
+
super.onCreate(savedInstanceState);
context = this;
+
}
@@ -27,7 +32,13 @@ public class LotsaText extends Activity implements TorConstants{
super.onStart();
setContentView(R.layout.scrollingtext_buttons_view);
- stepOne();
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+ boolean wizardScreen1 = prefs.getBoolean("wizardscreen1",false);
+ if(wizardScreen1)
+ stepOne();
+ else
+ stepTwo();
}
@@ -39,19 +50,15 @@ public class LotsaText extends Activity implements TorConstants{
}
- /*public void startWizard(){
-
- switch(step){
-
- case -1 : stepOne();break;
-
- }
- }
- */
+
private void stepOne() {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+ Editor pEdit = prefs.edit();
+ pEdit.putBoolean("wizardscreen1",true);
+ pEdit.commit();
- //setContentView(R.layout.scrollingtext_buttons_view);
String title = context.getString(R.string.wizard_title);
String msg = context.getString(R.string.wizard_title_msg);
@@ -79,7 +86,12 @@ public class LotsaText extends Activity implements TorConstants{
}
private void stepTwo() {
- step=0;
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+ Editor pEdit = prefs.edit();
+ pEdit.putBoolean("wizardscreen1",false);
+ pEdit.commit();
setContentView(R.layout.scrollingtext_buttons_view);
String title = context.getString(R.string.wizard_warning_title);
diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index 383929d..7f8af3b 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -455,7 +455,12 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
*/
private void showHelp ()
{
-
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+
+ Editor pEdit = prefs.edit();
+ pEdit.putBoolean("wizardscreen1",true);
+ pEdit.commit();
startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
}
diff --git a/src/org/torproject/android/Permissions.java b/src/org/torproject/android/Permissions.java
index a29b04a..3b782df 100644
--- a/src/org/torproject/android/Permissions.java
+++ b/src/org/torproject/android/Permissions.java
@@ -150,7 +150,7 @@ public class Permissions extends Activity implements TorConstants {
@Override
public void onClick(View v) {
- //Check and Install iptables - orTransProxy.testOwnerModule(this)
+ //Check and Install iptables - TorTransProxy.testOwnerModule(this)
startActivityForResult(new Intent(getBaseContext(), ConfigureTransProxy.class), 1);
diff --git a/src/org/torproject/android/WizardHelper.java b/src/org/torproject/android/WizardHelper.java
index 684a730..c85c50a 100644
--- a/src/org/torproject/android/WizardHelper.java
+++ b/src/org/torproject/android/WizardHelper.java
@@ -277,7 +277,7 @@ public class WizardHelper implements TorConstants {
public void showWizardRootConfigureTorification()
{
-
+ /*
LayoutInflater li = LayoutInflater.from(context);
View view = li.inflate(R.layout.layout_wizard_root, null);
@@ -347,7 +347,7 @@ public class WizardHelper implements TorConstants {
}
});
-
+ */
}
[View Less]
1
0

28 Oct '11
commit 4ec2d483757016397b0bed92afdf7b14aab1af74
Author: Sathyanarayanan Gunasekaran <gsathya.ceg(a)gmail.com>
Date: Sat Jun 11 03:37:42 2011 +0530
Fixed resizing issues in AppManager activity
Fixed the sizes of the icons to be 50 dip in length
and width to prevent icons to be of different sizes.
---
res/layout/layout_apps_item.xml | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/res/layout/layout_apps_item.xml b/res/layout/layout_apps_item.xml
…
[View More]index 4993964..8b4fc34 100644
--- a/res/layout/layout_apps_item.xml
+++ b/res/layout/layout_apps_item.xml
@@ -5,7 +5,7 @@
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
- <ImageView android:id="@+id/itemicon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dip"></ImageView>
+ <ImageView android:id="@+id/itemicon" android:layout_width="50dip" android:layout_height="50dip" android:padding="3dip"></ImageView>
<TextView android:layout_height="wrap_content" android:id="@+id/itemtext" android:text="uid:packages" android:textSize="18sp" android:padding="3dip"></TextView>
[View Less]
1
0
commit 791a6267df0b4e001cefea9a784de00b225676a5
Author: Sathyanarayanan Gunasekaran <gsathya.ceg(a)gmail.com>
Date: Fri Jun 10 01:25:01 2011 +0530
Updated Views
Added padding, formatting, etc to improve the design
of the various views.
---
res/layout/layout_wizard_permissions.xml | 4 ++--
res/layout/layout_wizard_root.xml | 2 +-
res/layout/layout_wizard_tips.xml | 3 +--
res/layout/scrollingtext_buttons_view.xml | 2 +-
res/values/…
[View More]strings.xml | 4 ++--
5 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/res/layout/layout_wizard_permissions.xml b/res/layout/layout_wizard_permissions.xml
index 168968b..7926750 100644
--- a/res/layout/layout_wizard_permissions.xml
+++ b/res/layout/layout_wizard_permissions.xml
@@ -36,9 +36,9 @@
android:layout_height="fill_parent"
android:layout_span="3">
<LinearLayout android:layout_width="wrap_content" android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="vertical">
- <TextView android:layout_width="wrap_content" android:textColor="#ffffff" android:layout_height="wrap_content" android:background="#222222" android:textSize="8pt" android:padding="6px" android:id="@+id/WizardTextBody1" android:text="this is sample text this is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample text"></TextView>
+ <TextView android:layout_width="wrap_content" android:textColor="#ffffff" android:layout_height="wrap_content" android:background="#222222" android:textSize="8pt" android:id="@+id/WizardTextBody1" android:text="this is sample text this is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample text" android:padding="20dip"></TextView>
<Button android:layout_width="wrap_content" android:visibility="gone" android:layout_height="wrap_content" android:gravity="center" android:text="Grant Permission" android:id="@+id/grantPermissions" android:layout_gravity="center"></Button>
- <TextView android:layout_width="wrap_content" android:visibility="gone" android:textColor="#ffffff" android:layout_height="wrap_content" android:background="#222222" android:textSize="8pt" android:padding="6px" android:id="@+id/WizardTextBody2" android:text="this is sample text this is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample text"></TextView>
+ <TextView android:layout_width="wrap_content" android:visibility="gone" android:textColor="#ffffff" android:layout_height="wrap_content" android:background="#222222" android:textSize="8pt" android:id="@+id/WizardTextBody2" android:text="this is sample text this is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample text" android:padding="20dip"></TextView>
<CheckBox android:id="@+id/checkBox" android:visibility="gone" android:layout_gravity="center" android:text="@string/wizard_permissions_consent" android:layout_height="wrap_content" android:layout_width="wrap_content"></CheckBox>
</LinearLayout>
diff --git a/res/layout/layout_wizard_root.xml b/res/layout/layout_wizard_root.xml
index afe6005..d038a96 100644
--- a/res/layout/layout_wizard_root.xml
+++ b/res/layout/layout_wizard_root.xml
@@ -40,7 +40,7 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3px">
-<TextView android:text="@string/wizard_transproxy_msg" android:textColor="#ffffff" android:id="@+id/WizardRootTextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
+<TextView android:text="@string/wizard_transproxy_msg" android:layout_width="wrap_content" android:textColor="#ffffff" android:layout_height="wrap_content" android:background="#222222" android:textSize="8pt" android:id="@+id/WizardTextBody1" android:padding="20dip"></TextView>
<RadioGroup android:id="@+id/radioGroup" android:layout_height="wrap_content" android:layout_width="wrap_content">
<RadioButton android:checked="true" android:text="@string/wizard_configure_all" android:id="@+id/radio0" android:layout_height="wrap_content" android:layout_width="wrap_content"></RadioButton>
<TextView android:layout_height="wrap_content"
diff --git a/res/layout/layout_wizard_tips.xml b/res/layout/layout_wizard_tips.xml
index 420bc3c..a9c4d0b 100644
--- a/res/layout/layout_wizard_tips.xml
+++ b/res/layout/layout_wizard_tips.xml
@@ -41,8 +41,7 @@
android:layout_height="fill_parent"
android:padding="3px">
-<TextView android:text="@string/wizard_tips_msg" android:layout_gravity="left" android:textColor="#ffffff" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
-
+<TextView android:text="@string/wizard_tips_msg" android:layout_width="wrap_content" android:textColor="#ffffff" android:layout_height="wrap_content" android:background="#222222" android:textSize="8pt" android:id="@+id/WizardTextBody1" android:padding="20dip"></TextView>
<Button android:text="@string/wizard_tips_gibberbot" android:layout_gravity="left" android:drawableLeft="@drawable/ic_launcher_gibberbot" android:layout_marginTop="10px" android:id="@+id/WizardRootButtonInstallGibberbot" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<Button android:text="@string/wizard_tips_firefox" android:layout_gravity="left" android:drawableLeft="@drawable/icon_firefox" android:layout_marginTop="10px" android:id="@+id/WizardRootButtonInstallFirefox" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
diff --git a/res/layout/scrollingtext_buttons_view.xml b/res/layout/scrollingtext_buttons_view.xml
index 75b7925..04023ff 100644
--- a/res/layout/scrollingtext_buttons_view.xml
+++ b/res/layout/scrollingtext_buttons_view.xml
@@ -48,7 +48,7 @@
android:layout_height="fill_parent"
android:layout_span="3">
- <TextView android:text="this is sample text this is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample text" android:padding="6px" android:background="#222222" android:textColor="#ffffff" android:id="@+id/WizardTextBody" android:textSize="8pt" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
+ <TextView android:text="this is sample text this is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample text" android:background="#222222" android:textColor="#ffffff" android:id="@+id/WizardTextBody" android:textSize="8pt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="20dip"></TextView>
</ScrollView>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index af22a49..720c03c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -127,10 +127,10 @@
<!-- New Wizard Strings -->
<!-- Title Screen -->
<string name="wizard_title">Orbot</string>
- <string name="wizard_title_msg">Orbot brings Tor to Android \nTor helps you defend against a form of network surveillance that threatens privacy, confidential business activity and relationships, and state security known as traffic analysis</string>
+ <string name="wizard_title_msg">Orbot brings Tor to Android \n\nTor helps you defend against a form of network surveillance that threatens privacy, confidential business activity and relationships, and state security known as traffic analysis</string>
<!-- Warning screen -->
<string name="wizard_warning_title">Warning</string>
- <string name="wizard_warning_msg">Simply installing Orbot will not automatically anonymize your mobile traffic.\nPlease follow the following steps to get started</string>
+ <string name="wizard_warning_msg">Simply installing Orbot will not automatically anonymize your mobile traffic.\n\nPlease follow the following steps to get started</string>
<!-- Permissions screen -->
<string name="wizard_permissions_title">Permissions</string>
<string name="wizard_permissions_root_msg1">Orbot has detected that you have root permissions enabled. To enable \'Transparent Proxying\', please grant superuser privileges to Orbot</string>
[View Less]
1
0
commit 870ce6a91d8072aa8169c7ce9bd6aadc9cb6a793
Author: Sathyanarayanan Gunasekaran <gsathya.ceg(a)gmail.com>
Date: Sat Jun 11 02:53:02 2011 +0530
Fixed CheckBox BUG
Previously, the "next" button was not disabled when the CheckBox
was unchecked. Changed it. Also, updated the logic inside the
CheckBox's listener.
---
src/org/torproject/android/Permissions.java | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/org/…
[View More]torproject/android/Permissions.java b/src/org/torproject/android/Permissions.java
index 3b782df..4b74c55 100644
--- a/src/org/torproject/android/Permissions.java
+++ b/src/org/torproject/android/Permissions.java
@@ -113,7 +113,7 @@ public class Permissions extends Activity implements TorConstants {
Button back = ((Button)findViewById(R.id.btnWizard1));
Button next = ((Button)findViewById(R.id.btnWizard2));
- next.setClickable(false);
+ next.setEnabled(false);
CheckBox consent = (CheckBox)findViewById(R.id.checkBox);
consent.setVisibility(CheckBox.VISIBLE);
@@ -129,16 +129,16 @@ public class Permissions extends Activity implements TorConstants {
Editor pEdit = prefs.edit();
- pEdit.putBoolean(PREF_TRANSPARENT, isChecked);
- pEdit.putBoolean(PREF_TRANSPARENT_ALL, isChecked);
+ pEdit.putBoolean(PREF_TRANSPARENT, !isChecked);
+ pEdit.putBoolean(PREF_TRANSPARENT_ALL, !isChecked);
pEdit.commit();
Button next = ((Button)findViewById(R.id.btnWizard2));
if(isChecked)
- next.setClickable(true);
+ next.setEnabled(true);
else
- next.setClickable(false);
+ next.setEnabled(false);
}
@@ -166,7 +166,9 @@ public class Permissions extends Activity implements TorConstants {
}
});
- next.setOnClickListener(new View.OnClickListener() {
+
+ next.setOnClickListener(new View.OnClickListener() {
+
@Override
public void onClick(View v) {
@@ -178,7 +180,7 @@ public class Permissions extends Activity implements TorConstants {
private void stepFour(){
-
+ Toast.makeText(context, "NON ROOT FUNC", Toast.LENGTH_SHORT).show();
String title = context.getString(R.string.wizard_permissions_title);
String msg = context.getString(R.string.wizard_permissions_msg);
[View Less]
1
0
commit 2103444e7c48187069572fcfb0a56287307fb10c
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Thu Jun 2 16:21:25 2011 -0400
new values for 0.0.0.0 binding
---
res/raw/torrc | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/res/raw/torrc b/res/raw/torrc
index ba0b61e..d1cd7fd 100644
--- a/res/raw/torrc
+++ b/res/raw/torrc
@@ -7,5 +7,8 @@ RelayBandwidthRate 20 KBytes
RelayBandwidthBurst 20 KBytes
UseBridges 0
AutomapHostsOnResolve 1
+…
[View More]TransListenAddress 0.0.0.0
TransPort 9040
+DNSListenAddress 0.0.0.0
DNSPort 5400
+
[View Less]
1
0
commit de5d9bfe464be1960cbd5be194c65cf685572b51
Author: Sathyanarayanan Gunasekaran <gsathya.ceg(a)gmail.com>
Date: Mon May 30 11:01:47 2011 +0530
First two wizard screens
---
AndroidManifest.xml | 5 +-
res/layout/scrollingtext_buttons_view.xml | 63 ++++++++
res/values/strings.xml | 14 ++-
src/org/torproject/android/AboutActivity.java | 204 ++++++++++++++++++++++++
src/org/torproject/android/Orbot.java | …
[View More] 4 +-
src/org/torproject/android/WizardActivity.java | 71 --------
6 files changed, 284 insertions(+), 77 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d01b58e..f11a63e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -28,8 +28,9 @@
<action android:name="org.torproject.android.START_TOR" />
</intent-filter>
</activity>
-
- <activity android:name=".SettingsPreferences" android:label="@string/app_name"/>
+
+ <activity android:name=".AboutActivity"/>
+ <activity android:name=".SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".AppManager" android:label="@string/app_name"/>
<activity android:name=".WizardActivity" android:label="@string/app_name"/>
diff --git a/res/layout/scrollingtext_buttons_view.xml b/res/layout/scrollingtext_buttons_view.xml
new file mode 100644
index 0000000..623f59c
--- /dev/null
+++ b/res/layout/scrollingtext_buttons_view.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@drawable/background">
+
+<RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/relativeLayout1"
+ android:layout_gravity="center_horizontal">
+ <ImageView
+ android:src="@drawable/tor"
+ android:id="@+id/gibber_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:paddingLeft="20px" android:paddingRight="20px" >
+ </ImageView>
+ <TextView android:textSize="10pt"
+ android:layout_toRightOf="@id/gibber_image"
+ android:layout_alignParentTop="true"
+ android:gravity="center_vertical"
+ android:layout_height="wrap_content"
+ android:id="@+id/WizardTextTitle"
+ android:layout_width="wrap_content"
+ android:fadingEdge="vertical"
+ android:text="TITLE"
+ android:textColor="#00ff00"
+ android:singleLine="true"
+
+
+
+ android:layout_centerInParent="true"
+ android:padding="20px">
+ </TextView>
+ </RelativeLayout>
+<TableLayout android:id="@+id/TableLayout01" android:stretchColumns="*" android:layout_height="fill_parent" android:layout_width="wrap_content">
+
+<TableRow android:id="@+id/TableRow01" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent">
+
+
+ <ScrollView android:id="@+id/helpscrollview"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_span="3">
+
+ <TextView android:text="this is sample text this is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample text" android:padding="6px" android:background="#222222" android:textColor="#ffffff" android:id="@+id/WizardTextBody" android:textSize="8pt" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
+
+ </ScrollView>
+
+</TableRow>
+<TableRow android:id="@+id/TableRow01" android:textColor="#00ff00" android:layout_width="fill_parent" android:layout_height="30px">
+ <Button android:text="button1" android:id="@+id/btnWizard1" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
+ <Button android:text="button2" android:id="@+id/btnWizard2" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
+</TableRow>
+</TableLayout>
+</LinearLayout>
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bca3df9..2212f49 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -69,8 +69,6 @@
<string name="title_error">Application Error</string>
-<string name="wizard_title">Welcome to Orbot</string>
-
<string name="wizard_btn_tell_me_more">About Orbot</string>
<string name="btn_next">Next</string>
<string name="btn_back">Back</string>
@@ -130,5 +128,15 @@
<string name="pref_general_group">General</string>
<string name="pref_start_boot_title">Start Orbot on Boot</string>
<string name="pref_start_boot_summary">Automatically start Orbot and connect Tor when your Android device boots</string>
-
+ <!-- New Wizard Strings -->
+ <!-- Title Screen -->
+ <string name="wizard_title">Orbot</string>
+ <string name="wizard_title_msg">Orbot brings Tor to Android \nTor helps you defend against a form of network surveillance that threatens privacy, confidential business activity and relationships, and state security known as traffic analysis</string>
+ <!-- Warning screen -->
+ <string name="wizard_warning_title">Warning</string>
+ <string name="wizard_warning_msg">Simply installing Orbot will not automatically anonymize your mobile traffic.\nPlease follow the following steps to get started</string>
+ <!-- Permissions screen -->
+ <string name="wizard_permissions_title">Permissions</string>
+
+
</resources>
diff --git a/src/org/torproject/android/AboutActivity.java b/src/org/torproject/android/AboutActivity.java
new file mode 100644
index 0000000..a03314b
--- /dev/null
+++ b/src/org/torproject/android/AboutActivity.java
@@ -0,0 +1,204 @@
+package org.torproject.android;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.DialogInterface.OnClickListener;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class AboutActivity extends Activity implements OnClickListener
+{
+ //WizardHelper wizard = null;
+
+ private int title[] = {
+ R.string.wizard_title,
+ R.string.wizard_warning_title,
+ R.string.wizard_permissions_title
+ };
+
+ private int msg[] = {
+ R.string.wizard_title_msg,
+ R.string.wizard_warning_msg,
+ };
+
+ private String buttons[][] =
+ {
+ {null,"Next"},
+ {"Back","Next"},
+ {"Back","Next"},
+ {"Back","Next"},
+
+ };
+
+ private View.OnClickListener listener[][] =
+ {
+ {
+ null,
+ new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+ nextContent();
+
+ }
+ }
+ },
+
+ {
+ new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ prevContent();
+
+ }
+ },
+ new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+ nextContent();
+
+ }
+ }
+ },
+
+ {
+ new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ prevContent();
+
+ }
+ },
+ new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+
+ //Intent intent = new Intent(getBaseContext(), AccountWizardActivity.class);
+
+
+ //startActivity(intent);
+
+ }
+ }
+ },
+
+
+
+ };
+
+
+ private int contentIdx = -1;
+
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ }
+
+ @Override
+ protected void onStart() {
+
+ super.onStart();
+
+ if (contentIdx == -1)
+ {
+ setContentView(R.layout.scrollingtext_buttons_view);
+
+ nextContent ();
+ }
+ }
+
+ private void prevContent ()
+ {
+ contentIdx--;
+ showContent(contentIdx);
+ }
+
+ private void nextContent ()
+ {
+ contentIdx++;
+ showContent(contentIdx);
+ }
+
+ private void showContent (int contentIdx)
+ {
+ TextView txtTitle = ((TextView)findViewById(R.id.WizardTextTitle));
+ txtTitle.setText(getString(title[contentIdx]));
+
+ TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody));
+ txtBody.setText(getString(msg[contentIdx]));
+
+ Button btn1 = ((Button)findViewById(R.id.btnWizard1));
+
+ ImageView img = (ImageView) findViewById(R.id.gibber_image);
+
+ if (buttons[contentIdx][0] != null)
+ {
+ btn1.setText(buttons[contentIdx][0]);
+ btn1.setOnClickListener(listener[contentIdx][0]);
+ btn1.setVisibility(Button.VISIBLE);
+
+ }
+ else
+ {
+ btn1.setVisibility(Button.INVISIBLE);
+ }
+
+ Button btn2 = ((Button)findViewById(R.id.btnWizard2));
+ if (buttons[contentIdx][1] != null)
+ {
+ btn2.setText(buttons[contentIdx][1]);
+ btn2.setOnClickListener(listener[contentIdx][1]);
+ btn2.setVisibility(Button.VISIBLE);
+
+ }
+ else
+ {
+ btn2.setVisibility(Button.INVISIBLE);
+ }
+
+ if(contentIdx !=0)
+ {
+ img.setVisibility(ImageView.GONE);
+ }
+ else
+ {
+ img.setVisibility(ImageView.VISIBLE);
+ }
+
+ }
+
+
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+
+ }
+
+
+
+
+ @Override
+ public void onClick(DialogInterface arg0, int arg1) {
+
+
+ }
+
+
+
+}
diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index 4bc5695..eb26960 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -4,6 +4,8 @@
package org.torproject.android;
+
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -454,7 +456,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
private void showHelp ()
{
- new WizardHelper(this).showWizard();
+ startActivityForResult(new Intent(getBaseContext(), AboutActivity.class), 1);
}
diff --git a/src/org/torproject/android/WizardActivity.java b/src/org/torproject/android/WizardActivity.java
deleted file mode 100644
index 2a8bf33..0000000
--- a/src/org/torproject/android/WizardActivity.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.torproject.android;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-
-public class WizardActivity extends Activity implements OnClickListener
-{
-
- protected void onCreate(Bundle savedInstanceState)
- {
-
- this.setContentView(R.layout.layout_help);
-
- }
-
-
-
- @Override
- protected void onStart() {
-
- super.onStart();
-
-
- }
-
-
-
- @Override
- protected void onResume() {
- super.onResume();
-
- showStep1();
- }
-
-
-
- public void showStep1()
- {
- showDialog("Test","","foo","bar",this);
- }
-
- private void showDialog (String title, String msg, String button1, String button2, OnClickListener ocListener)
- {
-
- new AlertDialog.Builder(this)
- .setInverseBackgroundForced(true)
- .setTitle(title)
- .setMessage(msg)
- .setNeutralButton(button1, ocListener)
- .setNegativeButton(button2, ocListener)
- .show();
-
-
- }
-
-
-
- @Override
- public void onClick(DialogInterface arg0, int arg1) {
-
-
- }
-
-
-
-}
[View Less]
1
0
commit ddb4793b0a051afc9cb9f7dd5d7e7c6589ef861e
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Thu Jun 2 16:21:50 2011 -0400
added tethering support
---
src/org/torproject/android/Orbot.java | 1303 +++++++++++---------
.../android/boot/OnbootBroadcastReceiver.java | 37 -
src/org/torproject/android/service/TorService.java | 15 +-
.../torproject/android/service/TorTransProxy.java | 43 +-
4 files changed, 737 insertions(+), 661 deletions(-)
diff --…
[View More]git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index 4bc5695..690ce10 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -1,9 +1,8 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
+/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - https://guardianproject.info */
/* See LICENSE for licensing information */
package org.torproject.android;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -45,43 +44,56 @@ import android.widget.TextView;
public class Orbot extends Activity implements OnLongClickListener, TorConstants
{
-
- /* Useful UI bits */
- private TextView lblStatus = null; //the main text display widget
- private ImageView imgStatus = null; //the main touchable image for activating Orbot
- private ProgressDialog progressDialog;
- private MenuItem mItemOnOff = null;
-
- /* Some tracking bits */
- private int torStatus = STATUS_READY; //latest status reported from the tor service
-
- /* Tor Service interaction */
- /* The primary interface we will be calling on the service. */
- ITorService mService = null;
- private boolean autoStartOnBind = false;
-
- SharedPreferences prefs;
-
- /** Called when the activity is first created. */
+
+ /* Useful UI bits */
+ // so this is probably pretty obvious, here, but also an area
+ // which we might see quite a bit of change+complexity was the main screen
+ // UI gets new features
+ private TextView lblStatus = null; //the main text display widget
+ private ImageView imgStatus = null; //the main touchable image for activating Orbot
+ private ProgressDialog progressDialog; //the spinning progress dialog that shows up now and then
+ private MenuItem mItemOnOff = null; //the menu item which we toggle based on Orbot state
+
+ /* Some tracking bits */
+ private int torStatus = STATUS_READY; //latest status reported from the tor service
+ // this is a value we get passed back from the TorService
+
+ /* Tor Service interaction */
+ /* The primary interface we will be calling on the service. */
+ ITorService mService = null; //interface to remote TorService
+ private boolean autoStartOnBind = false; //controls whether service starts when class binds to it
+
+ SharedPreferences prefs; //what the user really wants!
+
+ /**
+ * When the Orbot activity is created, we call startService
+ * to ensure the Tor remote service is running. However, it may
+ * already be running, and this should not create more than one instnace
+ */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//if Tor binary is not running, then start the service up
- startService(new Intent(INTENT_TOR_SERVICE));
-
-
- setTheme(android.R.style.Theme_Black_NoTitleBar);
-
- prefs = PreferenceManager.getDefaultSharedPreferences(this);
-
- setContentView(R.layout.layout_main);
-
- lblStatus = (TextView)findViewById(R.id.lblStatus);
- lblStatus.setOnLongClickListener(this);
- imgStatus = (ImageView)findViewById(R.id.imgStatus);
- imgStatus.setOnLongClickListener(this);
-
-
+ //might want to look at whether we need to call this every time
+ //or whether binding to the service is enough
+ startService(new Intent(INTENT_TOR_SERVICE));
+
+ //something to play with on the UI branch
+ setTheme(android.R.style.Theme_Black_NoTitleBar);
+
+ prefs = PreferenceManager.getDefaultSharedPreferences(this);
+
+ //same here - layout_main has been cleaned up since 1.0.5.2 a bit (removed table as you recmnd)
+ //but ther eis more to be done
+ setContentView(R.layout.layout_main);
+
+ //obvious? -yep got everything so far
+ lblStatus = (TextView)findViewById(R.id.lblStatus);
+ lblStatus.setOnLongClickListener(this);
+ imgStatus = (ImageView)findViewById(R.id.imgStatus);
+ imgStatus.setOnLongClickListener(this);
+
+
}
@@ -119,562 +131,636 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
private void showAbout ()
- {
-
- LayoutInflater li = LayoutInflater.from(this);
+ {
+
+ LayoutInflater li = LayoutInflater.from(this);
View view = li.inflate(R.layout.layout_about, null);
TextView versionName = (TextView)view.findViewById(R.id.versionName);
versionName.setText(R.string.app_version);
- new AlertDialog.Builder(this)
+ new AlertDialog.Builder(this)
.setTitle(getString(R.string.button_about))
.setView(view)
.show();
- }
+ }
/* When a menu item is selected launch the appropriate view or activity
* (non-Javadoc)
- * @see android.app.Activity#onMenuItemSelected(int, android.view.MenuItem)
- */
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
-
- super.onMenuItemSelected(featureId, item);
-
- if (item.getItemId() == 1)
- {
-
- try
- {
-
- if (mService == null)
- {
-
- }
- else if (mService.getStatus() == STATUS_READY)
- {
- if (mItemOnOff != null)
- mItemOnOff.setTitle(R.string.menu_stop);
- startTor();
-
- }
- else
- {
- if (mItemOnOff != null)
- mItemOnOff.setTitle(R.string.menu_start);
- stopTor();
-
- }
-
- }
- catch (RemoteException re)
- {
- Log.w(TAG, "Unable to start/top Tor from menu UI", re);
- }
- }
- else if (item.getItemId() == 4)
- {
- showSettings();
- }
- else if (item.getItemId() == 3)
- {
- showHelp();
- }
- else if (item.getItemId() == 7)
- {
- doTorCheck();
- }
- else if (item.getItemId() == 8)
- {
- //exit app
- doExit();
-
-
- }
- else if (item.getItemId() == 6)
- {
- showAbout();
-
-
- }
-
+ * @see android.app.Activity#onMenuItemSelected(int, android.view.MenuItem)
+ */
+ public boolean onMenuItemSelected(int featureId, MenuItem item) {
+
+ super.onMenuItemSelected(featureId, item);
+
+ if (item.getItemId() == 1)
+ {
+
+ try
+ {
+
+ if (mService == null)
+ {
+
+ }
+ else if (mService.getStatus() == STATUS_READY)
+ {
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_stop);
+ startTor();
+
+ }
+ else
+ {
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_start);
+ stopTor();
+
+ }
+
+ }
+ catch (RemoteException re)
+ {
+ Log.w(TAG, "Unable to start/top Tor from menu UI", re);
+ }
+ }
+ else if (item.getItemId() == 4)
+ {
+ showSettings();
+ }
+ else if (item.getItemId() == 3)
+ {
+ showHelp();
+ }
+ else if (item.getItemId() == 7)
+ {
+ doTorCheck();
+ }
+ else if (item.getItemId() == 8)
+ {
+ //exit app
+ doExit();
+
+
+ }
+ else if (item.getItemId() == 6)
+ {
+ showAbout();
+
+
+ }
+
return true;
- }
-
- private void doExit ()
- {
- try {
-
- stopTor();
-
- stopService(new Intent(ITorService.class.getName()));
-
- NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- mNotificationManager.cancelAll();
-
-
- } catch (RemoteException e) {
- Log.w(TAG, e);
- }
-
- finish();
-
- }
-
- /* Return to the main view when the back key is pressed
- * (non-Javadoc)
- * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
- */
- /*
- public boolean onKeyDown(int keyCode, KeyEvent event){
-
- if(keyCode==KeyEvent.KEYCODE_BACK){
-
- if(currentView != R.layout.layout_main){
-
- showMain ();
- return true;
- }
- else{
- return super.onKeyDown(keyCode, event);
- }
- }
-
- return super.onKeyDown(keyCode, event);
-
- }*/
+ }
+
+ /**
+ * This is our attempt to REALLY exit Orbot, and stop the background service
+ * However, Android doesn't like people "quitting" apps, and/or our code may not
+ * be quite right b/c no matter what we do, it seems like the TorService still exists
+ **/
+ private void doExit ()
+ {
+ try {
+
+ //one of the confusing things about all of this code is the multiple
+ //places where things like "stopTor" are called, both in the Activity and the Service
+ //not something to tackle in your first iteration, but i thin we can talk about fixing
+ //terminology but also making sure there are clear distinctions in control
+ stopTor();
+
+ //perhaps this should be referenced as INTENT_TOR_SERVICE as in startService
+ stopService(new Intent(ITorService.class.getName()));
+
+ //clears all notifications from the status bar
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ mNotificationManager.cancelAll();
+
+
+ } catch (RemoteException e) {
+ Log.w(TAG, e);
+ }
+
+ finish();
+
+ }
+
+ /* Return to the main view when the back key is pressed
+ * (non-Javadoc)
+ * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
+ */
+ /*
+ public boolean onKeyDown(int keyCode, KeyEvent event){
+
+ //yeah this should probably go away now :) - or not
+ if(keyCode==KeyEvent.KEYCODE_BACK){
+
+ if(currentView != R.layout.layout_main){
+
+ showMain ();
+ return true;
+ }
+ else{
+ return super.onKeyDown(keyCode, event);
+ }
+ }
+
+ return super.onKeyDown(keyCode, event);
+
+ }*/
/* (non-Javadoc)
- * @see android.app.Activity#onPause()
- */
- protected void onPause() {
- super.onPause();
-
- hideProgressDialog();
-
- if (aDialog != null)
- aDialog.dismiss();
- }
-
- public void onSaveInstanceState(Bundle savedInstanceState) {
- // Save UI state changes to the savedInstanceState.
- // This bundle will be passed to onCreate if the process is
- // killed and restarted.
- // etc.
- super.onSaveInstanceState(savedInstanceState);
- }
-
- public void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- // Restore UI state from the savedInstanceState.
- // This bundle has also been passed to onCreate.
-
- }
-
- private void doTorCheck ()
- {
-
- DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- switch (which){
- case DialogInterface.BUTTON_POSITIVE:
-
- openBrowser(URL_TOR_CHECK);
-
-
-
- break;
-
- case DialogInterface.BUTTON_NEGATIVE:
-
- //do nothing
- break;
- }
- }
- };
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(R.string.tor_check).setPositiveButton(R.string.btn_okay, dialogClickListener)
- .setNegativeButton(R.string.btn_cancel, dialogClickListener).show();
-
- }
-
- private void enableHiddenServicePort (int hsPort)
- {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- Editor pEdit = prefs.edit();
-
- String hsPortString = prefs.getString("pref_hs_ports", "");
-
- if (hsPortString.length() > 0 && hsPortString.indexOf(hsPort+"")==-1)
- hsPortString += ',' + hsPort;
- else
- hsPortString = hsPort + "";
-
- pEdit.putString("pref_hs_ports", hsPortString);
- pEdit.putBoolean("pref_hs_enable", true);
-
- pEdit.commit();
-
- String onionHostname = prefs.getString("pref_hs_hostname","");
-
- Intent nResult = new Intent();
- nResult.putExtra("hs_host", onionHostname);
- setResult(RESULT_OK, nResult);
-
- }
-
- /* (non-Javadoc)
- * @see android.app.Activity#onResume()
- */
- protected void onResume() {
- super.onResume();
-
- bindService();
-
- updateStatus("");
-
- if (getIntent() == null)
- return;
-
- String action = getIntent().getAction();
-
- if (action == null)
- return;
-
- if (action.equals("org.torproject.android.REQUEST_HS_PORT"))
- {
-
- DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- switch (which){
- case DialogInterface.BUTTON_POSITIVE:
-
- int hsPort = getIntent().getIntExtra("hs_port", -1);
-
- enableHiddenServicePort (hsPort);
-
- finish();
-
-
- break;
-
- case DialogInterface.BUTTON_NEGATIVE:
- //No button clicked
- finish();
- break;
- }
- }
- };
-
- int hsPort = getIntent().getIntExtra("hs_port", -1);
-
- String requestMsg = "An app wants to open a server port (" + hsPort + ") to the Tor network. This is safe if you trust the app.";
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener)
- .setNegativeButton("Deny", dialogClickListener).show();
-
-
- }
- else if (action.equals("org.torproject.android.START_TOR"))
- {
- autoStartOnBind = true;
-
- if (mService == null)
- bindService();
-
- }
- else
- {
-
- //setTitle(getString(R.string.app_name) + ' ' + getString(R.string.app_version));
-
- NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- mNotificationManager.cancelAll();
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-
- boolean showWizard = prefs.getBoolean("show_wizard",true);
-
- if (showWizard)
- {
-
- Editor pEdit = prefs.edit();
-
- pEdit.putBoolean("show_wizard",false);
-
- pEdit.commit();
-
- new WizardHelper(this).showWizard();
-
- }
-
- }
- }
-
- /* (non-Javadoc)
- * @see android.app.Activity#onStart()
- */
- protected void onStart() {
- super.onStart();
-
-
- updateStatus ("");
-
- }
-
- /* (non-Javadoc)
- * @see android.app.Activity#onStop()
- */
- protected void onStop() {
- super.onStop();
-
- //unbindService();
- }
-
-
-
- /*
- * Launch the system activity for Uri viewing with the provided url
- */
- private void openBrowser(String url)
- {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
-
- }
-
-
-
- /*
- * Show the help view - a popup dialog
- */
- private void showHelp ()
- {
-
+ * @see android.app.Activity#onPause()
+ */
+ protected void onPause() {
+ super.onPause();
+
+ hideProgressDialog();
+
+ if (aDialog != null)
+ aDialog.dismiss();
+ }
+
+/**
+* i think we need to suport this onSave/Restore code more b/c i think
+* when someone rotates the screen, and the state is lost during setup
+* etc it causes problems. this might be the place to solve that in the wizard - hmm this prob coz android restarts the activity when the screen is rotated. this will prob be fixed(?) when
+we redesign the wizard into a view not just a dialogbox
+cool
+**/
+ public void onSaveInstanceState(Bundle savedInstanceState) {
+ // Save UI state changes to the savedInstanceState.
+ // This bundle will be passed to onCreate if the process is
+ // killed and restarted.
+ // etc.
+ super.onSaveInstanceState(savedInstanceState);
+ }
+
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ // Restore UI state from the savedInstanceState.
+ // This bundle has also been passed to onCreate.
+
+ //we do nothing here
+ }
+
+ /**
+ * confirm with the user that they want to open a browser to connect to https://check.torproject.org
+ and then launch the URL.
+ this may be where the TorCheck API code/UI is added, though always offering the web-based confirm
+ should be an option, since users know it
+
+ **/
+ private void doTorCheck ()
+ {
+
+ DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ switch (which){
+ case DialogInterface.BUTTON_POSITIVE:
+
+ openBrowser(URL_TOR_CHECK);
+
+
+
+ break;
+
+ case DialogInterface.BUTTON_NEGATIVE:
+
+ //do nothing
+ break;
+ }
+ }
+ };
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(R.string.tor_check).setPositiveButton(R.string.btn_okay, dialogClickListener)
+ .setNegativeButton(R.string.btn_cancel, dialogClickListener).show();
+
+ }
+
+ /**
+ * this adds a port to the list of hidden service ports
+ * we might want to add remove/disable port too
+ * this is used by external apps that launch an intent
+ * to request a hidden service on a specific port
+ * currently, we haven't promoted this intent API or capability
+ * that much, but we hope to
+ **/
+ private void enableHiddenServicePort (int hsPort)
+ {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ Editor pEdit = prefs.edit();
+
+ String hsPortString = prefs.getString("pref_hs_ports", "");
+
+ if (hsPortString.length() > 0 && hsPortString.indexOf(hsPort+"")==-1)
+ hsPortString += ',' + hsPort;
+ else
+ hsPortString = hsPort + "";
+
+ pEdit.putString("pref_hs_ports", hsPortString);
+ pEdit.putBoolean("pref_hs_enable", true);
+
+ pEdit.commit();
+
+ String onionHostname = prefs.getString("pref_hs_hostname","");
+
+ Intent nResult = new Intent();
+ nResult.putExtra("hs_host", onionHostname);
+ setResult(RESULT_OK, nResult);
+
+ }
+
+ /* (non-Javadoc)
+ * @see android.app.Activity#onResume()
+ */
+ protected void onResume() {
+ super.onResume();
+
+ //this is where we make sure we have a handle to ITorService
+ bindService();
+
+ //this is a hack which basically pings the ITorService to update our status for the UI
+ // - the dialogbox/progressbar ?
+ // right, this was for when the label displayed the status, and not the progress, so it may
+ // not make as much sense now; there is a bunch of loose ends like this that should be
+ // cleaned up with the transition to the progressdialog - ok
+ updateStatus("");
+
+ //this checks if we were launched via an Intent call from another app or activity
+ //- how does this matter? if Orbot has been launched via an Intent or not ?
+ //we want to know if this is a launch by the user from the home screen, or via back, or some
+ // standard interaction, or if it is another app launching Orbot for a programmatic/API request
+ // this is how we can add more functionality into ORlib, for instance via Intent launching - hmm ok
+ if (getIntent() == null)
+ return;
+
+ String action = getIntent().getAction();
+
+ if (action == null)
+ return;
+
+ //this relates to the previously discussed hidden port capability
+ if (action.equals("org.torproject.android.REQUEST_HS_PORT"))
+ {
+
+ //tell the user an app is trying to open a hidden port and ask for permission
+ DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ switch (which){
+ case DialogInterface.BUTTON_POSITIVE:
+
+ int hsPort = getIntent().getIntExtra("hs_port", -1);
+
+ enableHiddenServicePort (hsPort);
+
+ finish();
+
+
+ break;
+
+ case DialogInterface.BUTTON_NEGATIVE:
+ //No button clicked
+ finish();
+ break;
+ }
+ }
+ };
+
+ int hsPort = getIntent().getIntExtra("hs_port", -1);
+
+ String requestMsg = "An app wants to open a server port (" + hsPort + ") to the Tor network. This is safe if you trust the app.";
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener)
+ .setNegativeButton("Deny", dialogClickListener).show();
+
+
+ }
+ else if (action.equals("org.torproject.android.START_TOR")) //this is the intent used to start Tor from another app, again meant for ORlib functionality
+ {
+ autoStartOnBind = true;
+
+ if (mService == null)
+ bindService();
+
+ }
+ else
+ {
+ //hmm not sure when this is ever reached honestly ;P
+ //but it looks like a general UI reset
+
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ mNotificationManager.cancelAll();
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+
+ boolean showWizard = prefs.getBoolean("show_wizard",true);
+
+ if (showWizard)
+ {
+
+ Editor pEdit = prefs.edit();
+
+ pEdit.putBoolean("show_wizard",false);
+
+ pEdit.commit();
+
+ new WizardHelper(this).showWizard();
+
+ }
+
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see android.app.Activity#onStart()
+ */
+ protected void onStart() {
+ super.onStart();
+
+
+ updateStatus ("");
+
+ }
+
+ /* (non-Javadoc)
+ * @see android.app.Activity#onStop()
+ */
+ protected void onStop() {
+ super.onStop();
+
+ //unbindService();
+ }
+
+
+
+ /*
+ * Launch the system activity for Uri viewing with the provided url
+ */
+ private void openBrowser(String url)
+ {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+
+ }
+
+
+
+ /*
+ * Show the help view - a popup dialog
+ */
+ private void showHelp ()
+ {
+
new WizardHelper(this).showWizard();
- }
-
-
+ }
+
+
/*
* Load the basic settings application to display torrc
*/
- private void showSettings ()
- {
-
- startActivityForResult(new Intent(this, SettingsPreferences.class), 1);
- }
-
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
-
- if (requestCode == 1 && resultCode == 1010 && mService != null)
- {
- new ProcessSettingsAsyncTask().execute(mService);
- }
- }
-
- AlertDialog aDialog = null;
-
- private void showAlert(String title, String msg, boolean button)
- {
- try
- {
- if (aDialog != null && aDialog.isShowing())
- aDialog.dismiss();
- }
- catch (Exception e){} //swallow any errors
-
- if (button)
- {
- aDialog = new AlertDialog.Builder(this)
- .setIcon(R.drawable.icon)
- .setTitle(title)
- .setMessage(msg)
- .setPositiveButton(android.R.string.ok, null)
- .show();
- }
- else
- {
- aDialog = new AlertDialog.Builder(this)
- .setIcon(R.drawable.icon)
- .setTitle(title)
- .setMessage(msg)
- .show();
- }
-
- aDialog.setCanceledOnTouchOutside(true);
- }
+ private void showSettings ()
+ {
+
+ startActivityForResult(new Intent(this, SettingsPreferences.class), 1);
+ }
+
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+
+ //if we get a response from an activity we launched (like from line 527 where we launch the Settings/Prefs screen)
+ //and the resultCode matches our arbitrary 1010 value, AND Tor is running
+ //then update the preferences in an async background task
+ if (requestCode == 1 && resultCode == 1010 && mService != null)
+ {
+ new ProcessSettingsAsyncTask().execute(mService);
+ }
+ }
+
+ AlertDialog aDialog = null;
+
+ //general alert dialog for mostly Tor warning messages
+ //sometimes this can go haywire or crazy with too many error
+ //messages from Tor, and the user cannot stop or exit Orbot
+ //so need to ensure repeated error messages are not spamming this method
+ private void showAlert(String title, String msg, boolean button)
+ {
+ try
+ {
+ if (aDialog != null && aDialog.isShowing())
+ aDialog.dismiss();
+ }
+ catch (Exception e){} //swallow any errors
+
+ if (button)
+ {
+ aDialog = new AlertDialog.Builder(this)
+ .setIcon(R.drawable.icon)
+ .setTitle(title)
+ .setMessage(msg)
+ .setPositiveButton(android.R.string.ok, null)
+ .show();
+ }
+ else
+ {
+ aDialog = new AlertDialog.Builder(this)
+ .setIcon(R.drawable.icon)
+ .setTitle(title)
+ .setMessage(msg)
+ .show();
+ }
+
+ aDialog.setCanceledOnTouchOutside(true);
+ }
/*
* Set the state of the running/not running graphic and label
+ * this all needs to be looked at w/ the shift to progressDialog
*/
public void updateStatus (String torServiceMsg)
{
- try
- {
-
- if (mService != null)
- torStatus = mService.getStatus();
-
- if (imgStatus != null)
- {
-
- if (torStatus == STATUS_ON)
- {
- imgStatus.setImageResource(R.drawable.toron);
-
- hideProgressDialog();
-
- String lblMsg = getString(R.string.status_activated);
- //+ "\n" + torServiceMsg;
-
- lblStatus.setText(lblMsg);
-
- if (torServiceMsg.length() > 0)
- showAlert("Update", torServiceMsg, false);
-
- boolean showFirstTime = prefs.getBoolean("connect_first_time",true);
-
- if (showFirstTime)
- {
-
- Editor pEdit = prefs.edit();
-
- pEdit.putBoolean("connect_first_time",false);
-
- pEdit.commit();
-
- showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time),true);
-
- }
-
- if (mItemOnOff != null)
- mItemOnOff.setTitle(R.string.menu_stop);
-
-
- }
- else if (torStatus == STATUS_CONNECTING)
- {
-
- imgStatus.setImageResource(R.drawable.torstarting);
-
- if (progressDialog != null)
- progressDialog.setMessage(torServiceMsg);
-
- if (mItemOnOff != null)
- mItemOnOff.setTitle(R.string.menu_stop);
-
- }
- else if (torStatus == STATUS_OFF)
- {
- imgStatus.setImageResource(R.drawable.toroff);
-
-
- hideProgressDialog();
-
- lblStatus.setText(getString(R.string.status_shutting_down));
-
- if (mItemOnOff != null)
- mItemOnOff.setTitle(R.string.menu_start);
- }
- else
- {
-
-
- hideProgressDialog();
-
- imgStatus.setImageResource(R.drawable.toroff);
- lblStatus.setText(getString(R.string.status_disabled) + "\n" + getString(R.string.press_to_start));
-
- if (mItemOnOff != null)
- mItemOnOff.setTitle(R.string.menu_start);
-
- }
- }
-
- }
- catch (RemoteException e)
- {
- Log.e(TAG,"remote exception updating status",e);
- }
-
+ try
+ {
+ //if the serivce is bound, query it for the curren status value (int)
+ if (mService != null)
+ torStatus = mService.getStatus();
+
+ //now update the layout_main UI based on the status
+ if (imgStatus != null)
+ {
+
+ if (torStatus == STATUS_ON)
+ {
+ imgStatus.setImageResource(R.drawable.toron);
+
+ hideProgressDialog();
+
+ String lblMsg = getString(R.string.status_activated);
+ //+ "\n" + torServiceMsg;
+
+ lblStatus.setText(lblMsg);
+
+ if (torServiceMsg.length() > 0)
+ showAlert("Update", torServiceMsg, false);
+
+ boolean showFirstTime = prefs.getBoolean("connect_first_time",true);
+
+ if (showFirstTime)
+ {
+
+ Editor pEdit = prefs.edit();
+
+ pEdit.putBoolean("connect_first_time",false);
+
+ pEdit.commit();
+
+ showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time),true);
+
+ }
+
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_stop);
+
+
+ }
+ else if (torStatus == STATUS_CONNECTING)
+ {
+
+ imgStatus.setImageResource(R.drawable.torstarting);
+
+ if (progressDialog != null)
+ progressDialog.setMessage(torServiceMsg);
+
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_stop);
+
+ }
+ else if (torStatus == STATUS_OFF)
+ {
+ imgStatus.setImageResource(R.drawable.toroff);
+
+
+ hideProgressDialog();
+
+ lblStatus.setText(getString(R.string.status_shutting_down));
+
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_start);
+ }
+ else
+ {
+
+
+ hideProgressDialog();
+
+ imgStatus.setImageResource(R.drawable.toroff);
+ lblStatus.setText(getString(R.string.status_disabled) + "\n" + getString(R.string.press_to_start));
+
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_start);
+
+ }
+ }
+
+ }
+ catch (RemoteException e)
+ {
+ Log.e(TAG,"remote exception updating status",e);
+ }
+
}
+ // guess what? this start's Tor! actually no it just requests via the local ITorService to the remote TorService instance
+ // to start Tor
private void startTor () throws RemoteException
{
-
- bindService();
-
- mService.setProfile(TorServiceConstants.PROFILE_ON); //this means turn on
-
- imgStatus.setImageResource(R.drawable.torstarting);
- lblStatus.setText(getString(R.string.status_starting_up));
-
- Message msg = mHandler.obtainMessage(TorServiceConstants.ENABLE_TOR_MSG);
- mHandler.sendMessage(msg);
-
-
-
+ // here we bind AGAIN - at some point i think we had to bind multiple times just in case
+ // but i would love to clarify, clean this up
+ bindService();
+
+ // this is a bit of a strange/old/borrowed code/design i used to change the service state
+ // not sure it really makes sense when what we want to say is just "startTor"
+ mService.setProfile(TorServiceConstants.PROFILE_ON); //this means turn on
+
+ //here we update the UI which is a bit sloppy and mixed up code wise
+ //might be best to just call updateStatus() instead of directly manipulating UI in this method - yep makes sense
+ imgStatus.setImageResource(R.drawable.torstarting);
+ lblStatus.setText(getString(R.string.status_starting_up));
+
+
+ //we send a message here to the progressDialog i believe, but we can clarify that shortly
+ Message msg = mHandler.obtainMessage(TorServiceConstants.ENABLE_TOR_MSG);
+ mHandler.sendMessage(msg);
+
+
+
}
+ //now we stop Tor! amazing!
private void stopTor () throws RemoteException
{
- if (mService != null)
- {
- mService.setProfile(TorServiceConstants.PROFILE_OFF);
- Message msg = mHandler.obtainMessage(TorServiceConstants.DISABLE_TOR_MSG);
- mHandler.sendMessage(msg);
- }
-
+ //if the service is bound, then turn it off, using the same "PROFILE_" technique
+ if (mService != null)
+ {
+ mService.setProfile(TorServiceConstants.PROFILE_OFF);
+
+ //again this is related to the progress dialog or some other threaded UI object
+ Message msg = mHandler.obtainMessage(TorServiceConstants.DISABLE_TOR_MSG);
+ mHandler.sendMessage(msg);
+ }
+
}
- /*
+ /*
* (non-Javadoc)
* @see android.view.View.OnClickListener#onClick(android.view.View)
*/
- public boolean onLongClick(View view) {
-
-
- try
- {
-
- if (mService == null)
- {
-
- }
- else if (mService.getStatus() == STATUS_READY)
- {
-
- createProgressDialog(getString(R.string.status_starting_up));
-
- startTor();
- }
- else
- {
-
- stopTor();
-
- }
-
- }
- catch (Exception e)
- {
- Log.d(TAG,"error onclick",e);
- }
-
- return true;
- }
-
+ public boolean onLongClick(View view) {
+
+
+ try
+ {
+
+ if (mService == null)
+ {
+
+ }
+ else if (mService.getStatus() == STATUS_READY)
+ {
+
+ createProgressDialog(getString(R.string.status_starting_up));
+
+ startTor();
+ }
+ else
+ {
+
+ stopTor();
+
+ }
+
+ }
+ catch (Exception e)
+ {
+ Log.d(TAG,"error onclick",e);
+ }
+
+ return true;
+ }
+
/**
* This implementation is used to receive callbacks from the remote
- * service.
+ * service.
+ *
+ * If we have this setup probably, we shouldn't have to poll or query status
+ * to the service, as it should send it as it changes or when we bind/unbind to it
+ * from this activity
*/
private ITorServiceCallback mCallback = new ITorServiceCallback.Stub() {
/**
@@ -684,50 +770,55 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
* NOT be running in our main thread like most other things -- so,
* to update the UI, we need to use a Handler to hop over there.
*/
+
+ //receive a new string vaule end-user displayable message from the ITorService
public void statusChanged(String value) {
- Message msg = mHandler.obtainMessage(TorServiceConstants.STATUS_MSG);
- msg.getData().putString(HANDLER_TOR_MSG, value);
- mHandler.sendMessage(msg);
+ //pass it off to the progressDialog
+ Message msg = mHandler.obtainMessage(TorServiceConstants.STATUS_MSG);
+ msg.getData().putString(HANDLER_TOR_MSG, value);
+ mHandler.sendMessage(msg);
}
- @Override
- public void logMessage(String value) throws RemoteException {
-
- Message msg = mHandler.obtainMessage(TorServiceConstants.LOG_MSG);
- msg.getData().putString(HANDLER_TOR_MSG, value);
- mHandler.sendMessage(msg);
-
- }
+ @Override //this was when we displayed the log in the main Activity; can prob take this out now
+ public void logMessage(String value) throws RemoteException {
+
+ Message msg = mHandler.obtainMessage(TorServiceConstants.LOG_MSG);
+ msg.getData().putString(HANDLER_TOR_MSG, value);
+ mHandler.sendMessage(msg);
+
+ }
};
+// this is what takes messages or values from the callback threads or other non-mainUI threads
+//and passes them back into the main UI thread for display to the user
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case TorServiceConstants.STATUS_MSG:
- String torServiceMsg = (String)msg.getData().getString(HANDLER_TOR_MSG);
-
- updateStatus(torServiceMsg);
-
+ String torServiceMsg = (String)msg.getData().getString(HANDLER_TOR_MSG);
+
+ updateStatus(torServiceMsg);
+
break;
case TorServiceConstants.LOG_MSG:
-
-
+
+
break;
case TorServiceConstants.ENABLE_TOR_MSG:
-
-
- updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
-
- break;
+
+
+ updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
+
+ break;
case TorServiceConstants.DISABLE_TOR_MSG:
-
- updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
-
- break;
-
+
+ updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
+
+ break;
+
default:
super.handleMessage(msg);
}
@@ -741,6 +832,10 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
/**
* Class for interacting with the main interface of the service.
*/
+ // this is the connection that gets called back when a successfull bind occurs
+ // we should use this to activity monitor unbind so that we don't have to call
+ // bindService() a million times
+
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className,
IBinder service) {
@@ -756,14 +851,15 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
try {
mService.registerCallback(mCallback);
+ //again with the update status?!? :P
updateStatus("");
if (autoStartOnBind)
{
- autoStartOnBind = false;
-
- startTor();
-
+ autoStartOnBind = false;
+
+ startTor();
+
}
} catch (RemoteException e) {
@@ -771,7 +867,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
// do anything with it; we can count on soon being
// disconnected (and then reconnected if it can be restarted)
// so there is no need to do anything here.
- Log.d(TAG,"error registering callback to service",e);
+ Log.d(TAG,"error registering callback to service",e);
}
@@ -789,20 +885,26 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
}
};
+ //should move this up with all the other class variables
boolean mIsBound = false;
+ //this is where we bind!
private void bindService ()
{
- bindService(new Intent(ITorService.class.getName()),
+ //since its auto create, we prob don't ever need to call startService
+ //also we should again be consistent with using either iTorService.class.getName()
+ //or the variable constant
+ bindService(new Intent(ITorService.class.getName()),
mConnection, Context.BIND_AUTO_CREATE);
-
- mIsBound = true;
+
+ mIsBound = true;
}
+ //unbind removes the callback, and unbinds the service
private void unbindService ()
{
- if (mIsBound) {
+ if (mIsBound) {
// If we have received the service, and hence registered with
// it, then now is the time to unregister.
if (mService != null) {
@@ -813,7 +915,10 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
// There is nothing special we need to do if the service
// has crashed.
}
- }
+ }
+
+ //maybe needs this?
+ mService = null;
// Detach our existing connection.
unbindService(mConnection);
@@ -821,26 +926,26 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
}
}
-
+
private void createProgressDialog (String msg)
{
- if (progressDialog != null && progressDialog.isShowing())
- return;
-
- progressDialog = ProgressDialog.show(Orbot.this, "", msg);
- progressDialog.setCancelable(true);
+ if (progressDialog != null && progressDialog.isShowing())
+ return;
+
+ progressDialog = ProgressDialog.show(Orbot.this, "", msg);
+ progressDialog.setCancelable(true);
}
private void hideProgressDialog ()
{
- if (progressDialog != null && progressDialog.isShowing())
- {
- progressDialog.dismiss();
+ if (progressDialog != null && progressDialog.isShowing())
+ {
+ progressDialog.dismiss();
- }
-
-
+ }
+
+
}
}
diff --git a/src/org/torproject/android/boot/OnbootBroadcastReceiver.java b/src/org/torproject/android/boot/OnbootBroadcastReceiver.java
deleted file mode 100644
index 163e708..0000000
--- a/src/org/torproject/android/boot/OnbootBroadcastReceiver.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.torproject.android.boot;
-
-import org.torproject.android.service.ITorService;
-import org.torproject.android.service.TorService;
-import org.torproject.android.service.TorServiceConstants;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
-import android.util.Log;
-
-public class OnbootBroadcastReceiver extends BroadcastReceiver implements TorServiceConstants {
- @Override
- public void onReceive(Context context, Intent intent) {
-
- Log.d(TAG, "received on boot notification");
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
-
- boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
-
- Log.d(TAG, "startOnBoot:" + startOnBoot);
-
- if (startOnBoot)
- {
- Intent serviceIntent = new Intent(context,TorService.class);
- serviceIntent.setAction("onboot");
- context.startService(serviceIntent);
- }
-
- //bindService(new Intent(ITorService.class.getName()),
- // mConnection, Context.BIND_AUTO_CREATE);
- }
-
-}
\ No newline at end of file
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 4be1eee..1b11492 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
+/* Copyright (c) 2009-2011, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
/* See LICENSE for licensing information */
package org.torproject.android.service;
@@ -545,6 +545,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
boolean enableTransparentProxy = prefs.getBoolean("pref_transparent", false);
boolean transProxyAll = prefs.getBoolean("pref_transparent_all", false);
boolean transProxyPortFallback = prefs.getBoolean("pref_transparent_port_fallback", false);
+ boolean transProxyTethering = prefs.getBoolean("pref_transparent_tethering", false);
TorService.logMessage ("Transparent Proxying: " + enableTransparentProxy);
@@ -581,6 +582,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
showAlert("Status", "Setting up app-based transparent proxying...");
code = TorTransProxy.setTransparentProxyingByApp(this,AppManager.getApps(this));
}
+
}
TorService.logMessage ("TorTransProxy resp code: " + code);
@@ -588,11 +590,22 @@ public class TorService extends Service implements TorServiceConstants, Runnable
if (code == 0)
{
showAlert("Status", "Transparent proxying ENABLED");
+
+
+
+ if (transProxyTethering)
+ {
+ showAlert("Status", "TransProxy enabled for Tethering!");
+
+ TorTransProxy.enableTetheringRules(this);
+ }
}
else
{
showAlert("Status", "WARNING: error starting transparent proxying!");
}
+
+
return true;
diff --git a/src/org/torproject/android/service/TorTransProxy.java b/src/org/torproject/android/service/TorTransProxy.java
index 548dda6..de8ea83 100644
--- a/src/org/torproject/android/service/TorTransProxy.java
+++ b/src/org/torproject/android/service/TorTransProxy.java
@@ -313,14 +313,12 @@ public class TorTransProxy implements TorServiceConstants {
return code;
}
- public static int enableWifiHotspotRules (Context context) throws Exception
+ public static int enableTetheringRules (Context context) throws Exception
{
boolean runRoot = true;
boolean waitFor = true;
- //redirectDNSResolvConf(); //not working yet
-
String ipTablesPath = new File(context.getDir("bin", 0),"iptables").getAbsolutePath();
StringBuilder script = new StringBuilder();
@@ -328,25 +326,24 @@ public class TorTransProxy implements TorServiceConstants {
StringBuilder res = new StringBuilder();
int code = -1;
- script.append(ipTablesPath);
- script.append(" -I FORWARD");
- script.append(" -m state --state ESTABLISHED,RELATED -j ACCEPT");
- script.append(" || exit\n");
-
- script.append(ipTablesPath);
- script.append(" -I FORWARD");
- script.append(" -j ACCEPT");
- script.append(" || exit\n");
-
- /*
- script.append(ipTablesPath);
- script.append(" -P FORWARD DROP");
- script.append(" || exit\n");
- */
-
- script.append(ipTablesPath);
- script.append(" -t nat -I POSTROUTING -j MASQUERADE");
- script.append(" || exit\n");
+ String[] hwinterfaces = {"usb0","wl0.1"};
+
+ for (int i = 0; i < hwinterfaces.length; i++)
+ {
+ script.append(ipTablesPath);
+ script.append(" -t nat -A PREROUTING -i ");
+ script.append(hwinterfaces[i]);
+ script.append(" -p udp --dport 53 -j REDIRECT --to-ports ");
+ script.append(TOR_DNS_PORT);
+ script.append(" || exit\n");
+
+ script.append(ipTablesPath);
+ script.append(" -t nat -A PREROUTING -i ");
+ script.append(hwinterfaces[i]);
+ script.append(" -p tcp -j REDIRECT --to-ports ");
+ script.append(TOR_TRANSPROXY_PORT);
+ script.append(" || exit\n");
+ }
String[] cmdAdd = {script.toString()};
@@ -374,8 +371,6 @@ public class TorTransProxy implements TorServiceConstants {
purgeIptables(context);
- enableWifiHotspotRules(context);
-
int torUid = context.getApplicationInfo().uid;
// Set up port redirection
[View Less]
1
0
commit 422ba4bbcd66cceb51ed454f30be5882554fa570
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Thu Jun 2 16:21:38 2011 -0400
new UI strings for tethering support
---
res/values/strings.xml | 4 ++++
res/xml/preferences.xml | 7 +++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bca3df9..1a5daf3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -131,4 +131,8 @@
<string …
[View More]name="pref_start_boot_title">Start Orbot on Boot</string>
<string name="pref_start_boot_summary">Automatically start Orbot and connect Tor when your Android device boots</string>
+ <string name="pref_transparent_tethering_title">Tor Tethering</string>
+ <string name="pref_transparent_tethering_summary">Enable Tor Transparent Proxying for Wifi and USB Tethered Devices</string>
+
+
</resources>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 067cd74..e1aaad4 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -39,6 +39,13 @@ android:title="Select Apps"
android:summary="Choose Apps to Route Through Tor"
android:enabled="true"/>
+<CheckBoxPreference
+android:defaultValue="false"
+android:key="pref_transparent_tethering"
+android:summary="@string/pref_transparent_tethering_summary"
+android:enabled="true"
+android:title="@string/pref_transparent_tethering_title"/>
+
</PreferenceCategory>
[View Less]
1
0
commit 3181d00c1d8a5b5e78dbe26da548bdb177481b04
Author: Sathyanarayanan Gunasekaran <gsathya.ceg(a)gmail.com>
Date: Fri Jun 3 23:07:30 2011 +0530
First two screens - rewrite
---
AndroidManifest.xml | 2 +-
res/layout/scrollingtext_buttons_view.xml | 8 +-
src/org/torproject/android/AboutActivity.java | 204 -------------------------
src/org/torproject/android/LotsaText.java | 122 +++++++++++++++
src/org/torproject/android/Orbot.java …
[View More] | 2 +-
5 files changed, 128 insertions(+), 210 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f11a63e..59c2cca 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -29,7 +29,7 @@
</intent-filter>
</activity>
- <activity android:name=".AboutActivity"/>
+ <activity android:name=".LotsaText"/>
<activity android:name=".SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".AppManager" android:label="@string/app_name"/>
<activity android:name=".WizardActivity" android:label="@string/app_name"/>
diff --git a/res/layout/scrollingtext_buttons_view.xml b/res/layout/scrollingtext_buttons_view.xml
index 623f59c..75b7925 100644
--- a/res/layout/scrollingtext_buttons_view.xml
+++ b/res/layout/scrollingtext_buttons_view.xml
@@ -13,14 +13,14 @@
android:layout_gravity="center_horizontal">
<ImageView
android:src="@drawable/tor"
- android:id="@+id/gibber_image"
+ android:id="@+id/orbot_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingLeft="20px" android:paddingRight="20px" >
</ImageView>
<TextView android:textSize="10pt"
- android:layout_toRightOf="@id/gibber_image"
+ android:layout_toRightOf="@id/orbot_image"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:layout_height="wrap_content"
@@ -54,8 +54,8 @@
</TableRow>
<TableRow android:id="@+id/TableRow01" android:textColor="#00ff00" android:layout_width="fill_parent" android:layout_height="30px">
- <Button android:text="button1" android:id="@+id/btnWizard1" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
- <Button android:text="button2" android:id="@+id/btnWizard2" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
+ <Button android:text="Back" android:id="@+id/btnWizard1" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
+ <Button android:text="Next" android:id="@+id/btnWizard2" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
</LinearLayout>
diff --git a/src/org/torproject/android/AboutActivity.java b/src/org/torproject/android/AboutActivity.java
deleted file mode 100644
index a03314b..0000000
--- a/src/org/torproject/android/AboutActivity.java
+++ /dev/null
@@ -1,204 +0,0 @@
-package org.torproject.android;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.DialogInterface.OnClickListener;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-public class AboutActivity extends Activity implements OnClickListener
-{
- //WizardHelper wizard = null;
-
- private int title[] = {
- R.string.wizard_title,
- R.string.wizard_warning_title,
- R.string.wizard_permissions_title
- };
-
- private int msg[] = {
- R.string.wizard_title_msg,
- R.string.wizard_warning_msg,
- };
-
- private String buttons[][] =
- {
- {null,"Next"},
- {"Back","Next"},
- {"Back","Next"},
- {"Back","Next"},
-
- };
-
- private View.OnClickListener listener[][] =
- {
- {
- null,
- new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
-
- nextContent();
-
- }
- }
- },
-
- {
- new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
- prevContent();
-
- }
- },
- new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
-
- nextContent();
-
- }
- }
- },
-
- {
- new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
- prevContent();
-
- }
- },
- new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
-
-
- //Intent intent = new Intent(getBaseContext(), AccountWizardActivity.class);
-
-
- //startActivity(intent);
-
- }
- }
- },
-
-
-
- };
-
-
- private int contentIdx = -1;
-
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- }
-
- @Override
- protected void onStart() {
-
- super.onStart();
-
- if (contentIdx == -1)
- {
- setContentView(R.layout.scrollingtext_buttons_view);
-
- nextContent ();
- }
- }
-
- private void prevContent ()
- {
- contentIdx--;
- showContent(contentIdx);
- }
-
- private void nextContent ()
- {
- contentIdx++;
- showContent(contentIdx);
- }
-
- private void showContent (int contentIdx)
- {
- TextView txtTitle = ((TextView)findViewById(R.id.WizardTextTitle));
- txtTitle.setText(getString(title[contentIdx]));
-
- TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody));
- txtBody.setText(getString(msg[contentIdx]));
-
- Button btn1 = ((Button)findViewById(R.id.btnWizard1));
-
- ImageView img = (ImageView) findViewById(R.id.gibber_image);
-
- if (buttons[contentIdx][0] != null)
- {
- btn1.setText(buttons[contentIdx][0]);
- btn1.setOnClickListener(listener[contentIdx][0]);
- btn1.setVisibility(Button.VISIBLE);
-
- }
- else
- {
- btn1.setVisibility(Button.INVISIBLE);
- }
-
- Button btn2 = ((Button)findViewById(R.id.btnWizard2));
- if (buttons[contentIdx][1] != null)
- {
- btn2.setText(buttons[contentIdx][1]);
- btn2.setOnClickListener(listener[contentIdx][1]);
- btn2.setVisibility(Button.VISIBLE);
-
- }
- else
- {
- btn2.setVisibility(Button.INVISIBLE);
- }
-
- if(contentIdx !=0)
- {
- img.setVisibility(ImageView.GONE);
- }
- else
- {
- img.setVisibility(ImageView.VISIBLE);
- }
-
- }
-
-
-
- @Override
- protected void onResume() {
- super.onResume();
-
-
- }
-
-
-
-
- @Override
- public void onClick(DialogInterface arg0, int arg1) {
-
-
- }
-
-
-
-}
diff --git a/src/org/torproject/android/LotsaText.java b/src/org/torproject/android/LotsaText.java
new file mode 100644
index 0000000..d044c57
--- /dev/null
+++ b/src/org/torproject/android/LotsaText.java
@@ -0,0 +1,122 @@
+package org.torproject.android;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class LotsaText extends Activity implements TorConstants{
+
+ private Context context;
+ private int step = -1;
+
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ context = this;
+
+ }
+
+ @Override
+ protected void onStart() {
+
+ super.onStart();
+
+
+ if (step == -1)
+ {
+ setContentView(R.layout.scrollingtext_buttons_view);
+ stepOne();
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+
+ }
+
+
+ /*public void startWizard(){
+
+ switch(step){
+
+ case -1 : stepOne();break;
+
+ }
+ }
+ */
+ private void stepOne() {
+
+ step++;
+
+ //setContentView(R.layout.scrollingtext_buttons_view);
+ String title = context.getString(R.string.wizard_title);
+ String msg = context.getString(R.string.wizard_title_msg);
+
+ TextView txtTitle = ((TextView)findViewById(R.id.WizardTextTitle));
+ txtTitle.setText(title);
+
+ TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody));
+ txtBody.setText(msg);
+
+ Button btn1 = ((Button)findViewById(R.id.btnWizard1));
+ Button btn2 = ((Button)findViewById(R.id.btnWizard2));
+ ImageView img = (ImageView) findViewById(R.id.orbot_image);
+
+ btn1.setVisibility(Button.INVISIBLE);
+ img.setVisibility(ImageView.VISIBLE);
+
+ btn2.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ stepTwo();
+ }
+ });
+
+ }
+
+ private void stepTwo() {
+ step++;
+
+ setContentView(R.layout.scrollingtext_buttons_view);
+ String title = context.getString(R.string.wizard_warning_title);
+ String msg = context.getString(R.string.wizard_warning_msg);
+
+ TextView txtTitle = ((TextView)findViewById(R.id.WizardTextTitle));
+ txtTitle.setText(title);
+
+ TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody));
+ txtBody.setText(msg);
+
+ Button btn1 = ((Button)findViewById(R.id.btnWizard1));
+ Button btn2 = ((Button)findViewById(R.id.btnWizard2));
+ ImageView img = (ImageView) findViewById(R.id.orbot_image);
+
+ btn1.setVisibility(Button.VISIBLE);
+ img.setVisibility(ImageView.INVISIBLE);
+
+ btn1.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+ stepOne();
+ }
+ });
+
+ btn2.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ //stepThree();
+ }
+ });
+
+ }
+}
\ No newline at end of file
diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index eb26960..383929d 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -456,7 +456,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
private void showHelp ()
{
- startActivityForResult(new Intent(getBaseContext(), AboutActivity.class), 1);
+ startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
}
[View Less]
1
0

28 Oct '11
commit f6b1dc2805ce23d4f7fddcf2714b13f718d20038
Author: Sebastian Hahn <sebastian(a)torproject.org>
Date: Fri Oct 28 11:19:16 2011 +0200
Fix typo, spotted by tmpname0901. Thanks!
---
changes/bug4331 | 4 ++++
src/or/hibernate.c | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/changes/bug4331 b/changes/bug4331
new file mode 100644
index 0000000..011238a
--- /dev/null
+++ b/changes/bug4331
@@ -0,0 +1,4 @@
+ o Trivial fixes:
+ - Fixed a typo in a …
[View More]hibernation-related log message. Fixes bug 4331;
+ bugfix on 0.2.2.23-alpha; found by "tmpname0901".
+
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index aebce4c..2f7170f 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -943,7 +943,7 @@ consider_hibernation(time_t now)
if (hibernate_soft_limit_reached()) {
log_notice(LD_ACCT,
"Bandwidth soft limit reached; commencing hibernation. "
- "No new conncetions will be accepted");
+ "No new connections will be accepted");
hibernate_begin(HIBERNATE_STATE_LOWBANDWIDTH, now);
} else if (accounting_enabled && now < interval_wakeup_time) {
format_local_iso_time(buf,interval_wakeup_time);
[View Less]
1
0