• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Settings


Commit MetaInfo

Révisione988a213419c1f4d3f4def78ba598043e2a03b68 (tree)
l'heure2011-08-05 15:37:50
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

KeyboardPicker: refine the keyboard layout list to be more extendable

Other improvements:
* use ISO 639-1 language code for layout names.
* add Japanese, Swedish and United Kingdom to the list.
* add license notice.

Change Summary

Modification

--- a/src/com/android/settings/KeyboardPicker.java
+++ b/src/com/android/settings/KeyboardPicker.java
@@ -1,19 +1,38 @@
1+/*
2+ * Copyright (C) 2009 The Android-x86 Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117 package com.android.settings;
218
319 import java.util.ArrayList;
420 import java.util.List;
21+import java.util.TreeMap;
522
623 import android.app.ListActivity;
724 import android.os.Bundle;
825 import android.os.SystemProperties;
9-import android.util.Log;
1026 import android.view.View;
1127 import android.widget.ArrayAdapter;
1228 import android.widget.ListView;
1329 import android.widget.Toast;
1430
15-public class KeyboardPicker extends ListActivity{
16- int getContentView() {
31+public class KeyboardPicker extends ListActivity {
32+ private List<String> mKeyboardList;
33+ private TreeMap<String,String> mKeyboardLayouts;
34+
35+ int getContentView() {
1736 return R.layout.keyboard_picker;
1837 }
1938
@@ -23,46 +42,28 @@ public class KeyboardPicker extends ListActivity{
2342 setContentView(getContentView());
2443 int layoutId = R.layout.keyboard_picker_item;
2544 int fieldId = R.id.keyboard;
26- List<String> mKeyboardLayout = new ArrayList<String>();
27- mKeyboardLayout.add("American(Standard keyboard)");
28- mKeyboardLayout.add("Finnish");
29- mKeyboardLayout.add("French");
30- mKeyboardLayout.add("German");
31- mKeyboardLayout.add("Ireland");
32- mKeyboardLayout.add("Russia");
33- mKeyboardLayout.add("Spanish(Latin America)");
34-
45+ mKeyboardLayouts = new TreeMap<String,String>();
46+ mKeyboardLayouts.put("American(Standard keyboard)", "qwerty");
47+ mKeyboardLayouts.put("Finnish", "fn");
48+ mKeyboardLayouts.put("French", "fr");
49+ mKeyboardLayouts.put("German", "de");
50+ mKeyboardLayouts.put("Ireland", "uk");
51+ mKeyboardLayouts.put("Japanese", "jp");
52+ mKeyboardLayouts.put("Russian", "ru");
53+ mKeyboardLayouts.put("Spanish(Latin America)", "es_latin");
54+ mKeyboardLayouts.put("Swedish", "fn");
55+ mKeyboardLayouts.put("United Kingdom", "uk");
3556
57+ mKeyboardList = new ArrayList<String>(mKeyboardLayouts.keySet());
3658 ArrayAdapter<String> adapter =
37- new ArrayAdapter<String>(this, layoutId, fieldId, mKeyboardLayout);
59+ new ArrayAdapter<String>(this, layoutId, fieldId, mKeyboardList);
3860 getListView().setAdapter(adapter);
3961 }
4062 @Override
4163 protected void onListItemClick(ListView l, View v, int position, long id) {
42- switch(position){
43- case 1:
44- SystemProperties.set("persist.sys.keylayout","fn");
45- break;
46- case 2:
47- SystemProperties.set("persist.sys.keylayout","fr");
48- break;
49- case 3:
50- SystemProperties.set("persist.sys.keylayout","de");
51- break;
52- case 4:
53- SystemProperties.set("persist.sys.keylayout","Ireland");
54- break;
55- case 5:
56- SystemProperties.set("persist.sys.keylayout","ru");
57- break;
58- case 6:
59- SystemProperties.set("persist.sys.keylayout","spanish_latin");
60- break;
61- default:
62- SystemProperties.set("persist.sys.keylayout","qwerty");
63- break;
64- }
65-
66- Toast.makeText(this, "Please reboot your machine to enable the new keyboard layout.", Toast.LENGTH_LONG).show();
64+ String kb = mKeyboardList.get(position);
65+ SystemProperties.set("persist.sys.keylayout", mKeyboardLayouts.get(kb));
66+ Toast.makeText(this, "Set keyboard layout to " + kb +
67+ ".\nPlease reboot your machine to enable the new keyboard layout.", Toast.LENGTH_LONG).show();
6768 }
6869 }