CustomTabsIntent.java revision 64694064caedb59afda4ef69b04feaee12c0a33f
108889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal/* 208889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Copyright (C) 2015 The Android Open Source Project 308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * 408889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Licensed under the Apache License, Version 2.0 (the "License"); 508889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * you may not use this file except in compliance with the License. 608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * You may obtain a copy of the License at 708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * 808889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * http://www.apache.org/licenses/LICENSE-2.0 908889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * 1008889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Unless required by applicable law or agreed to in writing, software 1108889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * distributed under the License is distributed on an "AS IS" BASIS, 1208889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * See the License for the specific language governing permissions and 1408889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * limitations under the License. 1508889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 1608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 1708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysalpackage android.support.customtabs; 1808889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 1908889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysalimport android.app.Activity; 2008889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysalimport android.app.PendingIntent; 2197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lizeimport android.content.Context; 2208889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysalimport android.content.Intent; 2308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysalimport android.graphics.Bitmap; 2408889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysalimport android.graphics.Color; 2508889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysalimport android.net.Uri; 2608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysalimport android.os.Bundle; 2797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lizeimport android.support.annotation.AnimRes; 28e063d4d36883c9f7ca100036b9344b665ab6fd1eYusuf Ozuysalimport android.support.annotation.ColorInt; 29c5c0045de7c8848144a570665e0d3c950816f314Yusuf Ozuysalimport android.support.annotation.NonNull; 3097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lizeimport android.support.annotation.Nullable; 311b7158bbc0d0ba4569881f547d12f52e405e125eIan Lakeimport android.support.v4.app.ActivityCompat; 321b7158bbc0d0ba4569881f547d12f52e405e125eIan Lakeimport android.support.v4.app.ActivityOptionsCompat; 33c5c0045de7c8848144a570665e0d3c950816f314Yusuf Ozuysalimport android.support.v4.app.BundleCompat; 3408889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 3597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lizeimport java.util.ArrayList; 3608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 3708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal/** 3897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Class holding the {@link Intent} and start bundle for a Custom Tabs Activity. 3997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 4097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * <p> 4197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * <strong>Note:</strong> The constants below are public for the browser implementation's benefit. 4297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * You are strongly encouraged to use {@link CustomTabsIntent.Builder}.</p> 4308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 4497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lizepublic final class CustomTabsIntent { 4508889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 4608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 4708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Extra used to match the session. This has to be included in the intent to open in 4808889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * a custom tab. This is the same IBinder that gets passed to ICustomTabsService#newSession. 4908889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Null if there is no need to match any service side sessions with the intent. 5008889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 5108889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal public static final String EXTRA_SESSION = "android.support.customtabs.extra.SESSION"; 5208889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 5308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 5408889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Extra that changes the background color for the toolbar. colorRes is an int that specifies a 5508889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * {@link Color}, not a resource id. 5608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 5708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal public static final String EXTRA_TOOLBAR_COLOR = 5808889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal "android.support.customtabs.extra.TOOLBAR_COLOR"; 5908889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 6008889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 619440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal * Boolean extra that enables the url bar to hide as the user scrolls down the page 629440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal */ 639440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal public static final String EXTRA_ENABLE_URLBAR_HIDING = 649440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal "android.support.customtabs.extra.ENABLE_URLBAR_HIDING"; 659440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal 669440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal /** 6797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Extra bitmap that specifies the icon of the back button on the toolbar. If the client chooses 6897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * not to customize it, a default close button will be used. 6997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 7097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public static final String EXTRA_CLOSE_BUTTON_ICON = 7197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize "android.support.customtabs.extra.CLOSE_BUTTON_ICON"; 7297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 7397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 7497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Extra (int) that specifies state for showing the page title. Default is {@link #NO_TITLE}. 7597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 7697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public static final String EXTRA_TITLE_VISIBILITY_STATE = 7797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize "android.support.customtabs.extra.TITLE_VISIBILITY"; 7897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 7997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 8097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Don't show any title. Shows only the domain. 8197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 8297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public static final int NO_TITLE = 0; 8397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 8497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 8597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Shows the page title and the domain. 8697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 8797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public static final int SHOW_PAGE_TITLE = 1; 8897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 8997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 908a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal * Bundle used for adding a custom action button to the custom tab toolbar. The client should 918a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal * provide a description, an icon {@link Bitmap} and a {@link PendingIntent} for the button. 928a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal * All three keys must be present. 9308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 9408889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal public static final String EXTRA_ACTION_BUTTON_BUNDLE = 9508889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal "android.support.customtabs.extra.ACTION_BUTTON_BUNDLE"; 9608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 9708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 98179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * List<Bundle> used for adding items to the top and bottom action bars. The client should 99179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * provide an ID, a description, an icon {@link Bitmap} for each item. They may also provide a 100179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * {@link PendingIntent} if the item is a button. 101179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal */ 102179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal public static final String EXTRA_ACTION_BAR_ITEMS = 103179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal "android.support.customtabs.extra.ACTION_BAR_ITEMS"; 104179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal 105179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal /** 10664694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal * Extra that changes the background color for the secondary action bar. The value should be an 10764694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal * int that specifies a {@link Color}, not a resource id. 10864694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal */ 10964694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal public static final String EXTRA_SECONDARY_ACTION_BAR_COLOR = 11064694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal "android.support.customtabs.extra.SECONDARY_ACTION_BAR_COLOR"; 11164694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal 11264694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal /** 11308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Key that specifies the {@link Bitmap} to be used as the image source for the action button. 1148a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal * The icon should't be more than 24dp in height (No padding needed. The button itself will be 1158a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal * 48dp in height) and have a width/height ratio of less than 2. 11608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 11708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal public static final String KEY_ICON = "android.support.customtabs.customaction.ICON"; 11808889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 11908889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 1208a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal * Key that specifies the content description for the custom action button. 1218a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal */ 1228a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal public static final String KEY_DESCRIPTION = 1238a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal "android.support.customtabs.customaction.DESCRIPTION"; 1248a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal 1258a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal /** 12608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Key that specifies the PendingIntent to launch when the action button or menu item was 12708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * clicked. The custom tab will be calling {@link PendingIntent#send()} on clicks after adding 12808889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * the url as data. The client app can call {@link Intent#getDataString()} to get the url. 12908889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 13008889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal public static final String KEY_PENDING_INTENT = 13108889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal "android.support.customtabs.customaction.PENDING_INTENT"; 13208889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 13308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 1349440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal * Extra boolean that specifies whether the custom action button should be tinted. Default is 1359440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal * false and the action button will not be tinted. 1369440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal */ 1379440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal public static final String EXTRA_TINT_ACTION_BUTTON = 1389440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal "android.support.customtabs.extra.TINT_ACTION_BUTTON"; 1399440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal 1409440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal /** 14108889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Use an {@code ArrayList<Bundle>} for specifying menu related params. There should be a 14208889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * separate {@link Bundle} for each custom menu item. 14308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 14408889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS"; 14508889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 14608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 14708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * Key for specifying the title of a menu item. 14808889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 14908889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal public static final String KEY_MENU_ITEM_TITLE = 15008889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal "android.support.customtabs.customaction.MENU_ITEM_TITLE"; 15108889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 15208889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 1531b7158bbc0d0ba4569881f547d12f52e405e125eIan Lake * Bundle constructed out of {@link ActivityOptionsCompat} that will be running when the 15408889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * {@link Activity} that holds the custom tab gets finished. A similar ActivityOptions 15508889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * for creation should be constructed and given to the startActivity() call that 15608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal * launches the custom tab. 15708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 15808889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal public static final String EXTRA_EXIT_ANIMATION_BUNDLE = 15908889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE"; 16008889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 16108889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 1628b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal * Boolean extra that specifies whether a default share button will be shown in the menu. 1638b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal */ 1648b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal public static final String EXTRA_DEFAULT_SHARE_MENU_ITEM = 1658b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal "android.support.customtabs.extra.SHARE_MENU_ITEM"; 1668b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal 1678b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal /** 168179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * Key that specifies the unique ID for an action button. To make a button to show on the 169179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * toolbar, use {@link #TOOLBAR_ACTION_BUTTON_ID} as its ID. 170179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal */ 171179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal public static final String KEY_ID = "android.support.customtabs.customaction.ID"; 172179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal 173179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal /** 174179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * The ID allocated to the custom action button that is shown on the toolbar. 175179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal */ 176179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal public static final int TOOLBAR_ACTION_BUTTON_ID = 0; 177179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal 178179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal /** 179179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * The maximum allowed number of action bar items. 180179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal */ 181179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal private static final int MAX_ACTION_BAR_ITEMS = 5; 182179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal 183179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal /** 18497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * An {@link Intent} used to start the Custom Tabs Activity. 18597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 18697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize @NonNull public final Intent intent; 18797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 18897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 18997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * A {@link Bundle} containing the start animation for the Custom Tabs Activity. 19008889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal */ 19197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize @Nullable public final Bundle startAnimationBundle; 19297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 19397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 19497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Convenience method to launch a Custom Tabs Activity. 19597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param context The source Activity. 19697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param url The URL to load in the Custom Tab. 19797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 19897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public void launchUrl(Activity context, Uri url) { 19997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize intent.setData(url); 2001b7158bbc0d0ba4569881f547d12f52e405e125eIan Lake ActivityCompat.startActivity(context, intent, startAnimationBundle); 20197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 20297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 20397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize private CustomTabsIntent(Intent intent, Bundle startAnimationBundle) { 20497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize this.intent = intent; 20597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize this.startAnimationBundle = startAnimationBundle; 20608889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal } 20708889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal 20808889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal /** 20997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Builder class for {@link CustomTabsIntent} objects. 21097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 21197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public static final class Builder { 21297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize private final Intent mIntent = new Intent(Intent.ACTION_VIEW); 21397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize private ArrayList<Bundle> mMenuItems = null; 21497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize private Bundle mStartAnimationBundle = null; 215179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal private ArrayList<Bundle> mActionButtons = null; 21697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 21797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 21897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Creates a {@link CustomTabsIntent.Builder} object associated with no 21997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * {@link CustomTabsSession}. 22097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 22197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public Builder() { 22297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize this(null); 22397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 22497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 22597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 22697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Creates a {@link CustomTabsIntent.Builder} object associated with a given 22797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * {@link CustomTabsSession}. 22897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 22997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Guarantees that the {@link Intent} will be sent to the same component as the one the 23097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * session is associated with. 23197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 23297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param session The session to associate this Builder with. 23397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 23497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public Builder(@Nullable CustomTabsSession session) { 23597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize if (session != null) mIntent.setPackage(session.getComponentName().getPackageName()); 23697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize Bundle bundle = new Bundle(); 237c5c0045de7c8848144a570665e0d3c950816f314Yusuf Ozuysal BundleCompat.putBinder( 238c5c0045de7c8848144a570665e0d3c950816f314Yusuf Ozuysal bundle, EXTRA_SESSION, session == null ? null : session.getBinder()); 23997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize mIntent.putExtras(bundle); 24097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 24197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 24297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 24397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Sets the toolbar color. 24497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 24597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param color {@link Color} 24697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 24797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public Builder setToolbarColor(@ColorInt int color) { 24897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize mIntent.putExtra(EXTRA_TOOLBAR_COLOR, color); 24997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize return this; 25097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 25197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 25297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 2539440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal * Enables the url bar to hide as the user scrolls down on the page. 2549440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal */ 2559440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal public Builder enableUrlBarHiding() { 2569440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal mIntent.putExtra(EXTRA_ENABLE_URLBAR_HIDING, true); 2579440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal return this; 2589440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal } 2599440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal 2609440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal /** 26197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Sets the Close button icon for the custom tab. 26297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 26397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param icon The icon {@link Bitmap} 26497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 26597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public Builder setCloseButtonIcon(@NonNull Bitmap icon) { 26697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize mIntent.putExtra(EXTRA_CLOSE_BUTTON_ICON, icon); 26797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize return this; 26897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 26997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 27097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 27197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Sets whether the title should be shown in the custom tab. 27297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 27397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param showTitle Whether the title should be shown. 27497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 27597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public Builder setShowTitle(boolean showTitle) { 27697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize mIntent.putExtra(EXTRA_TITLE_VISIBILITY_STATE, 27797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize showTitle ? SHOW_PAGE_TITLE : NO_TITLE); 27897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize return this; 27997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 28097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 28197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 28297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Adds a menu item. 28397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 28497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param label Menu label. 28597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param pendingIntent Pending intent delivered when the menu item is clicked. 28697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 28797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public Builder addMenuItem(@NonNull String label, @NonNull PendingIntent pendingIntent) { 28897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize if (mMenuItems == null) mMenuItems = new ArrayList<>(); 28997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize Bundle bundle = new Bundle(); 29097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize bundle.putString(KEY_MENU_ITEM_TITLE, label); 29197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize bundle.putParcelable(KEY_PENDING_INTENT, pendingIntent); 29297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize mMenuItems.add(bundle); 29397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize return this; 29497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 29597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 29697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 2978b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal * Adds a default share item to the menu. 2988b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal */ 2998b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal public Builder addDefaultShareMenuItem() { 3008b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal mIntent.putExtra(EXTRA_DEFAULT_SHARE_MENU_ITEM, true); 3018b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal return this; 3028b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal } 3038b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal 3048b26db5521378d84391e4ac4c932ca39d1ac83e1Yusuf Ozuysal /** 305179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * Set the action button that is displayed in the Toolbar. 306179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * <p> 307179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * This is equivalent to calling 308179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * {@link CustomTabsIntent.Builder#addActionBarItem(int, Bitmap, String, PendingIntent)} 309179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * with {@link #TOOLBAR_ACTION_BUTTON_ID} as id. 31097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 31197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param icon The icon. 3128a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal * @param description The description for the button. To be used for accessibility. 31397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param pendingIntent pending intent delivered when the button is clicked. 3149440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal * @param shouldTint Whether the action button should be tinted. 315179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * 316179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * @see CustomTabsIntent.Builder#addActionBarItem(int, Bitmap, String, PendingIntent) 31797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 3189440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal public Builder setActionButton(@NonNull Bitmap icon, @NonNull String description, 3199440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal @NonNull PendingIntent pendingIntent, boolean shouldTint) { 32097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize Bundle bundle = new Bundle(); 321179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal bundle.putInt(KEY_ID, TOOLBAR_ACTION_BUTTON_ID); 32297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize bundle.putParcelable(KEY_ICON, icon); 3238a1ccd14081000d6501622de72a16da67c33030cYusuf Ozuysal bundle.putString(KEY_DESCRIPTION, description); 32497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize bundle.putParcelable(KEY_PENDING_INTENT, pendingIntent); 32597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize mIntent.putExtra(EXTRA_ACTION_BUTTON_BUNDLE, bundle); 3269440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal mIntent.putExtra(EXTRA_TINT_ACTION_BUTTON, shouldTint); 32797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize return this; 32897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 32997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 33097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 331179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * Sets the action button that is displayed in the Toolbar with default tinting behavior. 332179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * 333179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * @see {@link CustomTabsIntent.Builder#setActionButton( 3349440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal * Bitmap, String, PendingIntent, boolean)} 3359440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal */ 3369440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal public Builder setActionButton(@NonNull Bitmap icon, @NonNull String description, 3379440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal @NonNull PendingIntent pendingIntent) { 3389440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal return setActionButton(icon, description, pendingIntent, false); 3399440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal } 3409440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal 3419440f0b000fc2740382eb4ae5f1afec58c245c2cYusuf Ozuysal /** 342179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * Adds an action button to the custom tab. Multiple buttons can be added via this method. 343179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * If the given id equals {@link #TOOLBAR_ACTION_BUTTON_ID}, the button will be placed on 344179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * the toolbar; if the bitmap is too wide, it will be put to the bottom bar instead. If 345179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * the id is not {@link #TOOLBAR_ACTION_BUTTON_ID}, it will be directly put on bottom bar. 346179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * The maximum number of allowed action bar items is 5. Throws an 347179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * {@link IllegalStateException} when that number is exceeded. 348179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * 349179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * @param id The unique id of the action button. This should be non-negative. 350179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * @param icon The icon. 351179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * @param description The description for the button. To be used for accessibility. 352179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * @param pendingIntent The pending intent delivered when the button is clicked. 353179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * 354179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * @see CustomTabsIntent#getMaxActionBarItems(). 355179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal */ 356179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal public Builder addActionBarItem(int id, @NonNull Bitmap icon, @NonNull String description, 357179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal PendingIntent pendingIntent) throws IllegalStateException { 358179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal if (mActionButtons == null) { 359179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal mActionButtons = new ArrayList<>(); 360179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal } 361179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal if (mActionButtons.size() >= MAX_ACTION_BAR_ITEMS) { 362179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal throw new IllegalStateException( 363179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal "Exceeded maximum action bar item count of " + MAX_ACTION_BAR_ITEMS); 364179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal } 365179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal Bundle bundle = new Bundle(); 366179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal bundle.putInt(KEY_ID, id); 367179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal bundle.putParcelable(KEY_ICON, icon); 368179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal bundle.putString(KEY_DESCRIPTION, description); 369179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal bundle.putParcelable(KEY_PENDING_INTENT, pendingIntent); 370179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal mActionButtons.add(bundle); 371179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal return this; 372179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal } 373179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal 374179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal /** 37564694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal * Sets the color of the secondary action bar. 37664694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal * @param color The color for the secondary action bar. 37764694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal */ 37864694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal public Builder setSecondaryActionBarColor(@ColorInt int color) { 37964694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal mIntent.putExtra(EXTRA_CUSTOM_ACTION_BAR_COLOR, color); 38064694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal return this; 38164694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal } 38264694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal 38364694064caedb59afda4ef69b04feaee12c0a33fYusuf Ozuysal /** 38497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Sets the start animations, 38597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 38697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param context Application context. 38797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param enterResId Resource ID of the "enter" animation for the browser. 38897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param exitResId Resource ID of the "exit" animation for the application. 38997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 39097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public Builder setStartAnimations( 39197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize @NonNull Context context, @AnimRes int enterResId, @AnimRes int exitResId) { 3921b7158bbc0d0ba4569881f547d12f52e405e125eIan Lake mStartAnimationBundle = ActivityOptionsCompat.makeCustomAnimation( 3931b7158bbc0d0ba4569881f547d12f52e405e125eIan Lake context, enterResId, exitResId).toBundle(); 39497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize return this; 39597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 39697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 39797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 39897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Sets the exit animations, 39997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * 40097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param context Application context. 40197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param enterResId Resource ID of the "enter" animation for the application. 40297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * @param exitResId Resource ID of the "exit" animation for the browser. 40397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 40497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public Builder setExitAnimations( 40597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize @NonNull Context context, @AnimRes int enterResId, @AnimRes int exitResId) { 4061b7158bbc0d0ba4569881f547d12f52e405e125eIan Lake Bundle bundle = ActivityOptionsCompat.makeCustomAnimation( 4071b7158bbc0d0ba4569881f547d12f52e405e125eIan Lake context, enterResId, exitResId).toBundle(); 40897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize mIntent.putExtra(EXTRA_EXIT_ANIMATION_BUNDLE, bundle); 40997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize return this; 41097ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 41197ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize 41297ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize /** 41397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * Combines all the options that have been set and returns a new {@link CustomTabsIntent} 41497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize * object. 41597ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize */ 41697ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize public CustomTabsIntent build() { 41797ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize if (mMenuItems != null) { 41897ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize mIntent.putParcelableArrayListExtra(CustomTabsIntent.EXTRA_MENU_ITEMS, mMenuItems); 41997ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 420179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal if (mActionButtons != null) { 421179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal mIntent.putParcelableArrayListExtra(EXTRA_ACTION_BAR_ITEMS, mActionButtons); 422179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal } 42397ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize return new CustomTabsIntent(mIntent, mStartAnimationBundle); 42497ee4f3f353309991efd3ceca369548b485e9a5fBenoit Lize } 42508889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal } 426179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal 427179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal /** 428179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal * @return The maximum number of allowed action bar items. 429179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal */ 430179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal public static int getMaxActionBarItems() { 431179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal return MAX_ACTION_BAR_ITEMS; 432179ab306d366df2ac610dd8c72bf19a5a8887970Yusuf Ozuysal } 43308889acbc842c73b64f94a761910154d9d42ee4cYusuf Ozuysal} 434