[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] r24631: {projects} handling settings update to stop hanging (projects/android/trunk/Orbot/src/org/torproject/android)



Author: n8fr8
Date: 2011-04-15 16:39:22 +0000 (Fri, 15 Apr 2011)
New Revision: 24631

Modified:
   projects/android/trunk/Orbot/src/org/torproject/android/OnBootReceiver.java
   projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
Log:
handling settings update to stop hanging


Modified: projects/android/trunk/Orbot/src/org/torproject/android/OnBootReceiver.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/OnBootReceiver.java	2011-04-15 16:38:53 UTC (rev 24630)
+++ projects/android/trunk/Orbot/src/org/torproject/android/OnBootReceiver.java	2011-04-15 16:39:22 UTC (rev 24631)
@@ -14,5 +14,6 @@
 
 	}
 
+	
 }
 

Modified: projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java	2011-04-15 16:38:53 UTC (rev 24630)
+++ projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java	2011-04-15 16:39:22 UTC (rev 24631)
@@ -16,6 +16,7 @@
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.NotificationManager;
+import android.app.ProgressDialog;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -44,10 +45,10 @@
 {
 	
 	/* Useful UI bits */
-	private TextView txtMessageLog = null; //the full screen log view of Tor control messages
+	//private TextView txtMessageLog = null; //the full screen log view of Tor control messages
 	private TextView lblStatus = null; //the main text display widget
 	private ImageView imgStatus = null; //the main touchable image for activating Orbot
-//	private ProgressDialog progressDialog;
+	private ProgressDialog progressDialog;
 	private MenuItem mItemOnOff = null;
 	
 	/* Some tracking bits */
@@ -59,6 +60,8 @@
 		/* The primary interface we will be calling on the service. */
     ITorService mService = null;
 	private boolean autoStartOnBind = false;
+
+	SharedPreferences prefs;
 	
     Orbot mOrbot = null;
     
@@ -69,9 +72,9 @@
         mOrbot = this;
         
     	setTheme(android.R.style.Theme_Black_NoTitleBar);
-    	//setTitle(getString(R.string.app_name) + ' ' + getString(R.string.app_version));
-        showMain();
-
+    	
+    	prefs = PreferenceManager.getDefaultSharedPreferences(this);
+    	
     }
     
    /*
@@ -93,8 +96,8 @@
         mItem = menu.add(0, 7, Menu.NONE, getString(R.string.menu_verify));
         mItem.setIcon(R.drawable.ic_menu_check);
       
-        mItem =  menu.add(0,6, Menu.NONE, getString(R.string.menu_log));
-        mItem.setIcon(R.drawable.ic_menu_reports);
+       // mItem =  menu.add(0,6, Menu.NONE, getString(R.string.menu_log));
+       // mItem.setIcon(R.drawable.ic_menu_reports);
         
         mItem = menu.add(0, 3, Menu.NONE, getString(R.string.menu_info));
         mItem.setIcon(R.drawable.ic_menu_about);
@@ -146,10 +149,6 @@
 		{
 			showSettings();
 		}
-		else if (item.getItemId() == 6)
-		{
-			showMessageLog();
-		}
 		else if (item.getItemId() == 3)
 		{
 			showHelp();
@@ -193,6 +192,7 @@
 	 * (non-Javadoc)
 	 * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
 	 */
+	/*
 	public boolean onKeyDown(int keyCode, KeyEvent event){
 		
 		if(keyCode==KeyEvent.KEYCODE_BACK){
@@ -209,7 +209,7 @@
 	
 		return super.onKeyDown(keyCode, event);
 		
-	}
+	}*/
  
     /* (non-Javadoc)
 	 * @see android.app.Activity#onPause()
@@ -306,7 +306,8 @@
 	protected void onResume() {
 		super.onResume();
 		
-		
+		 showMain();
+		 
 		if (getIntent() == null)
 			return;
 		
@@ -361,7 +362,8 @@
 		else
 		{
 			
-		
+			//setTitle(getString(R.string.app_name) + ' ' + getString(R.string.app_version));
+	    
 			NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 			mNotificationManager.cancelAll();
 			
@@ -382,6 +384,7 @@
 			    new WizardHelper(this).showWizard();
 
 			}
+			
 		}
 	}
 
@@ -400,9 +403,6 @@
 
 	}
 
-
-
-
 	/* (non-Javadoc)
 	 * @see android.app.Activity#onStop()
 	 */
@@ -419,7 +419,7 @@
 	 */
 	private void showMain ()
     {
-		bindService(); //connect the UI activity to the remote service
+	//	bindService(); //connect the UI activity to the remote service
 		
 		currentView = R.layout.layout_main;
 		setContentView(currentView);
@@ -458,6 +458,7 @@
 	/*
 	 * Show the message log UI
 	 */
+	/*
 	private void showMessageLog ()
 	{
 		currentView = R.layout.layout_log;
@@ -469,7 +470,7 @@
     	txtMessageLog.setText(logBuffer.toString());
     	
 		
-	}
+	}*/
 	
 	
     /*
@@ -495,19 +496,17 @@
 			} catch (RemoteException e) {
 				e.printStackTrace();
 			}
+	
 		}
 	}
 
 	private void processSettings () throws RemoteException
 	{
-		
 		try
 		{
 			if (mService == null)
 				return; //nothing to do if the service isn't connected yet
 			
-			SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-			
 			boolean useBridges = prefs.getBoolean(PREF_BRIDGES_ENABLED, false);
 			
 			//boolean autoUpdateBridges = prefs.getBoolean(PREF_BRIDGES_UPDATED, false);
@@ -518,12 +517,10 @@
 	
 	        boolean enableHiddenServices = prefs.getBoolean("pref_hs_enable", false);
 			
-			
-			boolean enableTransparentProxy = prefs.getBoolean(PREF_TRANSPARENT, false);
-			
-		
+			boolean enableTransparentProxy = prefs.getBoolean(PREF_TRANSPARENT, false);		
 			mService.updateTransProxy();
 			
+	        
 			String bridgeList = prefs.getString(PREF_BRIDGES_LIST,"");
 	
 			if (useBridges)
@@ -648,11 +645,11 @@
 	        }
 	        else
 	        {
-	        	mService.updateConfiguration("HiddenServiceDir","", false);
-	        	
+	        	mService.updateConfiguration("HiddenServiceDir","", false);	       
 	        }
 	        
 	        mService.saveConfiguration();
+	        
 		 }
         catch (Exception e)
         {
@@ -665,6 +662,7 @@
 
 	}
 	
+	
 	private String getHiddenServiceHostname ()
 	{
     	String appHome = "/data/data/" + TorServiceConstants.TOR_APP_USERNAME + "/";
@@ -709,7 +707,13 @@
 		    	{
 		    		imgStatus.setImageResource(R.drawable.toron);
 		    	//	imgStatus.clearAnimation();
+		    		if (progressDialog != null)
+		    		{
+		    			progressDialog.dismiss();
+		    			progressDialog = null;
+		    		}
 		    		
+		    		
 		    		String lblMsg = getString(R.string.status_activated) + "\n" + torServiceMsg;
 		    		
 		    		lblStatus.setText(lblMsg);
@@ -753,10 +757,15 @@
 		    	{
 		    		
 		    		imgStatus.setImageResource(R.drawable.torstarting);
+		    		if (progressDialog == null)
+		    		{
+		    			progressDialog =ProgressDialog.show(this, "", getString(R.string.status_starting_up));
+		    		}
+		    		else
+		    			progressDialog.setMessage(torServiceMsg);
+		    		//lblStatus.setText(torServiceMsg);
 		    		
 		    		
-		    		lblStatus.setText(torServiceMsg);
-		    		
 		    		/*
 	    			int idx = torServiceMsg.indexOf("%");
 	    			
@@ -774,12 +783,23 @@
 		    		imgStatus.setImageResource(R.drawable.torstopping);
 		    	//	imgStatus.clearAnimation();
 		    		
+		    		if (progressDialog != null)
+		    		{
+		    			progressDialog.dismiss();
+		    			progressDialog = null;
+		    		}
+		    		
 		    		lblStatus.setText(getString(R.string.status_shutting_down));
 		    			
 		    	}
 		    	else
 		    	{
 
+		    		if (progressDialog != null)
+		    		{
+		    			progressDialog.dismiss();
+		    			progressDialog = null;
+		    		}
 		    		
 		    	//	imgStatus.clearAnimation();
 		    		
@@ -953,17 +973,9 @@
                 	
                     break;
                 case LOG_MSG:
-
-                	String torLogMsg = (String)msg.getData().getString(HANDLER_TOR_MSG);
+                	//do nothing
                 	
-                	logBuffer.append(torLogMsg);
-                	logBuffer.append('\n');
                 	
-                	if (txtMessageLog != null)
-                	{
-                		txtMessageLog.append(torLogMsg + '\n');
-                	}
-                	
                     break;
                 case ENABLE_TOR_MSG:
                 	

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits