[tor-commits] [orbot/master] Merge branch 'wizard'

n8fr8 at torproject.org n8fr8 at torproject.org
Fri Oct 28 15:28:27 UTC 2011


commit cd6c533a7189a126384377f0d4e8bc2f700f776f
Merge: 9b3419e d7c15dd
Author: Nathan Freitas <nathan at freitas.net>
Date:   Sun Jul 24 17:09:30 2011 -0400

    Merge branch 'wizard'
    
    Conflicts:
    	res/values/strings.xml
    	src/org/torproject/android/Orbot.java

 AUTHORS                                            |    2 +-
 AndroidManifest.xml                                |    2 +-
 res/drawable/icon_firefox.png                      |  Bin 0 -> 9233 bytes
 res/drawable/icon_orweb.png                        |  Bin 8783 -> 0 bytes
 res/drawable/icon_otrchat.png                      |  Bin 4610 -> 0 bytes
 res/drawable/proxymob.png                          |  Bin 0 -> 11265 bytes
 res/drawable/warning.png                           |  Bin 0 -> 2922 bytes
 res/layout/layout_apps_item.xml                    |    3 +-
 res/layout/layout_wizard_permissions.xml           |   55 +++
 res/layout/layout_wizard_root.xml                  |   64 +++-
 res/layout/layout_wizard_tips.xml                  |   56 ++-
 res/layout/scrollingtext_buttons_view.xml          |   68 +++
 res/values/strings.xml                             |   31 ++-
 res/values/theme.xml                               |    9 +
 .../torproject/android/ConfigureTransProxy.java    |  183 ++++++++
 src/org/torproject/android/LotsaText.java          |  133 ++++++
 src/org/torproject/android/Orbot.java              |  438 +++++++++-----------
 src/org/torproject/android/Permissions.java        |  229 ++++++++++
 src/org/torproject/android/TipsAndTricks.java      |  139 +++++++
 src/org/torproject/android/WizardActivity.java     |   71 ----
 src/org/torproject/android/WizardHelper.java       |   10 +-
 .../android/service/TorServiceUtils.java           |   37 ++-
 22 files changed, 1190 insertions(+), 340 deletions(-)

diff --cc res/layout/layout_wizard_permissions.xml
index 0000000,151bb3e..1ba5fec
mode 000000,100644..100644
--- a/res/layout/layout_wizard_permissions.xml
+++ b/res/layout/layout_wizard_permissions.xml
@@@ -1,0 -1,55 +1,55 @@@
+ <?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">
+             
+ <RelativeLayout 
 -	android:layout_width="match_parent" 
++	android:layout_width="fill_parent" 
+ 	android:layout_height="wrap_content" 
+ 	android:id="@+id/relativeLayout1" 
+ 	android:layout_gravity="center_horizontal"
+ 	android:background="#000000">
+         
+         <TextView android:textSize="10pt" 
+         	android:textColor="#FFFFFF"
+         	android:layout_alignParentTop="true"
+        	 	android:layout_height="wrap_content" 
+         	android:id="@+id/WizardTextTitle" 
+         	android:layout_width="wrap_content" 
+         	android:fadingEdge="vertical" 
+         	android:text="TITLE" 
+         	android:singleLine="true" 
+           	android:padding="20px" android:layout_centerInParent="true"> 
+         </TextView>
+     </RelativeLayout>    
+ <TableLayout android:id="@+id/TableLayout01" android:stretchColumns="*" android:layout_height="fill_parent" android:layout_width="wrap_content">
+ 
+ <TableRow android:layout_margin="10dip" 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"
+ 		 >
+ 		<LinearLayout android:background="#575757" 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: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: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:layout_gravity="center" android:text="@string/wizard_permissions_consent" android:layout_height="wrap_content" android:layout_width="wrap_content" android:gravity="center" android:visibility="visible"></CheckBox>
+ 		</LinearLayout>
+ 
+ 		</ScrollView>
+ 		
+ </TableRow>
+ <TableRow android:background="#000000" android:layout_marginTop="10dip" android:paddingTop="10dip" android:id="@+id/TableRow01" android:textColor="#00ff00" android:layout_width="fill_parent" android:layout_height="30px">
+ 	   	<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 --cc res/layout/layout_wizard_root.xml
index f71c284,443106e..530d917
--- a/res/layout/layout_wizard_root.xml
+++ b/res/layout/layout_wizard_root.xml
@@@ -3,8 -3,31 +3,31 @@@
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
-     android:layout_height="wrap_content">
+     android:layout_height="fill_parent">
+             
+ <RelativeLayout 
 -	android:layout_width="match_parent" 
++	android:layout_width="fill_parent" 
+ 	android:layout_height="wrap_content" 
+ 	android:id="@+id/relativeLayout1" 
+ 	android:layout_gravity="center_horizontal"
+ 	android:background="#000000">
+          <TextView android:textSize="10pt" 
+         	android:textColor="#FFFFFF"
+         	android:layout_alignParentTop="true"
+        	 	android:layout_height="wrap_content" 
+         	android:id="@+id/WizardTextTitle" 
+         	android:layout_width="wrap_content" 
+         	android:fadingEdge="vertical" 
+         	android:text="TITLE" 
+         	android:singleLine="true" 
+           	android:padding="20px" android:layout_centerInParent="true"> 
+         </TextView>
+     </RelativeLayout>    
+ <TableLayout android:id="@+id/TableLayout01" android:stretchColumns="*" android:layout_height="fill_parent" android:layout_width="wrap_content">
+ 
+ <TableRow android:layout_margin="10dip" 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" 
diff --cc res/layout/layout_wizard_tips.xml
index 19aaef0,1b7b50b..17ddb88
--- a/res/layout/layout_wizard_tips.xml
+++ b/res/layout/layout_wizard_tips.xml
@@@ -3,8 -3,31 +3,31 @@@
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
-     android:layout_height="wrap_content">
+     android:layout_height="fill_parent">
+             
+ <RelativeLayout 
 -	android:layout_width="match_parent" 
++	android:layout_width="fill_parent" 
+ 	android:layout_height="wrap_content" 
+ 	android:id="@+id/relativeLayout1" 
+ 	android:layout_gravity="center_horizontal"
+ 	android:background="#000000">
+          <TextView android:textSize="10pt" 
+         	android:textColor="#FFFFFF"
+         	android:layout_alignParentTop="true"
+        	 	android:layout_height="wrap_content" 
+         	android:id="@+id/WizardTextTitle" 
+         	android:layout_width="wrap_content" 
+         	android:fadingEdge="vertical" 
+         	android:text="TITLE" 
+         	android:singleLine="true" 
+           	android:padding="20px" android:layout_centerInParent="true"> 
+         </TextView>
+     </RelativeLayout>    
+ <TableLayout  android:id="@+id/TableLayout01" android:stretchColumns="*" android:layout_height="fill_parent" android:layout_width="wrap_content">
+ 
+ <TableRow android:layout_margin="10dip"   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" 
diff --cc res/layout/scrollingtext_buttons_view.xml
index 0000000,ebecfad..df59922
mode 000000,100644..100644
--- a/res/layout/scrollingtext_buttons_view.xml
+++ b/res/layout/scrollingtext_buttons_view.xml
@@@ -1,0 -1,68 +1,68 @@@
+ <?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"
+    >
+             
+ <RelativeLayout 
 -	android:layout_width="match_parent" 
++	android:layout_width="fill_parent" 
+ 	android:layout_height="wrap_content" 
+ 	android:id="@+id/relativeLayout1" 
+ 	android:layout_gravity="center_horizontal"
+ 	android:background="#000000"
+ 	>
+         <ImageView 
+         	android:src="@drawable/warning" 
+         	android:id="@+id/orbot_image" 
+         	android:layout_width="wrap_content" 
+         	android:layout_height="wrap_content" 
+         	android:layout_alignParentLeft="true"
+         	android:paddingLeft="20px" android:layout_marginLeft="10dip" android:layout_marginTop="8dip">
+         </ImageView>
+         <TextView 
+         	android:textColor="#FFFFFF"
+         	android:textSize="10pt" 
+         	android:layout_toRightOf="@id/orbot_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:singleLine="true" 
+         	
+         	
+         	
+         	android:layout_centerInParent="true" 
+         	android:paddingLeft="5px"
+         	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" android:layout_margin="10dip">
+ 
+ 
+ 	<ScrollView android:id="@+id/helpscrollview" 
+ 		android:orientation="vertical"
+ 		android:layout_width="fill_parent" 
+ 		android:layout_height="fill_parent"
+ 		 android:layout_span="3">    
+ 
+ 			<TextView  android:background="#575757" 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:textColor="#ffffff"  android:id="@+id/WizardTextBody" android:textSize="8pt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="20dip"></TextView>
+ 
+ 		</ScrollView>
+ 		
+ </TableRow>
+ <TableRow  android:background="#000000" android:id="@+id/TableRow01" android:textColor="#00ff00" android:layout_width="fill_parent" android:layout_height="30px" android:layout_marginTop="10dip" android:paddingTop="10dip">
+ 	   	<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 --cc res/values/strings.xml
index 1a5daf3,720c03c..6a82430
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@@ -130,9 -124,30 +130,32 @@@
      <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>
-     
-     <string name="pref_transparent_tethering_title">Tor Tethering</string>
+  <!--  New Wizard Strings -->
+ 	<!-- Title Screen -->
 -	<string name="wizard_title">Orbot</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.\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>
+ 	<string name="wizard_permissions_root_msg2">If you choose to continue without providing superuser privileges, make sure to use apps made to work with orbot</string>
+ 	<string name="wizard_permissions_msg">Orbot has detected that you do not have root permissions.\nTransparent Proxying is not possible without superuser privileges.\nMake sure to use apps that have been configured to work with Orbot</string>
 -    <string name="wizard_permissions_consent">I understand and would like to continue without root</string>
+ 	<!-- TipsAndTricks screen -->
+ 	<string name="wizard_tips_title">Orbot configured Apps</string>
+ 	<string name="wizard_tips_gibberbot">Gibberbot - Secure instant messaging client for Android</string>
+ 	<string name="wizard_tips_firefox">Firefox - Android browser - To be used along with ProxyMob Add-on </string>
+ 	<string name="wizard_tips_proxymob">ProxyMob - Simple Firefox Add-on for setting HTTP, SOCKS and SSL proxy settings</string>
+ 	<string name="gibberbot_apk_url">https://market.android.com/details?id=info.guardianproject.otr.app.im</string>
+     <string name="firefox_apk_url">https://market.android.com/details?id=org.mozilla.firefox</string>
+     <string name="proxymob_url">https://addons.mozilla.org/mobile/downloads/latest/251558/type:attachment/addon-251558-latest.xpi?src=addon-detail</string>
+     <!-- Transparent Proxy screen -->
+     <string name="wizard_transproxy_title">Transparent Proxy</string>
+     <string name="wizard_transproxy_msg">Transparent Proxying allows you to redirect client requests without any special configuration or knowledge at the client.</string>
+     <string name="wizard_transproxy_hint">(Check this box if you have no idea what we are talking about)</string>
+     <string name="wizard_transproxy_none">None</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 --cc src/org/torproject/android/Orbot.java
index 690ce10,f5f5f03..7374822
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@@ -147,353 -137,305 +150,317 @@@ public class Orbot extends Activity imp
      
      /* 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();
+ 	 * @see android.app.Activity#onPause()
+ 	 */
+ 	protected void onPause() {
+ 		super.onPause();
+ 		
+ 		hideProgressDialog();
  
-                 if (aDialog != null)
-                         aDialog.dismiss();
-         }
+ 		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);
+ 	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;
+ 					
+ 		        	
+ 		            break;
  
-                         case DialogInterface.BUTTON_NEGATIVE:
-                         
-                                 //do nothing
-                             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();
+ 		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","");
+ 	}
+ 	
+ 	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;
+ 		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;
-                                 }
-                             }
-                         };
+ 			        case DialogInterface.BUTTON_NEGATIVE:
+ 			            //No button clicked
+ 			        	finish();
+ 			            break;
+ 			        }
+ 			    }
+ 			};
  
-                 int hsPort = getIntent().getIntExtra("hs_port", -1);
+         	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();
+ 			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();
+ 				
+ 				startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
  
-                         }
-                         
-                 }
-         }
+ 			}
+ 			
+ 		}
+ 	}
  
-         /* (non-Javadoc)
-          * @see android.app.Activity#onStart()
-          */
-         protected void onStart() {
-                 super.onStart();
-                 
-                 
-                 updateStatus ("");
-                 
-         }
+ 	/* (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();
-         }
+ 	/* (non-Javadoc)
+ 	 * @see android.app.Activity#onStop()
+ 	 */
+ 	protected void onStop() {
+ 		super.onStop();
+ 		
+ 		//unbindService();
+ 	}
  
  
  





More information about the tor-commits mailing list