Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java

Issue 1237623013: Allow client app choose whether custom action button is tinted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
index 03a1efc11e4a31b51a66ca46bba06b7b489d5d17..edc82a074ef99114b3e0aee2fa3670b3084777d8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
@@ -11,6 +11,8 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
@@ -22,6 +24,7 @@ import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.util.IntentUtils;
+import org.chromium.chrome.browser.widget.TintedDrawable;
import java.util.ArrayList;
import java.util.List;
@@ -72,6 +75,13 @@ public class CustomTabIntentDataProvider {
*/
public static final int SHOW_PAGE_TITLE = 1;
+ /**
+ * Extra boolean that specifies whether the custom action button should be tinted. Default is
+ * false and the action button will not be tinted.
+ */
+ public static final String EXTRA_TINT_ACTION_BUTTON =
+ "android.support.customtabs.extra.TINT_ACTION_BUTTON";
+
private static final String BUNDLE_PACKAGE_NAME = "android:packageName";
private static final String BUNDLE_ENTER_ANIMATION_RESOURCE = "android:animEnterRes";
private static final String BUNDLE_EXIT_ANIMATION_RESOURCE = "android:animExitRes";
@@ -80,7 +90,7 @@ public class CustomTabIntentDataProvider {
private final int mTitleVisibilityState;
private final int mCloseButtonResId;
private int mToolbarColor;
- private Bitmap mIcon;
+ private Drawable mIcon;
private PendingIntent mActionButtonPendingIntent;
private List<Pair<String, PendingIntent>> mMenuEntries = new ArrayList<>();
private Bundle mAnimationBundle;
@@ -100,13 +110,21 @@ public class CustomTabIntentDataProvider {
Bundle actionButtonBundle =
IntentUtils.safeGetBundleExtra(intent, CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE);
if (actionButtonBundle != null) {
- mIcon = IntentUtils.safeGetParcelable(actionButtonBundle, CustomTabsIntent.KEY_ICON);
- if (mIcon != null && !checkBitmapSizeWithinBounds(context, mIcon)) {
- mIcon.recycle();
- mIcon = null;
- } else if (mIcon != null) {
+ Bitmap bitmap = IntentUtils.safeGetParcelable(actionButtonBundle,
+ CustomTabsIntent.KEY_ICON);
+ if (bitmap != null && !checkBitmapSizeWithinBounds(context, bitmap)) {
+ bitmap.recycle();
+ bitmap = null;
+ } else if (bitmap != null) {
mActionButtonPendingIntent = IntentUtils.safeGetParcelable(
actionButtonBundle, CustomTabsIntent.KEY_PENDING_INTENT);
+ boolean shouldTint = IntentUtils.safeGetBooleanExtra(intent,
+ EXTRA_TINT_ACTION_BUTTON, false);
+ if (shouldTint) {
+ mIcon = TintedDrawable.constructTintedDrawable(context.getResources(), bitmap);
+ } else {
+ mIcon = new BitmapDrawable(context.getResources(), bitmap);
+ }
}
}
@@ -188,7 +206,7 @@ public class CustomTabIntentDataProvider {
/**
* @return The title visibility state for the toolbar.
- * Default is {@link CustomTabIntentDataProvider#CUSTOM_TAB_NO_TITLE}.
+ * Default is {@link CustomTabIntentDataProvider#NO_TITLE}.
*/
public int getTitleVisibilityState() {
return mTitleVisibilityState;
@@ -205,7 +223,7 @@ public class CustomTabIntentDataProvider {
/**
* @return The icon used for the action button. Will be null if not set in the intent.
*/
- public Bitmap getActionButtonIcon() {
+ public Drawable getActionButtonIcon() {
return mIcon;
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698