Commit 31099d6f authored by Sinan Sahin's avatar Sinan Sahin Committed by Commit Bot

Update the colors of Update Chrome item on app menu for dark theme

Bug: 961780
Change-Id: I919783dc96c81b06bd576cb0f6b15b3b2e14e9df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1605448
Commit-Queue: Sinan Sahin <sinansahin@google.com>
Reviewed-by: default avatarBecky Zhou <huayinz@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659202}
parent 77aeb178
......@@ -6,4 +6,5 @@
<resources>
<drawable name="ntp_search_box">@drawable/modern_toolbar_text_box_background</drawable>
<drawable name="badge_update">@drawable/badge_update_dark</drawable>
<drawable name="ic_error_24dp_filled">@drawable/ic_error_grey800_24dp_filled</drawable>
</resources>
\ No newline at end of file
......@@ -4,4 +4,5 @@
found in the LICENSE file. -->
<resources>
<drawable name="badge_update">@drawable/badge_update_light</drawable>
<drawable name="ic_error_24dp_filled">@drawable/ic_error_white_24dp_filled</drawable>
</resources>
\ No newline at end of file
......@@ -11,6 +11,7 @@ import android.animation.ObjectAnimator;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.support.annotation.IntDef;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.content.res.AppCompatResources;
import android.text.TextUtils;
import android.view.LayoutInflater;
......@@ -207,7 +208,7 @@ class AppMenuAdapter extends BaseAdapter {
holder.text.setText(itemState.title);
holder.text.setContentDescription(resources.getString(itemState.title));
holder.text.setTextColor(
ApiCompatibilityUtils.getColor(resources, itemState.titleColor));
ApiCompatibilityUtils.getColor(resources, itemState.titleColorId));
if (!TextUtils.isEmpty(itemState.summary)) {
holder.summary.setText(itemState.summary);
......@@ -218,6 +219,10 @@ class AppMenuAdapter extends BaseAdapter {
}
holder.image.setImageResource(itemState.icon);
if (itemState.iconTintId != 0) {
DrawableCompat.setTint(holder.image.getDrawable(),
ApiCompatibilityUtils.getColor(resources, itemState.iconTintId));
}
convertView.setEnabled(itemState.enabled);
}
break;
......
......@@ -9,7 +9,7 @@ import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
......@@ -61,7 +61,7 @@ public class UpdateMenuItemHelper {
public @StringRes int title;
/** The color resource of the title. Always set if this object is not {@code null}. */
public @ColorInt int titleColor;
public @ColorRes int titleColorId;
/** The summary string for the menu. Maybe {@code null} if no summary should be shown. */
public @Nullable String summary;
......@@ -69,6 +69,9 @@ public class UpdateMenuItemHelper {
/** An icon resource for the menu item. May be {@code 0} if no icon is specified. */
public @DrawableRes int icon;
/** The color resource of the icon tint. May be {@code 0} if no tint is specified. */
public @ColorRes int iconTintId;
/** Whether or not the menu item should be enabled (and clickable). */
public boolean enabled;
}
......@@ -287,7 +290,7 @@ public class UpdateMenuItemHelper {
mMenuUiState.itemState = new MenuItemState();
mMenuUiState.itemState.title = R.string.menu_update;
mMenuUiState.itemState.titleColor = R.color.error_text_color;
mMenuUiState.itemState.titleColorId = R.color.error_text_color;
mMenuUiState.itemState.icon = R.drawable.badge_update;
mMenuUiState.itemState.enabled = true;
mMenuUiState.itemState.summary = UpdateConfigs.getCustomSummary();
......@@ -316,10 +319,10 @@ public class UpdateMenuItemHelper {
mMenuUiState.itemState = new MenuItemState();
mMenuUiState.itemState.title = R.string.menu_update_unsupported;
mMenuUiState.itemState.titleColor = R.color.default_text_color;
mMenuUiState.itemState.titleColorId = R.color.default_text_color;
mMenuUiState.itemState.summary =
resources.getString(R.string.menu_update_unsupported_summary_default);
mMenuUiState.itemState.icon = R.drawable.ic_error_grey800_24dp_filled;
mMenuUiState.itemState.icon = R.drawable.ic_error_24dp_filled;
mMenuUiState.itemState.enabled = false;
break;
case UpdateState.INLINE_UPDATE_AVAILABLE:
......@@ -339,35 +342,38 @@ public class UpdateMenuItemHelper {
mMenuUiState.itemState = new MenuItemState();
mMenuUiState.itemState.title = R.string.menu_update;
mMenuUiState.itemState.titleColor = R.color.default_text_color_blue;
mMenuUiState.itemState.titleColorId = R.color.default_text_color_blue;
mMenuUiState.itemState.summary = UpdateConfigs.getCustomSummary();
if (TextUtils.isEmpty(mMenuUiState.itemState.summary)) {
mMenuUiState.itemState.summary =
resources.getString(R.string.menu_update_summary_default);
}
mMenuUiState.itemState.icon = R.drawable.ic_history_googblue_24dp;
mMenuUiState.itemState.iconTintId = R.color.default_icon_color_blue;
mMenuUiState.itemState.enabled = true;
break;
case UpdateState.INLINE_UPDATE_DOWNLOADING:
mMenuUiState.itemState = new MenuItemState();
mMenuUiState.itemState.title = R.string.menu_inline_update_downloading;
mMenuUiState.itemState.titleColor = R.color.default_text_color_secondary;
mMenuUiState.itemState.titleColorId = R.color.default_text_color_secondary;
break;
case UpdateState.INLINE_UPDATE_READY:
mMenuUiState.itemState = new MenuItemState();
mMenuUiState.itemState.title = R.string.menu_inline_update_ready;
mMenuUiState.itemState.titleColor = R.color.default_text_color_blue;
mMenuUiState.itemState.titleColorId = R.color.default_text_color_blue;
mMenuUiState.itemState.summary =
resources.getString(R.string.menu_inline_update_ready_summary);
mMenuUiState.itemState.icon = R.drawable.infobar_chrome;
mMenuUiState.itemState.iconTintId = R.color.default_icon_color_blue;
mMenuUiState.itemState.enabled = true;
break;
case UpdateState.INLINE_UPDATE_FAILED:
mMenuUiState.itemState = new MenuItemState();
mMenuUiState.itemState.title = R.string.menu_inline_update_failed;
mMenuUiState.itemState.titleColor = R.color.default_text_color_blue;
mMenuUiState.itemState.titleColorId = R.color.default_text_color_blue;
mMenuUiState.itemState.summary = resources.getString(R.string.try_again);
mMenuUiState.itemState.icon = R.drawable.ic_history_googblue_24dp;
mMenuUiState.itemState.iconTintId = R.color.default_icon_color_blue;
mMenuUiState.itemState.enabled = true;
break;
case UpdateState.NONE:
......
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