| Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/ButtonParams.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ActionButtonParams.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ButtonParams.java
|
| similarity index 55%
|
| copy from chrome/android/java/src/org/chromium/chrome/browser/customtabs/ActionButtonParams.java
|
| copy to chrome/android/java/src/org/chromium/chrome/browser/customtabs/ButtonParams.java
|
| index 9c959b26699ac70725974b8190411bdb876f964e..fb2aa160aec3cf67ceff60fab222c21dbadb5d18 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ActionButtonParams.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ButtonParams.java
|
| @@ -18,21 +18,19 @@ import android.text.TextUtils;
|
| import org.chromium.base.Log;
|
| import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.util.IntentUtils;
|
| -import org.chromium.chrome.browser.widget.TintedDrawable;
|
|
|
| /**
|
| - * Container for all parameters related to creating a custom action button.
|
| + * Container for all parameters related to creating a customizable button.
|
| */
|
| -/* package */ class ActionButtonParams {
|
| - private static final String TAG = "CustomTabs";
|
| +/* package */ abstract class ButtonParams {
|
| + protected static final String TAG = "CustomTabs";
|
|
|
| - private Bitmap mIcon;
|
| - private String mDescription;
|
| - private final PendingIntent mPendingIntent;
|
| - private boolean mShouldTint;
|
| + protected Bitmap mIcon;
|
| + protected String mDescription;
|
| + protected final PendingIntent mPendingIntent;
|
|
|
| - private ActionButtonParams(@NonNull Bitmap icon, @NonNull String description,
|
| - @NonNull PendingIntent pendingIntent) {
|
| + protected ButtonParams(@NonNull Bitmap icon, @NonNull String description,
|
| + PendingIntent pendingIntent) {
|
| mIcon = icon;
|
| mDescription = description;
|
| mPendingIntent = pendingIntent;
|
| @@ -47,65 +45,27 @@ import org.chromium.chrome.browser.widget.TintedDrawable;
|
| }
|
|
|
| /**
|
| - * Sets whether the action button icon should be tinted.
|
| - */
|
| - void setTinted(boolean shouldTint) {
|
| - mShouldTint = shouldTint;
|
| - }
|
| -
|
| - /**
|
| - * @return The drawable for the action button. Will be a {@link TintedDrawable} if in the VIEW
|
| - * intent the client required to tint it.
|
| + * @return The drawable for the customized button.
|
| */
|
| Drawable getIcon(Resources res) {
|
| - Drawable drawable = null;
|
| - if (mShouldTint) {
|
| - drawable = TintedDrawable.constructTintedDrawable(res, mIcon);
|
| - } else {
|
| - drawable = new BitmapDrawable(res, mIcon);
|
| - }
|
| - return drawable;
|
| + return new BitmapDrawable(res, mIcon);
|
| }
|
|
|
| /**
|
| - * @return The content description for the custom action button.
|
| + * @return The content description for the customized button.
|
| */
|
| String getDescription() {
|
| return mDescription;
|
| }
|
|
|
| /**
|
| - * @return The {@link PendingIntent} that will be sent when the user clicks the action button.
|
| + * @return The {@link PendingIntent} that will be sent when user clicks the customized button.
|
| */
|
| PendingIntent getPendingIntent() {
|
| return mPendingIntent;
|
| }
|
|
|
| /**
|
| - * Parses an {@link ActionButtonParams} from an action button bundle sent by clients.
|
| - * @param bundle The action button bundle specified by
|
| - * {@link CustomTabsIntent#EXTRA_ACTION_BUTTON_BUNDLE}
|
| - * @return The parsed {@link ActionButtonParams}. Return null if input is invalid.
|
| - */
|
| - static ActionButtonParams fromBundle(Context context, Bundle bundle) {
|
| - if (bundle == null) return null;
|
| -
|
| - Bitmap bitmap = tryParseBitmapFromBundle(context, bundle);
|
| - if (bitmap == null) return null;
|
| -
|
| - String description = tryParseDescriptionFromBundle(bundle);
|
| - if (TextUtils.isEmpty(description)) {
|
| - bitmap.recycle();
|
| - return null;
|
| - }
|
| -
|
| - PendingIntent pi = IntentUtils.safeGetParcelable(bundle,
|
| - CustomTabsIntent.KEY_PENDING_INTENT);
|
| - if (pi == null) return null;
|
| - return new ActionButtonParams(bitmap, description, pi);
|
| - }
|
| -
|
| - /**
|
| * @return The bitmap contained in the given {@link Bundle}. Will return null if input is
|
| * invalid.
|
| */
|
| @@ -114,7 +74,7 @@ import org.chromium.chrome.browser.widget.TintedDrawable;
|
| Bitmap bitmap = IntentUtils.safeGetParcelable(bundle, CustomTabsIntent.KEY_ICON);
|
| if (bitmap == null) return null;
|
| if (!checkCustomButtonIconWithinBounds(context, bitmap)) {
|
| - Log.w(TAG, "Action button's icon size not acceptable. Please refer to "
|
| + Log.w(TAG, "Button's icon size not acceptable. Please refer to "
|
| + "https://developer.android.com/reference/android/support/customtabs/"
|
| + "CustomTabsIntent.html#KEY_ICON");
|
| bitmap.recycle();
|
|
|