Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8478e5a authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

All Apps Search API council feedback (second round)

Bug: 186756959
Test: atest CtsSearchUiServiceTestCases
Change-Id: I0c83d79ede8801f71c89e71cc6ec2c73b2d8bfcd
parent 666d4451
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1528,6 +1528,9 @@ package android.app.search {
    method public boolean shouldHide();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.search.SearchTarget> CREATOR;
    field public static final String LAYOUT_TYPE_ICON = "icon";
    field public static final String LAYOUT_TYPE_ICON_ROW = "icon_row";
    field public static final String LAYOUT_TYPE_SHORT_ICON_ROW = "short_icon_row";
    field public static final int RESULT_TYPE_APPLICATION = 1; // 0x1
    field public static final int RESULT_TYPE_SHORTCUT = 2; // 0x2
    field public static final int RESULT_TYPE_SLICE = 4; // 0x4
@@ -1541,7 +1544,7 @@ package android.app.search {
    method @NonNull public android.app.search.SearchTarget.Builder setExtras(@NonNull android.os.Bundle);
    method @NonNull public android.app.search.SearchTarget.Builder setPackageName(@NonNull String);
    method @NonNull public android.app.search.SearchTarget.Builder setParentId(@NonNull String);
    method @NonNull public android.app.search.SearchTarget.Builder setScore(float);
    method @NonNull public android.app.search.SearchTarget.Builder setScore(@FloatRange(from=0.0f, to=1.0f) float);
    method @NonNull public android.app.search.SearchTarget.Builder setSearchAction(@Nullable android.app.search.SearchAction);
    method @NonNull public android.app.search.SearchTarget.Builder setShortcutInfo(@NonNull android.content.pm.ShortcutInfo);
    method @NonNull public android.app.search.SearchTarget.Builder setShouldHide(boolean);
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public final class SearchContext implements Parcelable {
     * @param resultTypes {@link SearchTarget.SearchResultType}s combined using bit OR operation
     * @param timeoutMillis timeout before client renders its own fallback result
     */
    public SearchContext(int resultTypes, int timeoutMillis) {
    public SearchContext(@SearchTarget.SearchResultType int resultTypes, int timeoutMillis) {
        this(resultTypes, timeoutMillis, new Bundle());
    }

+35 −4
Original line number Diff line number Diff line
@@ -15,9 +15,11 @@
 */
package android.app.search;

import android.annotation.FloatRange;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringDef;
import android.annotation.SystemApi;
import android.app.slice.SliceManager;
import android.appwidget.AppWidgetProviderInfo;
@@ -66,6 +68,24 @@ public final class SearchTarget implements Parcelable {
    public static final int RESULT_TYPE_SHORTCUT = 1 << 1;
    public static final int RESULT_TYPE_SLICE = 1 << 2;
    public static final int RESULT_TYPE_WIDGETS = 1 << 3;

    //     ------
    //    | icon |
    //     ------
    //      text
    public static final String LAYOUT_TYPE_ICON = "icon";

    //     ------                            ------   ------
    //    |      | title                    |(opt)|  |(opt)|
    //    | icon | subtitle (optional)      | icon|  | icon|
    //     ------                            ------  ------
    public static final String LAYOUT_TYPE_ICON_ROW = "icon_row";

    //     ------
    //    | icon | title / subtitle (optional)
    //     ------
    public static final String LAYOUT_TYPE_SHORT_ICON_ROW = "short_icon_row";

    /**
     * @hide
     */
@@ -79,6 +99,17 @@ public final class SearchTarget implements Parcelable {
    public @interface SearchResultType {}
    private final int mResultType;

    /**
     * @hide
     */
    @StringDef(prefix = {"LAYOUT_TYPE_"}, value = {
            LAYOUT_TYPE_ICON,
            LAYOUT_TYPE_ICON_ROW,
            LAYOUT_TYPE_SHORT_ICON_ROW,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SearchLayoutType {}

    /**
     * Constant to express how the group of {@link SearchTarget} should be rendered on
     * the client side. (e.g., "icon", "icon_row", "short_icon_row")
@@ -178,7 +209,7 @@ public final class SearchTarget implements Parcelable {
     * Retrieves the layout type.
     */
    @NonNull
    public String getLayoutType() {
    public @SearchLayoutType String getLayoutType() {
        return mLayoutType;
    }

@@ -337,7 +368,7 @@ public final class SearchTarget implements Parcelable {
        private Bundle mExtras;

        public Builder(@SearchResultType int resultType,
                @NonNull String layoutType,
                @SearchLayoutType @NonNull String layoutType,
                @NonNull String id) {
            mId = id;
            mLayoutType = Objects.requireNonNull(layoutType);
@@ -433,13 +464,13 @@ public final class SearchTarget implements Parcelable {
         * Sets the score of the object.
         */
        @NonNull
        public Builder setScore(float score) {
        public Builder setScore(@FloatRange(from = 0.0f, to = 1.0f) float score) {
            mScore = score;
            return this;
        }

        /**
         * Sets whether the result should be hidden by default inside client.
         * Sets whether the result should be hidden (e.g. not visible) by default inside client.
         */
        @NonNull
        public Builder setShouldHide(boolean shouldHide) {