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

Commit 8dc03bc0 authored by Seigo Nonaka's avatar Seigo Nonaka Committed by Android (Google) Code Review
Browse files

Merge "Revive drop shadow of SuggestionWindow."

parents f11f14cb 60490d1a
Loading
Loading
Loading
Loading
+24 −8
Original line number Diff line number Diff line
@@ -2872,6 +2872,7 @@ public class Editor {
        protected PopupWindow mPopupWindow;
        protected ViewGroup mContentView;
        int mPositionX, mPositionY;
        int mClippingLimitLeft, mClippingLimitRight;

        protected abstract void createPopupWindow();
        protected abstract void initContentView();
@@ -2939,8 +2940,9 @@ public class Editor {
            // Horizontal clipping
            final DisplayMetrics displayMetrics = mTextView.getResources().getDisplayMetrics();
            final int width = mContentView.getMeasuredWidth();
            positionX = Math.min(displayMetrics.widthPixels - width, positionX);
            positionX = Math.max(0, positionX);
            positionX = Math.min(
                    displayMetrics.widthPixels - width + mClippingLimitRight, positionX);
            positionX = Math.max(-mClippingLimitLeft, positionX);

            if (isShowing()) {
                mPopupWindow.update(positionX, positionY, -1, -1);
@@ -3118,6 +3120,8 @@ public class Editor {
        private TextView mAddToDictionaryButton;
        private TextView mDeleteButton;
        private SuggestionSpan mMisspelledSpan;
        private int mContainerMarginWidth;
        private int mContainerMarginTop;

        private class CustomPopupWindow extends PopupWindow {
            @Override
@@ -3155,10 +3159,20 @@ public class Editor {
        protected void initContentView() {
            final LayoutInflater inflater = (LayoutInflater) mTextView.getContext().
                    getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final LinearLayout linearLayout = (LinearLayout) inflater.inflate(
            final ViewGroup relativeLayout = (ViewGroup) inflater.inflate(
                    mTextView.mTextEditSuggestionContainerLayout, null);

            final ListView suggestionListView = (ListView) linearLayout.findViewById(
            final LinearLayout suggestionWindowContainer =
                    (LinearLayout) relativeLayout.findViewById(
                            com.android.internal.R.id.suggestionWindowContainer);
            ViewGroup.MarginLayoutParams lp =
                    (ViewGroup.MarginLayoutParams) suggestionWindowContainer.getLayoutParams();
            mContainerMarginWidth = lp.leftMargin + lp.rightMargin;
            mContainerMarginTop = lp.topMargin;
            mClippingLimitLeft = lp.leftMargin;
            mClippingLimitRight = lp.rightMargin;

            final ListView suggestionListView = (ListView) relativeLayout.findViewById(
                    com.android.internal.R.id.suggestionContainer);

            mSuggestionsAdapter = new SuggestionAdapter();
@@ -3171,9 +3185,9 @@ public class Editor {
                mSuggestionInfos[i] = new SuggestionInfo();
            }

            mContentView = linearLayout;
            mContentView = relativeLayout;

            mAddToDictionaryButton = (TextView) linearLayout.findViewById(
            mAddToDictionaryButton = (TextView) relativeLayout.findViewById(
                    com.android.internal.R.id.addToDictionaryButton);
            mAddToDictionaryButton.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
@@ -3197,7 +3211,7 @@ public class Editor {
                }
            });

            mDeleteButton = (TextView) linearLayout.findViewById(
            mDeleteButton = (TextView) relativeLayout.findViewById(
                    com.android.internal.R.id.deleteButton);
            mDeleteButton.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
@@ -3306,6 +3320,8 @@ public class Editor {
            mDeleteButton.measure(horizontalMeasure, verticalMeasure);
            width = Math.max(width, mDeleteButton.getMeasuredWidth());

            width += mContainerMarginWidth;

            // Enforce the width based on actual text widths
            mContentView.measure(
                    View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
@@ -3327,7 +3343,7 @@ public class Editor {

        @Override
        protected int getVerticalLocalPosition(int line) {
            return mTextView.getLayout().getLineBottom(line);
            return mTextView.getLayout().getLineBottom(line) - mContainerMarginTop;
        }

        @Override
+34 −25
Original line number Diff line number Diff line
@@ -14,8 +14,16 @@
     limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <LinearLayout
        android:id="@+id/suggestionWindowContainer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:elevation="2dp"
        android:layout_margin="20dp"
        android:background="@drawable/text_edit_suggestions_window"
        android:dropDownSelector="@drawable/list_selector_background"
        android:divider="@null">
@@ -43,3 +51,4 @@
                android:text="@string/deleteText" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>
+32 −23
Original line number Diff line number Diff line
@@ -16,20 +16,28 @@

<!-- Background of the popup window is the same as the one of the floating toolbar.
     Use floating toolbar background style. -->
<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <LinearLayout
        android:id="@+id/suggestionWindowContainer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="?android:attr/floatingToolbarPopupBackgroundDrawable"
        android:elevation="2dp"
        android:layout_margin="20dp"
        android:orientation="vertical"
        android:divider="?android:attr/listDivider"
        android:showDividers="middle">
        <ListView
            android:id="@+id/suggestionContainer"
        android:layout_width="match_parent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        android:paddingTop="8dip"
        android:paddingBottom="0dip"
            android:paddingTop="8dp"
            android:paddingBottom="0dp"
            android:divider="@null" />
        <LinearLayout
        android:layout_width="match_parent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TextView
@@ -42,3 +50,4 @@
                android:text="@string/deleteText" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>
+1 −0
Original line number Diff line number Diff line
@@ -2388,6 +2388,7 @@
  <java-symbol type="color" name="system_bar_background_semi_transparent" />

  <!-- EditText suggestion popup. -->
  <java-symbol type="id" name="suggestionWindowContainer" />
  <java-symbol type="id" name="suggestionContainer" />
  <java-symbol type="id" name="addToDictionaryButton" />
  <java-symbol type="id" name="deleteButton" />