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

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 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..fa22509ad314a46b4bf636147280cef2b34f409d
--- /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 {
+ final private String mTitle;
Yusuf 2017/04/05 02:38:30 private final
ltian 2017/04/07 23:14:55 Done.
+ final private 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.
+ * @return The icon of a custom item.
Yusuf 2017/04/05 02:38:30 just @return is fine
ltian 2017/04/07 23:14:55 Done.
+ */
+ public Bitmap getIcon() {
+ return mIcon;
+ }
+
+ /**
+ * Gets the title of a custom item.
+ * @return The title of a custom item.
Yusuf 2017/04/05 02:38:30 just @return for calls with no param and a single
ltian 2017/04/07 23:14:55 Done.
+ */
+ public String getTitle() {
+ return mTitle;
+ }
+
+ /**
+ * Gets the action of a custom item.
+ * @return The {@link PendingIntent} action of a custom item.
+ */
+ public PendingIntent getAction() {
+ return mAction;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698