1 /* 2 * Copyright 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.browser.browseractions; 18 19 import android.app.PendingIntent; 20 21 import androidx.annotation.DrawableRes; 22 import androidx.annotation.NonNull; 23 24 /** 25 * A wrapper class holding custom item of Browser Actions menu. 26 * The Bitmap is optional for a BrowserActionItem. 27 */ 28 public class BrowserActionItem { 29 private final String mTitle; 30 private final PendingIntent mAction; 31 @DrawableRes 32 private final int mIconId; 33 34 /** 35 * Constructor for BrowserActionItem with icon, string and action provided. 36 * @param title The string shown for a custom item. 37 * @param action The PendingIntent executed when a custom item is selected 38 * @param iconId The resource id of the icon shown for a custom item. 39 */ BrowserActionItem( @onNull String title, @NonNull PendingIntent action, @DrawableRes int iconId)40 public BrowserActionItem( 41 @NonNull String title, @NonNull PendingIntent action, @DrawableRes int iconId) { 42 mTitle = title; 43 mAction = action; 44 mIconId = iconId; 45 } 46 47 /** 48 * Constructor for BrowserActionItem with only string and action provided. 49 * @param title The icon shown for a custom item. 50 * @param action The string shown for a custom item. 51 */ BrowserActionItem(@onNull String title, @NonNull PendingIntent action)52 public BrowserActionItem(@NonNull String title, @NonNull PendingIntent action) { 53 this(title, action, 0); 54 } 55 56 /** 57 * @return The resource id of the icon. 58 */ getIconId()59 public int getIconId() { 60 return mIconId; 61 } 62 63 /** 64 * @return The title of a custom item. 65 */ getTitle()66 public String getTitle() { 67 return mTitle; 68 } 69 70 /** 71 * @return The action of a custom item. 72 */ getAction()73 public PendingIntent getAction() { 74 return mAction; 75 } 76 } 77