Loading core/java/android/widget/Editor.java +24 −8 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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); Loading Loading @@ -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 Loading Loading @@ -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(); Loading @@ -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) { Loading @@ -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) { Loading Loading @@ -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), Loading @@ -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 Loading core/res/res/layout/text_edit_suggestion_container.xml +34 −25 Original line number Diff line number Diff line Loading @@ -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"> Loading Loading @@ -43,3 +51,4 @@ android:text="@string/deleteText" /> </LinearLayout> </LinearLayout> </RelativeLayout> core/res/res/layout/text_edit_suggestion_container_material.xml +32 −23 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -42,3 +50,4 @@ android:text="@string/deleteText" /> </LinearLayout> </LinearLayout> </RelativeLayout> core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -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" /> Loading Loading
core/java/android/widget/Editor.java +24 −8 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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); Loading Loading @@ -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 Loading Loading @@ -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(); Loading @@ -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) { Loading @@ -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) { Loading Loading @@ -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), Loading @@ -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 Loading
core/res/res/layout/text_edit_suggestion_container.xml +34 −25 Original line number Diff line number Diff line Loading @@ -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"> Loading Loading @@ -43,3 +51,4 @@ android:text="@string/deleteText" /> </LinearLayout> </LinearLayout> </RelativeLayout>
core/res/res/layout/text_edit_suggestion_container_material.xml +32 −23 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -42,3 +50,4 @@ android:text="@string/deleteText" /> </LinearLayout> </LinearLayout> </RelativeLayout>
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -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" /> Loading