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

Unified Diff: ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java

Issue 2909633002: Photo Picker dialog: Show the dialog when image types are being requested. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
diff --git a/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java b/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
index 753a559340d994f64956f794b4dcb295ea7ed12a..71502436a688eb8ebc2c3ac2516cb5d36d71d768 100644
--- a/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
+++ b/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
@@ -18,6 +18,7 @@ import android.os.AsyncTask;
import android.os.Build;
import android.provider.MediaStore;
import android.text.TextUtils;
+import android.webkit.MimeTypeMap;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContentUriUtils;
@@ -251,7 +252,8 @@ public class SelectFileDialog implements WindowAndroid.IntentCallback,
// Use new photo picker, if available.
Activity activity = mWindowAndroid.getActivity().get();
- if (activity != null && UiUtils.showPhotoPicker(activity, this, mAllowMultiple)) {
+ if (activity != null && usePhotoPicker()
Ted C 2017/05/26 20:21:14 Could usePhotoPicker() be: TextUtils.equals(getCo
Finnur 2017/05/29 15:18:36 I don't see how that can work. There's two ways
Ted C 2017/05/30 04:20:52 If that is the case, then I'd argue the previous/e
Finnur 2017/05/30 11:16:10 I tend to agree with you. I suspect the previous b
+ && UiUtils.showPhotoPicker(activity, this, mAllowMultiple)) {
return;
}
@@ -267,6 +269,26 @@ public class SelectFileDialog implements WindowAndroid.IntentCallback,
}
}
+ /**
+ * Determines if a photo picker can be used instead of the stock Android picker.
+ * @return True if only images types are being requested.
+ *
Ted C 2017/05/26 20:21:14 remove extra blank line
Finnur 2017/05/29 15:18:36 Done.
+ */
+ private boolean usePhotoPicker() {
+ boolean usePhotoPicker = false;
+ for (String type : mFileTypes) {
+ String mimeType;
+ if (type.startsWith(".")) {
+ String extension = type.substring(1, type.length());
+ mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
+ } else {
+ mimeType = type;
+ }
+ usePhotoPicker = mimeType != null && mimeType.startsWith("image/");
+ }
+ return usePhotoPicker;
+ }
+
@Override
public void onPickerUserAction(Action action, String[] photos) {
UiUtils.dismissPhotoPicker();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698