[tor-commits] [orbot/master] added new language chooser for wizard

n8fr8 at torproject.org n8fr8 at torproject.org
Mon Feb 27 04:24:19 UTC 2012


commit 6a32a53d12d40038e57391463d89bc55bb35cb57
Author: Nathan Freitas <nathan at freitas.net>
Date:   Sun Feb 26 22:45:55 2012 -0500

    added new language chooser for wizard
---
 res/layout/layout_wizard_locale.xml                |   58 +++++++
 .../android/wizard/ChooseLocaleWizardActivity.java |  159 ++++++++++++++++++++
 2 files changed, 217 insertions(+), 0 deletions(-)

diff --git a/res/layout/layout_wizard_locale.xml b/res/layout/layout_wizard_locale.xml
new file mode 100644
index 0000000..897aca9
--- /dev/null
+++ b/res/layout/layout_wizard_locale.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical" >
+            
+<RelativeLayout 
+	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="@string/wizard_locale_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">
+  
+
+<LinearLayout
+			android:background="#575757"
+		    android:orientation="vertical"
+		    android:layout_width="fill_parent"
+		    android:layout_height="fill_parent"
+		    android:layout_weight="1" 
+		    android:padding="3px">
+<TextView android:text="@string/wizard_locale_msg" android:layout_width="wrap_content" android:textColor="#ffffff" android:layout_height="wrap_content"  android:textSize="8pt" android:id="@+id/WizardTextBody1" android:padding="20dip"></TextView>
+<ListView 
+    android:id="@+id/wizard_locale_list"
+    android:layout_width="fill_parent"
+	android:layout_height="wrap_content"
+	android:layout_weight="1"
+	android:entries="@array/languages"
+    >    
+</ListView>
+
+
+			</LinearLayout>
+		
+</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="@string/btn_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/wizard/ChooseLocaleWizardActivity.java b/src/org/torproject/android/wizard/ChooseLocaleWizardActivity.java
new file mode 100644
index 0000000..c958221
--- /dev/null
+++ b/src/org/torproject/android/wizard/ChooseLocaleWizardActivity.java
@@ -0,0 +1,159 @@
+package org.torproject.android.wizard;
+
+import java.util.Locale;
+
+import org.torproject.android.Orbot;
+import org.torproject.android.R;
+import org.torproject.android.TorConstants;
+import org.torproject.android.R.drawable;
+import org.torproject.android.R.id;
+import org.torproject.android.R.layout;
+import org.torproject.android.R.string;
+import org.torproject.android.settings.AppManager;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.content.res.Configuration;
+import android.net.Uri;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.ListView;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.Toast;
+
+public class ChooseLocaleWizardActivity extends Activity implements TorConstants {
+
+	private Context context;
+	private int flag = 0;
+	private ListView listLocales;
+	
+	protected void onCreate(Bundle savedInstanceState)
+	{
+        super.onCreate(savedInstanceState);
+        context = this;
+       
+	}
+	
+	@Override
+	protected void onStart() {
+		
+		super.onStart();
+		setContentView(R.layout.layout_wizard_locale);
+		
+		stepSix();
+        
+	}
+	
+	@Override
+	protected void onResume() {
+		super.onResume();
+	
+		 setupUI();
+	
+		
+		
+	}
+
+	
+	private void setupUI ()
+	{
+//		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+		
+	}
+	
+	
+	private void stepSix(){
+		
+			listLocales = (ListView)findViewById(R.id.wizard_locale_list);
+		    Button next = ((Button)findViewById(R.id.btnWizard2));
+		   // next.setEnabled(false);
+		    
+		    listLocales.setSelection(0);
+		    
+		    listLocales.setOnItemClickListener(new OnItemClickListener() {
+				
+
+				@Override
+				public void onItemClick(AdapterView<?> arg0, View arg1,
+						int arg2, long arg3) {
+					
+					setLocalePref(arg2);
+					startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
+					
+				}
+			});
+		        
+		    next.setOnClickListener(new View.OnClickListener() {
+				
+				public void onClick(View v) {
+					
+					
+					startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
+
+				}
+			});
+		    
+
+	       
+	}
+	
+	private void setLocalePref(int selId)
+	{
+
+		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
+
+        Configuration config = getResources().getConfiguration();
+
+        String[] localeVals = getResources().getStringArray(R.array.languages_values);
+        
+        String lang = localeVals[selId];
+
+    	Editor pEdit = prefs.edit();
+		pEdit.putString(PREF_DEFAULT_LOCALE, lang);
+		pEdit.commit();
+		Locale locale = null;
+		
+        if (lang.equals("xx"))
+        {
+        	locale = Locale.getDefault();
+        
+        }
+        else
+        	locale = new Locale(lang);
+        
+        Locale.setDefault(locale);
+        config.locale = locale;
+        getResources().updateConfiguration(config, getResources().getDisplayMetrics());
+        
+        
+    
+		
+	}
+
+	@Override
+	protected void onRestoreInstanceState(Bundle savedInstanceState) {
+		super.onRestoreInstanceState(savedInstanceState);
+	}
+
+	@Override
+	protected void onSaveInstanceState(Bundle outState) {
+		super.onSaveInstanceState(outState);
+		
+	}
+}
\ No newline at end of file





More information about the tor-commits mailing list