Implement multiple locales and sublocales in Settings
Does drag-and-drop reordering, supports adding / removing locales,
suggestions, search, removes locales already selected in the
user preferences.
Bug: 25800339
Change-Id: Iffe7b9810c77ec93a84d848ab20b2ba405249676
diff --git a/res/drawable/drag_handle.xml b/res/drawable/drag_handle.xml
new file mode 100644
index 0000000..c01ee1c
--- /dev/null
+++ b/res/drawable/drag_handle.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="50dp"
+ android:width="50dp"
+ android:viewportHeight="100"
+ android:viewportWidth="100"
+ android:tint="#757575" >
+
+ <path android:fillColor="@android:color/white"
+ android:pathData="M29,48 l 0,-4 42,0 0,4 z" />
+ <path android:fillColor="@android:color/white"
+ android:pathData="M29,56 l 0,-4 42,0 0,4 z" />
+
+</vector>
diff --git a/res/layout/locale_drag_cell.xml b/res/layout/locale_drag_cell.xml
new file mode 100644
index 0000000..978e0ad
--- /dev/null
+++ b/res/layout/locale_drag_cell.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android 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.
+-->
+
+<com.android.settings.localepicker.LocaleDragCell
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"
+ android:baselineAligned="false"
+ android:layoutDirection="locale"
+ android:textDirection="locale">
+
+ <TextView
+ android:id="@+id/miniLabel"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="12dp"
+ android:layout_marginRight="12dp"
+ tools:text="22"
+ android:textColor="?android:attr/colorAccent"
+ android:minWidth="20sp"
+ android:textAlignment="textEnd"
+ android:gravity="center_vertical|end"
+ android:background="?android:colorBackground"/>
+
+ <CheckBox
+ android:id="@+id/checkbox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minWidth="20sp"
+ android:layout_marginLeft="6dp"
+ android:layout_marginRight="6dp"
+ android:visibility="gone"
+ android:background="?android:colorBackground"/>
+
+ <TextView
+ android:id="@+id/label"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:padding="12dp"
+ tools:text="France"
+ android:textAppearance="?android:attr/textAppearanceListItem"
+ android:background="?android:colorBackground"/>
+
+ <ImageView
+ android:id="@+id/l10nWarn"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:src="@android:drawable/stat_sys_warning"
+ android:focusableInTouchMode="false"
+ android:focusable="false"
+ android:paddingStart="12dp"
+ android:paddingEnd="12dp"
+ android:tint="?android:attr/colorAccent"/>
+
+ <ImageView
+ android:id="@+id/dragHandle"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_vertical"
+ android:src="@drawable/drag_handle"/>
+
+</com.android.settings.localepicker.LocaleDragCell>
diff --git a/res/layout/locale_order_list.xml b/res/layout/locale_order_list.xml
new file mode 100644
index 0000000..97ba9a3
--- /dev/null
+++ b/res/layout/locale_order_list.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android 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:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layoutDirection="locale"
+ android:orientation="vertical"
+ android:textDirection="locale">
+
+ <com.android.settings.localepicker.LocaleRecyclerView
+ android:id="@+id/dragList"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
+
+ <TextView
+ android:id="@+id/add_language"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clickable="true"
+ android:contextClickable="true"
+ android:drawableStart="@drawable/ic_add_24dp"
+ android:drawablePadding="12dp"
+ android:gravity="center_vertical"
+ android:measureWithLargestChild="false"
+ android:padding="16dp"
+ android:text="@string/add_a_language"
+ android:textAppearance="?android:attr/textAppearanceListItem"/>
+
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index db68d71..7a5d768 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -513,8 +513,27 @@
<string name="next_label">Next</string>
<!-- LocalePicker -->
- <!-- Title for the locale picker activity -->
- <string name="language_picker_title">Language</string>
+
+ <!-- Title for the language selection screen [CHAR LIMIT=25] -->
+ <string name="pref_title_lang_selection">Language preference</string>
+
+ <!-- Menu item in the locale menu. Will remove the selected locales. [CHAR LIMIT=30] -->
+ <string name="locale_remove_menu">Remove</string>
+
+ <!-- "Button" that opens a language picker. The selected language gets added to the language list. [CHAR LIMIT=30] -->
+ <string name="add_a_language">Add a language</string>
+
+ <!-- The title of the confirmation dialog shown when the user selected several languages and tries to remove them [CHAR LIMIT=60] -->
+ <string name="dlg_remove_locales_title">Remove from your language preference?</string>
+ <!-- TODO: come up with a good string -->
+ <!-- The text of the confirmation dialog shown when the user selected several languages and tries to remove them [CHAR LIMIT=NONE] -->
+ <string name="dlg_remove_locales_message" translatable="false">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla egestas porta aliquet. Ut laoreet orci tellus, id cursus enim volutpat in.</string>
+
+ <!-- The title of the error dialog shown when the user selected all the languages and tries to remove them [CHAR LIMIT=60] -->
+ <string name="dlg_remove_locales_error_title">Language removal error</string>
+ <!-- The text of the error dialog shown when the user selected all the languages and tries to remove them [CHAR LIMIT=NONE] -->
+ <string name="dlg_remove_locales_error_message">Can’t remove all the languages, you should leave at least one.</string>
+
<!-- The title of the dialog to pick an activity. This is shown when there are multiple activities that can do a particular action. For example, suppose you click on the "Share" menu item in the Browser. Since you can share the webpage URL via many communication methods, this dialog would come up with choices like "Email", "IM", etc. This is a generic message, and the previous example is a single possible scenario (so please don't assume it's for the browser or anything :) ). -->
<string name="activity_picker_label">Choose activity</string>
diff --git a/res/xml/language_settings.xml b/res/xml/language_settings.xml
index fa96a56..83a0985 100644
--- a/res/xml/language_settings.xml
+++ b/res/xml/language_settings.xml
@@ -4,9 +4,9 @@
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.
@@ -22,7 +22,7 @@
<PreferenceScreen
android:key="phone_language"
android:title="@string/phone_language"
- android:fragment="com.android.settings.LocalePicker"
+ android:fragment="com.android.settings.localepicker.LocaleListEditor"
/>
<!-- Spell checker preference title, summary and fragment will be set programmatically. -->