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

Unified Diff: customtabs/src/android/support/customtabs/browseractions/BrowserActionItem.java

Issue 2787723002: [Android] Add public API for Browser Action in support library (Closed)
Patch Set: Update based on Yusuf's new comments. Created 3 years, 8 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
Index: customtabs/src/android/support/customtabs/browseractions/BrowserActionItem.java
diff --git a/customtabs/src/android/support/customtabs/browseractions/BrowserActionItem.java b/customtabs/src/android/support/customtabs/browseractions/BrowserActionItem.java
new file mode 100644
index 0000000000000000000000000000000000000000..11e2c90fa777af5bbe5773af1b9f5bf9a7a46e51
--- /dev/null
+++ b/customtabs/src/android/support/customtabs/browseractions/BrowserActionItem.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.customtabs.browseractions;
+
+import android.app.PendingIntent;
+import android.graphics.Bitmap;
+import android.support.annotation.NonNull;
+
+/**
+ * A wrapper class holding custom item of Browser Actions menu.
+ * The Bitmap is optional for a BrowserActionItem.
+ */
+public class BrowserActionItem {
+ private final String mTitle;
+ private final PendingIntent mAction;
+ private Bitmap mIcon;
+
+ /**
+ * Constructor for BrowserActionItem with icon, string and action provided.
+ * @param icon The icon shown for a custom item.
+ * @param title The string shown for a custom item.
+ * @param action The PendingIntent executed when a custom item is selected
+ */
+ public BrowserActionItem(@NonNull String title, @NonNull PendingIntent action, Bitmap icon) {
+ mTitle = title;
+ mAction = action;
+ mIcon = icon;
+ }
+
+ /**
+ * Constructor for BrowserActionItem with only string and action provided.
+ * @param title The icon shown for a custom item.
+ * @param action The string shown for a custom item.
+ */
+ public BrowserActionItem(@NonNull String title, @NonNull PendingIntent action) {
+ this(title, action, null);
+ }
+
+ /**
+ * Sets the icon of a custom item.
+ * @param icon The icon for a custom item.
+ */
+ public void setIcon(Bitmap icon) {
+ mIcon = icon;
+ }
+
+ /**
+ * Gets the icon of of a custom item.
Yusuf 2017/04/18 17:44:16 /** * @return the icon of of a custom item. */
ltian 2017/04/18 22:30:31 Done.
+ * @return the icon of of a custom item..
+ */
+ public Bitmap getIcon() {
+ return mIcon;
+ }
+
+ /**
+ * Gets the title of a custom item.
+ * @return the title of a custom item..
Yusuf 2017/04/18 17:44:16 here as well
ltian 2017/04/18 22:30:31 Done.
+ */
+ public String getTitle() {
+ return mTitle;
+ }
+
+ /**
+ * Gets the {@link PendingIntent} action of a custom item.
+ * @return the action of a custom item.
Yusuf 2017/04/18 17:44:16 ditto
ltian 2017/04/18 22:30:31 Done.
+ */
+ public PendingIntent getAction() {
+ return mAction;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698