Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Unified Diff: ui/android/java/src/org/chromium/ui/UiUtils.java

Issue 2737393002: Implement the new Photo picker, part one. (Closed)
Patch Set: Address comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..66e7a28019039ef8d71081ba25a3bac2cd127287 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 showing the photo picker.
Michael van Ouwerkerk 2017/03/14 15:57:27 It does not just show, also dismiss. A more genera
Finnur 2017/03/15 13:25:07 Yeah, sorry. I didn't follow your initial comment
+ */
+ 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.
+ * @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.
Michael van Ouwerkerk 2017/03/14 15:57:27 nit: no space after @
Finnur 2017/03/15 13:25:07 Done.
+ */
+ 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(
+ Context context, OnPhotoPickerListener listener, boolean allowMultiple) {
+ if (sPhotoPickerDelegate == null) return false;
+ sPhotoPickerDelegate.showPhotoPicker(context, listener, allowMultiple);
+ return true;
+ }
+
+ public static void dismissPhotoPicker() {
+ if (sPhotoPickerDelegate == null) return;
+ sPhotoPickerDelegate.dismissPhotoPicker();
+ }
+
/**
* Inserts a {@link View} into a {@link ViewGroup} after directly before a given {@View}.
* @param container The {@link View} to add newView to.

Powered by Google App Engine
This is Rietveld 408576698