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

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

Issue 2869963003: Photo Picker Dialog: Handle the user selection in the dialog. (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 ce76c282c158c139a494e2861bd9b3407ad11abe..372bbfc2eceff0ecfea441d38e4494753e57e17d 100644
--- a/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
+++ b/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
@@ -169,7 +169,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);
}
@@ -272,18 +273,44 @@ public class SelectFileDialog implements WindowAndroid.IntentCallback,
break;
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.photo_picker_select_images);
+ 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;
}
}
@@ -294,6 +321,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 {
@@ -323,7 +361,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);
+ }
}
}
« 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