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

Commit 2c54385e authored by Brandon Dayauon's avatar Brandon Dayauon Committed by Android (Google) Code Review
Browse files

Merge "Add extras to know if SearchTarget is zero-state recent item" into tm-qpr-dev

parents 4bc82611 58188b73
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.app.search;

import android.app.search.Query;
import android.os.Bundle;

/**
 * Utility class used to define implicit contract between aiai and launcher regarding
@@ -37,4 +36,7 @@ public class QueryExtras {

    // This value overrides the timeout that is defined inside {@link SearchContext#getTimeout}
    public static final String EXTRAS_KEY_TIMEOUT_OVERRIDE = "timeout";

    // Used to know which target is deleted.
    public static final String EXTRAS_BUNDLE_DELETED_TARGET_ID = "deleted_target_id";
}
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.app.search.SearchActionExtras.BUNDLE_EXTRA_HIDE_SUBTIT
import static com.android.app.search.SearchTargetExtras.BUNDLE_EXTRA_CLASS;
import static com.android.app.search.SearchTargetExtras.BUNDLE_EXTRA_SUBTITLE_OVERRIDE;
import static com.android.app.search.SearchTargetExtras.BUNDLE_EXTRA_SUPPORT_QUERY_BUILDER;
import static com.android.app.search.SearchTargetExtras.EXTRAS_RECENT_BLOCK_TARGET;

import android.app.search.SearchAction;
import android.app.search.SearchTarget;
@@ -49,6 +50,7 @@ public class SearchTargetConverter {
        searchTargetBundle.putBoolean(BUNDLE_EXTRA_HIDE_SUBTITLE, false);
        searchTargetBundle.putString(BUNDLE_EXTRA_SUBTITLE_OVERRIDE, subtitle);
        searchTargetBundle.putBoolean(BUNDLE_EXTRA_HIDE_ICON, false);
        searchTargetBundle.putBoolean(EXTRAS_RECENT_BLOCK_TARGET, true);

        SearchTarget.Builder builder = new SearchTarget.Builder(resultType,
                SMALL_ICON_HORIZONTAL_TEXT, searchTarget.getId())
+15 −4
Original line number Diff line number Diff line
@@ -32,15 +32,15 @@ import androidx.annotation.Nullable;
public class SearchTargetExtras {

    /** on device data related extras and helper methods */
    // Used to extra component name
    // Used to extra component name.
    public static final String BUNDLE_EXTRA_CLASS = "class";

    // Used for UI treatment. Labels whether search target should support quick launch
    // Used for UI treatment. Labels whether search target should support quick launch.
    public static final String BUNDLE_EXTRA_QUICK_LAUNCH = "quick_launch";
    // Used for UI treatment. Targets grouped with same group id are decorated together.
    public static final String BUNDLE_EXTRA_GROUP_ID = "group_id";
    public static final String BUNDLE_EXTRA_GROUP_DECORATE_TOGETHER = "decorate_together";
    // Used if slice title should be rendered else where outside of slice (e.g., edit text)
    // Used if slice title should be rendered else where outside of slice (e.g., edit text).
    public static final String BUNDLE_EXTRA_SLICE_TITLE = "slice_title";
    // Used if slice view should be rendered using full height mode.
    public static final String BUNDLE_EXTRA_USE_FULL_HEIGHT = "use_full_height";
@@ -56,12 +56,15 @@ public class SearchTargetExtras {
    public static final String BUNDLE_EXTRA_RESULT_MATCH_USER_TYPED = "result_match_user_typed";
    // Used for logging. Returns the timestamp when system service received the data.
    public static final String BUNDLE_EXTRA_START_TIMESTAMP = "start_timestamp";
    // Indicates the search result app location column
    // Indicates the search result app location column.
    public static final String BUNDLE_EXTRA_RESULT_APP_GRIDX = "app_gridx";

    // Used for thumbnail loading. Contains handle to retrieve Blobstore asset.
    public static final String BUNDLE_EXTRA_BLOBSTORE_HANDLE = "blobstore_handle_key";

    // Used to denote this searchTarget is for recent block in 0-state.
    public static final String EXTRAS_RECENT_BLOCK_TARGET = "recent_block_target";

    public static final int GROUPING = 1 << 1;

    @Nullable
@@ -90,6 +93,14 @@ public class SearchTargetExtras {
                BUNDLE_EXTRA_BLOBSTORE_HANDLE) instanceof BlobHandle;
    }

    /** Check if SearchTarget contains information to tell if this target is from recent block. */
    public static boolean isSearchTargetRecentItem(@Nullable SearchTarget target) {
        if (isTargetOrExtrasNull(target)) {
            return false;
        }
        return target.getExtras().getBoolean(EXTRAS_RECENT_BLOCK_TARGET, false);
    }

    private static boolean isTargetOrExtrasNull(@Nullable SearchTarget target) {
        return target == null || target.getExtras() == null;
    }