Commit 76ed93dc authored by Ender's avatar Ender Committed by Commit Bot

Revert "Fix chopped text on tab switcher long-press menu when text size is huge"

This reverts commit bec9b617.

Reason for revert: breaks org.chromium.chrome.browser.compositor.overlays.strip.TabStripTest suite

Original change's description:
> Fix chopped text on tab switcher long-press menu when text size is huge
> 
> There exists some unknown issue on the measurement of a text view with
> a compound drawable. Using a linear layout containing an imageview and
> a textview inside can avoid this issue.
> 
> Bug: 1053448
> Change-Id: Ibdcd220e0eba7218c1d500d870da17d37c7e767c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083729
> Commit-Queue: Lijin Shen <lazzzis@chromium.org>
> Reviewed-by: Theresa  <twellington@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#747078}

TBR=twellington@chromium.org,lazzzis@chromium.org

Change-Id: I8cc77daf8bfdf3a7a74a4288034de5a5ccdbc992
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1053448
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090598Reviewed-by: default avatarEnder <ender@google.com>
Commit-Queue: Ender <ender@google.com>
Cr-Commit-Position: refs/heads/master@{#747412}
parent 4019383a
......@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.tasks.tab_management;
import android.view.View;
import android.widget.TextView;
import org.chromium.chrome.tab_ui.R;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
......@@ -17,8 +16,7 @@ import org.chromium.ui.modelutil.PropertyModel;
public class TabGridDialogMenuItemBinder {
public static void binder(PropertyModel model, View view, PropertyKey propertyKey) {
if (propertyKey == TabGridDialogMenuItemProperties.TITLE) {
TextView textView = view.findViewById(R.id.menu_item_text);
textView.setText(model.get(TabGridDialogMenuItemProperties.TITLE));
((TextView) view).setText(model.get(TabGridDialogMenuItemProperties.TITLE));
}
}
}
......@@ -519,7 +519,7 @@ public class TabGridDialogTest {
private void verifyTabGridDialogToolbarMenuItem(ListView listView, int index, String text) {
View menuItemView = listView.getChildAt(index);
TextView menuItemText = menuItemView.findViewById(R.id.menu_item_text);
TextView menuItemText = menuItemView.findViewById(R.id.menu_item);
assertEquals(text, menuItemText.getText());
}
......
......@@ -2,31 +2,16 @@
<!-- Copyright 2017 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<!-- Do not replace this with TextViewWithCompoundDrawables
https://crbug.com/1053448
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<org.chromium.components.browser_ui.widget.text.TextViewWithCompoundDrawables
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/menu_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="@style/TextAppearance.ListMenuItem"
android:drawablePadding="@dimen/menu_drawable_padding"
android:gravity="center_vertical"
android:background="?attr/selectableItemBackground"
style="@style/ListMenuItemStyle"
android:minHeight="?android:attr/listPreferredItemHeightSmall" >
<org.chromium.ui.widget.ChromeImageView
android:id="@+id/menu_item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:tint="@color/default_icon_color_secondary" />
<TextView
android:id="@+id/menu_item_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:singleLine="false"
android:textAppearance="@style/TextAppearance.ListMenuItem" />
</LinearLayout>
app:chromeDrawableTint="@color/default_icon_color_secondary" />
......@@ -38,6 +38,7 @@
<!-- Custom Menu dimensions -->
<dimen name="menu_negative_software_vertical_offset">0dp</dimen>
<dimen name="menu_divider_padding">8dp</dimen>
<dimen name="menu_drawable_padding">16dp</dimen>
<dimen name="menu_padding_start">16dp</dimen>
<!-- Drag-Reorderable List dimensions -->
......
......@@ -25,8 +25,8 @@
<!-- ListMenuButton -->
<style name="ListMenuItemStyle">
<item name="android:paddingStart">@dimen/default_list_row_padding</item>
<item name="android:paddingEnd">@dimen/default_list_row_padding</item>
<item name="android:paddingStart">?android:attr/listPreferredItemPaddingStart</item>
<item name="android:paddingEnd">?android:attr/listPreferredItemPaddingEnd</item>
</style>
<style name="OverflowMenuAnim">
......
......@@ -9,8 +9,7 @@ import org.chromium.ui.modelutil.PropertyModel.WritableBooleanPropertyKey;
import org.chromium.ui.modelutil.PropertyModel.WritableIntPropertyKey;
/**
* The properties controlling the state of the list menu items. Any given list item can have either
* one start icon or one end icon but not both.
* The properties controlling the state of the list menu items.
*/
public class ListMenuItemProperties {
public static final WritableIntPropertyKey TITLE_ID = new WritableIntPropertyKey();
......
......@@ -8,52 +8,43 @@ import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.content.res.AppCompatResources;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.components.browser_ui.widget.R;
import org.chromium.components.browser_ui.widget.text.TextViewWithCompoundDrawables;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModel.ReadableIntPropertyKey;
/**
* Class responsible for binding the model of the ListMenuItem and the view.
*/
public class ListMenuItemViewBinder {
public static void binder(PropertyModel model, View view, PropertyKey propertyKey) {
TextView textView = view.findViewById(R.id.menu_item_text);
ImageView imageView = view.findViewById(R.id.menu_item_icon);
TextViewWithCompoundDrawables textView = (TextViewWithCompoundDrawables) view;
if (propertyKey == ListMenuItemProperties.TITLE_ID) {
textView.setText(model.get(ListMenuItemProperties.TITLE_ID));
} else if (propertyKey == ListMenuItemProperties.START_ICON_ID
|| propertyKey == ListMenuItemProperties.END_ICON_ID) {
int id = model.get((ReadableIntPropertyKey) propertyKey);
} else if (propertyKey == ListMenuItemProperties.START_ICON_ID) {
int id = model.get(ListMenuItemProperties.START_ICON_ID);
Drawable[] drawables = textView.getCompoundDrawablesRelative();
Drawable drawable =
id == 0 ? null : AppCompatResources.getDrawable(view.getContext(), id);
imageView.setImageDrawable(drawable);
if (drawable != null) {
if (propertyKey == ListMenuItemProperties.START_ICON_ID) {
// need more space between the start and the icon if icon is on the start.
textView.setPaddingRelative(
view.getResources().getDimensionPixelOffset(R.dimen.menu_padding_start),
textView.getPaddingTop(), textView.getPaddingEnd(),
textView.getPaddingBottom());
} else {
// Move to the end.
ViewGroup layout = (ViewGroup) view;
layout.removeView(imageView);
layout.addView(imageView);
}
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(
drawable, drawables[1], drawables[2], drawables[3]);
if (id != 0) {
// need more space between the start and the icon if icon is on the start.
textView.setPaddingRelative(
view.getResources().getDimensionPixelOffset(R.dimen.menu_padding_start),
view.getPaddingTop(), view.getPaddingEnd(), view.getPaddingBottom());
}
} else if (propertyKey == ListMenuItemProperties.END_ICON_ID) {
int id = model.get(ListMenuItemProperties.END_ICON_ID);
Drawable[] drawables = textView.getCompoundDrawablesRelative();
Drawable drawable =
id == 0 ? null : AppCompatResources.getDrawable(view.getContext(), id);
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(
drawables[0], drawables[1], drawable, drawables[3]);
} else if (propertyKey == ListMenuItemProperties.TINT_COLOR_ID) {
ApiCompatibilityUtils.setImageTintList(imageView,
ContextCompat.getColorStateList(
view.getContext(), model.get(ListMenuItemProperties.TINT_COLOR_ID)));
} else if (propertyKey == ListMenuItemProperties.ENABLED) {
textView.setEnabled(model.get(ListMenuItemProperties.ENABLED));
imageView.setEnabled(model.get(ListMenuItemProperties.ENABLED));
textView.setDrawableTintColor(ContextCompat.getColorStateList(
view.getContext(), model.get(ListMenuItemProperties.TINT_COLOR_ID)));
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment