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

[tor-commits] [orbot/master] added locale selection pref capability



commit 332bf93ffd7a1b1ba9de6620eb9566dfd8120922
Author: Nathan Freitas <nathan@xxxxxxxxxxx>
Date:   Sun Feb 26 22:48:30 2012 -0500

    added locale selection pref capability
---
 src/org/torproject/android/Orbot.java              |   57 ++++++-------------
 src/org/torproject/android/OrbotApp.java           |    9 +++-
 src/org/torproject/android/service/TorService.java |    2 +-
 .../android/settings/SettingsPreferences.java      |   13 ++++-
 4 files changed, 38 insertions(+), 43 deletions(-)

diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index d71567f..7a21607 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -10,6 +10,7 @@ import org.torproject.android.service.ITorServiceCallback;
 import org.torproject.android.service.TorServiceConstants;
 import org.torproject.android.settings.ProcessSettingsAsyncTask;
 import org.torproject.android.settings.SettingsPreferences;
+import org.torproject.android.wizard.ChooseLocaleWizardActivity;
 import org.torproject.android.wizard.LotsaText;
 
 import android.app.Activity;
@@ -35,6 +36,7 @@ import android.preference.PreferenceManager;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.Menu;
+import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnLongClickListener;
@@ -82,14 +84,8 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
         	bindService();
            	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
@@ -108,28 +104,10 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
     */
     public boolean onCreateOptionsMenu(Menu menu) {
         super.onCreateOptionsMenu(menu);
-        
-        MenuItem mItem = null;
-        
-        mItemOnOff = menu.add(0, 1, Menu.NONE, getString(R.string.menu_start));
-        mItemOnOff.setIcon(android.R.drawable.ic_menu_share);
-        mItemOnOff.setAlphabeticShortcut('t');
-        
-        mItem = menu.add(0, 4, Menu.NONE, getString(R.string.menu_settings));
-        mItem.setIcon(R.drawable.ic_menu_settings);
-       
-        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_about));
-        mItem.setIcon(R.drawable.ic_menu_about);
-        
-        mItem = menu.add(0, 3, Menu.NONE, getString(R.string.menu_wizard));
-        mItem.setIcon(R.drawable.ic_menu_goto);
-       
-        mItem = menu.add(0, 8, Menu.NONE, getString(R.string.menu_exit));
-        mItem.setIcon(R.drawable.ic_menu_exit);
+        MenuInflater inflater = getMenuInflater();
+        inflater.inflate(R.menu.main, menu);
        
+        mItemOnOff = menu.getItem(0);
         
         return true;
     }
@@ -166,7 +144,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
                 
                 super.onMenuItemSelected(featureId, item);
                 
-                if (item.getItemId() == 1)
+                if (item.getItemId() == R.id.menu_start)
                 {
                         
                         try
@@ -197,26 +175,26 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
                                 Log.w(TAG, "Unable to start/top Tor from menu UI", re);
                         }
                 }
-                else if (item.getItemId() == 4)
+                else if (item.getItemId() == R.id.menu_settings)
                 {
                         showSettings();
                 }
-                else if (item.getItemId() == 3)
+                else if (item.getItemId() == R.id.menu_wizard)
                 {
-                        showHelp();
+                		startWizard();
                 }
-                else if (item.getItemId() == 7)
+                else if (item.getItemId() == R.id.menu_verify)
                 {
                         doTorCheck();
                 }
-                else if (item.getItemId() == 8)
+                else if (item.getItemId() == R.id.menu_exit)
                 {
                         //exit app
                         doExit();
                         
                         
                 }
-                else if (item.getItemId() == 6)
+                else if (item.getItemId() == R.id.menu_about)
                 {
                         showAbout();
                         
@@ -415,13 +393,14 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
 			if (showWizard)
 			{
 			
-				Editor pEdit = prefs.edit();
 				
+				Editor pEdit = prefs.edit();
 				pEdit.putBoolean("show_wizard",false);
-				
 				pEdit.commit();
+	
+				startWizard();
 				
-				startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
+				//startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
 
 			}
 			
@@ -464,7 +443,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
 	/*
 	 * Show the help view - a popup dialog
 	 */
-	private void showHelp ()
+	private void startWizard ()
 	{
 
         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
@@ -472,7 +451,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
 		Editor pEdit = prefs.edit();
 		pEdit.putBoolean("wizardscreen1",true);
 		pEdit.commit();
-		startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
+		startActivityForResult(new Intent(getBaseContext(), ChooseLocaleWizardActivity.class), 1);
 	}
 	
 	
diff --git a/src/org/torproject/android/OrbotApp.java b/src/org/torproject/android/OrbotApp.java
index c5528c9..66a1e9a 100644
--- a/src/org/torproject/android/OrbotApp.java
+++ b/src/org/torproject/android/OrbotApp.java
@@ -26,7 +26,14 @@ public class OrbotApp extends Application implements TorConstants
         
         if (! "".equals(lang) && ! config.locale.getLanguage().equals(lang))
         {
-            locale = new Locale(lang);
+        	if (lang.equals("xx"))
+            {
+            	locale = Locale.getDefault();
+            
+            }
+            else
+            	locale = new Locale(lang);
+        	
             Locale.setDefault(locale);
             config.locale = locale;
             getResources().updateConfiguration(config, getResources().getDisplayMetrics());
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 70f29a1..04e347e 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -1384,7 +1384,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
     	
     	prefPersistNotifications = prefs.getBoolean(TorConstants.PREF_PERSIST_NOTIFICATIONS, true);
     	
-		boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, true); //default true for using bridges
+		boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false); 
 		
 		//boolean autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
 
diff --git a/src/org/torproject/android/settings/SettingsPreferences.java b/src/org/torproject/android/settings/SettingsPreferences.java
index aa93e5a..afac094 100644
--- a/src/org/torproject/android/settings/SettingsPreferences.java
+++ b/src/org/torproject/android/settings/SettingsPreferences.java
@@ -171,8 +171,17 @@ public class SettingsPreferences
 		        Configuration config = getResources().getConfiguration();
 
 		        String lang = settings.getString("pref_default_locale", "");
-		     
-	        	Locale locale = new Locale(lang);
+		        
+		        Locale locale;
+		        
+		        if (lang.equals("xx"))
+		        {
+		        	locale = Locale.getDefault();
+		        
+		        }
+		        else
+		        	locale = new Locale(lang);
+		        
 	            Locale.setDefault(locale);
 	            config.locale = locale;
 	            getResources().updateConfiguration(config, getResources().getDisplayMetrics());



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