1 /* 2 * Copyright 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.photopicker.core.selection 18 19 import android.provider.MediaStore 20 import com.android.photopicker.core.configuration.PhotopickerConfiguration 21 22 /** 23 * Selection of items and the way items are processed can vary based on the configuration 24 * photo picker is being used in. This class provides all the different modes for selection and also 25 * a method that accepts the configuration and returns the suitable mode of selection suitable for 26 * it. 27 */ 28 enum class SelectionStrategy { 29 DEFAULT, 30 GRANTS_AWARE_SELECTION; 31 32 companion object { determineSelectionStrategynull33 fun determineSelectionStrategy( 34 configuration: PhotopickerConfiguration 35 ): SelectionStrategy { 36 when (configuration.action) { 37 // if the current action in configuration is 38 // MediaStore.ACTION_USER_SELECT_IMAGES_FOR_APP then the returned selection should 39 // be of implementation GrantsAwareSelectionImpl. 40 MediaStore.ACTION_USER_SELECT_IMAGES_FOR_APP -> 41 return GRANTS_AWARE_SELECTION 42 43 else -> 44 return DEFAULT 45 } 46 } 47 } 48 } 49