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..c0948beb0c97a77f2c26e5ac15ac586738afbaea 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 that shows the file picker. */ |
Michael van Ouwerkerk
2017/03/13 14:04:17
It does more than showing the picker, so let's giv
Finnur
2017/03/14 14:35:41
Done.
|
+ private static FilePickerDelegate sFilePickerDelegate; |
+ |
/** |
* A delegate that can be implemented to override whether or not keyboard detection will be |
* used. |
@@ -71,6 +74,24 @@ public class UiUtils { |
} |
/** |
+ * A delegate interface for showing the photo picker. |
+ */ |
+ public interface FilePickerDelegate { |
Michael van Ouwerkerk
2017/03/13 14:04:17
This is called FilePicker but lots of places say p
Finnur
2017/03/14 14:35:41
Done.
|
+ /** |
+ * Called to display the photo picker. |
+ * @param context The context to use. |
+ * @param listener The listener that will be notified of the selection. |
+ * @param allowMultiple Whether the dialog should allow multiple images to be selected. |
+ */ |
+ void showFilePicker(Context context, OnPhotoPickerListener listener, boolean allowMultiple); |
+ |
+ /** |
+ * Called when the photo picker dialog should be dismissed. |
+ */ |
+ void dismissFilePicker(); |
+ } |
+ |
+ /** |
* Allows setting a delegate to override the default software keyboard visibility detection. |
* @param delegate A {@link KeyboardShowingDelegate} instance. |
*/ |
@@ -79,6 +100,14 @@ public class UiUtils { |
} |
/** |
+ * Allows setting a delegate to override the default software keyboard visibility detection. |
Michael van Ouwerkerk
2017/03/13 14:04:17
These docs seem to have been copied from the metho
Finnur
2017/03/14 14:35:41
Yeah, special two-for one price at the store. Coul
|
+ * @ param delegate A {@link KeyboardShowingDelegate} instance. |
+ */ |
+ public static void setFilePickerDelegate(FilePickerDelegate delegate) { |
+ sFilePickerDelegate = delegate; |
+ } |
+ |
+ /** |
* Shows the software keyboard if necessary. |
* @param view The currently focused {@link View}, which would receive soft keyboard input. |
*/ |
@@ -170,6 +199,20 @@ public class UiUtils { |
return locales; |
} |
+ // FilePickerDelegate: |
+ |
+ public static boolean showFilePicker( |
+ Context context, OnPhotoPickerListener listener, boolean allowMultiple) { |
+ if (sFilePickerDelegate == null) return false; |
+ sFilePickerDelegate.showFilePicker(context, listener, allowMultiple); |
+ return true; |
+ } |
+ |
+ public static void dismissFilePicker() { |
+ if (sFilePickerDelegate == null) return; |
+ sFilePickerDelegate.dismissFilePicker(); |
+ } |
+ |
/** |
* Inserts a {@link View} into a {@link ViewGroup} after directly before a given {@View}. |
* @param container The {@link View} to add newView to. |