Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a69bea3 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Make SearchView RTL aware

- see bug #5429822 UI should be mirrored for RTL locales (Arabic, Hebrew, farsi)

Change-Id: I7e7b51dccdd3b111e0594509334579b0502d24c8
parent 2b8c4b07
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1078,6 +1078,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
            mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
            mPopup.setListItemExpandMax(EXPAND_MAX);
        }
        mPopup.setLayoutDirection(getResolvedLayoutDirection());
        mPopup.show();
        mPopup.getListView().setOverScrollMode(View.OVER_SCROLL_ALWAYS);
    }
+6 −0
Original line number Diff line number Diff line
@@ -1121,6 +1121,12 @@ public class ListPopupWindow {
        return listContent + otherHeights;
    }

    public void setLayoutDirection(int resolvedLayoutDirection) {
        if (mDropDownList != null) {
            mDropDownList.setLayoutDirection(resolvedLayoutDirection);
        }
    }

    /**
     * <p>Wrapper class for a ListView. This wrapper can hijack the focus to
     * make sure the list uses the appropriate drawables and states when
+16 −5
Original line number Diff line number Diff line
@@ -326,7 +326,6 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
                        int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    adjustDropDownSizeAndPosition();
                }

            });
        }

@@ -1285,15 +1284,22 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
            Resources res = getContext().getResources();
            int anchorPadding = mSearchPlate.getPaddingLeft();
            Rect dropDownPadding = new Rect();
            final boolean isLayoutRtl = isLayoutRtl();
            int iconOffset = mIconifiedByDefault
                    ? res.getDimensionPixelSize(R.dimen.dropdownitem_icon_width)
                    + res.getDimensionPixelSize(R.dimen.dropdownitem_text_padding_left)
                    : 0;
            mQueryTextView.getDropDownBackground().getPadding(dropDownPadding);
            mQueryTextView.setDropDownHorizontalOffset(-(dropDownPadding.left + iconOffset)
                    + anchorPadding);
            mQueryTextView.setDropDownWidth(mDropDownAnchor.getWidth() + dropDownPadding.left
                    + dropDownPadding.right + iconOffset - (anchorPadding));
            int offset;
            if (isLayoutRtl) {
                offset = - dropDownPadding.left;
            } else {
                offset = anchorPadding - (dropDownPadding.left + iconOffset);
            }
            mQueryTextView.setDropDownHorizontalOffset(offset);
            final int width = mDropDownAnchor.getWidth() + dropDownPadding.left
                    + dropDownPadding.right + iconOffset - anchorPadding;
            mQueryTextView.setDropDownWidth(width);
        }
    }

@@ -1347,6 +1353,11 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
        }
    };

    @Override
    public void onResolvedLayoutDirectionChanged() {
        mQueryTextView.setLayoutDirection(getResolvedLayoutDirection());
    }

    /**
     * Query rewriting.
     */