Chromium Code Reviews| Index: ui/android/java/src/org/chromium/ui/UiUtils.java |
| diff --git a/ui/android/java/src/org/chromium/ui/UiUtils.java b/ui/android/java/src/org/chromium/ui/UiUtils.java |
| index 61fa37f2cf3329ee49812dae8339a9d63282d62e..331028961d9c244cb9d873ff15435327fcbfc085 100644 |
| --- a/ui/android/java/src/org/chromium/ui/UiUtils.java |
| +++ b/ui/android/java/src/org/chromium/ui/UiUtils.java |
| @@ -56,6 +56,9 @@ public class UiUtils { |
| /** A delegate that allows disabling keyboard visibility detection. */ |
| private static KeyboardShowingDelegate sKeyboardShowingDelegate; |
| + /** A delegate for the photo picker. */ |
| + private static PhotoPickerDelegate sPhotoPickerDelegate; |
| + |
| /** |
| * A delegate that can be implemented to override whether or not keyboard detection will be |
| * used. |
| @@ -71,6 +74,25 @@ public class UiUtils { |
| } |
| /** |
| + * A delegate interface for the photo picker. |
| + */ |
| + public interface PhotoPickerDelegate { |
| + /** |
| + * Called to display the photo picker. |
| + * @param context The context to use. |
| + * @param listener The listener that will be notified of the selection. |
|
Theresa
2017/03/15 15:56:32
nit: ... notified of the action the user took in t
Finnur
2017/03/16 11:38:04
Done.
|
| + * @param allowMultiple Whether the dialog should allow multiple images to be selected. |
| + */ |
| + void showPhotoPicker( |
| + Context context, OnPhotoPickerListener listener, boolean allowMultiple); |
| + |
| + /** |
| + * Called when the photo picker dialog should be dismissed. |
| + */ |
| + void dismissPhotoPicker(); |
| + } |
| + |
| + /** |
| * Allows setting a delegate to override the default software keyboard visibility detection. |
| * @param delegate A {@link KeyboardShowingDelegate} instance. |
| */ |
| @@ -79,6 +101,14 @@ public class UiUtils { |
| } |
| /** |
| + * Allows setting a delegate to override the default Android stock photo picker. |
| + * @param delegate A {@link PhotoPickerDelegate} instance. |
| + */ |
| + public static void setPhotoPickerDelegate(PhotoPickerDelegate delegate) { |
| + sPhotoPickerDelegate = delegate; |
| + } |
| + |
| + /** |
| * Shows the software keyboard if necessary. |
| * @param view The currently focused {@link View}, which would receive soft keyboard input. |
| */ |
| @@ -170,6 +200,20 @@ public class UiUtils { |
| return locales; |
| } |
| + // PhotoPickerDelegate: |
| + |
| + public static boolean showPhotoPicker( |
|
Theresa
2017/03/15 15:56:32
nit: let's move the setPhotoPickerDelegate() metho
Finnur
2017/03/16 11:38:04
Oh, I didn't realize these were keyboard methods b
Theresa
2017/03/16 16:26:17
I don't think insertBefore, et al. are keyboard me
|
| + Context context, OnPhotoPickerListener listener, boolean allowMultiple) { |
| + if (sPhotoPickerDelegate == null) return false; |
| + sPhotoPickerDelegate.showPhotoPicker(context, listener, allowMultiple); |
| + return true; |
| + } |
| + |
| + public static void dismissPhotoPicker() { |
|
Theresa
2017/03/15 15:56:32
This method and the one above need JavaDocs.
Finnur
2017/03/16 11:38:04
Done.
|
| + if (sPhotoPickerDelegate == null) return; |
| + sPhotoPickerDelegate.dismissPhotoPicker(); |
|
Theresa
2017/03/15 15:56:32
In Android N+ multi-window, will it be possible fo
Finnur
2017/03/16 11:38:04
That's a good point. I'll take it into considerati
|
| + } |
| + |
| /** |
| * Inserts a {@link View} into a {@link ViewGroup} after directly before a given {@View}. |
| * @param container The {@link View} to add newView to. |