Fix various UX bugs.
* In the drag & drop list align numbers with the + in the "+ Add a language" button * Keep the "+ Add a language" button under the list * Shadow cell while drag & drop * Updated various strings for dialog titles and messages Bug: 26557242 Bug: 26710677 Bug: 26712004 Bug: 27070104 Change-Id: I10d26eac9581c955328e667d7309b5f0ac649110
This commit is contained in:
@@ -40,12 +40,11 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/miniLabel"
|
||||
style="@style/LanguageCheckboxAndLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
|
||||
tools:text="22"
|
||||
android:textColor="?android:attr/colorAccent"
|
||||
android:minWidth="32sp"
|
||||
android:minWidth="24sp"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:layout_alignTop="@id/checkbox"
|
||||
android:layout_alignBottom="@id/checkbox"/>
|
||||
|
@@ -14,33 +14,38 @@
|
||||
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:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:orientation="vertical"
|
||||
android:layoutDirection="locale"
|
||||
android:textDirection="locale">
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layoutDirection="locale"
|
||||
android:textDirection="locale">
|
||||
|
||||
<com.android.settings.localepicker.LocaleRecyclerView
|
||||
android:id="@+id/dragList"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:scrollbars="vertical"/>
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_language"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:listPreferredItemHeight"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:drawableStart="@drawable/ic_add_24dp"
|
||||
android:drawablePadding="24dp"
|
||||
android:textAlignment="textStart"
|
||||
android:text="@string/add_a_language"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"/>
|
||||
<com.android.settings.localepicker.LocaleRecyclerView
|
||||
android:id="@+id/dragList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
<Button
|
||||
android:id="@+id/add_language"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:listPreferredItemHeight"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:drawableStart="@drawable/ic_add_24dp"
|
||||
android:drawablePadding="24dp"
|
||||
android:textAlignment="textStart"
|
||||
android:text="@string/add_a_language"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
@@ -525,20 +525,22 @@
|
||||
<!-- "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 confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
||||
<plurals name="dlg_remove_locales_title">
|
||||
<item quantity="one">Remove selected language?</item>
|
||||
<item quantity="other">Remove selected languages?</item>
|
||||
</plurals>
|
||||
|
||||
<!-- 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 text of the confirmation dialog shown when the user selects several languages and tries to remove them [CHAR LIMIT=NONE] -->
|
||||
<string name="dlg_remove_locales_message">Text will be displayed in another language</string>
|
||||
|
||||
<!-- TODO: Marked non-translatable for now, as it is not final. Waiting on b/27070104 -->
|
||||
<!-- This text shows in the language picker when the system is not translated into that languages [CHAR LIMIT=130] -->
|
||||
<string name="locale_not_translated" translatable="false">Not all applications are translated into this language; you might experience a mixture.</string>
|
||||
<!-- The title of the error dialog shown when the user selects all the languages and tries to remove them [CHAR LIMIT=60] -->
|
||||
<string name="dlg_remove_locales_error_title">Can’t remove all languages</string>
|
||||
<!-- The text of the error dialog shown when the user selects all the languages and tries to remove them [CHAR LIMIT=NONE] -->
|
||||
<string name="dlg_remove_locales_error_message">Keep at least one preferred language</string>
|
||||
|
||||
<!-- This text shows in the language picker when the system is not translated into that languages [CHAR LIMIT=80] -->
|
||||
<string name="locale_not_translated">May not be available in some apps</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>
|
||||
|
@@ -17,22 +17,24 @@
|
||||
package com.android.settings.localepicker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.support.v4.view.MotionEventCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.util.LocaleList;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import com.android.internal.app.LocalePicker;
|
||||
import com.android.internal.app.LocaleStore;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -79,6 +81,10 @@ class LocaleDragAndDropAdapter
|
||||
this.mFeedItemList = feedItemList;
|
||||
|
||||
this.mContext = context;
|
||||
|
||||
final float dragElevation = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
|
||||
context.getResources().getDisplayMetrics());
|
||||
|
||||
this.mItemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(
|
||||
ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0 /* no swipe */) {
|
||||
|
||||
@@ -93,6 +99,35 @@ class LocaleDragAndDropAdapter
|
||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) {
|
||||
// Swipe is disabled, this is intentionally empty.
|
||||
}
|
||||
|
||||
private static final int SELECTION_GAINED = 1;
|
||||
private static final int SELECTION_LOST = 0;
|
||||
private static final int SELECTION_UNCHANGED = -1;
|
||||
private int mSelectionStatus = SELECTION_UNCHANGED;
|
||||
@Override
|
||||
public void onChildDraw(Canvas c, RecyclerView recyclerView,
|
||||
RecyclerView.ViewHolder viewHolder, float dX, float dY,
|
||||
int actionState, boolean isCurrentlyActive) {
|
||||
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY,
|
||||
actionState, isCurrentlyActive);
|
||||
// We change the elevation if selection changed
|
||||
if (mSelectionStatus != SELECTION_UNCHANGED) {
|
||||
viewHolder.itemView.setElevation(
|
||||
mSelectionStatus == SELECTION_GAINED ? dragElevation : 0);
|
||||
mSelectionStatus = SELECTION_UNCHANGED;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
|
||||
super.onSelectedChanged(viewHolder, actionState);
|
||||
if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
|
||||
mSelectionStatus = SELECTION_GAINED;
|
||||
} else if (actionState == ItemTouchHelper.ACTION_STATE_IDLE) {
|
||||
mSelectionStatus = SELECTION_LOST;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -187,6 +222,15 @@ class LocaleDragAndDropAdapter
|
||||
return result;
|
||||
}
|
||||
|
||||
LocaleStore.LocaleInfo getFirstChecked() {
|
||||
for (LocaleStore.LocaleInfo li : mFeedItemList) {
|
||||
if (li.getChecked()) {
|
||||
return li;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void addLocale(LocaleStore.LocaleInfo li) {
|
||||
mFeedItemList.add(li);
|
||||
notifyItemInserted(mFeedItemList.size() - 1);
|
||||
|
@@ -21,7 +21,6 @@ import android.app.FragmentTransaction;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.LocaleList;
|
||||
@@ -33,12 +32,11 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import com.android.internal.app.LocalePicker;
|
||||
import com.android.internal.app.LocalePickerWithRegion;
|
||||
import com.android.internal.app.LocaleStore;
|
||||
import com.android.settings.InstrumentedFragment;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -107,16 +105,16 @@ public class LocaleListEditor extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void removeLocaleWarningDialog() {
|
||||
int checked = mAdapter.getCheckedCount();
|
||||
int checkedCount = mAdapter.getCheckedCount();
|
||||
|
||||
// Nothing checked, just exit remove mode without a warning dialog
|
||||
if (checked == 0) {
|
||||
if (checkedCount == 0) {
|
||||
setRemoveMode(!mRemoveMode);
|
||||
return;
|
||||
}
|
||||
|
||||
// All locales selected, warning dialog, can't remove them all
|
||||
if (checked == mAdapter.getItemCount()) {
|
||||
if (checkedCount == mAdapter.getItemCount()) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.dlg_remove_locales_error_title)
|
||||
.setMessage(R.string.dlg_remove_locales_error_message)
|
||||
@@ -130,8 +128,10 @@ public class LocaleListEditor extends SettingsPreferenceFragment
|
||||
return;
|
||||
}
|
||||
|
||||
final String title = getResources().getQuantityString(R.plurals.dlg_remove_locales_title,
|
||||
checkedCount);
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.dlg_remove_locales_title)
|
||||
.setTitle(title)
|
||||
.setMessage(R.string.dlg_remove_locales_message)
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
@@ -161,9 +161,9 @@ public class LocaleListEditor extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private static List<LocaleStore.LocaleInfo> getUserLocaleList(Context context) {
|
||||
List<LocaleStore.LocaleInfo> result = new ArrayList<>();
|
||||
final List<LocaleStore.LocaleInfo> result = new ArrayList<>();
|
||||
|
||||
LocaleList localeList = LocalePicker.getLocales();
|
||||
final LocaleList localeList = LocalePicker.getLocales();
|
||||
for (int i = 0; i < localeList.size(); i++) {
|
||||
Locale locale = localeList.get(i);
|
||||
result.add(LocaleStore.getLocaleInfo(locale));
|
||||
@@ -173,8 +173,10 @@ public class LocaleListEditor extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void configureDragAndDrop(View view) {
|
||||
RecyclerView list = (RecyclerView) view.findViewById(R.id.dragList);
|
||||
list.setLayoutManager(new LinearLayoutManager(this.getContext()));
|
||||
final RecyclerView list = (RecyclerView) view.findViewById(R.id.dragList);
|
||||
final LinearLayoutManager llm = new LinearLayoutManager(this.getContext());
|
||||
llm.setAutoMeasureEnabled(true);
|
||||
list.setLayoutManager(llm);
|
||||
|
||||
list.setHasFixedSize(true);
|
||||
mAdapter.setRecyclerView(list);
|
||||
|
Reference in New Issue
Block a user