• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Gallery2


Commit MetaInfo

修订版deff258ea4e5723b351739418919251ae1048e46 (tree)
时间2011-09-15 19:34:02
作者Ray Chen <raychen@goog...>
CommiterRay Chen

Log Message

Fix 5290260 Unable to rotate left or right to album from Gallery

Separate menu operation and sharing options to different methods so
execution side is consistent with menu options.

Change-Id: Ia0105b333035051e33e9563fb2186cf1a29bc225

更改概述

差异

--- a/src/com/android/gallery3d/ui/ActionModeHandler.java
+++ b/src/com/android/gallery3d/ui/ActionModeHandler.java
@@ -164,26 +164,25 @@ public class ActionModeHandler implements ActionMode.Callback {
164164 return true;
165165 }
166166
167- private void updateMenuOptionsAndSharingIntent(JobContext jc) {
168- ArrayList<Path> paths = mSelectionManager.getSelected(true);
167+ // Menu options are determined by selection set itself.
168+ // We cannot expand it because MenuExecuter executes it based on
169+ // the selection set instead of the expanded result.
170+ // e.g. LocalImage can be rotated but collections of them (LocalAlbum) can't.
171+ private void updateMenuOptions(JobContext jc) {
172+ ArrayList<Path> paths = mSelectionManager.getSelected(false);
169173 if (paths.size() == 0) return;
170174
171175 int operation = MediaObject.SUPPORT_ALL;
172176 DataManager manager = mActivity.getDataManager();
173- final ArrayList<Uri> uris = new ArrayList<Uri>();
174177 int type = 0;
175178 for (Path path : paths) {
176179 if (jc.isCancelled()) return;
177180 int support = manager.getSupportedOperations(path);
178181 type |= manager.getMediaType(path);
179182 operation &= support;
180- if ((support & MediaObject.SUPPORT_SHARE) != 0) {
181- uris.add(manager.getContentUri(path));
182- }
183183 }
184- final Intent intent = new Intent();
185- final String mimeType = MenuExecutor.getMimeType(type);
186184
185+ final String mimeType = MenuExecutor.getMimeType(type);
187186 if (paths.size() == 1) {
188187 if (!GalleryUtils.isEditorAvailable((Context) mActivity, mimeType)) {
189188 operation &= ~MediaObject.SUPPORT_EDIT;
@@ -192,9 +191,42 @@ public class ActionModeHandler implements ActionMode.Callback {
192191 operation &= SUPPORT_MULTIPLE_MASK;
193192 }
194193
194+ final int supportedOperation = operation;
195+
196+ mMainHandler.post(new Runnable() {
197+ @Override
198+ public void run() {
199+ mMenuTask = null;
200+ MenuExecutor.updateMenuOperation(mMenu, supportedOperation);
201+ }
202+ });
203+ }
204+
205+ // Share intent needs to expand the selection set so we can get URI of
206+ // each media item
207+ private void updateSharingIntent(JobContext jc) {
208+ if (mShareActionProvider == null) return;
209+ ArrayList<Path> paths = mSelectionManager.getSelected(true);
210+ if (paths.size() == 0) return;
211+
212+ final ArrayList<Uri> uris = new ArrayList<Uri>();
213+
214+ DataManager manager = mActivity.getDataManager();
215+ int type = 0;
216+
217+ final Intent intent = new Intent();
218+ for (Path path : paths) {
219+ int support = manager.getSupportedOperations(path);
220+ type |= manager.getMediaType(path);
221+
222+ if ((support & MediaObject.SUPPORT_SHARE) != 0) {
223+ uris.add(manager.getContentUri(path));
224+ }
225+ }
226+
195227 final int size = uris.size();
196- Log.v(TAG, "Sharing intent MIME type=" + mimeType + ", uri size = "+ uris.size());
197228 if (size > 0) {
229+ final String mimeType = MenuExecutor.getMimeType(type);
198230 if (size > 1) {
199231 intent.setAction(Intent.ACTION_SEND_MULTIPLE).setType(mimeType);
200232 intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
@@ -203,22 +235,15 @@ public class ActionModeHandler implements ActionMode.Callback {
203235 intent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
204236 }
205237 intent.setType(mimeType);
206- }
207-
208- final int supportedOperation = operation;
209-
210- mMainHandler.post(new Runnable() {
211- @Override
212- public void run() {
213- mMenuTask = null;
214- MenuExecutor.updateMenuOperation(mMenu, supportedOperation);
215238
216- if (mShareActionProvider != null && size > 0) {
239+ mMainHandler.post(new Runnable() {
240+ @Override
241+ public void run() {
217242 Log.v(TAG, "Sharing intent is ready: action = " + intent.getAction());
218243 mShareActionProvider.setShareIntent(intent);
219244 }
220- }
221- });
245+ });
246+ }
222247 }
223248
224249 public void updateSupportedOperation(Path path, boolean selected) {
@@ -240,7 +265,8 @@ public class ActionModeHandler implements ActionMode.Callback {
240265 // Generate sharing intent and update supported operations in the background
241266 mMenuTask = mActivity.getThreadPool().submit(new Job<Void>() {
242267 public Void run(JobContext jc) {
243- updateMenuOptionsAndSharingIntent(jc);
268+ updateMenuOptions(jc);
269+ updateSharingIntent(jc);
244270 return null;
245271 }
246272 });