Commit 880920be authored by Lei Tian's avatar Lei Tian Committed by Commit Bot

Fix copy items' icon not shown in Chrome context menu.

Recently all copy related items' change from png to vector drawable,
this makes TintedDrawable.constructTintedDrawable fail to render the
icon because VectorDrawable does not extend TintedDrawable. Also since
ApiCompatibilityUtils.getDrawable cannot render vector drawable on pre-L
devices, change to use AppCompatResources.getDrawable to render icon for
context menu.

Bug: 791780
Change-Id: I35dead93f8ab5d89da49ef32180bebb644effc78
Reviewed-on: https://chromium-review.googlesource.com/807344
Commit-Queue: Lei Tian <ltian@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521778}
parent 6521b2fc
...@@ -21,6 +21,7 @@ import android.graphics.Color; ...@@ -21,6 +21,7 @@ import android.graphics.Color;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.PowerManager; import android.os.PowerManager;
...@@ -445,6 +446,8 @@ public class ApiCompatibilityUtils { ...@@ -445,6 +446,8 @@ public class ApiCompatibilityUtils {
/** /**
* @see android.content.res.Resources#getDrawable(int id). * @see android.content.res.Resources#getDrawable(int id).
* TODO(ltian): use {@link AppCompatResources} to parse drawable to prevent fail on
* {@link VectorDrawable}. (http://crbug.com/792129)
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static Drawable getDrawable(Resources res, int id) throws NotFoundException { public static Drawable getDrawable(Resources res, int id) throws NotFoundException {
......
...@@ -9,8 +9,8 @@ import android.graphics.drawable.Drawable; ...@@ -9,8 +9,8 @@ import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes; import android.support.annotation.IdRes;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v7.content.res.AppCompatResources;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.DefaultBrowserInfo; import org.chromium.chrome.browser.DefaultBrowserInfo;
import org.chromium.chrome.browser.search_engines.TemplateUrlService; import org.chromium.chrome.browser.search_engines.TemplateUrlService;
...@@ -132,8 +132,9 @@ public enum ChromeContextMenuItem implements ContextMenuItem { ...@@ -132,8 +132,9 @@ public enum ChromeContextMenuItem implements ContextMenuItem {
public Drawable getDrawable(Context context) { public Drawable getDrawable(Context context) {
if (mIconId == R.drawable.context_menu_new_tab if (mIconId == R.drawable.context_menu_new_tab
|| mIconId == R.drawable.context_menu_add_to_contacts || mIconId == R.drawable.context_menu_add_to_contacts
|| mIconId == R.drawable.context_menu_load_image) { || mIconId == R.drawable.context_menu_load_image
return ApiCompatibilityUtils.getDrawable(context.getResources(), mIconId); || mIconId == R.drawable.ic_content_copy_black) {
return AppCompatResources.getDrawable(context, mIconId);
} else if (mIconId == 0) { } else if (mIconId == 0) {
return null; return null;
} else { } else {
......
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