1 /* 2 * Copyright (C) 2017 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 package com.android.wallpaper.picker; 17 18 import android.annotation.Nullable; 19 import android.content.Context; 20 import android.content.Intent; 21 22 /** 23 * Interface for activities that launch an Android custom image picker. 24 */ 25 public interface MyPhotosStarter { 26 27 /** 28 * Requests that this Activity show the Android custom photo picker for the sake of picking a 29 * photo to set as the device's wallpaper. 30 */ requestCustomPhotoPicker(PermissionChangedListener listener)31 void requestCustomPhotoPicker(PermissionChangedListener listener); 32 33 /** 34 * Interface for clients to implement in order to be notified of permissions grant status changes. 35 */ 36 interface PermissionChangedListener { 37 /** 38 * Notifies that the user granted permissions. 39 */ onPermissionsGranted()40 void onPermissionsGranted(); 41 42 /** 43 * Notifies that the user denied permissions. 44 * 45 * @param dontAskAgain True if user checked "Don't ask again" on the most recent permissions 46 * request prior to denying it. 47 */ onPermissionsDenied(boolean dontAskAgain)48 void onPermissionsDenied(boolean dontAskAgain); 49 } 50 51 interface MyPhotosStarterProvider { 52 getMyPhotosStarter()53 MyPhotosStarter getMyPhotosStarter(); 54 } 55 56 /** 57 * Interface for a provider of the intent to start the "My Photos" picker. 58 * Defaults to resolving {@link Intent#ACTION_PICK}. 59 */ 60 interface MyPhotosIntentProvider { 61 62 /** 63 * @return the Intent to use to start the "My Photos" picker. 64 */ getMyPhotosIntent(Context context)65 default Intent getMyPhotosIntent(Context context) { 66 Intent intent = new Intent(Intent.ACTION_PICK); 67 intent.setType("image/*"); 68 return intent; 69 } 70 71 @Nullable getFallbackIntent(Context context)72 default Intent getFallbackIntent(Context context) { 73 return null; 74 } 75 } 76 } 77