Loading core/api/current.txt +2 −1 Original line number Diff line number Diff line Loading @@ -42018,11 +42018,12 @@ package android.service.chooser { @FlaggedApi("android.service.chooser.interactive_chooser") public final class ChooserSession { method public void addStateListener(@NonNull java.util.concurrent.Executor, @NonNull android.service.chooser.ChooserSession.StateListener); method public void close(); method public void endSession(); method @Nullable public android.graphics.Rect getBounds(); method public int getState(); method @NonNull public android.service.chooser.ChooserSessionToken getToken(); method public void removeStateListener(@NonNull android.service.chooser.ChooserSession.StateListener); method public void setMinimized(boolean); method public void setTargetsEnabled(boolean); method public void updateIntent(@NonNull android.content.Intent); field public static final int STATE_CLOSED = 2; // 0x2 core/java/android/service/chooser/ChooserManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ import java.util.Objects; * <h3>Usage Example:</h3> * <pre>{@code * ChooserManager chooserManager = context.getSystemService(ChooserManager.class); * if (chooserManager == null) { * // handle the case when the interactive chooser session functionality is not supported. * } * * // Construct the sharing intent * Intent targetIntent = new Intent(Intent.ACTION_SEND); Loading core/java/android/service/chooser/ChooserSession.java +27 −23 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.content.Intent; import android.graphics.Rect; import android.os.Binder; Loading Loading @@ -51,7 +50,6 @@ import java.util.function.Consumer; * @see ChooserManager */ @FlaggedApi(Flags.FLAG_INTERACTIVE_CHOOSER) @SuppressLint("NotCloseable") public final class ChooserSession { /** * @hide Loading Loading @@ -133,25 +131,28 @@ public final class ChooserSession { /** * Terminates the session and closes Chooser. */ public void close() { public void endSession() { mChooserSession.close(); } /** * Updates chooser intent in a Chooser session. * <p>Updates to the following extras will be honored: * Updates the chooser intent in an active Chooser session, causing Chooser to refresh its state * and targets. * <p> * Only updates to the following extras in the provided intent are respected: * <ul> * <li> {@link Intent#EXTRA_INTENT} * <li> {@link Intent#EXTRA_EXCLUDE_COMPONENTS} * <li> {@link Intent#EXTRA_CHOOSER_TARGETS} * <li> {@link Intent#EXTRA_ALTERNATE_INTENTS} * <li> {@link Intent#EXTRA_REPLACEMENT_EXTRAS} * <li> {@link Intent#EXTRA_INITIAL_INTENTS} * <li> {@link Intent#EXTRA_CHOOSER_RESULT_INTENT_SENDER} * <li> {@link Intent#EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} * <li>{@link Intent#EXTRA_INTENT}</li> * <li>{@link Intent#EXTRA_EXCLUDE_COMPONENTS}</li> * <li>{@link Intent#EXTRA_CHOOSER_TARGETS}</li> * <li>{@link Intent#EXTRA_ALTERNATE_INTENTS}</li> * <li>{@link Intent#EXTRA_REPLACEMENT_EXTRAS}</li> * <li>{@link Intent#EXTRA_INITIAL_INTENTS}</li> * <li>{@link Intent#EXTRA_CHOOSER_RESULT_INTENT_SENDER}</li> * <li>{@link Intent#EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}</li> * </ul> * </p> * <p>A no-op when the session is not in the {@link #STATE_STARTED}.</p> * This method is a no-op if the session is not in the {@link #STATE_STARTED} state. * * @param intent The new intent to apply to the session. */ public void updateIntent(@NonNull Intent intent) { Objects.requireNonNull(intent, "intent should not be null"); Loading @@ -166,14 +167,17 @@ public final class ChooserSession { } /** * Collapses Chooser to temporary yield more screen space for the app. * Chooser will stay collapsed until its first user interaction. * <p>A no-op when the session is not in the {@link #STATE_STARTED}.</p> * Sets the minimized state of the Chooser UI. * <p> * Passing {@code true} requests that the Chooser minimize to its smallest footprint * to yield screen space for the calling application. This state is temporary and can be * overridden by any direct user interaction with the Chooser (e.g., dragging the share sheet). * * @hide * @param isMinimized {@code true} to request that the Chooser be minimized; * {@code false} to restore it to its standard layout. */ public void collapse() { mChooserSession.collapse(); public void setMinimized(boolean isMinimized) { mChooserSession.setMinimized(isMinimized); } /** Loading Loading @@ -301,11 +305,11 @@ public final class ChooserSession { doClose(false); } public void collapse() { public void setMinimized(boolean isMinimized) { IChooserController controller = getChooserController(); if (controller != null) { try { controller.collapse(); controller.setMinimized(isMinimized); } catch (DeadObjectException e) { doClose(true); } catch (RemoteException e) { Loading core/java/android/service/chooser/IChooserController.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,6 @@ import android.content.Intent; /** {@hide} */ interface IChooserController { oneway void updateIntent(in Intent intent); oneway void collapse(); oneway void setMinimized(in boolean isMinimized); oneway void setTargetsEnabled(in boolean isEnabled); } core/tests/coretests/src/android/service/chooser/ChooserManagerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ class ChooserManagerTest { assertThat(testSubject.getSession(session.token)).isEqualTo(session) session.close() session.endSession() assertThat(testSubject.getSession(session.token)).isNull() } Loading Loading
core/api/current.txt +2 −1 Original line number Diff line number Diff line Loading @@ -42018,11 +42018,12 @@ package android.service.chooser { @FlaggedApi("android.service.chooser.interactive_chooser") public final class ChooserSession { method public void addStateListener(@NonNull java.util.concurrent.Executor, @NonNull android.service.chooser.ChooserSession.StateListener); method public void close(); method public void endSession(); method @Nullable public android.graphics.Rect getBounds(); method public int getState(); method @NonNull public android.service.chooser.ChooserSessionToken getToken(); method public void removeStateListener(@NonNull android.service.chooser.ChooserSession.StateListener); method public void setMinimized(boolean); method public void setTargetsEnabled(boolean); method public void updateIntent(@NonNull android.content.Intent); field public static final int STATE_CLOSED = 2; // 0x2
core/java/android/service/chooser/ChooserManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ import java.util.Objects; * <h3>Usage Example:</h3> * <pre>{@code * ChooserManager chooserManager = context.getSystemService(ChooserManager.class); * if (chooserManager == null) { * // handle the case when the interactive chooser session functionality is not supported. * } * * // Construct the sharing intent * Intent targetIntent = new Intent(Intent.ACTION_SEND); Loading
core/java/android/service/chooser/ChooserSession.java +27 −23 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.content.Intent; import android.graphics.Rect; import android.os.Binder; Loading Loading @@ -51,7 +50,6 @@ import java.util.function.Consumer; * @see ChooserManager */ @FlaggedApi(Flags.FLAG_INTERACTIVE_CHOOSER) @SuppressLint("NotCloseable") public final class ChooserSession { /** * @hide Loading Loading @@ -133,25 +131,28 @@ public final class ChooserSession { /** * Terminates the session and closes Chooser. */ public void close() { public void endSession() { mChooserSession.close(); } /** * Updates chooser intent in a Chooser session. * <p>Updates to the following extras will be honored: * Updates the chooser intent in an active Chooser session, causing Chooser to refresh its state * and targets. * <p> * Only updates to the following extras in the provided intent are respected: * <ul> * <li> {@link Intent#EXTRA_INTENT} * <li> {@link Intent#EXTRA_EXCLUDE_COMPONENTS} * <li> {@link Intent#EXTRA_CHOOSER_TARGETS} * <li> {@link Intent#EXTRA_ALTERNATE_INTENTS} * <li> {@link Intent#EXTRA_REPLACEMENT_EXTRAS} * <li> {@link Intent#EXTRA_INITIAL_INTENTS} * <li> {@link Intent#EXTRA_CHOOSER_RESULT_INTENT_SENDER} * <li> {@link Intent#EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} * <li>{@link Intent#EXTRA_INTENT}</li> * <li>{@link Intent#EXTRA_EXCLUDE_COMPONENTS}</li> * <li>{@link Intent#EXTRA_CHOOSER_TARGETS}</li> * <li>{@link Intent#EXTRA_ALTERNATE_INTENTS}</li> * <li>{@link Intent#EXTRA_REPLACEMENT_EXTRAS}</li> * <li>{@link Intent#EXTRA_INITIAL_INTENTS}</li> * <li>{@link Intent#EXTRA_CHOOSER_RESULT_INTENT_SENDER}</li> * <li>{@link Intent#EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}</li> * </ul> * </p> * <p>A no-op when the session is not in the {@link #STATE_STARTED}.</p> * This method is a no-op if the session is not in the {@link #STATE_STARTED} state. * * @param intent The new intent to apply to the session. */ public void updateIntent(@NonNull Intent intent) { Objects.requireNonNull(intent, "intent should not be null"); Loading @@ -166,14 +167,17 @@ public final class ChooserSession { } /** * Collapses Chooser to temporary yield more screen space for the app. * Chooser will stay collapsed until its first user interaction. * <p>A no-op when the session is not in the {@link #STATE_STARTED}.</p> * Sets the minimized state of the Chooser UI. * <p> * Passing {@code true} requests that the Chooser minimize to its smallest footprint * to yield screen space for the calling application. This state is temporary and can be * overridden by any direct user interaction with the Chooser (e.g., dragging the share sheet). * * @hide * @param isMinimized {@code true} to request that the Chooser be minimized; * {@code false} to restore it to its standard layout. */ public void collapse() { mChooserSession.collapse(); public void setMinimized(boolean isMinimized) { mChooserSession.setMinimized(isMinimized); } /** Loading Loading @@ -301,11 +305,11 @@ public final class ChooserSession { doClose(false); } public void collapse() { public void setMinimized(boolean isMinimized) { IChooserController controller = getChooserController(); if (controller != null) { try { controller.collapse(); controller.setMinimized(isMinimized); } catch (DeadObjectException e) { doClose(true); } catch (RemoteException e) { Loading
core/java/android/service/chooser/IChooserController.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,6 @@ import android.content.Intent; /** {@hide} */ interface IChooserController { oneway void updateIntent(in Intent intent); oneway void collapse(); oneway void setMinimized(in boolean isMinimized); oneway void setTargetsEnabled(in boolean isEnabled); }
core/tests/coretests/src/android/service/chooser/ChooserManagerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ class ChooserManagerTest { assertThat(testSubject.getSession(session.token)).isEqualTo(session) session.close() session.endSession() assertThat(testSubject.getSession(session.token)).isNull() } Loading