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

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

Issue 2758313002: Implement the new Photo picker, part two. (Closed)
Patch Set: Polish 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/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 841b60ad2a91d18828119299305fdd7f04081604..df737bf34acdf8ece14cc0d7354aaf50d7664528 100644
--- a/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
+++ b/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
@@ -167,7 +167,8 @@ public class SelectFileDialog implements WindowAndroid.IntentCallback,
boolean hasCameraPermission = mWindowAndroid.hasPermission(Manifest.permission.CAMERA);
if (mSupportsImageCapture && hasCameraPermission) {
// GetCameraIntentTask will call LaunchSelectFileWithCameraIntent later.
- new GetCameraIntentTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new GetCameraIntentTask(false, mWindowAndroid, this)
+ .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
launchSelectFileWithCameraIntent(hasCameraPermission, null);
}
@@ -266,18 +267,46 @@ public class SelectFileDialog implements WindowAndroid.IntentCallback,
switch (action) {
case PHOTOS_SELECTED:
- // TODO(finnur): Implement.
- onFileNotSelected();
+ if (photos.length == 0) {
+ onFileNotSelected();
+ return;
+ }
+
+ if (photos.length == 1) {
+ GetDisplayNameTask task =
+ new GetDisplayNameTask(ContextUtils.getApplicationContext(), false);
+ task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Uri.parse(photos[0]));
+ return;
+ } else {
+ Uri[] filePathArray = new Uri[photos.length];
+ for (int i = 0; i < photos.length; ++i) {
+ filePathArray[i] = Uri.parse(photos[i]);
+ }
+ GetDisplayNameTask task =
+ new GetDisplayNameTask(ContextUtils.getApplicationContext(), true);
+ task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, filePathArray);
+ }
break;
case LAUNCH_GALLERY:
- // TODO(finnur): Implement.
- onFileNotSelected();
+ Intent intent = new Intent();
+ intent.setType("image/*");
+ if (mAllowMultiple) {
+ intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+ }
+ intent.setAction(Intent.ACTION_GET_CONTENT);
+ Activity activity = mWindowAndroid.getActivity().get();
+ if (activity != null) {
+ String label = activity.getResources().getString(
+ R.string.picker_dialog_select_picture);
+ activity.startActivityForResult(
+ Intent.createChooser(intent, label), PhotoPickerListener.SHOW_GALLERY);
+ }
break;
case LAUNCH_CAMERA:
- // TODO(finnur): Implement.
- onFileNotSelected();
+ new GetCameraIntentTask(true, mWindowAndroid, this)
+ .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
break;
}
}
@@ -288,6 +317,17 @@ public class SelectFileDialog implements WindowAndroid.IntentCallback,
}
private class GetCameraIntentTask extends AsyncTask<Void, Void, Uri> {
+ private Boolean mDirectToCamera;
+ private WindowAndroid mWindow;
+ private WindowAndroid.IntentCallback mCallback;
+
+ public GetCameraIntentTask(Boolean directToCamera, WindowAndroid window,
+ WindowAndroid.IntentCallback callback) {
+ mDirectToCamera = directToCamera;
+ mWindow = window;
+ mCallback = callback;
+ }
+
@Override
public Uri doInBackground(Void...voids) {
try {
@@ -317,7 +357,11 @@ public class SelectFileDialog implements WindowAndroid.IntentCallback,
mWindowAndroid.getApplicationContext().getContentResolver(),
UiUtils.IMAGE_FILE_PATH, mCameraOutputUri));
}
- launchSelectFileWithCameraIntent(true, camera);
+ if (mDirectToCamera) {
+ mWindow.showIntent(camera, mCallback, R.string.low_memory_error);
+ } else {
+ launchSelectFileWithCameraIntent(true, camera);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698