diff --git a/res/drawable/drag_handle.xml b/res/drawable/drag_handle.xml index c01ee1cf1ba..33a68c68638 100644 --- a/res/drawable/drag_handle.xml +++ b/res/drawable/drag_handle.xml @@ -15,15 +15,13 @@ --> + android:height="24dp" + android:width="24dp" + android:viewportHeight="48" + android:viewportWidth="48" + android:tint="@color/material_grey_600"> - + android:pathData="M8,18v4h32v-4hm-32,8v4h32v-4z" /> diff --git a/res/layout/locale_drag_cell.xml b/res/layout/locale_drag_cell.xml index 978e0adf9cc..eb26d2c3e39 100644 --- a/res/layout/locale_drag_cell.xml +++ b/res/layout/locale_drag_cell.xml @@ -19,61 +19,64 @@ 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:minHeight="?android:listPreferredItemHeight" + android:background="?android:colorBackground" android:layoutDirection="locale" android:textDirection="locale"> + + + + - - + android:minWidth="32sp" + android:gravity="center_vertical|center_horizontal" + android:layout_alignTop="@id/checkbox" + android:layout_alignBottom="@id/checkbox"/> - - + style="@style/LanguageCheckboxAndLabel" + android:layout_marginTop="-28dp" + android:paddingStart="48dp" + android:textAppearance="?android:attr/textAppearanceListItemSecondary" + android:textColor="?android:textColorSecondary" + android:text="@string/locale_not_translated" + android:layout_toStartOf="@+id/dragHandle" + android:layout_below="@id/label"/> + android:src="@drawable/drag_handle" + android:layout_alignParentEnd="true" + android:layout_alignTop="@id/checkbox" + android:layout_alignBottom="@id/checkbox"/> + + diff --git a/res/layout/locale_order_list.xml b/res/layout/locale_order_list.xml index e210c65052e..a5021d15e7d 100644 --- a/res/layout/locale_order_list.xml +++ b/res/layout/locale_order_list.xml @@ -17,8 +17,10 @@ Can’t remove all the languages, you should leave at least one. + + + Not all applications are translated into this language; you might experience a mixture. Choose activity diff --git a/res/values/styles.xml b/res/values/styles.xml index df5490b9804..a74d70bb4d1 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -372,4 +372,14 @@ @android:color/tertiary_text_light @android:color/primary_text_light + + + diff --git a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java index 785c6fd14d7..1b5594c523d 100644 --- a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java +++ b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java @@ -21,6 +21,7 @@ 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.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -41,6 +42,7 @@ import java.util.Locale; class LocaleDragAndDropAdapter extends RecyclerView.Adapter { + private static final String TAG = "LocaleDragAndDropAdapter"; private final Context mContext; private final List mFeedItemList; private final ItemTouchHelper mItemTouchHelper; @@ -55,8 +57,6 @@ class LocaleDragAndDropAdapter super(view); mLocaleDragCell = view; mLocaleDragCell.getDragHandle().setOnTouchListener(this); - mLocaleDragCell.getTextLabel().setOnTouchListener(this); - mLocaleDragCell.getTranslateableLabel().setOnTouchListener(this); } public LocaleDragCell getLocaleDragCell() { @@ -144,7 +144,14 @@ class LocaleDragAndDropAdapter } private void onItemMove(int fromPosition, int toPosition) { - Collections.swap(mFeedItemList, fromPosition, toPosition); + if (fromPosition >= 0 && toPosition >= 0) { + Collections.swap(mFeedItemList, fromPosition, toPosition); + } else { + // TODO: It looks like sometimes the RecycleView tries to swap item -1 + // Investigate and file a bug. + Log.e(TAG, String.format(Locale.US, + "Negative position in onItemMove %d -> %d", fromPosition, toPosition)); + } notifyItemChanged(fromPosition); // to update the numbers notifyItemChanged(toPosition); notifyItemMoved(fromPosition, toPosition); diff --git a/src/com/android/settings/localepicker/LocaleDragCell.java b/src/com/android/settings/localepicker/LocaleDragCell.java index 8b1fa3c5f8f..b3ecfad095d 100644 --- a/src/com/android/settings/localepicker/LocaleDragCell.java +++ b/src/com/android/settings/localepicker/LocaleDragCell.java @@ -20,16 +20,19 @@ import android.content.Context; import android.util.AttributeSet; import android.widget.CheckBox; import android.widget.ImageView; -import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.TextView; import com.android.settings.R; -class LocaleDragCell extends LinearLayout { +class LocaleDragCell extends RelativeLayout { + // We need to keep the label and the checkbox "in sync" + // The checkbox shows in remove mode, and the label shows in normal mode, in the same position. + // So we need to set the same text to both of them, and coordinate the show / hide. private TextView mLabel; - private TextView mMiniLabel; - private ImageView mLocalized; private CheckBox mCheckbox; + private TextView mMiniLabel; + private TextView mLocalized; private ImageView mDragHandle; public LocaleDragCell(Context context, AttributeSet attrs) { @@ -40,20 +43,31 @@ class LocaleDragCell extends LinearLayout { protected void onFinishInflate() { super.onFinishInflate(); mLabel = (TextView) findViewById(R.id.label); - mLocalized = (ImageView) findViewById(R.id.l10nWarn); + mLocalized = (TextView) findViewById(R.id.l10nWarn); mMiniLabel = (TextView) findViewById(R.id.miniLabel); mCheckbox = (CheckBox) findViewById(R.id.checkbox); mDragHandle = (ImageView) findViewById(R.id.dragHandle); } public void setShowHandle(boolean showHandle) { - mDragHandle.setVisibility(showHandle ? VISIBLE : GONE); + // We want invisible, not gone, so that everything else stays the same. + // With GONE there is more space for the labels and the text wrapping change. + // So the transition between "normal" mode (with numbers) and + // "remove mode" (with checkboxes) is not that "smooth" + mDragHandle.setVisibility(showHandle ? VISIBLE : INVISIBLE); invalidate(); requestLayout(); } public void setShowCheckbox(boolean showCheckbox) { - mCheckbox.setVisibility(showCheckbox ? VISIBLE : GONE); + // "Opposite" visibility for label / checkbox + if (showCheckbox) { + mCheckbox.setVisibility(VISIBLE); + mLabel.setVisibility(INVISIBLE); + } else { + mCheckbox.setVisibility(INVISIBLE); + mLabel.setVisibility(VISIBLE); + } invalidate(); requestLayout(); } @@ -75,11 +89,12 @@ class LocaleDragCell extends LinearLayout { public void setLabel(String labelText) { mLabel.setText(labelText); + mCheckbox.setText(labelText); invalidate(); } public void setLocalized(boolean localized) { - mLocalized.setVisibility(localized ? INVISIBLE : VISIBLE); + mLocalized.setVisibility(localized ? GONE : VISIBLE); invalidate(); } @@ -87,14 +102,6 @@ class LocaleDragCell extends LinearLayout { return mDragHandle; } - public ImageView getTranslateableLabel() { - return mLocalized; - } - - public TextView getTextLabel() { - return mLabel; - } - public CheckBox getCheckbox() { return mCheckbox; }