diff options
| author | Steve Kondik <steve@cyngn.com> | 2016-03-10 19:23:13 -0800 |
|---|---|---|
| committer | Steve Kondik <steve@cyngn.com> | 2016-03-10 19:23:13 -0800 |
| commit | 98e06d73262bc654d546ef2ded2cd6c4db5b92bf (patch) | |
| tree | d923c571c21849bf53185b26e3570fdb25fabff9 /customtabs | |
| parent | 6f0a2cb4415e2e170528c038a8f1cc2f68f60c3c (diff) | |
| parent | 4097efdd93078034122f17442d5b4df675d1028a (diff) | |
| download | android_frameworks_support-98e06d73262bc654d546ef2ded2cd6c4db5b92bf.tar.gz android_frameworks_support-98e06d73262bc654d546ef2ded2cd6c4db5b92bf.tar.bz2 android_frameworks_support-98e06d73262bc654d546ef2ded2cd6c4db5b92bf.zip | |
Merge tag 'android-6.0.1_r22' of https://android.googlesource.com/platform/frameworks/support into cm-13.0staging/cm-13.0+r22
Android 6.0.1 release 22
Change-Id: I032842dcd2a5a216a56a47a7cb109f0cee8ac251
Diffstat (limited to 'customtabs')
| -rw-r--r-- | customtabs/api/23.0.0.txt (renamed from customtabs/api/23.txt) | 0 | ||||
| -rw-r--r-- | customtabs/api/23.1.0.txt | 88 | ||||
| -rw-r--r-- | customtabs/api/current.txt | 8 | ||||
| -rw-r--r-- | customtabs/src/android/support/customtabs/CustomTabsCallback.java | 10 | ||||
| -rw-r--r-- | customtabs/src/android/support/customtabs/CustomTabsIntent.java | 36 | ||||
| -rw-r--r-- | customtabs/src/android/support/customtabs/CustomTabsService.java | 19 | ||||
| -rw-r--r-- | customtabs/src/android/support/customtabs/CustomTabsSession.java | 25 | ||||
| -rw-r--r-- | customtabs/src/android/support/customtabs/ICustomTabsService.aidl | 1 |
8 files changed, 183 insertions, 4 deletions
diff --git a/customtabs/api/23.txt b/customtabs/api/23.0.0.txt index 0e1745d183..0e1745d183 100644 --- a/customtabs/api/23.txt +++ b/customtabs/api/23.0.0.txt diff --git a/customtabs/api/23.1.0.txt b/customtabs/api/23.1.0.txt new file mode 100644 index 0000000000..caa5ea4b68 --- /dev/null +++ b/customtabs/api/23.1.0.txt @@ -0,0 +1,88 @@ +package android.support.customtabs { + + public class CustomTabsCallback { + ctor public CustomTabsCallback(); + method public void extraCallback(java.lang.String, android.os.Bundle); + method public void onNavigationEvent(int, android.os.Bundle); + field public static final int NAVIGATION_ABORTED = 4; // 0x4 + field public static final int NAVIGATION_FAILED = 3; // 0x3 + field public static final int NAVIGATION_FINISHED = 2; // 0x2 + field public static final int NAVIGATION_STARTED = 1; // 0x1 + field public static final int TAB_HIDDEN = 6; // 0x6 + field public static final int TAB_SHOWN = 5; // 0x5 + } + + public class CustomTabsClient { + method public static boolean bindCustomTabsService(android.content.Context, java.lang.String, android.support.customtabs.CustomTabsServiceConnection); + method public android.os.Bundle extraCommand(java.lang.String, android.os.Bundle); + method public android.support.customtabs.CustomTabsSession newSession(android.support.customtabs.CustomTabsCallback); + method public boolean warmup(long); + } + + public final class CustomTabsIntent { + method public void launchUrl(android.app.Activity, android.net.Uri); + field public static final java.lang.String EXTRA_ACTION_BUTTON_BUNDLE = "android.support.customtabs.extra.ACTION_BUTTON_BUNDLE"; + field public static final java.lang.String EXTRA_CLOSE_BUTTON_ICON = "android.support.customtabs.extra.CLOSE_BUTTON_ICON"; + field public static final java.lang.String EXTRA_ENABLE_URLBAR_HIDING = "android.support.customtabs.extra.ENABLE_URLBAR_HIDING"; + field public static final java.lang.String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE"; + field public static final java.lang.String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS"; + field public static final java.lang.String EXTRA_SESSION = "android.support.customtabs.extra.SESSION"; + field public static final java.lang.String EXTRA_TINT_ACTION_BUTTON = "android.support.customtabs.extra.TINT_ACTION_BUTTON"; + field public static final java.lang.String EXTRA_TITLE_VISIBILITY_STATE = "android.support.customtabs.extra.TITLE_VISIBILITY"; + field public static final java.lang.String EXTRA_TOOLBAR_COLOR = "android.support.customtabs.extra.TOOLBAR_COLOR"; + field public static final java.lang.String KEY_DESCRIPTION = "android.support.customtabs.customaction.DESCRIPTION"; + field public static final java.lang.String KEY_ICON = "android.support.customtabs.customaction.ICON"; + field public static final java.lang.String KEY_MENU_ITEM_TITLE = "android.support.customtabs.customaction.MENU_ITEM_TITLE"; + field public static final java.lang.String KEY_PENDING_INTENT = "android.support.customtabs.customaction.PENDING_INTENT"; + field public static final int NO_TITLE = 0; // 0x0 + field public static final int SHOW_PAGE_TITLE = 1; // 0x1 + field public final android.content.Intent intent; + field public final android.os.Bundle startAnimationBundle; + } + + public static final class CustomTabsIntent.Builder { + ctor public CustomTabsIntent.Builder(); + ctor public CustomTabsIntent.Builder(android.support.customtabs.CustomTabsSession); + method public android.support.customtabs.CustomTabsIntent.Builder addMenuItem(java.lang.String, android.app.PendingIntent); + method public android.support.customtabs.CustomTabsIntent build(); + method public android.support.customtabs.CustomTabsIntent.Builder enableUrlBarHiding(); + method public android.support.customtabs.CustomTabsIntent.Builder setActionButton(android.graphics.Bitmap, java.lang.String, android.app.PendingIntent, boolean); + method public android.support.customtabs.CustomTabsIntent.Builder setActionButton(android.graphics.Bitmap, java.lang.String, android.app.PendingIntent); + method public android.support.customtabs.CustomTabsIntent.Builder setCloseButtonIcon(android.graphics.Bitmap); + method public android.support.customtabs.CustomTabsIntent.Builder setExitAnimations(android.content.Context, int, int); + method public android.support.customtabs.CustomTabsIntent.Builder setShowTitle(boolean); + method public android.support.customtabs.CustomTabsIntent.Builder setStartAnimations(android.content.Context, int, int); + method public android.support.customtabs.CustomTabsIntent.Builder setToolbarColor(int); + } + + public abstract class CustomTabsService extends android.app.Service { + ctor public CustomTabsService(); + method protected boolean cleanUpSession(android.support.customtabs.CustomTabsSessionToken); + method protected abstract android.os.Bundle extraCommand(java.lang.String, android.os.Bundle); + method protected abstract boolean mayLaunchUrl(android.support.customtabs.CustomTabsSessionToken, android.net.Uri, android.os.Bundle, java.util.List<android.os.Bundle>); + method protected abstract boolean newSession(android.support.customtabs.CustomTabsSessionToken); + method public android.os.IBinder onBind(android.content.Intent); + method protected abstract boolean updateVisuals(android.support.customtabs.CustomTabsSessionToken, android.os.Bundle); + method protected abstract boolean warmup(long); + field public static final java.lang.String ACTION_CUSTOM_TABS_CONNECTION = "android.support.customtabs.action.CustomTabsService"; + field public static final java.lang.String KEY_URL = "android.support.customtabs.otherurls.URL"; + } + + public abstract class CustomTabsServiceConnection implements android.content.ServiceConnection { + ctor public CustomTabsServiceConnection(); + method public abstract void onCustomTabsServiceConnected(android.content.ComponentName, android.support.customtabs.CustomTabsClient); + method public final void onServiceConnected(android.content.ComponentName, android.os.IBinder); + } + + public final class CustomTabsSession { + method public boolean mayLaunchUrl(android.net.Uri, android.os.Bundle, java.util.List<android.os.Bundle>); + method public boolean setActionButton(android.graphics.Bitmap, java.lang.String); + } + + public class CustomTabsSessionToken { + method public android.support.customtabs.CustomTabsCallback getCallback(); + method public static android.support.customtabs.CustomTabsSessionToken getSessionTokenFromIntent(android.content.Intent); + } + +} + diff --git a/customtabs/api/current.txt b/customtabs/api/current.txt index b66c71e732..caa5ea4b68 100644 --- a/customtabs/api/current.txt +++ b/customtabs/api/current.txt @@ -8,6 +8,8 @@ package android.support.customtabs { field public static final int NAVIGATION_FAILED = 3; // 0x3 field public static final int NAVIGATION_FINISHED = 2; // 0x2 field public static final int NAVIGATION_STARTED = 1; // 0x1 + field public static final int TAB_HIDDEN = 6; // 0x6 + field public static final int TAB_SHOWN = 5; // 0x5 } public class CustomTabsClient { @@ -21,9 +23,11 @@ package android.support.customtabs { method public void launchUrl(android.app.Activity, android.net.Uri); field public static final java.lang.String EXTRA_ACTION_BUTTON_BUNDLE = "android.support.customtabs.extra.ACTION_BUTTON_BUNDLE"; field public static final java.lang.String EXTRA_CLOSE_BUTTON_ICON = "android.support.customtabs.extra.CLOSE_BUTTON_ICON"; + field public static final java.lang.String EXTRA_ENABLE_URLBAR_HIDING = "android.support.customtabs.extra.ENABLE_URLBAR_HIDING"; field public static final java.lang.String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE"; field public static final java.lang.String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS"; field public static final java.lang.String EXTRA_SESSION = "android.support.customtabs.extra.SESSION"; + field public static final java.lang.String EXTRA_TINT_ACTION_BUTTON = "android.support.customtabs.extra.TINT_ACTION_BUTTON"; field public static final java.lang.String EXTRA_TITLE_VISIBILITY_STATE = "android.support.customtabs.extra.TITLE_VISIBILITY"; field public static final java.lang.String EXTRA_TOOLBAR_COLOR = "android.support.customtabs.extra.TOOLBAR_COLOR"; field public static final java.lang.String KEY_DESCRIPTION = "android.support.customtabs.customaction.DESCRIPTION"; @@ -41,6 +45,8 @@ package android.support.customtabs { ctor public CustomTabsIntent.Builder(android.support.customtabs.CustomTabsSession); method public android.support.customtabs.CustomTabsIntent.Builder addMenuItem(java.lang.String, android.app.PendingIntent); method public android.support.customtabs.CustomTabsIntent build(); + method public android.support.customtabs.CustomTabsIntent.Builder enableUrlBarHiding(); + method public android.support.customtabs.CustomTabsIntent.Builder setActionButton(android.graphics.Bitmap, java.lang.String, android.app.PendingIntent, boolean); method public android.support.customtabs.CustomTabsIntent.Builder setActionButton(android.graphics.Bitmap, java.lang.String, android.app.PendingIntent); method public android.support.customtabs.CustomTabsIntent.Builder setCloseButtonIcon(android.graphics.Bitmap); method public android.support.customtabs.CustomTabsIntent.Builder setExitAnimations(android.content.Context, int, int); @@ -56,6 +62,7 @@ package android.support.customtabs { method protected abstract boolean mayLaunchUrl(android.support.customtabs.CustomTabsSessionToken, android.net.Uri, android.os.Bundle, java.util.List<android.os.Bundle>); method protected abstract boolean newSession(android.support.customtabs.CustomTabsSessionToken); method public android.os.IBinder onBind(android.content.Intent); + method protected abstract boolean updateVisuals(android.support.customtabs.CustomTabsSessionToken, android.os.Bundle); method protected abstract boolean warmup(long); field public static final java.lang.String ACTION_CUSTOM_TABS_CONNECTION = "android.support.customtabs.action.CustomTabsService"; field public static final java.lang.String KEY_URL = "android.support.customtabs.otherurls.URL"; @@ -69,6 +76,7 @@ package android.support.customtabs { public final class CustomTabsSession { method public boolean mayLaunchUrl(android.net.Uri, android.os.Bundle, java.util.List<android.os.Bundle>); + method public boolean setActionButton(android.graphics.Bitmap, java.lang.String); } public class CustomTabsSessionToken { diff --git a/customtabs/src/android/support/customtabs/CustomTabsCallback.java b/customtabs/src/android/support/customtabs/CustomTabsCallback.java index ea5f3e3edc..d7fdd3988d 100644 --- a/customtabs/src/android/support/customtabs/CustomTabsCallback.java +++ b/customtabs/src/android/support/customtabs/CustomTabsCallback.java @@ -44,6 +44,16 @@ public class CustomTabsCallback { public static final int NAVIGATION_ABORTED = 4; /** + * Sent when the tab becomes visible. + */ + public static final int TAB_SHOWN = 5; + + /** + * Sent when the tab becomes hidden. + */ + public static final int TAB_HIDDEN = 6; + + /** * To be called when a navigation event happens. * * @param navigationEvent The code corresponding to the navigation event. diff --git a/customtabs/src/android/support/customtabs/CustomTabsIntent.java b/customtabs/src/android/support/customtabs/CustomTabsIntent.java index 2276f94897..ab3685f8b2 100644 --- a/customtabs/src/android/support/customtabs/CustomTabsIntent.java +++ b/customtabs/src/android/support/customtabs/CustomTabsIntent.java @@ -57,6 +57,12 @@ public final class CustomTabsIntent { "android.support.customtabs.extra.TOOLBAR_COLOR"; /** + * Boolean extra that enables the url bar to hide as the user scrolls down the page + */ + public static final String EXTRA_ENABLE_URLBAR_HIDING = + "android.support.customtabs.extra.ENABLE_URLBAR_HIDING"; + + /** * Extra bitmap that specifies the icon of the back button on the toolbar. If the client chooses * not to customize it, a default close button will be used. */ @@ -109,6 +115,13 @@ public final class CustomTabsIntent { "android.support.customtabs.customaction.PENDING_INTENT"; /** + * Extra boolean that specifies whether the custom action button should be tinted. Default is + * false and the action button will not be tinted. + */ + public static final String EXTRA_TINT_ACTION_BUTTON = + "android.support.customtabs.extra.TINT_ACTION_BUTTON"; + + /** * Use an {@code ArrayList<Bundle>} for specifying menu related params. There should be a * separate {@link Bundle} for each custom menu item. */ @@ -202,6 +215,14 @@ public final class CustomTabsIntent { } /** + * Enables the url bar to hide as the user scrolls down on the page. + */ + public Builder enableUrlBarHiding() { + mIntent.putExtra(EXTRA_ENABLE_URLBAR_HIDING, true); + return this; + } + + /** * Sets the Close button icon for the custom tab. * * @param icon The icon {@link Bitmap} @@ -243,18 +264,29 @@ public final class CustomTabsIntent { * @param icon The icon. * @param description The description for the button. To be used for accessibility. * @param pendingIntent pending intent delivered when the button is clicked. + * @param shouldTint Whether the action button should be tinted. */ - public Builder setActionButton(@NonNull Bitmap icon, - @NonNull String description, @NonNull PendingIntent pendingIntent) { + public Builder setActionButton(@NonNull Bitmap icon, @NonNull String description, + @NonNull PendingIntent pendingIntent, boolean shouldTint) { Bundle bundle = new Bundle(); bundle.putParcelable(KEY_ICON, icon); bundle.putString(KEY_DESCRIPTION, description); bundle.putParcelable(KEY_PENDING_INTENT, pendingIntent); mIntent.putExtra(EXTRA_ACTION_BUTTON_BUNDLE, bundle); + mIntent.putExtra(EXTRA_TINT_ACTION_BUTTON, shouldTint); return this; } /** + * See {@link CustomTabsIntent.Builder#setActionButton( + * Bitmap, String, PendingIntent, boolean)} + */ + public Builder setActionButton(@NonNull Bitmap icon, @NonNull String description, + @NonNull PendingIntent pendingIntent) { + return setActionButton(icon, description, pendingIntent, false); + } + + /** * Sets the start animations, * * @param context Application context. diff --git a/customtabs/src/android/support/customtabs/CustomTabsService.java b/customtabs/src/android/support/customtabs/CustomTabsService.java index 37f1a60e43..25697c5e3b 100644 --- a/customtabs/src/android/support/customtabs/CustomTabsService.java +++ b/customtabs/src/android/support/customtabs/CustomTabsService.java @@ -50,7 +50,7 @@ import java.util.NoSuchElementException; public static final String KEY_URL = "android.support.customtabs.otherurls.URL"; - private Map<IBinder, DeathRecipient> mDeathRecipientMap = new ArrayMap<>(); + private final Map<IBinder, DeathRecipient> mDeathRecipientMap = new ArrayMap<>(); private ICustomTabsService.Stub mBinder = new ICustomTabsService.Stub() { @@ -90,6 +90,12 @@ import java.util.NoSuchElementException; public Bundle extraCommand(String commandName, Bundle args) { return CustomTabsService.this.extraCommand(commandName, args); } + + @Override + public boolean updateVisuals(ICustomTabsCallback callback, Bundle bundle) { + return CustomTabsService.this.updateVisuals( + new CustomTabsSessionToken(callback), bundle); + } }; @Override @@ -176,4 +182,15 @@ import java.util.NoSuchElementException; * @return The result {@link Bundle}, or null. */ protected abstract Bundle extraCommand(String commandName, Bundle args); + + /** + * Updates the visuals of custom tabs for the given session. Will only succeed if the given + * session matches the currently active one. + * @param sessionToken The currently active session that the custom tab belongs to. + * @param bundle The action button configuration bundle. This bundle should be constructed + * with the same structure in {@link CustomTabsIntent.Builder}. + * @return Whether the operation was successful. + */ + protected abstract boolean updateVisuals(CustomTabsSessionToken sessionToken, + Bundle bundle); } diff --git a/customtabs/src/android/support/customtabs/CustomTabsSession.java b/customtabs/src/android/support/customtabs/CustomTabsSession.java index ee45b7c7ce..a51cf0ea1e 100644 --- a/customtabs/src/android/support/customtabs/CustomTabsSession.java +++ b/customtabs/src/android/support/customtabs/CustomTabsSession.java @@ -17,10 +17,12 @@ package android.support.customtabs; import android.content.ComponentName; +import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; +import android.support.annotation.NonNull; import java.util.List; @@ -65,6 +67,27 @@ public final class CustomTabsSession { } } + /** + * Update the visuals for the button on a custom tab. Will only succeed if the given + * session is the active one in browser. + * @param icon The new icon of the action button. + * @param description Content description of the action button. + * @return Whether the update succeeded. + */ + public boolean setActionButton(@NonNull Bitmap icon, @NonNull String description) { + Bundle bundle = new Bundle(); + bundle.putParcelable(CustomTabsIntent.KEY_ICON, icon); + bundle.putString(CustomTabsIntent.KEY_DESCRIPTION, description); + + Bundle metaBundle = new Bundle(); + metaBundle.putBundle(CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE, bundle); + try { + return mService.updateVisuals(mCallback, metaBundle); + } catch (RemoteException e) { + return false; + } + } + /* package */ IBinder getBinder() { return mCallback.asBinder(); } @@ -72,4 +95,4 @@ public final class CustomTabsSession { /* package */ ComponentName getComponentName() { return mComponentName; } -}
\ No newline at end of file +} diff --git a/customtabs/src/android/support/customtabs/ICustomTabsService.aidl b/customtabs/src/android/support/customtabs/ICustomTabsService.aidl index 2565928880..e53ca84e23 100644 --- a/customtabs/src/android/support/customtabs/ICustomTabsService.aidl +++ b/customtabs/src/android/support/customtabs/ICustomTabsService.aidl @@ -32,4 +32,5 @@ interface ICustomTabsService { boolean mayLaunchUrl(in ICustomTabsCallback callback, in Uri url, in Bundle extras, in List<Bundle> otherLikelyBundles) = 3; Bundle extraCommand(String commandName, in Bundle args) = 4; + boolean updateVisuals(in ICustomTabsCallback callback, in Bundle bundle) = 5; } |
