diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-03-21 23:24:05 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-03-21 23:24:05 +0000 |
commit | 313ca2b3cbaef97cb4665b24412eccf3d4cdcae3 (patch) | |
tree | 5caf09c82cd6c95c67bf8cdd657de22063e78d71 | |
parent | 22f4b490196ca2158746bbe2fe2d639d913a35ec (diff) | |
parent | 767f8111be7ad6bdf597120fc5b2d052080dd5c1 (diff) | |
download | systemui-android13-qpr3-s8-release.tar.gz |
Snap for 9787270 from 767f8111be7ad6bdf597120fc5b2d052080dd5c1 to tm-qpr3-releaseandroid-13.0.0_r83android-13.0.0_r79android-13.0.0_r78android-13.0.0_r77android-13.0.0_r76android-13.0.0_r75android-13.0.0_r71android-13.0.0_r70android-13.0.0_r69android-13.0.0_r68android-13.0.0_r67android-13.0.0_r63android-13.0.0_r62android-13.0.0_r61android-13.0.0_r56android-13.0.0_r54android-13.0.0_r53android-13.0.0_r52android-13.0.0_r51android-13.0.0_r50android13-qpr3-s9-releaseandroid13-qpr3-s8-releaseandroid13-qpr3-s7-releaseandroid13-qpr3-s6-releaseandroid13-qpr3-s5-releaseandroid13-qpr3-s4-releaseandroid13-qpr3-s3-releaseandroid13-qpr3-s2-releaseandroid13-qpr3-s14-releaseandroid13-qpr3-s13-releaseandroid13-qpr3-s12-releaseandroid13-qpr3-s11-releaseandroid13-qpr3-s10-releaseandroid13-qpr3-s1-releaseandroid13-qpr3-release
Change-Id: Ifa8f8589634c65c2e805309deb3ccc741ac340a0
-rw-r--r-- | searchuilib/src/com/android/app/search/SearchTargetExtras.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/searchuilib/src/com/android/app/search/SearchTargetExtras.java b/searchuilib/src/com/android/app/search/SearchTargetExtras.java index 6421e18..887c457 100644 --- a/searchuilib/src/com/android/app/search/SearchTargetExtras.java +++ b/searchuilib/src/com/android/app/search/SearchTargetExtras.java @@ -21,6 +21,7 @@ import static com.android.app.search.LayoutType.TALL_CARD_WITH_IMAGE_NO_ICON; import android.app.blob.BlobHandle; import android.app.search.SearchAction; import android.app.search.SearchTarget; +import android.os.Bundle; import android.text.TextUtils; import androidx.annotation.Nullable; @@ -125,6 +126,8 @@ public class SearchTargetExtras { public static final String WEB_SUG_COUNT = "web_sug_count"; /** + * Replaced with thumbnail crop type + * * Flag to control whether thumbnail(s) should fill the thumbnail container's width or not. * When this flag is true, when there are less than the maximum number of thumbnails in the * container, the thumbnails will stretch to fill the container's width. @@ -133,8 +136,54 @@ public class SearchTargetExtras { * * Only relevant in {@link LayoutType#THUMBNAIL_CONTAINER} and {@link LayoutType#THUMBNAIL}. */ + @Deprecated public static final String BUNDLE_EXTRA_SHOULD_FILL_CONTAINER_WIDTH = "should_fill_container_width"; + + /** + * Flag to control thumbnail container's crop mode, controlling the layout + * + * <ul> + * <li>SQUARE: Thumbnail(s) will be cropped to a square aspect ratio around the center.</li> + * <li>FILL_WIDTH: Thumbnail(s) should collectively fill the thumbnail container's width. + * When there are less than the maximum number of thumbnails in the container, the + * layouts' width will stretch to fit the container, the images will fill the width + * and then the top/bottom cropped to fit.</li> + * <li>FILL_HEIGHT: Thumbnail(s) should fill height and be cropped to fit in the width + * based on {@link BUNDLE_EXTRA_THUMBNAIL_MAX_COUNT} as the column count. When the image + * width is larger than the width / column, both sides will be cropped while maintaining + * the center. + * When there are less thumbnails than the max count, the layout will be constrained to + * equally divide the width of the container. If there are more thumbnails than the max + * count, the excessive thumbnails will be ignored.</li> + * </ul> + * + * Only relevant in {@link LayoutType#THUMBNAIL_CONTAINER} and {@link LayoutType#THUMBNAIL}. + */ + public static final String BUNDLE_EXTRA_THUMBNAIL_CROP_TYPE = "thumbnail_crop_type"; + public enum ThumbnailCropType { + DEFAULT(0), // defaults to SQUARE behavior by {@link LayoutType#THUMBNAIL_CONTAINER}. + SQUARE(1), + FILL_WIDTH(2), + FILL_HEIGHT(3); + + private final int mTypeId; + + ThumbnailCropType(int typeId) { + mTypeId = typeId; + } + + public int toTypeId() { + return mTypeId; + } + }; + + /** + * How many grid spaces for the thumbnail container should be reserved. + * Only relevant for {@link ThumbnailCropType#FILL_HEIGHT} crop type. + */ + public static final String BUNDLE_EXTRA_THUMBNAIL_MAX_COUNT = "thumbnail_max_count"; + /** * Flag to control whether the SearchTarget's label should be hidden. * When this flag is true, label will be hidden. @@ -164,4 +213,16 @@ public class SearchTargetExtras { return target != null && isAnswer(target) && target.getLayoutType().equals(TALL_CARD_WITH_IMAGE_NO_ICON); } + + /** Get the crop type thumbnails should use. Returns DEFAULT if not specified. */ + public static ThumbnailCropType getThumbnailCropType(@Nullable SearchTarget target) + throws ArrayIndexOutOfBoundsException { + Bundle extras = target == null ? Bundle.EMPTY : target.getExtras(); + if (extras.isEmpty()) { + return ThumbnailCropType.DEFAULT; + } + ThumbnailCropType cropType = ThumbnailCropType.values()[extras.getInt( + BUNDLE_EXTRA_THUMBNAIL_CROP_TYPE)]; + return cropType != null ? cropType : ThumbnailCropType.DEFAULT; + } } |