OSDN Git Service

Add keyboard layout setting
authorWallace.Wang <Wallace1.Wang@gmail.com>
Thu, 12 Nov 2009 06:00:13 +0000 (14:00 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 26 Nov 2010 05:52:10 +0000 (13:52 +0800)
Change-Id: I8c1b7689c96c07676abf0653388940273e4aa935

AndroidManifest.xml
res/layout/keyboard_picker.xml [new file with mode: 0644]
res/layout/keyboard_picker_item.xml [new file with mode: 0644]
res/values/strings.xml
res/xml/language_settings.xml
src/com/android/settings/KeyboardPicker.java [new file with mode: 0644]

index 78c0f5b..7d29849 100644 (file)
             </intent-filter>
         </activity>
 
+        <activity android:name="KeyboardPicker" android:label="@string/keyboard_layout_title">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <action android:name="android.settings.LOCALE_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.VOICE_LAUNCH" />
+            </intent-filter>
+        </activity>
+
         <activity android:name="LanguageSettings"
                 android:label="@string/language_keyboard_settings_title"
                 android:clearTaskOnLaunch="true"
diff --git a/res/layout/keyboard_picker.xml b/res/layout/keyboard_picker.xml
new file mode 100644 (file)
index 0000000..e19d1df
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+       <!--
+               Copyright (C) 2009 The Android-x86 Open Source Project Licensed under the
+               Apache License, Version 2.0 (the "License"); you may not use this file
+               except in compliance with the License. You may obtain a copy of the
+               License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+               by applicable law or agreed to in writing, software distributed under
+               the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+               CONDITIONS OF ANY KIND, either express or implied. See the License for
+               the specific language governing permissions and limitations under the
+               License.
+       -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+       android:orientation="vertical" android:layout_width="fill_parent"
+       android:layout_height="fill_parent">
+
+       <ListView android:id="@android:id/list" android:layout_width="fill_parent"
+               android:layout_height="fill_parent" android:drawSelectorOnTop="false" />
+
+</LinearLayout>
diff --git a/res/layout/keyboard_picker_item.xml b/res/layout/keyboard_picker_item.xml
new file mode 100644 (file)
index 0000000..11e28b4
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+       <!--
+               Copyright (C) 2009 The Android-x86 Open Source Project Licensed under the
+               Apache License, Version 2.0 (the "License"); you may not use this file
+               except in compliance with the License. You may obtain a copy of the
+               License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+               by applicable law or agreed to in writing, software distributed under
+               the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+               CONDITIONS OF ANY KIND, either express or implied. See the License for
+               the specific language governing permissions and limitations under the
+               License.
+       -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+       android:orientation="horizontal" android:layout_height="wrap_content"
+       android:layout_width="fill_parent" android:gravity="center_vertical"
+       android:minHeight="?android:attr/listPreferredItemHeight"
+       android:padding="5dip">
+       <!--
+               <ImageView android:id="@+id/icon" android:layout_width="wrap_content"
+               android:layout_height="wrap_content" android:focusable="false"
+               android:clickable="false"
+               android:src="@drawable/place_holder_for_locale" />
+       -->
+       <TextView android:id="@+id/keyboard" android:layout_width="wrap_content"
+               android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" />
+</LinearLayout>
index 054ed6c..e1deff1 100644 (file)
@@ -2531,4 +2531,6 @@ found in the list of installed applications.</string>
 
     <string name="softkeyboard_enable">SoftKeyBoard Enable</string>
     <string name="softkeyboard_enable_summary">Enable SoftKeyBoard</string>
+    <string name="keyboard_layout_title">Keyboard layout setting</string>
+    <string name="keyboard_layout_summary">Choose a keyboard layout</string>
 </resources>
index d3c0e02..37256db 100644 (file)
                 android:targetClass="com.android.settings.LocalePicker"/>
     </PreferenceScreen>
 
+    <PreferenceScreen android:title="@string/keyboard_layout_title"
+               android:summary="@string/keyboard_layout_summary">
+               <intent android:action="android.intent.action.MAIN"
+                       android:targetPackage="com.android.settings" android:targetClass="com.android.settings.KeyboardPicker" />
+    </PreferenceScreen>
+
     <PreferenceCategory android:key="text_category"
             android:title="@string/text_category" />
 
diff --git a/src/com/android/settings/KeyboardPicker.java b/src/com/android/settings/KeyboardPicker.java
new file mode 100644 (file)
index 0000000..751a572
--- /dev/null
@@ -0,0 +1,68 @@
+package com.android.settings;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import android.app.ListActivity;
+import android.os.Bundle;
+import android.os.SystemProperties;
+import android.util.Log;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.Toast;
+
+public class KeyboardPicker extends ListActivity{
+       int getContentView() {
+        return R.layout.keyboard_picker;
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        setContentView(getContentView());
+        int layoutId = R.layout.keyboard_picker_item;
+        int fieldId = R.id.keyboard;
+        List<String> mKeyboardLayout = new ArrayList<String>();
+        mKeyboardLayout.add("American(Standard keyboard)");
+        mKeyboardLayout.add("Finnish");
+        mKeyboardLayout.add("French");
+        mKeyboardLayout.add("German");
+        mKeyboardLayout.add("Ireland");
+        mKeyboardLayout.add("Russia");
+        mKeyboardLayout.add("Spanish(Latin America)");
+
+
+        ArrayAdapter<String> adapter =
+            new ArrayAdapter<String>(this, layoutId, fieldId, mKeyboardLayout);
+        getListView().setAdapter(adapter);
+    }
+    @Override
+    protected void onListItemClick(ListView l, View v, int position, long id) {
+        switch(position){
+               case 1:
+                       SystemProperties.set("persist.sys.keylayout","fn");
+                       break;
+               case 2:
+                       SystemProperties.set("persist.sys.keylayout","fr");
+                       break;
+               case 3:
+                       SystemProperties.set("persist.sys.keylayout","de");
+                       break;
+               case 4:
+                       SystemProperties.set("persist.sys.keylayout","Ireland");
+                       break;
+               case 5:
+                       SystemProperties.set("persist.sys.keylayout","ru");
+                       break;
+               case 6:
+                       SystemProperties.set("persist.sys.keylayout","spanish_latin");
+                       break;
+               default:
+                       SystemProperties.set("persist.sys.keylayout","qwerty");
+                       break;
+         }
+
+        Toast.makeText(this, "Please reboot your machine to enable the new keyboard layout.", Toast.LENGTH_LONG).show();
+    }
+}