blob: 6108c8e3d5a8a7c235a925e3790ff7472f80abe8 [file] [log] [blame]
Paramananda Pradhan9382a972014-12-14 17:27:31 +05301/**
Owen Linf9a0a432011-08-17 22:07:43 +08002 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.gallery3d.app;
18
Yuli Huangfc869942012-06-29 18:59:17 +080019import android.annotation.TargetApi;
John Reck2abaaf72012-12-12 13:43:43 -080020import android.app.ActionBar.OnMenuVisibilityListener;
Owen Lin8bc5beb2011-11-17 15:26:56 +080021import android.app.Activity;
Ray Chen604f0532011-10-21 16:07:12 +080022import android.content.ActivityNotFoundException;
23import android.content.Context;
24import android.content.Intent;
Bobby Georgescua9948ef2012-09-11 17:02:03 -070025import android.content.pm.PackageManager;
Chao Zhang8724b7e2016-05-12 17:34:31 +080026import android.content.pm.ResolveInfo;
John Reck4ea5c272013-01-18 16:00:45 -080027import android.content.res.Configuration;
Yuli Huang04ac0452012-03-20 16:37:05 +080028import android.graphics.Rect;
Ray Chen604f0532011-10-21 16:07:12 +080029import android.net.Uri;
Martijn Coenen33ef0372012-03-26 18:25:50 -070030import android.nfc.NfcAdapter;
John Reckddf02252012-09-26 11:37:23 -070031import android.nfc.NfcAdapter.CreateBeamUrisCallback;
32import android.nfc.NfcEvent;
jinwu4fafa7a2017-04-07 13:27:48 +080033import android.os.AsyncTask;
Ray Chen604f0532011-10-21 16:07:12 +080034import android.os.Bundle;
35import android.os.Handler;
36import android.os.Message;
Bobby Georgescub27df462012-09-27 23:55:44 -070037import android.os.SystemClock;
kaiyized2687a2014-10-15 10:10:13 +080038import android.text.TextUtils;
John Reck2abaaf72012-12-12 13:43:43 -080039import android.view.Menu;
40import android.view.MenuItem;
ztenghui02f459f2013-08-30 16:34:23 -070041import android.view.View;
huiyan4c35ffd2016-03-09 11:48:47 +080042import android.view.ViewGroup;
43import android.view.Window;
huiyan8782c242016-04-23 14:52:23 +080044import android.view.WindowManager;
Bobby Georgescua9948ef2012-09-11 17:02:03 -070045import android.widget.RelativeLayout;
Ray Chen604f0532011-10-21 16:07:12 +080046import android.widget.Toast;
47
Likai Dingc83b5b72016-05-25 14:48:41 +080048import org.codeaurora.gallery.R;
jinwu4fafa7a2017-04-07 13:27:48 +080049
50import com.android.gallery3d.app.dualcam3d.ThreeDimensionalActivity;
Yuli Huangfc869942012-06-29 18:59:17 +080051import com.android.gallery3d.common.ApiHelper;
Bobby Georgescuee899c02012-10-01 17:49:30 -070052import com.android.gallery3d.data.ComboAlbum;
Owen Linf9a0a432011-08-17 22:07:43 +080053import com.android.gallery3d.data.DataManager;
Chih-Chung Chang6b891c62012-06-07 20:09:13 +080054import com.android.gallery3d.data.FilterDeleteSet;
Bobby Georgescu45f089d2012-10-02 13:30:09 -070055import com.android.gallery3d.data.FilterSource;
Owen Linf9a0a432011-08-17 22:07:43 +080056import com.android.gallery3d.data.MediaDetails;
57import com.android.gallery3d.data.MediaItem;
58import com.android.gallery3d.data.MediaObject;
George Mount4b4dbd22012-10-18 14:20:39 -070059import com.android.gallery3d.data.MediaObject.PanoramaSupportCallback;
Owen Linf9a0a432011-08-17 22:07:43 +080060import com.android.gallery3d.data.MediaSet;
Owen Linf9a0a432011-08-17 22:07:43 +080061import com.android.gallery3d.data.Path;
Wu-cheng Lia0ce6822012-08-22 19:15:35 +080062import com.android.gallery3d.data.SecureAlbum;
63import com.android.gallery3d.data.SecureSource;
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +080064import com.android.gallery3d.data.SnailAlbum;
65import com.android.gallery3d.data.SnailItem;
Chih-Chung Chang15b351a2012-03-15 16:38:45 +080066import com.android.gallery3d.data.SnailSource;
Ruben Brunk63926d22012-10-17 00:40:35 -070067import com.android.gallery3d.filtershow.FilterShowActivity;
jinwu4fafa7a2017-04-07 13:27:48 +080068import com.android.gallery3d.filtershow.imageshow.MasterImage;
Likai Dingb7c13c22017-02-16 14:54:04 +080069import com.android.gallery3d.filtershow.tools.DualCameraEffect;
Ray Chen4105e222011-08-24 11:40:04 +080070import com.android.gallery3d.ui.DetailsHelper;
71import com.android.gallery3d.ui.DetailsHelper.CloseListener;
72import com.android.gallery3d.ui.DetailsHelper.DetailsSource;
ztenghui02f459f2013-08-30 16:34:23 -070073import com.android.gallery3d.ui.GLRootView;
Owen Linf9a0a432011-08-17 22:07:43 +080074import com.android.gallery3d.ui.GLView;
Owen Linf9a0a432011-08-17 22:07:43 +080075import com.android.gallery3d.ui.MenuExecutor;
Owen Lin21a412c2012-04-20 18:42:22 +080076import com.android.gallery3d.ui.PhotoView;
Owen Linf9a0a432011-08-17 22:07:43 +080077import com.android.gallery3d.ui.SelectionManager;
78import com.android.gallery3d.ui.SynchronizedHandler;
Likai Dingb7c13c22017-02-16 14:54:04 +080079import com.android.gallery3d.util.GDepth;
Owen Linf9a0a432011-08-17 22:07:43 +080080import com.android.gallery3d.util.GalleryUtils;
Bobby Georgescuf37648b2013-03-12 22:45:17 -070081import com.android.gallery3d.util.UsageStatistics;
Likai Dingb2e91002013-08-13 14:07:48 +080082import com.android.gallery3d.util.ViewGifImage;
Owen Linf9a0a432011-08-17 22:07:43 +080083
Chao Zhang8724b7e2016-05-12 17:34:31 +080084import java.util.List;
kaiyized2687a2014-10-15 10:10:13 +080085import java.util.Locale;
86
Likai Dingba67cf52016-05-27 10:38:42 +080087//import android.drm.DrmHelper;
88
Bobby Georgescucfa7fde2012-11-05 14:12:51 -080089public abstract class PhotoPage extends ActivityState implements
maxwend57f7232016-06-04 22:51:06 +020090 PhotoView.Listener, AppBridge.Server, PhotoPageBottomControls.Delegate,
91 ThreeDButton.Delegate {
Owen Linf9a0a432011-08-17 22:07:43 +080092 private static final String TAG = "PhotoPage";
93
94 private static final int MSG_HIDE_BARS = 1;
Chih-Chung Changbd141b52012-04-26 10:10:49 +080095 private static final int MSG_ON_FULL_SCREEN_CHANGED = 4;
Chih-Chung Chang61f94712012-05-02 20:05:16 +080096 private static final int MSG_UPDATE_ACTION_BAR = 5;
Chih-Chung Change6251df2012-05-22 11:35:46 -070097 private static final int MSG_WANT_BARS = 7;
Bobby Georgescu3cf502a2012-10-01 15:50:11 -070098 private static final int MSG_REFRESH_BOTTOM_CONTROLS = 8;
99 private static final int MSG_ON_CAMERA_CENTER = 9;
Bobby Georgescuf4e22eb2012-10-02 18:34:08 -0700100 private static final int MSG_ON_PICTURE_CENTER = 10;
George Mountf122d562012-10-09 17:50:33 -0700101 private static final int MSG_REFRESH_IMAGE = 11;
Mangesh Ghiware423e45e2012-10-11 23:11:27 -0700102 private static final int MSG_UPDATE_PHOTO_UI = 12;
Mangesh Ghiware423e45e2012-10-11 23:11:27 -0700103 private static final int MSG_UPDATE_DEFERRED = 14;
George Mount4b4dbd22012-10-18 14:20:39 -0700104 private static final int MSG_UPDATE_SHARE_URI = 15;
105 private static final int MSG_UPDATE_PANORAMA_UI = 16;
Owen Lin6cf80742011-08-28 10:50:21 +0800106
Owen Linf9a0a432011-08-17 22:07:43 +0800107 private static final int HIDE_BARS_TIMEOUT = 3500;
108
109 private static final int REQUEST_SLIDESHOW = 1;
110 private static final int REQUEST_CROP = 2;
111 private static final int REQUEST_CROP_PICASA = 3;
Yuli Huangf50ce2b2012-05-02 00:50:56 +0800112 private static final int REQUEST_EDIT = 4;
Chih-Chung Chang71cd89a2012-05-17 18:22:27 -0700113 private static final int REQUEST_PLAY_VIDEO = 5;
Teng-Hui Zhu3f1f1ba2012-08-24 14:50:37 -0700114 private static final int REQUEST_TRIM = 6;
Owen Linf9a0a432011-08-17 22:07:43 +0800115
116 public static final String KEY_MEDIA_SET_PATH = "media-set-path";
117 public static final String KEY_MEDIA_ITEM_PATH = "media-item-path";
118 public static final String KEY_INDEX_HINT = "index-hint";
jinwu4fafa7a2017-04-07 13:27:48 +0800119 public static final String KEY_CURRENT_PHOTO_HINT = "currtent_photo_path";
Yuli Huang04ac0452012-03-20 16:37:05 +0800120 public static final String KEY_OPEN_ANIMATION_RECT = "open-animation-rect";
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800121 public static final String KEY_APP_BRIDGE = "app-bridge";
Yuli Huang54fe6202012-05-23 16:06:32 +0800122 public static final String KEY_TREAT_BACK_AS_UP = "treat-back-as-up";
Bobby Georgescu7eea4d32012-09-06 17:14:02 -0700123 public static final String KEY_START_IN_FILMSTRIP = "start-in-filmstrip";
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800124 public static final String KEY_RETURN_INDEX_HINT = "return-index-hint";
Wu-cheng Li23e595f2012-09-21 14:36:21 +0800125 public static final String KEY_SHOW_WHEN_LOCKED = "show_when_locked";
Bobby Georgescu45f089d2012-10-02 13:30:09 -0700126 public static final String KEY_IN_CAMERA_ROLL = "in_camera_roll";
John Hoford463b9182013-09-16 15:51:02 -0700127 public static final String KEY_READONLY = "read-only";
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530128 public static final String KEY_FROM_VIDEOS_SCREEN = "from-video-screen";
129 public static final String KEY_FROM_TIMELINE_SCREEN = "from-timeline-screen";
kaiyized2687a2014-10-15 10:10:13 +0800130
131 // Bundle key, used for checking whether it is from widget
132 public static final String KEY_IS_FROM_WIDGET = "is_from_widget";
133
Bobby Georgescu7eea4d32012-09-06 17:14:02 -0700134 public static final String KEY_ALBUMPAGE_TRANSITION = "albumpage-transition";
135 public static final int MSG_ALBUMPAGE_NONE = 0;
136 public static final int MSG_ALBUMPAGE_STARTED = 1;
137 public static final int MSG_ALBUMPAGE_RESUMED = 2;
138 public static final int MSG_ALBUMPAGE_PICKED = 4;
139
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700140 public static final String ACTION_NEXTGEN_EDIT = "action_nextgen_edit";
nicolasroard8c4e95f2013-04-08 18:16:17 -0700141 public static final String ACTION_SIMPLE_EDIT = "action_simple_edit";
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700142
Owen Linf9a0a432011-08-17 22:07:43 +0800143 private GalleryApp mApplication;
144 private SelectionManager mSelectionManager;
145
146 private PhotoView mPhotoView;
147 private PhotoPage.Model mModel;
Ray Chen4105e222011-08-24 11:40:04 +0800148 private DetailsHelper mDetailsHelper;
Owen Linf9a0a432011-08-17 22:07:43 +0800149 private boolean mShowDetails;
150
151 // mMediaSet could be null if there is no KEY_MEDIA_SET_PATH supplied.
152 // E.g., viewing a photo in gmail attachment
Chih-Chung Chang6b891c62012-06-07 20:09:13 +0800153 private FilterDeleteSet mMediaSet;
Owen Linf9a0a432011-08-17 22:07:43 +0800154
Wu-cheng Lia0ce6822012-08-22 19:15:35 +0800155 // The mediaset used by camera launched from secure lock screen.
156 private SecureAlbum mSecureAlbum;
157
Owen Linf9a0a432011-08-17 22:07:43 +0800158 private int mCurrentIndex = 0;
159 private Handler mHandler;
Owen Lin113bfc72011-08-30 10:38:59 +0800160 private boolean mShowBars = true;
Chih-Chung Chang61f94712012-05-02 20:05:16 +0800161 private volatile boolean mActionBarAllowed = true;
Ray Chen8cab3e82012-03-20 16:32:57 +0800162 private GalleryActionBar mActionBar;
Owen Linf9a0a432011-08-17 22:07:43 +0800163 private boolean mIsMenuVisible;
John Reck8fe22ec2012-09-26 16:13:02 -0700164 private boolean mHaveImageEditor;
Bobby Georgescuf44499d2012-09-17 18:12:11 -0700165 private PhotoPageBottomControls mBottomControls;
Owen Linf9a0a432011-08-17 22:07:43 +0800166 private MediaItem mCurrentPhoto = null;
167 private MenuExecutor mMenuExecutor;
168 private boolean mIsActive;
Bobby Georgescuba65c372012-10-06 01:06:43 -0700169 private boolean mShowSpinner;
Ray Chen84c220f2012-03-06 17:24:28 +0800170 private String mSetPathString;
Chih-Chung Changb1e9fd82012-04-30 17:33:21 +0800171 // This is the original mSetPathString before adding the camera preview item.
John Hoford463b9182013-09-16 15:51:02 -0700172 private boolean mReadOnlyView = false;
Chih-Chung Changb1e9fd82012-04-30 17:33:21 +0800173 private String mOriginalSetPathString;
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800174 private AppBridge mAppBridge;
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +0800175 private SnailItem mScreenNailItem;
176 private SnailAlbum mScreenNailSet;
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800177 private OrientationManager mOrientationManager;
Yuli Huang54fe6202012-05-23 16:06:32 +0800178 private boolean mTreatBackAsUp;
kaiyized2687a2014-10-15 10:10:13 +0800179 // Used for checking whether it is from widget
180 private boolean mIsFromWidget;
Bobby Georgescu7eea4d32012-09-06 17:14:02 -0700181 private boolean mStartInFilmstrip;
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -0700182 private boolean mHasCameraScreennailOrPlaceholder = false;
Bobby Georgescud81b2642012-10-07 16:25:54 -0700183 private boolean mRecenterCameraOnResume = true;
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530184 private boolean mIsFromVideoScreen;
185 private boolean mIsFromTimelineScreen;
Chih-Chung Chang15b351a2012-03-15 16:38:45 +0800186
Doris Liua680a0c2012-10-18 15:01:35 -0700187 // These are only valid after the panorama callback
188 private boolean mIsPanorama;
189 private boolean mIsPanorama360;
190
Bobby Georgescub27df462012-09-27 23:55:44 -0700191 private long mCameraSwitchCutoff = 0;
192 private boolean mSkipUpdateCurrentPhoto = false;
193 private static final long CAMERA_SWITCH_CUTOFF_THRESHOLD_MS = 300;
194
George Mount4b4dbd22012-10-18 14:20:39 -0700195 private static final long DEFERRED_UPDATE_MS = 250;
Bobby Georgescue23a9d42012-10-10 10:49:51 -0700196 private boolean mDeferredUpdateWaiting = false;
197 private long mDeferUpdateUntil = Long.MAX_VALUE;
198
Chih-Chung Chang6b891c62012-06-07 20:09:13 +0800199 // The item that is deleted (but it can still be undeleted before commiting)
200 private Path mDeletePath;
201 private boolean mDeleteIsFocus; // whether the deleted item was in focus
202
John Reckddf02252012-09-26 11:37:23 -0700203 private Uri[] mNfcPushUris = new Uri[1];
Martijn Coenen33ef0372012-03-26 18:25:50 -0700204
Owen Lin2bb717f2012-07-13 17:23:05 +0800205 private final MyMenuVisibilityListener mMenuVisibilityListener =
206 new MyMenuVisibilityListener();
207
ztenghui02f459f2013-08-30 16:34:23 -0700208 private int mLastSystemUiVis = 0;
209
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530210 private Intent mShareIntent;
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530211
jinwu4fafa7a2017-04-07 13:27:48 +0800212 private ThreeDButton m3DButton;
213 private boolean bShow3DButton;
Likai Dingb7c13c22017-02-16 14:54:04 +0800214 private ParseGDepthTask mParseGDepthTask;
jinwu4fafa7a2017-04-07 13:27:48 +0800215
George Mount4b4dbd22012-10-18 14:20:39 -0700216 private final PanoramaSupportCallback mUpdatePanoramaMenuItemsCallback = new PanoramaSupportCallback() {
217 @Override
218 public void panoramaInfoAvailable(MediaObject mediaObject, boolean isPanorama,
219 boolean isPanorama360) {
220 if (mediaObject == mCurrentPhoto) {
221 mHandler.obtainMessage(MSG_UPDATE_PANORAMA_UI, isPanorama360 ? 1 : 0, 0,
222 mediaObject).sendToTarget();
Mangesh Ghiware825afb12012-10-10 18:37:24 -0700223 }
George Mount4b4dbd22012-10-18 14:20:39 -0700224 }
225 };
226
227 private final PanoramaSupportCallback mRefreshBottomControlsCallback = new PanoramaSupportCallback() {
228 @Override
229 public void panoramaInfoAvailable(MediaObject mediaObject, boolean isPanorama,
230 boolean isPanorama360) {
231 if (mediaObject == mCurrentPhoto) {
Doris Liua680a0c2012-10-18 15:01:35 -0700232 mHandler.obtainMessage(MSG_REFRESH_BOTTOM_CONTROLS, isPanorama ? 1 : 0, isPanorama360 ? 1 : 0,
233 mediaObject).sendToTarget();
George Mount4b4dbd22012-10-18 14:20:39 -0700234 }
235 }
236 };
237
238 private final PanoramaSupportCallback mUpdateShareURICallback = new PanoramaSupportCallback() {
239 @Override
240 public void panoramaInfoAvailable(MediaObject mediaObject, boolean isPanorama,
241 boolean isPanorama360) {
242 if (mediaObject == mCurrentPhoto) {
243 mHandler.obtainMessage(MSG_UPDATE_SHARE_URI, isPanorama360 ? 1 : 0, 0, mediaObject)
244 .sendToTarget();
245 }
246 }
247 };
Mangesh Ghiware825afb12012-10-10 18:37:24 -0700248
Owen Linf9a0a432011-08-17 22:07:43 +0800249 public static interface Model extends PhotoView.Model {
250 public void resume();
251 public void pause();
252 public boolean isEmpty();
Owen Linf9a0a432011-08-17 22:07:43 +0800253 public void setCurrentPhoto(Path path, int indexHint);
254 }
255
256 private class MyMenuVisibilityListener implements OnMenuVisibilityListener {
Pin Ting06c64012012-05-03 08:26:17 +0800257 @Override
Owen Linf9a0a432011-08-17 22:07:43 +0800258 public void onMenuVisibilityChanged(boolean isVisible) {
259 mIsMenuVisible = isVisible;
260 refreshHidingMessage();
261 }
262 }
263
Bobby Georgescu915c2c52012-08-23 13:05:53 -0700264 @Override
265 protected int getBackgroundColorId() {
266 return R.color.photo_background;
267 }
268
Bobby Georgescuf4a707f2012-08-20 16:26:26 -0700269 private final GLView mRootPane = new GLView() {
Owen Linf9a0a432011-08-17 22:07:43 +0800270 @Override
Owen Linf9a0a432011-08-17 22:07:43 +0800271 protected void onLayout(
272 boolean changed, int left, int top, int right, int bottom) {
273 mPhotoView.layout(0, 0, right - left, bottom - top);
Owen Linf9a0a432011-08-17 22:07:43 +0800274 if (mShowDetails) {
Ray Chen8cab3e82012-03-20 16:32:57 +0800275 mDetailsHelper.layout(left, mActionBar.getHeight(), right, bottom);
Owen Linf9a0a432011-08-17 22:07:43 +0800276 }
277 }
278 };
279
280 @Override
281 public void onCreate(Bundle data, Bundle restoreState) {
Bobby Georgescu45c56f22012-08-26 23:47:19 -0700282 super.onCreate(data, restoreState);
Ray Chen8cab3e82012-03-20 16:32:57 +0800283 mActionBar = mActivity.getGalleryActionBar();
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530284 mActionBar.setBackGroundTransparent();
Owen Linf9a0a432011-08-17 22:07:43 +0800285 mSelectionManager = new SelectionManager(mActivity, false);
286 mMenuExecutor = new MenuExecutor(mActivity, mSelectionManager);
287
288 mPhotoView = new PhotoView(mActivity);
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800289 mPhotoView.setListener(this);
Owen Linf9a0a432011-08-17 22:07:43 +0800290 mRootPane.addComponent(mPhotoView);
Angus Kong83be4e02012-08-24 19:30:08 +0800291 mApplication = (GalleryApp) ((Activity) mActivity).getApplication();
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800292 mOrientationManager = mActivity.getOrientationManager();
Chih-Chung Chang2ef46ed2012-05-08 17:57:33 +0800293 mActivity.getGLRoot().setOrientationSource(mOrientationManager);
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530294 mIsFromVideoScreen = data.getBoolean(KEY_FROM_VIDEOS_SCREEN, false);
295 mIsFromTimelineScreen = data.getBoolean(KEY_FROM_TIMELINE_SCREEN, false);
Owen Linf9a0a432011-08-17 22:07:43 +0800296
Bobby Georgescud3973782012-09-12 13:48:50 -0700297 mHandler = new SynchronizedHandler(mActivity.getGLRoot()) {
298 @Override
299 public void handleMessage(Message message) {
300 switch (message.what) {
301 case MSG_HIDE_BARS: {
302 hideBars();
303 break;
304 }
Bobby Georgescuf44499d2012-09-17 18:12:11 -0700305 case MSG_REFRESH_BOTTOM_CONTROLS: {
George Mount4b4dbd22012-10-18 14:20:39 -0700306 if (mCurrentPhoto == message.obj && mBottomControls != null) {
Doris Liua680a0c2012-10-18 15:01:35 -0700307 mIsPanorama = message.arg1 == 1;
308 mIsPanorama360 = message.arg2 == 1;
309 mBottomControls.refresh();
jinwu4fafa7a2017-04-07 13:27:48 +0800310 if (null != m3DButton) {
311 m3DButton.refresh();
312 }
George Mount4b4dbd22012-10-18 14:20:39 -0700313 }
Bobby Georgescud3973782012-09-12 13:48:50 -0700314 break;
315 }
Bobby Georgescud3973782012-09-12 13:48:50 -0700316 case MSG_ON_FULL_SCREEN_CHANGED: {
Bobby Georgescudb99a102012-12-04 23:50:02 -0800317 if (mAppBridge != null) {
318 mAppBridge.onFullScreenChanged(message.arg1 == 1);
319 }
Bobby Georgescud3973782012-09-12 13:48:50 -0700320 break;
321 }
322 case MSG_UPDATE_ACTION_BAR: {
323 updateBars();
324 break;
325 }
326 case MSG_WANT_BARS: {
327 wantBars();
328 break;
329 }
Bobby Georgescue23a9d42012-10-10 10:49:51 -0700330 case MSG_UPDATE_DEFERRED: {
331 long nextUpdate = mDeferUpdateUntil - SystemClock.uptimeMillis();
332 if (nextUpdate <= 0) {
333 mDeferredUpdateWaiting = false;
334 updateUIForCurrentPhoto();
335 } else {
336 mHandler.sendEmptyMessageDelayed(MSG_UPDATE_DEFERRED, nextUpdate);
337 }
338 break;
339 }
Bobby Georgescub27df462012-09-27 23:55:44 -0700340 case MSG_ON_CAMERA_CENTER: {
341 mSkipUpdateCurrentPhoto = false;
Bobby Georgescubbc99312012-10-07 13:34:57 -0700342 boolean stayedOnCamera = false;
Bobby Georgescub27df462012-09-27 23:55:44 -0700343 if (!mPhotoView.getFilmMode()) {
Bobby Georgescubbc99312012-10-07 13:34:57 -0700344 stayedOnCamera = true;
Bobby Georgescub27df462012-09-27 23:55:44 -0700345 } else if (SystemClock.uptimeMillis() < mCameraSwitchCutoff &&
346 mMediaSet.getMediaItemCount() > 1) {
347 mPhotoView.switchToImage(1);
348 } else {
Bobby Georgescucc6ad822012-10-22 13:49:35 -0700349 if (mAppBridge != null) mPhotoView.setFilmMode(false);
Bobby Georgescubbc99312012-10-07 13:34:57 -0700350 stayedOnCamera = true;
Bobby Georgescub27df462012-09-27 23:55:44 -0700351 }
352
Bobby Georgescubbc99312012-10-07 13:34:57 -0700353 if (stayedOnCamera) {
Bobby Georgescu617551e2013-01-07 11:25:46 -0800354 if (mAppBridge == null && mMediaSet.getTotalMediaItemCount() > 1) {
Bobby Georgescu5bd00332012-10-24 12:09:38 -0700355 launchCamera();
Bobby Georgescucc6ad822012-10-22 13:49:35 -0700356 /* We got here by swiping from photo 1 to the
357 placeholder, so make it be the thing that
358 is in focus when the user presses back from
359 the camera app */
360 mPhotoView.switchToImage(1);
361 } else {
362 updateBars();
363 updateCurrentPhoto(mModel.getMediaItem(0));
364 }
Bobby Georgescub27df462012-09-27 23:55:44 -0700365 }
366 break;
367 }
Bobby Georgescuf4e22eb2012-10-02 18:34:08 -0700368 case MSG_ON_PICTURE_CENTER: {
Bobby Georgescue23a9d42012-10-10 10:49:51 -0700369 if (!mPhotoView.getFilmMode() && mCurrentPhoto != null
Bobby Georgescuf4e22eb2012-10-02 18:34:08 -0700370 && (mCurrentPhoto.getSupportedOperations() & MediaObject.SUPPORT_ACTION) != 0) {
371 mPhotoView.setFilmMode(true);
372 }
373 break;
374 }
George Mountf122d562012-10-09 17:50:33 -0700375 case MSG_REFRESH_IMAGE: {
Mangesh Ghiware423e45e2012-10-11 23:11:27 -0700376 final MediaItem photo = mCurrentPhoto;
377 mCurrentPhoto = null;
378 updateCurrentPhoto(photo);
379 break;
380 }
381 case MSG_UPDATE_PHOTO_UI: {
Mangesh Ghiware825afb12012-10-10 18:37:24 -0700382 updateUIForCurrentPhoto();
383 break;
384 }
George Mount4b4dbd22012-10-18 14:20:39 -0700385 case MSG_UPDATE_SHARE_URI: {
386 if (mCurrentPhoto == message.obj) {
387 boolean isPanorama360 = message.arg1 != 0;
388 Uri contentUri = mCurrentPhoto.getContentUri();
389 Intent panoramaIntent = null;
390 if (isPanorama360) {
391 panoramaIntent = createSharePanoramaIntent(contentUri);
392 }
393 Intent shareIntent = createShareIntent(mCurrentPhoto);
Paramananda Pradhan9382a972014-12-14 17:27:31 +0530394 if (shareIntent != null) {
maxwend57f7232016-06-04 22:51:06 +0200395 mActionBar.setShareIntents(panoramaIntent, shareIntent);
Paramananda Pradhan9382a972014-12-14 17:27:31 +0530396 }
George Mount4b4dbd22012-10-18 14:20:39 -0700397 setNfcBeamPushUri(contentUri);
398 }
399 break;
400 }
401 case MSG_UPDATE_PANORAMA_UI: {
402 if (mCurrentPhoto == message.obj) {
403 boolean isPanorama360 = message.arg1 != 0;
404 updatePanoramaUI(isPanorama360);
405 }
406 break;
407 }
Bobby Georgescud3973782012-09-12 13:48:50 -0700408 default: throw new AssertionError(message.what);
409 }
410 }
411 };
412
Ray Chen84c220f2012-03-06 17:24:28 +0800413 mSetPathString = data.getString(KEY_MEDIA_SET_PATH);
John Hoford463b9182013-09-16 15:51:02 -0700414 mReadOnlyView = data.getBoolean(KEY_READONLY);
Chih-Chung Changb1e9fd82012-04-30 17:33:21 +0800415 mOriginalSetPathString = mSetPathString;
John Reckddf02252012-09-26 11:37:23 -0700416 setupNfcBeamPush();
Bobby Georgescu7eea4d32012-09-06 17:14:02 -0700417 String itemPathString = data.getString(KEY_MEDIA_ITEM_PATH);
418 Path itemPath = itemPathString != null ?
419 Path.fromString(data.getString(KEY_MEDIA_ITEM_PATH)) :
420 null;
Yuli Huang54fe6202012-05-23 16:06:32 +0800421 mTreatBackAsUp = data.getBoolean(KEY_TREAT_BACK_AS_UP, false);
kaiyized2687a2014-10-15 10:10:13 +0800422 mIsFromWidget = data.getBoolean(KEY_IS_FROM_WIDGET, false);
Bobby Georgescu45f089d2012-10-02 13:30:09 -0700423 mStartInFilmstrip = data.getBoolean(KEY_START_IN_FILMSTRIP, false);
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -0700424 boolean inCameraRoll = data.getBoolean(KEY_IN_CAMERA_ROLL, false);
huiyane0e82562016-04-28 14:19:11 +0800425 if (restoreState == null || mSetPathString == null) {
426 mCurrentIndex = data.getInt(KEY_INDEX_HINT, 0);
427 } else {
428 mCurrentIndex = restoreState.getInt(KEY_INDEX_HINT, 0);
429 //we only save index in onSaveState, set itemPath to null to get the right path later
430 itemPath = null;
431 }
jinwu4fafa7a2017-04-07 13:27:48 +0800432 if ((mCurrentPhoto == null) && (restoreState != null)) {
433 String curPath = restoreState.getString(KEY_CURRENT_PHOTO_HINT, null);
434 if (curPath != null)
435 mCurrentPhoto = (MediaItem)
436 mActivity.getDataManager().getMediaObject(curPath);
437 }
Ray Chen84c220f2012-03-06 17:24:28 +0800438 if (mSetPathString != null) {
Bobby Georgescuba65c372012-10-06 01:06:43 -0700439 mShowSpinner = true;
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800440 mAppBridge = (AppBridge) data.getParcelable(KEY_APP_BRIDGE);
441 if (mAppBridge != null) {
Bobby Georgescu7eea4d32012-09-06 17:14:02 -0700442 mShowBars = false;
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -0700443 mHasCameraScreennailOrPlaceholder = true;
Chih-Chung Chang253c5ae2012-05-16 17:37:10 -0700444 mAppBridge.setServer(this);
Chih-Chung Chang15b351a2012-03-15 16:38:45 +0800445
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800446 // Get the ScreenNail from AppBridge and register it.
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +0800447 int id = SnailSource.newId();
Chih-Chung Changb29a27f2012-03-22 17:42:33 +0800448 Path screenNailSetPath = SnailSource.getSetPath(id);
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800449 Path screenNailItemPath = SnailSource.getItemPath(id);
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +0800450 mScreenNailSet = (SnailAlbum) mActivity.getDataManager()
451 .getMediaObject(screenNailSetPath);
452 mScreenNailItem = (SnailItem) mActivity.getDataManager()
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800453 .getMediaObject(screenNailItemPath);
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +0800454 mScreenNailItem.setScreenNail(mAppBridge.attachScreenNail());
Chih-Chung Changb29a27f2012-03-22 17:42:33 +0800455
Wu-cheng Li23e595f2012-09-21 14:36:21 +0800456 if (data.getBoolean(KEY_SHOW_WHEN_LOCKED, false)) {
Wu-cheng Liefd480e2012-08-30 16:44:32 +0800457 // Set the flag to be on top of the lock screen.
458 mFlags |= FLAG_SHOW_WHEN_LOCKED;
Wu-cheng Lia0ce6822012-08-22 19:15:35 +0800459 }
460
George Mount4e091eb2012-10-09 21:02:42 -0700461 // Don't display "empty album" action item for capture intents.
Wu-cheng Li2c83c5f2012-10-09 14:44:31 +0800462 if (!mSetPathString.equals("/local/all/0")) {
463 // Check if the path is a secure album.
464 if (SecureSource.isSecurePath(mSetPathString)) {
465 mSecureAlbum = (SecureAlbum) mActivity.getDataManager()
466 .getMediaSet(mSetPathString);
467 mShowSpinner = false;
Wu-cheng Li2c83c5f2012-10-09 14:44:31 +0800468 }
Bobby Georgescuc7e3c762012-09-27 16:36:03 -0700469 mSetPathString = "/filter/empty/{"+mSetPathString+"}";
470 }
471
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +0800472 // Combine the original MediaSet with the one for ScreenNail
473 // from AppBridge.
Chih-Chung Changb29a27f2012-03-22 17:42:33 +0800474 mSetPathString = "/combo/item/{" + screenNailSetPath +
475 "," + mSetPathString + "}";
476
477 // Start from the screen nail.
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800478 itemPath = screenNailItemPath;
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -0700479 } else if (inCameraRoll && GalleryUtils.isCameraAvailable(mActivity)) {
Bobby Georgescu45f089d2012-10-02 13:30:09 -0700480 mSetPathString = "/combo/item/{" + FilterSource.FILTER_CAMERA_SHORTCUT +
481 "," + mSetPathString + "}";
482 mCurrentIndex++;
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -0700483 mHasCameraScreennailOrPlaceholder = true;
Chih-Chung Changb29a27f2012-03-22 17:42:33 +0800484 }
485
Chih-Chung Chang6118af92012-06-22 20:56:04 +0800486 MediaSet originalSet = mActivity.getDataManager()
487 .getMediaSet(mSetPathString);
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -0700488 if (mHasCameraScreennailOrPlaceholder && originalSet instanceof ComboAlbum) {
Bobby Georgescuee899c02012-10-01 17:49:30 -0700489 // Use the name of the camera album rather than the default
490 // ComboAlbum behavior
491 ((ComboAlbum) originalSet).useNameOfChild(1);
492 }
Chih-Chung Chang6118af92012-06-22 20:56:04 +0800493 mSelectionManager.setSourceMediaSet(originalSet);
Chih-Chung Chang6b891c62012-06-07 20:09:13 +0800494 mSetPathString = "/filter/delete/{" + mSetPathString + "}";
495 mMediaSet = (FilterDeleteSet) mActivity.getDataManager()
496 .getMediaSet(mSetPathString);
huiyane9fa3d62016-04-13 12:48:07 +0800497 if (mMediaSet != null && mIsFromTimelineScreen) {
Kedi Xufece30c2016-10-21 15:13:32 +0800498 mMediaSet.setShowAlbumsetTimeTitle(false);
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530499 }
Owen Linf9a0a432011-08-17 22:07:43 +0800500 if (mMediaSet == null) {
Ray Chen84c220f2012-03-06 17:24:28 +0800501 Log.w(TAG, "failed to restore " + mSetPathString);
Owen Linf9a0a432011-08-17 22:07:43 +0800502 }
Bobby Georgescu7eea4d32012-09-06 17:14:02 -0700503 if (itemPath == null) {
Bobby Georgescu3eb2e642012-09-24 11:26:10 -0700504 int mediaItemCount = mMediaSet.getMediaItemCount();
505 if (mediaItemCount > 0) {
506 if (mCurrentIndex >= mediaItemCount) mCurrentIndex = 0;
Bobby Georgescud3973782012-09-12 13:48:50 -0700507 itemPath = mMediaSet.getMediaItem(mCurrentIndex, 1)
508 .get(0).getPath();
509 } else {
Bobby Georgescu3eb2e642012-09-24 11:26:10 -0700510 // Bail out, PhotoPage can't load on an empty album
Bobby Georgescud3973782012-09-12 13:48:50 -0700511 return;
512 }
Bobby Georgescu7eea4d32012-09-06 17:14:02 -0700513 }
Owen Linf9a0a432011-08-17 22:07:43 +0800514 PhotoDataAdapter pda = new PhotoDataAdapter(
Chih-Chung Changbd141b52012-04-26 10:10:49 +0800515 mActivity, mPhotoView, mMediaSet, itemPath, mCurrentIndex,
Angus Kong43a80fd2012-05-17 12:47:26 -0700516 mAppBridge == null ? -1 : 0,
Wu-cheng Lidbb6acc2012-08-19 17:04:02 +0800517 mAppBridge == null ? false : mAppBridge.isPanorama(),
Kedi Xu93a91822016-09-14 11:30:29 +0800518 mAppBridge == null ? false : mAppBridge.isStaticCamera());
Owen Linf9a0a432011-08-17 22:07:43 +0800519 mModel = pda;
520 mPhotoView.setModel(mModel);
521
kaiyized2687a2014-10-15 10:10:13 +0800522 // If RTL and from widget, set the flag into PhotoDataAdapter.
523 if (View.LAYOUT_DIRECTION_RTL == TextUtils
524 .getLayoutDirectionFromLocale(Locale.getDefault())
525 && mIsFromWidget) {
526 pda.setFromWidget(mIsFromWidget);
527 }
Owen Linf9a0a432011-08-17 22:07:43 +0800528 pda.setDataListener(new PhotoDataAdapter.DataListener() {
529
Owen Lin113bfc72011-08-30 10:38:59 +0800530 @Override
Owen Linf9a0a432011-08-17 22:07:43 +0800531 public void onPhotoChanged(int index, Path item) {
Bobby Georgescu00ccf352012-09-19 16:51:05 -0700532 int oldIndex = mCurrentIndex;
Owen Linf9a0a432011-08-17 22:07:43 +0800533 mCurrentIndex = index;
Bobby Georgescub27df462012-09-27 23:55:44 -0700534
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -0700535 if (mHasCameraScreennailOrPlaceholder) {
Bobby Georgescub27df462012-09-27 23:55:44 -0700536 if (mCurrentIndex > 0) {
Bobby Georgescub27df462012-09-27 23:55:44 -0700537 mSkipUpdateCurrentPhoto = false;
538 }
539
Bobby Georgescu00ccf352012-09-19 16:51:05 -0700540 if (oldIndex == 0 && mCurrentIndex > 0
541 && !mPhotoView.getFilmMode()) {
542 mPhotoView.setFilmMode(true);
Bobby Georgescu9b4c3e92013-03-13 09:45:18 -0700543 if (mAppBridge != null) {
544 UsageStatistics.onEvent("CameraToFilmstrip",
545 UsageStatistics.TRANSITION_SWIPE, null);
546 }
Bobby Georgescub27df462012-09-27 23:55:44 -0700547 } else if (oldIndex == 2 && mCurrentIndex == 1) {
548 mCameraSwitchCutoff = SystemClock.uptimeMillis() +
549 CAMERA_SWITCH_CUTOFF_THRESHOLD_MS;
550 mPhotoView.stopScrolling();
Bobby Georgescubbc99312012-10-07 13:34:57 -0700551 } else if (oldIndex >= 1 && mCurrentIndex == 0) {
Bobby Georgescuf4e22eb2012-10-02 18:34:08 -0700552 mPhotoView.setWantPictureCenterCallbacks(true);
Bobby Georgescub27df462012-09-27 23:55:44 -0700553 mSkipUpdateCurrentPhoto = true;
Bobby Georgescu00ccf352012-09-19 16:51:05 -0700554 }
555 }
Bobby Georgescub27df462012-09-27 23:55:44 -0700556 if (!mSkipUpdateCurrentPhoto) {
557 if (item != null) {
558 MediaItem photo = mModel.getMediaItem(0);
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530559 if (photo != null) {
560 mActionBar.setTitle(photo.getName());
561 updateCurrentPhoto(photo);
562 }
Bobby Georgescub27df462012-09-27 23:55:44 -0700563 }
564 updateBars();
565 }
Bobby Georgescu00ccf352012-09-19 16:51:05 -0700566 // Reset the timeout for the bars after a swipe
567 refreshHidingMessage();
Owen Linf9a0a432011-08-17 22:07:43 +0800568 }
569
570 @Override
Hung-ying Tyan05da3f52012-10-30 17:47:35 +0800571 public void onLoadingFinished(boolean loadingFailed) {
Owen Linf9a0a432011-08-17 22:07:43 +0800572 if (!mModel.isEmpty()) {
Owen Lin616a70f2012-05-07 16:35:53 +0800573 MediaItem photo = mModel.getMediaItem(0);
lihai556b0f62015-09-11 16:39:15 +0800574 if (photo != null) {
575 updateCurrentPhoto(photo);
576 } else {
577 mModel.resume();
578 }
Owen Linf9a0a432011-08-17 22:07:43 +0800579 } else if (mIsActive) {
Chih-Chung Changc3704762012-06-27 13:40:06 +0800580 // We only want to finish the PhotoPage if there is no
581 // deletion that the user can undo.
582 if (mMediaSet.getNumberOfDeletions() == 0) {
huiyane9fa3d62016-04-13 12:48:07 +0800583 onBackPressed();
Chih-Chung Changc3704762012-06-27 13:40:06 +0800584 }
Owen Linf9a0a432011-08-17 22:07:43 +0800585 }
586 }
587
Owen Linf9a0a432011-08-17 22:07:43 +0800588 @Override
589 public void onLoadingStarted() {
Owen Linf9a0a432011-08-17 22:07:43 +0800590 }
591 });
592 } else {
593 // Get default media set by the URI
594 MediaItem mediaItem = (MediaItem)
595 mActivity.getDataManager().getMediaObject(itemPath);
596 mModel = new SinglePhotoDataAdapter(mActivity, mPhotoView, mediaItem);
597 mPhotoView.setModel(mModel);
598 updateCurrentPhoto(mediaItem);
Bobby Georgescuba65c372012-10-06 01:06:43 -0700599 mShowSpinner = false;
Owen Linf9a0a432011-08-17 22:07:43 +0800600 }
Ray Chencf46a3a2011-09-14 16:46:32 +0800601
Bobby Georgescub265ebb2012-09-12 16:37:53 -0700602 mPhotoView.setFilmMode(mStartInFilmstrip && mMediaSet.getMediaItemCount() > 1);
George Mountf122d562012-10-09 17:50:33 -0700603 RelativeLayout galleryRoot = (RelativeLayout) ((Activity) mActivity)
604 .findViewById(mAppBridge != null ? R.id.content : R.id.gallery_root);
605 if (galleryRoot != null) {
606 if (mSecureAlbum == null) {
Bobby Georgescuf44499d2012-09-17 18:12:11 -0700607 mBottomControls = new PhotoPageBottomControls(this, mActivity, galleryRoot);
jinwu4fafa7a2017-04-07 13:27:48 +0800608 m3DButton = new ThreeDButton(this, mActivity, galleryRoot);
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700609 }
Bobby Georgescuf44499d2012-09-17 18:12:11 -0700610 }
ztenghui02f459f2013-08-30 16:34:23 -0700611
612 ((GLRootView) mActivity.getGLRoot()).setOnSystemUiVisibilityChangeListener(
613 new View.OnSystemUiVisibilityChangeListener() {
614 @Override
615 public void onSystemUiVisibilityChange(int visibility) {
616 int diff = mLastSystemUiVis ^ visibility;
617 mLastSystemUiVis = visibility;
618 if ((diff & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0
619 && (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
620 showBars();
621 }
622 }
623 });
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700624 }
625
Sascha Haeberlinge3b50f12012-10-15 18:28:42 -0700626 @Override
huiyane0e82562016-04-28 14:19:11 +0800627 protected void onSaveState(Bundle outState) {
jinwu80a22b32017-05-16 20:10:30 +0800628 if (mCurrentPhoto != null) {
629 outState.putInt(KEY_INDEX_HINT,mCurrentIndex);
630 outState.putString(KEY_CURRENT_PHOTO_HINT, mCurrentPhoto.getFilePath());
631 super.onSaveState(outState);
632 } else {
633 onBackPressed();
634 }
huiyane0e82562016-04-28 14:19:11 +0800635 }
636
637 @Override
Bobby Georgescuf4e22eb2012-10-02 18:34:08 -0700638 public void onPictureCenter(boolean isCamera) {
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -0700639 isCamera = isCamera || (mHasCameraScreennailOrPlaceholder && mAppBridge == null);
Bobby Georgescuf4e22eb2012-10-02 18:34:08 -0700640 mPhotoView.setWantPictureCenterCallbacks(false);
641 mHandler.removeMessages(MSG_ON_CAMERA_CENTER);
642 mHandler.removeMessages(MSG_ON_PICTURE_CENTER);
643 mHandler.sendEmptyMessage(isCamera ? MSG_ON_CAMERA_CENTER : MSG_ON_PICTURE_CENTER);
Bobby Georgescub27df462012-09-27 23:55:44 -0700644 }
645
Sascha Haeberlinge3b50f12012-10-15 18:28:42 -0700646 @Override
Bobby Georgescuf44499d2012-09-17 18:12:11 -0700647 public boolean canDisplayBottomControls() {
Bobby Georgescu94958432012-10-23 20:52:26 -0700648 return mIsActive && !mPhotoView.canUndo();
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700649 }
650
Sascha Haeberlinge3b50f12012-10-15 18:28:42 -0700651 @Override
Doris Liua680a0c2012-10-18 15:01:35 -0700652 public boolean canDisplayBottomControl(int control) {
George Mount4b4dbd22012-10-18 14:20:39 -0700653 if (mCurrentPhoto == null) {
654 return false;
655 }
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530656 switch (control) {
657 case R.id.photopage_bottom_controls:
658 return mShowBars;
659 case R.id.photopage_bottom_control_edit:
660 return mHaveImageEditor
661 && mShowBars
662 && !mReadOnlyView
663 && !mPhotoView.getFilmMode()
664 && (mCurrentPhoto.getSupportedOperations() & MediaItem.SUPPORT_EDIT) != 0
665 && mCurrentPhoto.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE;
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530666 case R.id.photopage_bottom_control_share:
667 mShareIntent = new Intent(Intent.ACTION_SEND);
668 return mShowBars;
669 case R.id.photopage_bottom_control_delete:
yongga2a611a42016-01-14 17:45:13 +0800670 return mShowBars && !mReadOnlyView;
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530671 default:
672 return false;
Bobby Georgescuf44499d2012-09-17 18:12:11 -0700673 }
674 }
675
Sascha Haeberlinge3b50f12012-10-15 18:28:42 -0700676 @Override
Bobby Georgescuf44499d2012-09-17 18:12:11 -0700677 public void onBottomControlClicked(int control) {
678 switch(control) {
679 case R.id.photopage_bottom_control_edit:
680 launchPhotoEditor();
681 return;
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530682 case R.id.photopage_bottom_control_share:
683 if (mModel != null && mModel.getMediaItem(0) != null) {
Abhishek Panjikar9775cc32015-11-06 17:30:50 +0530684 Uri uri = mActivity.getDataManager().getContentUri(mModel.getMediaItem(0).getPath());
jinwu4fafa7a2017-04-07 13:27:48 +0800685 mActivity.isTopMenuShow = true;
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530686 mShareIntent.setType(MenuExecutor.getMimeType(mModel
687 .getMediaItem(0).getMediaType()));
688 mShareIntent.putExtra(Intent.EXTRA_STREAM, uri);
c_yongga81d10a12016-01-27 13:29:33 +0800689 String shareTitle = mActivity.getResources().
690 getString(R.string.share_dialogue_title);
zhuw58347032018-09-20 14:00:43 +0800691 if (uri.toString().contains("file:")) {
692 Log.d(TAG, "can't share uri started with file://");
693 return;
694 }
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530695 mActivity.startActivity(Intent.createChooser(mShareIntent,
c_yongga81d10a12016-01-27 13:29:33 +0800696 shareTitle));
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530697 }
698 return;
699
700 case R.id.photopage_bottom_control_delete:
701 String confirmMsg = null;
702 confirmMsg = mActivity.getResources().getQuantityString(
703 R.plurals.delete_selection, 1);
704 if (mModel != null && mModel.getMediaItem(0) != null) {
705 Path path = mModel.getMediaItem(0).getPath();
706 mSelectionManager.deSelectAll();
707 mSelectionManager.toggle(path);
708 MenuItem item = null;
709 mMenuExecutor.onMenuClicked(item, confirmMsg,
710 mConfirmDialogListener);
711 }
Bobby Georgescuf44499d2012-09-17 18:12:11 -0700712 return;
Ravi Banuri49f14dd2015-10-21 15:54:59 +0530713 default:
714 return;
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700715 }
Owen Linf9a0a432011-08-17 22:07:43 +0800716 }
717
jinwu4fafa7a2017-04-07 13:27:48 +0800718 @Override
719 public boolean canDisplay3DButton() {
720 return bShow3DButton && mShowBars
721 && (mPhotoView == null ? false : !mPhotoView.getFilmMode());
722 }
723
724 @Override
725 public void on3DButtonClicked() {
726 if (mCurrentPhoto != null) {
727 Path p = mCurrentPhoto.getPath();
728 Uri uri = mActivity.getDataManager().getContentUri(p);
729 Intent intent = new Intent();
730 intent.setClass(mActivity, ThreeDimensionalActivity.class);
731 intent.setData(uri);
732 mActivity.startActivity(intent);
733 }
734 }
735
Chih-Chung Chang67721732012-07-03 12:49:45 +0800736 @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
John Reckddf02252012-09-26 11:37:23 -0700737 private void setupNfcBeamPush() {
738 if (!ApiHelper.HAS_SET_BEAM_PUSH_URIS) return;
739
huiyan73c16da2016-03-24 11:39:23 +0800740 try {
741 NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mActivity);
742 if (adapter != null) {
743 adapter.setBeamPushUris(null, mActivity);
744 adapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() {
745 @Override
746 public Uri[] createBeamUris(NfcEvent event) {
747 return mNfcPushUris;
748 }
749 }, mActivity);
750 }
751 } catch (NullPointerException e) {
752 e.printStackTrace();
753 } catch (Exception e) {
754 e.printStackTrace();
Yuli Huangfc869942012-06-29 18:59:17 +0800755 }
756 }
757
John Reckddf02252012-09-26 11:37:23 -0700758 private void setNfcBeamPushUri(Uri uri) {
759 mNfcPushUris[0] = uri;
760 }
761
Paramananda Pradhan9382a972014-12-14 17:27:31 +0530762 private Intent createShareIntent(MediaObject mediaObject) {
George Mount4b4dbd22012-10-18 14:20:39 -0700763 int type = mediaObject.getMediaType();
Owen Linca181a62012-10-16 10:22:54 +0800764 return new Intent(Intent.ACTION_SEND)
765 .setType(MenuExecutor.getMimeType(type))
George Mount4b4dbd22012-10-18 14:20:39 -0700766 .putExtra(Intent.EXTRA_STREAM, mediaObject.getContentUri())
Owen Linca181a62012-10-16 10:22:54 +0800767 .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Mangesh Ghiware5172dee2012-09-27 21:05:41 -0700768 }
Owen Lin2bb717f2012-07-13 17:23:05 +0800769
George Mount4b4dbd22012-10-18 14:20:39 -0700770 private static Intent createSharePanoramaIntent(Uri contentUri) {
Owen Linca181a62012-10-16 10:22:54 +0800771 return new Intent(Intent.ACTION_SEND)
772 .setType(GalleryUtils.MIME_TYPE_PANORAMA360)
George Mount4b4dbd22012-10-18 14:20:39 -0700773 .putExtra(Intent.EXTRA_STREAM, contentUri)
Owen Linca181a62012-10-16 10:22:54 +0800774 .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Wu-cheng Lifb557192012-07-19 17:11:06 +0800775 }
776
Bobby Georgescu48129f32012-10-22 11:13:34 -0700777 private void overrideTransitionToEditor() {
Bobby Georgescu2db8b142013-02-08 13:53:17 -0800778 ((Activity) mActivity).overridePendingTransition(android.R.anim.fade_in,
Bobby Georgescu48129f32012-10-22 11:13:34 -0700779 android.R.anim.fade_out);
780 }
781
Doris Liua680a0c2012-10-18 15:01:35 -0700782 private void launchTinyPlanet() {
783 // Deep link into tiny planet
784 MediaItem current = mModel.getMediaItem(0);
785 Intent intent = new Intent(FilterShowActivity.TINY_PLANET_ACTION);
786 intent.setClass(mActivity, FilterShowActivity.class);
787 intent.setDataAndType(current.getContentUri(), current.getMimeType())
788 .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Bobby Georgescua850a542012-10-23 15:40:06 -0700789 intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN,
790 mActivity.isFullscreen());
Doris Liua680a0c2012-10-18 15:01:35 -0700791 mActivity.startActivityForResult(intent, REQUEST_EDIT);
Bobby Georgescu48129f32012-10-22 11:13:34 -0700792 overrideTransitionToEditor();
Doris Liua680a0c2012-10-18 15:01:35 -0700793 }
794
Bobby Georgescu5bd00332012-10-24 12:09:38 -0700795 private void launchCamera() {
Mangesh Ghiware55705d52013-08-19 11:52:32 -0700796 mRecenterCameraOnResume = false;
797 GalleryUtils.startCameraActivity(mActivity);
Bobby Georgescu5bd00332012-10-24 12:09:38 -0700798 }
799
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700800 private void launchPhotoEditor() {
801 MediaItem current = mModel.getMediaItem(0);
Bobby Georgescu462923e2012-10-02 10:30:07 -0700802 if (current == null || (current.getSupportedOperations()
803 & MediaObject.SUPPORT_EDIT) == 0) {
804 return;
805 }
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700806
807 Intent intent = new Intent(ACTION_NEXTGEN_EDIT);
Owen Linb6692652012-10-04 11:26:30 +0800808
809 intent.setDataAndType(current.getContentUri(), current.getMimeType())
810 .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700811 if (mActivity.getPackageManager()
812 .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) {
813 intent.setAction(Intent.ACTION_EDIT);
814 }
Bobby Georgescua850a542012-10-23 15:40:06 -0700815 intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN,
816 mActivity.isFullscreen());
Chao Zhang8724b7e2016-05-12 17:34:31 +0800817
818 List<ResolveInfo> resolveInfoList = mActivity.getPackageManager()
819 .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
820 if (resolveInfoList != null && resolveInfoList.size() > 0) {
821 if (resolveInfoList.size() == 1) {
822 // only one app can resolve intent, don't use createChooser.
823 mActivity.startActivityForResult(intent, REQUEST_EDIT);
824 } else {
825 mActivity.startActivityForResult(Intent.createChooser(intent, null), REQUEST_EDIT);
826 }
827 overrideTransitionToEditor();
828 }
Bobby Georgescua9948ef2012-09-11 17:02:03 -0700829 }
830
nicolasroard8c4e95f2013-04-08 18:16:17 -0700831 private void launchSimpleEditor() {
832 MediaItem current = mModel.getMediaItem(0);
833 if (current == null || (current.getSupportedOperations()
834 & MediaObject.SUPPORT_EDIT) == 0) {
835 return;
836 }
837
838 Intent intent = new Intent(ACTION_SIMPLE_EDIT);
839
840 intent.setDataAndType(current.getContentUri(), current.getMimeType())
841 .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
842 if (mActivity.getPackageManager()
843 .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) {
844 intent.setAction(Intent.ACTION_EDIT);
845 }
846 intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN,
847 mActivity.isFullscreen());
848 ((Activity) mActivity).startActivityForResult(Intent.createChooser(intent, null),
849 REQUEST_EDIT);
850 overrideTransitionToEditor();
851 }
852
Bobby Georgescue23a9d42012-10-10 10:49:51 -0700853 private void requestDeferredUpdate() {
854 mDeferUpdateUntil = SystemClock.uptimeMillis() + DEFERRED_UPDATE_MS;
855 if (!mDeferredUpdateWaiting) {
856 mDeferredUpdateWaiting = true;
857 mHandler.sendEmptyMessageDelayed(MSG_UPDATE_DEFERRED, DEFERRED_UPDATE_MS);
858 }
859 }
860
861 private void updateUIForCurrentPhoto() {
Owen Linf9a0a432011-08-17 22:07:43 +0800862 if (mCurrentPhoto == null) return;
Bobby Georgescuc7e3c762012-09-27 16:36:03 -0700863
864 // If by swiping or deletion the user ends up on an action item
865 // and zoomed in, zoom out so that the context of the action is
866 // more clear
Bobby Georgescue23a9d42012-10-10 10:49:51 -0700867 if ((mCurrentPhoto.getSupportedOperations() & MediaObject.SUPPORT_ACTION) != 0
Bobby Georgescuc7e3c762012-09-27 16:36:03 -0700868 && !mPhotoView.getFilmMode()) {
Bobby Georgescuf4e22eb2012-10-02 18:34:08 -0700869 mPhotoView.setWantPictureCenterCallbacks(true);
Bobby Georgescuc7e3c762012-09-27 16:36:03 -0700870 }
871
Owen Linf9a0a432011-08-17 22:07:43 +0800872 updateMenuOperations();
George Mount4b4dbd22012-10-18 14:20:39 -0700873 refreshBottomControlsWhenReady();
Likai Dingb7c13c22017-02-16 14:54:04 +0800874 parseGDepth();
Owen Linf9a0a432011-08-17 22:07:43 +0800875 if (mShowDetails) {
Michael Kolb995c4562012-07-20 12:23:09 -0700876 mDetailsHelper.reloadDetails();
Owen Linf9a0a432011-08-17 22:07:43 +0800877 }
Wu-cheng Li898a2f42012-08-27 00:10:38 +0800878 if ((mSecureAlbum == null)
Bobby Georgescue23a9d42012-10-10 10:49:51 -0700879 && (mCurrentPhoto.getSupportedOperations() & MediaItem.SUPPORT_SHARE) != 0) {
George Mount4b4dbd22012-10-18 14:20:39 -0700880 mCurrentPhoto.getPanoramaSupport(mUpdateShareURICallback);
Bobby Georgescue23a9d42012-10-10 10:49:51 -0700881 }
882 }
883
884 private void updateCurrentPhoto(MediaItem photo) {
885 if (mCurrentPhoto == photo) return;
886 mCurrentPhoto = photo;
jinwu4fafa7a2017-04-07 13:27:48 +0800887 if (mPhotoView == null) {
888 return;
889 }
Bobby Georgescue23a9d42012-10-10 10:49:51 -0700890 if (mPhotoView.getFilmMode()) {
891 requestDeferredUpdate();
892 } else {
893 updateUIForCurrentPhoto();
Paramanandac12b8b12015-03-24 17:51:29 +0530894
895 // Manage DRM rights while image selection changed. this
896 // flow will comes for both image and video, but here
897 // we will consume rights for image files only.
898 // Do not consume rights of a GIF image and video here.
899 // ViewGifImage will take care of GIF rights consumption stub.
900 // MediaPlayer will handle the video rights consumption stub.
Anand Chaudhari922a2fa2015-09-23 18:01:06 +0530901// String mime = mCurrentPhoto.getMimeType();
902// if (!TextUtils.isEmpty(mime) && !mime.equals("image/gif")
903// && !mime.startsWith("video/")) {
904// DrmHelper.manageDrmLicense(mActivity.getAndroidContext(),
905// mHandler, mCurrentPhoto.getFilePath(),
906// mCurrentPhoto.getMimeType());
907// }
Chih-Chung Chang15b351a2012-03-15 16:38:45 +0800908 }
Mangesh Ghiware825afb12012-10-10 18:37:24 -0700909 }
910
Owen Linf9a0a432011-08-17 22:07:43 +0800911 private void updateMenuOperations() {
Owen Lin24081fe2012-08-28 18:04:00 +0800912 Menu menu = mActionBar.getMenu();
913
914 // it could be null if onCreateActionBar has not been called yet
915 if (menu == null) return;
916
917 MenuItem item = menu.findItem(R.id.action_slideshow);
John Reck53fe9f72012-09-27 15:26:00 -0700918 if (item != null) {
919 item.setVisible((mSecureAlbum == null) && canDoSlideShow());
920 }
Chih-Chung Chang20662002011-11-18 18:04:10 +0800921 if (mCurrentPhoto == null) return;
Owen Lin24081fe2012-08-28 18:04:00 +0800922
Owen Linf9a0a432011-08-17 22:07:43 +0800923 int supportedOperations = mCurrentPhoto.getSupportedOperations();
John Hoford463b9182013-09-16 15:51:02 -0700924 if (mReadOnlyView) {
kaiyiz078fa1b2015-01-08 13:50:23 +0800925 supportedOperations &= ~MediaObject.SUPPORT_EDIT;
John Hoford463b9182013-09-16 15:51:02 -0700926 }
Wu-cheng Li898a2f42012-08-27 00:10:38 +0800927 if (mSecureAlbum != null) {
Owen Lin24081fe2012-08-28 18:04:00 +0800928 supportedOperations &= MediaObject.SUPPORT_DELETE;
Sascha Haeberling8e582832013-04-22 16:06:25 -0700929 } else {
930 mCurrentPhoto.getPanoramaSupport(mUpdatePanoramaMenuItemsCallback);
931 if (!mHaveImageEditor) {
932 supportedOperations &= ~MediaObject.SUPPORT_EDIT;
933 }
lihai260fcaa2015-08-20 08:54:29 +0800934 // If current photo page is single item only, to cut some menu items
935 boolean singleItemOnly = mData.getBoolean("SingleItemOnly", false);
936 if (singleItemOnly) {
937 supportedOperations &= ~MediaObject.SUPPORT_DELETE;
938 supportedOperations &= ~MediaObject.SUPPORT_ROTATE;
939 supportedOperations &= ~MediaObject.SUPPORT_SHARE;
940 supportedOperations &= ~MediaObject.SUPPORT_CROP;
941 supportedOperations &= ~MediaObject.SUPPORT_INFO;
942 supportedOperations &= ~MediaObject.SUPPORT_SETAS;
943 }
Owen Linf9a0a432011-08-17 22:07:43 +0800944 }
Owen Lin24081fe2012-08-28 18:04:00 +0800945 MenuExecutor.updateMenuOperation(menu, supportedOperations);
Owen Linf9a0a432011-08-17 22:07:43 +0800946 }
947
Chih-Chung Chang20662002011-11-18 18:04:10 +0800948 private boolean canDoSlideShow() {
949 if (mMediaSet == null || mCurrentPhoto == null) {
950 return false;
951 }
952 if (mCurrentPhoto.getMediaType() != MediaObject.MEDIA_TYPE_IMAGE) {
953 return false;
954 }
Chih-Chung Chang20662002011-11-18 18:04:10 +0800955 return true;
956 }
957
Chih-Chung Chang61f94712012-05-02 20:05:16 +0800958 //////////////////////////////////////////////////////////////////////////
959 // Action Bar show/hide management
960 //////////////////////////////////////////////////////////////////////////
961
Owen Linf9a0a432011-08-17 22:07:43 +0800962 private void showBars() {
963 if (mShowBars) return;
964 mShowBars = true;
Chih-Chung Change6251df2012-05-22 11:35:46 -0700965 mOrientationManager.unlockOrientation();
Owen Linf9a0a432011-08-17 22:07:43 +0800966 mActionBar.show();
Joey Rizzolicca548c2016-06-10 17:53:02 +0200967 mActivity.getGLRoot().setLightsOutMode(false);
Chih-Chung Chang61f94712012-05-02 20:05:16 +0800968 refreshHidingMessage();
George Mount4b4dbd22012-10-18 14:20:39 -0700969 refreshBottomControlsWhenReady();
Owen Linf9a0a432011-08-17 22:07:43 +0800970 }
971
972 private void hideBars() {
973 if (!mShowBars) return;
974 mShowBars = false;
975 mActionBar.hide();
Chih-Chung Chang0b2486c2012-05-17 16:45:12 -0700976 mActivity.getGLRoot().setLightsOutMode(true);
Chih-Chung Chang61f94712012-05-02 20:05:16 +0800977 mHandler.removeMessages(MSG_HIDE_BARS);
George Mount4b4dbd22012-10-18 14:20:39 -0700978 refreshBottomControlsWhenReady();
Owen Linf9a0a432011-08-17 22:07:43 +0800979 }
980
981 private void refreshHidingMessage() {
982 mHandler.removeMessages(MSG_HIDE_BARS);
shenfe94f1e042016-10-25 13:07:29 +0800983 if (mPhotoView == null) {
jinwu4fafa7a2017-04-07 13:27:48 +0800984 return;
shenfe94f1e042016-10-25 13:07:29 +0800985 }
Bobby Georgescu7eea4d32012-09-06 17:14:02 -0700986 if (!mIsMenuVisible && !mPhotoView.getFilmMode()) {
Owen Linf9a0a432011-08-17 22:07:43 +0800987 mHandler.sendEmptyMessageDelayed(MSG_HIDE_BARS, HIDE_BARS_TIMEOUT);
988 }
989 }
990
Chih-Chung Changaeb30622012-05-03 11:41:05 +0800991 private boolean canShowBars() {
992 // No bars if we are showing camera preview.
Bobby Georgescu56bdcb72012-09-19 15:14:53 -0700993 if (mAppBridge != null && mCurrentIndex == 0
994 && !mPhotoView.getFilmMode()) return false;
995
Chih-Chung Changaeb30622012-05-03 11:41:05 +0800996 // No bars if it's not allowed.
997 if (!mActionBarAllowed) return false;
Chih-Chung Changaeb30622012-05-03 11:41:05 +0800998
John Reck4ea5c272013-01-18 16:00:45 -0800999 Configuration config = mActivity.getResources().getConfiguration();
1000 if (config.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH) {
1001 return false;
1002 }
1003
Chih-Chung Changaeb30622012-05-03 11:41:05 +08001004 return true;
1005 }
1006
Chih-Chung Change6251df2012-05-22 11:35:46 -07001007 private void wantBars() {
1008 if (canShowBars()) showBars();
1009 }
1010
Chih-Chung Chang61f94712012-05-02 20:05:16 +08001011 private void toggleBars() {
Owen Linf9a0a432011-08-17 22:07:43 +08001012 if (mShowBars) {
1013 hideBars();
Chih-Chung Changaeb30622012-05-03 11:41:05 +08001014 } else {
Chih-Chung Change6251df2012-05-22 11:35:46 -07001015 if (canShowBars()) showBars();
Owen Linf9a0a432011-08-17 22:07:43 +08001016 }
1017 }
1018
Chih-Chung Chang61f94712012-05-02 20:05:16 +08001019 private void updateBars() {
Chih-Chung Change6251df2012-05-22 11:35:46 -07001020 if (!canShowBars()) {
Chih-Chung Chang61f94712012-05-02 20:05:16 +08001021 hideBars();
1022 }
Owen Linf9a0a432011-08-17 22:07:43 +08001023 }
1024
Owen Linf9a0a432011-08-17 22:07:43 +08001025 @Override
1026 protected void onBackPressed() {
nicolasroard4d7efab2013-10-15 15:36:16 -07001027 showBars();
Owen Linf9a0a432011-08-17 22:07:43 +08001028 if (mShowDetails) {
1029 hideDetails();
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +08001030 } else if (mAppBridge == null || !switchWithCaptureAnimation(-1)) {
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001031 // We are leaving this page. Set the result now.
1032 setResult();
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001033 if (mStartInFilmstrip && !mPhotoView.getFilmMode()) {
1034 mPhotoView.setFilmMode(true);
1035 } else if (mTreatBackAsUp) {
Yuli Huang54fe6202012-05-23 16:06:32 +08001036 onUpPressed();
1037 } else {
huiyane9fa3d62016-04-13 12:48:07 +08001038 if (mMediaSet != null && mIsFromTimelineScreen) {
1039 //if back to TimeLinePage, need show timeline title
Kedi Xufece30c2016-10-21 15:13:32 +08001040 mMediaSet.setShowAlbumsetTimeTitle(true);
huiyane9fa3d62016-04-13 12:48:07 +08001041 }
Yuli Huang54fe6202012-05-23 16:06:32 +08001042 super.onBackPressed();
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301043 mActionBar.setBackGroundDefault();
1044 int count = mActivity.getStateManager().getStateCount();
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301045 if (mIsFromVideoScreen || count == 1 || mIsFromTimelineScreen) {
Arne Coucheronccbf7a72017-07-13 01:36:11 +02001046 ((GalleryActivity) mActivity).toggleNavBar(true);
wqi57d76b02016-03-25 11:24:08 +08001047 if (mModel instanceof PhotoDataAdapter) {
1048 ((PhotoDataAdapter) mModel).setDataListener(null);
1049 }
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301050 }
Yuli Huang54fe6202012-05-23 16:06:32 +08001051 }
Owen Linf9a0a432011-08-17 22:07:43 +08001052 }
1053 }
1054
Chih-Chung Changb1e9fd82012-04-30 17:33:21 +08001055 private void onUpPressed() {
Bobby Georgescu833f7752012-09-26 14:22:57 -07001056 if ((mStartInFilmstrip || mAppBridge != null)
1057 && !mPhotoView.getFilmMode()) {
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001058 mPhotoView.setFilmMode(true);
1059 return;
1060 }
1061
Chih-Chung Changb1e9fd82012-04-30 17:33:21 +08001062 if (mActivity.getStateManager().getStateCount() > 1) {
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001063 setResult();
Chih-Chung Changb1e9fd82012-04-30 17:33:21 +08001064 super.onBackPressed();
Chih-Chung Changba12eae2012-05-07 02:29:37 +08001065 return;
Chih-Chung Chang66ca8482012-05-04 21:54:01 +08001066 }
1067
1068 if (mOriginalSetPathString == null) return;
1069
1070 if (mAppBridge == null) {
Chih-Chung Changb1e9fd82012-04-30 17:33:21 +08001071 // We're in view mode so set up the stacks on our own.
1072 Bundle data = new Bundle(getData());
1073 data.putString(AlbumPage.KEY_MEDIA_PATH, mOriginalSetPathString);
1074 data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH,
1075 mActivity.getDataManager().getTopSetPath(
1076 DataManager.INCLUDE_ALL));
1077 mActivity.getStateManager().switchState(this, AlbumPage.class, data);
Chih-Chung Chang66ca8482012-05-04 21:54:01 +08001078 } else {
Bobby Georgescu833f7752012-09-26 14:22:57 -07001079 GalleryUtils.startGalleryActivity(mActivity);
Chih-Chung Changb1e9fd82012-04-30 17:33:21 +08001080 }
1081 }
1082
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001083 private void setResult() {
1084 Intent result = null;
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001085 result = new Intent();
1086 result.putExtra(KEY_RETURN_INDEX_HINT, mCurrentIndex);
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001087 setStateResult(Activity.RESULT_OK, result);
1088 }
1089
1090 //////////////////////////////////////////////////////////////////////////
1091 // AppBridge.Server interface
1092 //////////////////////////////////////////////////////////////////////////
1093
1094 @Override
Chih-Chung Chang2ef46ed2012-05-08 17:57:33 +08001095 public void setCameraRelativeFrame(Rect frame) {
1096 mPhotoView.setCameraRelativeFrame(frame);
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001097 }
1098
1099 @Override
Chih-Chung Chang2c617382012-04-20 20:06:19 +08001100 public boolean switchWithCaptureAnimation(int offset) {
1101 return mPhotoView.switchWithCaptureAnimation(offset);
1102 }
1103
Owen Linf9a0a432011-08-17 22:07:43 +08001104 @Override
Chih-Chung Chang65757942012-05-06 03:25:16 +08001105 public void setSwipingEnabled(boolean enabled) {
1106 mPhotoView.setSwipingEnabled(enabled);
1107 }
1108
1109 @Override
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +08001110 public void notifyScreenNailChanged() {
1111 mScreenNailItem.setScreenNail(mAppBridge.attachScreenNail());
1112 mScreenNailSet.notifyChange();
1113 }
1114
1115 @Override
Wu-cheng Lia0ce6822012-08-22 19:15:35 +08001116 public void addSecureAlbumItem(boolean isVideo, int id) {
1117 mSecureAlbum.addMediaItem(isVideo, id);
1118 }
1119
1120 @Override
Owen Linf9a0a432011-08-17 22:07:43 +08001121 protected boolean onCreateActionBar(Menu menu) {
Owen Linb21b8e52012-08-24 12:25:57 +08001122 mActionBar.createActionBarMenu(R.menu.photo, menu);
John Reck8fe22ec2012-09-26 16:13:02 -07001123 mHaveImageEditor = GalleryUtils.isEditorAvailable(mActivity, "image/*");
Owen Linf9a0a432011-08-17 22:07:43 +08001124 updateMenuOperations();
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301125 //mActionBar.setTitle(mMediaSet != null ? mMediaSet.getName() : "");
Owen Linb21b8e52012-08-24 12:25:57 +08001126 return true;
Owen Linf9a0a432011-08-17 22:07:43 +08001127 }
1128
Owen Lind759b7c2012-05-16 15:32:02 -07001129 private MenuExecutor.ProgressListener mConfirmDialogListener =
1130 new MenuExecutor.ProgressListener() {
1131 @Override
1132 public void onProgressUpdate(int index) {}
1133
1134 @Override
1135 public void onProgressComplete(int result) {}
1136
1137 @Override
1138 public void onConfirmDialogShown() {
1139 mHandler.removeMessages(MSG_HIDE_BARS);
1140 }
1141
1142 @Override
1143 public void onConfirmDialogDismissed(boolean confirmed) {
1144 refreshHidingMessage();
1145 }
Bobby Georgescuba50b942012-08-08 00:09:50 -07001146
1147 @Override
1148 public void onProgressStart() {}
Owen Lind759b7c2012-05-16 15:32:02 -07001149 };
1150
Bobby Georgescu3cf502a2012-10-01 15:50:11 -07001151 private void switchToGrid() {
Bobby Georgescu55858262012-10-15 13:48:08 -07001152 if (mActivity.getStateManager().hasStateClass(AlbumPage.class)) {
Bobby Georgescu3cf502a2012-10-01 15:50:11 -07001153 onUpPressed();
1154 } else {
1155 if (mOriginalSetPathString == null) return;
Bobby Georgescu3cf502a2012-10-01 15:50:11 -07001156 Bundle data = new Bundle(getData());
1157 data.putString(AlbumPage.KEY_MEDIA_PATH, mOriginalSetPathString);
1158 data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH,
1159 mActivity.getDataManager().getTopSetPath(
1160 DataManager.INCLUDE_ALL));
1161
1162 // We only show cluster menu in the first AlbumPage in stack
1163 // TODO: Enable this when running from the camera app
1164 boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class);
1165 data.putBoolean(AlbumPage.KEY_SHOW_CLUSTER_MENU, !inAlbum
1166 && mAppBridge == null);
1167
1168 data.putBoolean(PhotoPage.KEY_APP_BRIDGE, mAppBridge != null);
1169
1170 // Account for live preview being first item
1171 mActivity.getTransitionStore().put(KEY_RETURN_INDEX_HINT,
1172 mAppBridge != null ? mCurrentIndex - 1 : mCurrentIndex);
1173
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -07001174 if (mHasCameraScreennailOrPlaceholder && mAppBridge != null) {
Bobby Georgescu55858262012-10-15 13:48:08 -07001175 mActivity.getStateManager().startState(AlbumPage.class, data);
1176 } else {
1177 mActivity.getStateManager().switchState(this, AlbumPage.class, data);
1178 }
Bobby Georgescu3cf502a2012-10-01 15:50:11 -07001179 }
1180 }
1181
Owen Linf9a0a432011-08-17 22:07:43 +08001182 @Override
1183 protected boolean onItemSelected(MenuItem item) {
Bobby Georgescud3973782012-09-12 13:48:50 -07001184 if (mModel == null) return true;
Owen Lind759b7c2012-05-16 15:32:02 -07001185 refreshHidingMessage();
Owen Lin616a70f2012-05-07 16:35:53 +08001186 MediaItem current = mModel.getMediaItem(0);
Owen Linf9a0a432011-08-17 22:07:43 +08001187
Doris Liu599bdd62012-11-12 15:17:36 -08001188 // This is a shield for monkey when it clicks the action bar
1189 // menu when transitioning from filmstrip to camera
1190 if (current instanceof SnailItem) return true;
1191 // TODO: We should check the current photo against the MediaItem
1192 // that the menu was initially created for. We need to fix this
1193 // after PhotoPage being refactored.
Owen Linf9a0a432011-08-17 22:07:43 +08001194 if (current == null) {
1195 // item is not ready, ignore
1196 return true;
1197 }
Owen Linf9a0a432011-08-17 22:07:43 +08001198 int currentIndex = mModel.getCurrentIndex();
kaiyized2687a2014-10-15 10:10:13 +08001199
1200 // If RTL, the current index need be revised.
1201 if (View.LAYOUT_DIRECTION_RTL == TextUtils
1202 .getLayoutDirectionFromLocale(Locale.getDefault())) {
1203 currentIndex = mMediaSet.getMediaItemCount() - currentIndex - 1;
1204 }
Owen Linf9a0a432011-08-17 22:07:43 +08001205 Path path = current.getPath();
1206
1207 DataManager manager = mActivity.getDataManager();
1208 int action = item.getItemId();
Ray Chen9a033b02012-05-15 11:22:21 +08001209 String confirmMsg = null;
Owen Linf9a0a432011-08-17 22:07:43 +08001210 switch (action) {
Ray Chen84c220f2012-03-06 17:24:28 +08001211 case android.R.id.home: {
Chih-Chung Changb1e9fd82012-04-30 17:33:21 +08001212 onUpPressed();
Ray Chen84c220f2012-03-06 17:24:28 +08001213 return true;
1214 }
Owen Linf9a0a432011-08-17 22:07:43 +08001215 case R.id.action_slideshow: {
1216 Bundle data = new Bundle();
Owen Lin6cf80742011-08-28 10:50:21 +08001217 data.putString(SlideshowPage.KEY_SET_PATH, mMediaSet.getPath().toString());
Ray Chen604f0532011-10-21 16:07:12 +08001218 data.putString(SlideshowPage.KEY_ITEM_PATH, path.toString());
Owen Linf9a0a432011-08-17 22:07:43 +08001219 data.putInt(SlideshowPage.KEY_PHOTO_INDEX, currentIndex);
1220 data.putBoolean(SlideshowPage.KEY_REPEAT, true);
1221 mActivity.getStateManager().startStateForResult(
1222 SlideshowPage.class, REQUEST_SLIDESHOW, data);
1223 return true;
1224 }
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301225 /*case R.id.action_crop: {
Wu-cheng Li898a2f42012-08-27 00:10:38 +08001226 Activity activity = mActivity;
Ruben Brunkc3178ca2013-04-16 16:17:45 -07001227 Intent intent = new Intent(CropActivity.CROP_ACTION);
1228 intent.setClass(activity, CropActivity.class);
Ruben Brunk63926d22012-10-17 00:40:35 -07001229 intent.setDataAndType(manager.getContentUri(path), current.getMimeType())
1230 .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Owen Linf9a0a432011-08-17 22:07:43 +08001231 activity.startActivityForResult(intent, PicasaSource.isPicasaImage(current)
1232 ? REQUEST_CROP_PICASA
1233 : REQUEST_CROP);
1234 return true;
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301235 }*/
Teng-Hui Zhu50ea2d22012-08-23 16:45:11 -07001236 case R.id.action_trim: {
Teng-Hui Zhu3f1f1ba2012-08-24 14:50:37 -07001237 Intent intent = new Intent(mActivity, TrimVideo.class);
1238 intent.setData(manager.getContentUri(path));
Teng-Hui Zhu15ff1b12012-09-23 15:02:56 -07001239 // We need the file path to wrap this into a RandomAccessFile.
Likai Ding4dc5e6d2016-05-20 14:21:43 +08001240 String str = current.getMimeType();
xiaoqiny3be69402014-12-25 13:39:42 +08001241 if("video/mp4".equals(str) || "video/mpeg4".equals(str)
1242 || "video/3gpp".equals(str) || "video/3gpp2".equals(str)) {
1243 intent.putExtra(KEY_MEDIA_ITEM_PATH, current.getFilePath());
1244 mActivity.startActivityForResult(intent, REQUEST_TRIM);
1245 } else {
1246 Toast.makeText(mActivity,mActivity.getString(R.string.can_not_trim),
1247 Toast.LENGTH_SHORT).show();
1248 }
Teng-Hui Zhu50ea2d22012-08-23 16:45:11 -07001249 return true;
1250 }
Teng-Hui Zhu648b3392012-11-13 10:39:26 -08001251 case R.id.action_mute: {
Bobby Georgescu1a719802013-03-14 15:19:23 -07001252 MuteVideo muteVideo = new MuteVideo(current.getFilePath(),
Teng-Hui Zhu648b3392012-11-13 10:39:26 -08001253 manager.getContentUri(path), mActivity);
1254 muteVideo.muteInBackground();
1255 return true;
1256 }
Yuli Huangf50ce2b2012-05-02 00:50:56 +08001257 case R.id.action_edit: {
Bobby Georgescua9948ef2012-09-11 17:02:03 -07001258 launchPhotoEditor();
Yuli Huangf50ce2b2012-05-02 00:50:56 +08001259 return true;
1260 }
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301261 /*case R.id.action_simple_edit: {
nicolasroard8c4e95f2013-04-08 18:16:17 -07001262 launchSimpleEditor();
1263 return true;
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301264 }*/
Owen Linf9a0a432011-08-17 22:07:43 +08001265 case R.id.action_details: {
1266 if (mShowDetails) {
1267 hideDetails();
1268 } else {
Michael Kolb995c4562012-07-20 12:23:09 -07001269 showDetails();
Owen Linf9a0a432011-08-17 22:07:43 +08001270 }
1271 return true;
1272 }
nicolasroard513eb242013-08-19 16:21:12 -07001273 case R.id.print: {
huiyan5101dc62016-05-11 15:10:28 +08001274 try {
1275 mActivity.printSelectedImage(manager.getContentUri(path));
1276 } catch (SecurityException e) {
1277 e.printStackTrace();
1278 mActivity.finish();
1279 }
nicolasroard513eb242013-08-19 16:21:12 -07001280 return true;
1281 }
Ray Chen67098d12012-04-05 17:25:43 +08001282 case R.id.action_delete:
Ray Chen9a033b02012-05-15 11:22:21 +08001283 confirmMsg = mActivity.getResources().getQuantityString(
1284 R.plurals.delete_selection, 1);
Owen Linf9a0a432011-08-17 22:07:43 +08001285 case R.id.action_setas:
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301286 //case R.id.action_rotate_ccw:
1287 //case R.id.action_rotate_cw:
Owen Linf9a0a432011-08-17 22:07:43 +08001288 case R.id.action_show_on_map:
Owen Linf9a0a432011-08-17 22:07:43 +08001289 mSelectionManager.deSelectAll();
1290 mSelectionManager.toggle(path);
Owen Lind759b7c2012-05-16 15:32:02 -07001291 mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener);
Owen Linf9a0a432011-08-17 22:07:43 +08001292 return true;
Anand Chaudhari922a2fa2015-09-23 18:01:06 +05301293// case R.id.action_drm_info:
1294// String filepath = current.getFilePath();
1295// if (DrmHelper.isDrmFile(filepath)) {
1296// DrmHelper.showDrmInfo(mActivity.getAndroidContext(), filepath);
1297// }
1298// return true;
Owen Linf9a0a432011-08-17 22:07:43 +08001299 default :
1300 return false;
1301 }
1302 }
1303
1304 private void hideDetails() {
1305 mShowDetails = false;
Ray Chen4105e222011-08-24 11:40:04 +08001306 mDetailsHelper.hide();
Owen Linf9a0a432011-08-17 22:07:43 +08001307 }
1308
Michael Kolb995c4562012-07-20 12:23:09 -07001309 private void showDetails() {
Owen Linf9a0a432011-08-17 22:07:43 +08001310 mShowDetails = true;
Ray Chen4105e222011-08-24 11:40:04 +08001311 if (mDetailsHelper == null) {
1312 mDetailsHelper = new DetailsHelper(mActivity, mRootPane, new MyDetailsSource());
1313 mDetailsHelper.setCloseListener(new CloseListener() {
Pin Ting06c64012012-05-03 08:26:17 +08001314 @Override
Owen Linf9a0a432011-08-17 22:07:43 +08001315 public void onClose() {
1316 hideDetails();
1317 }
1318 });
Owen Linf9a0a432011-08-17 22:07:43 +08001319 }
Ray Chen4105e222011-08-24 11:40:04 +08001320 mDetailsHelper.show();
Owen Linf9a0a432011-08-17 22:07:43 +08001321 }
1322
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001323 ////////////////////////////////////////////////////////////////////////////
1324 // Callbacks from PhotoView
1325 ////////////////////////////////////////////////////////////////////////////
1326 @Override
Owen Linf9a0a432011-08-17 22:07:43 +08001327 public void onSingleTapUp(int x, int y) {
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001328 if (mAppBridge != null) {
1329 if (mAppBridge.onSingleTapUp(x, y)) return;
Wu-cheng Li014d9582012-04-18 17:10:02 +08001330 }
1331
Owen Lin616a70f2012-05-07 16:35:53 +08001332 MediaItem item = mModel.getMediaItem(0);
Wu-cheng Lib5dc5422012-04-30 18:36:22 +08001333 if (item == null || item == mScreenNailItem) {
1334 // item is not ready or it is camera preview, ignore
Owen Linf9a0a432011-08-17 22:07:43 +08001335 return;
1336 }
Likai Dingb2e91002013-08-13 14:07:48 +08001337 if (item.getMimeType().equals(MediaItem.MIME_TYPE_GIF)) {
1338 viewAnimateGif((Activity) mActivity, item.getContentUri());
1339 return;
1340 }
Owen Linf9a0a432011-08-17 22:07:43 +08001341
Wu-cheng Li8868aa12012-09-24 18:32:59 +08001342 int supported = item.getSupportedOperations();
Angus Kong3935ca32012-11-01 15:08:44 +08001343 boolean playVideo = ((supported & MediaItem.SUPPORT_PLAY) != 0);
Wu-cheng Li8868aa12012-09-24 18:32:59 +08001344 boolean unlock = ((supported & MediaItem.SUPPORT_UNLOCK) != 0);
Bobby Georgescuc7e3c762012-09-27 16:36:03 -07001345 boolean goBack = ((supported & MediaItem.SUPPORT_BACK) != 0);
Bobby Georgescu45f089d2012-10-02 13:30:09 -07001346 boolean launchCamera = ((supported & MediaItem.SUPPORT_CAMERA_SHORTCUT) != 0);
Owen Linf9a0a432011-08-17 22:07:43 +08001347
1348 if (playVideo) {
1349 // determine if the point is at center (1/6) of the photo view.
1350 // (The position of the "play" icon is at center (1/6) of the photo)
1351 int w = mPhotoView.getWidth();
1352 int h = mPhotoView.getHeight();
1353 playVideo = (Math.abs(x - w / 2) * 12 <= w)
1354 && (Math.abs(y - h / 2) * 12 <= h);
1355 }
1356
1357 if (playVideo) {
Angus Kong3935ca32012-11-01 15:08:44 +08001358 if (mSecureAlbum == null) {
1359 playVideo(mActivity, item.getPlayUri(), item.getName());
1360 } else {
1361 mActivity.getStateManager().finishState(this);
1362 }
Bobby Georgescuc7e3c762012-09-27 16:36:03 -07001363 } else if (goBack) {
1364 onBackPressed();
Wu-cheng Li8868aa12012-09-24 18:32:59 +08001365 } else if (unlock) {
Mangesh Ghiware06c02762013-09-11 15:59:59 -07001366 Intent intent = new Intent(mActivity, GalleryActivity.class);
1367 intent.putExtra(GalleryActivity.KEY_DISMISS_KEYGUARD, true);
Wu-cheng Li6455ba92012-11-02 13:36:07 +08001368 mActivity.startActivity(intent);
Bobby Georgescu45f089d2012-10-02 13:30:09 -07001369 } else if (launchCamera) {
Bobby Georgescu5bd00332012-10-24 12:09:38 -07001370 launchCamera();
Owen Linf9a0a432011-08-17 22:07:43 +08001371 } else {
Chih-Chung Chang61f94712012-05-02 20:05:16 +08001372 toggleBars();
Owen Linf9a0a432011-08-17 22:07:43 +08001373 }
1374 }
1375
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001376 @Override
Chih-Chung Chang61f94712012-05-02 20:05:16 +08001377 public void onActionBarAllowed(boolean allowed) {
1378 mActionBarAllowed = allowed;
1379 mHandler.sendEmptyMessage(MSG_UPDATE_ACTION_BAR);
1380 }
1381
1382 @Override
Chih-Chung Change6251df2012-05-22 11:35:46 -07001383 public void onActionBarWanted() {
1384 mHandler.sendEmptyMessage(MSG_WANT_BARS);
1385 }
1386
1387 @Override
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001388 public void onFullScreenChanged(boolean full) {
1389 Message m = mHandler.obtainMessage(
1390 MSG_ON_FULL_SCREEN_CHANGED, full ? 1 : 0, 0);
1391 m.sendToTarget();
1392 }
1393
Chih-Chung Chang6b891c62012-06-07 20:09:13 +08001394 // How we do delete/undo:
1395 //
1396 // When the user choose to delete a media item, we just tell the
1397 // FilterDeleteSet to hide that item. If the user choose to undo it, we
1398 // again tell FilterDeleteSet not to hide it. If the user choose to commit
1399 // the deletion, we then actually delete the media item.
1400 @Override
1401 public void onDeleteImage(Path path, int offset) {
Chih-Chung Chang6118af92012-06-22 20:56:04 +08001402 onCommitDeleteImage(); // commit the previous deletion
Chih-Chung Chang6b891c62012-06-07 20:09:13 +08001403 mDeletePath = path;
1404 mDeleteIsFocus = (offset == 0);
kaiyized2687a2014-10-15 10:10:13 +08001405
1406 // If RTL, the index need be revised.
1407 if (View.LAYOUT_DIRECTION_RTL == TextUtils
1408 .getLayoutDirectionFromLocale(Locale.getDefault())) {
1409 mMediaSet.addDeletion(path, mMediaSet.getMediaItemCount() - mCurrentIndex - 1);
1410 } else {
1411 mMediaSet.addDeletion(path, mCurrentIndex + offset);
1412 }
Chih-Chung Chang6b891c62012-06-07 20:09:13 +08001413 }
1414
1415 @Override
1416 public void onUndoDeleteImage() {
Chih-Chung Chang6118af92012-06-22 20:56:04 +08001417 if (mDeletePath == null) return;
Chih-Chung Chang6b891c62012-06-07 20:09:13 +08001418 // If the deletion was done on the focused item, we want the model to
1419 // focus on it when it is undeleted.
1420 if (mDeleteIsFocus) mModel.setFocusHintPath(mDeletePath);
Chih-Chung Chang6118af92012-06-22 20:56:04 +08001421 mMediaSet.removeDeletion(mDeletePath);
Chih-Chung Chang6b891c62012-06-07 20:09:13 +08001422 mDeletePath = null;
Chih-Chung Chang6b891c62012-06-07 20:09:13 +08001423 }
1424
1425 @Override
1426 public void onCommitDeleteImage() {
1427 if (mDeletePath == null) return;
Bobby Georgescud00f5212013-01-28 16:16:44 -08001428 mMenuExecutor.startSingleItemAction(R.id.action_delete, mDeletePath);
Chih-Chung Chang6b891c62012-06-07 20:09:13 +08001429 mDeletePath = null;
1430 }
1431
Bobby Georgescud81b2642012-10-07 16:25:54 -07001432 public void playVideo(Activity activity, Uri uri, String title) {
Likai Ding4dc5e6d2016-05-20 14:21:43 +08001433 if (GalleryUtils.isTelephonyCallInProgress(mActivity)) {
Chao Zhang0e305772016-01-27 15:07:11 +08001434 Log.w(TAG, "CS/CSVT Call is in progress, can't play video");
1435 return;
1436 }
Owen Linf9a0a432011-08-17 22:07:43 +08001437 try {
1438 Intent intent = new Intent(Intent.ACTION_VIEW)
Ray Chena3871052012-05-17 12:15:08 +08001439 .setDataAndType(uri, "video/*")
1440 .putExtra(Intent.EXTRA_TITLE, title)
1441 .putExtra(MovieActivity.KEY_TREAT_UP_AS_BACK, true);
Chih-Chung Chang71cd89a2012-05-17 18:22:27 -07001442 activity.startActivityForResult(intent, REQUEST_PLAY_VIDEO);
Owen Linf9a0a432011-08-17 22:07:43 +08001443 } catch (ActivityNotFoundException e) {
1444 Toast.makeText(activity, activity.getString(R.string.video_err),
1445 Toast.LENGTH_SHORT).show();
1446 }
1447 }
1448
Yuli Huangf50ce2b2012-05-02 00:50:56 +08001449 private void setCurrentPhotoByIntent(Intent intent) {
1450 if (intent == null) return;
1451 Path path = mApplication.getDataManager()
1452 .findPathByUri(intent.getData(), intent.getType());
1453 if (path != null) {
Doris Liu0addfc72012-10-17 16:15:51 -07001454 Path albumPath = mApplication.getDataManager().getDefaultSetOf(path);
ztenghuieb295032013-08-20 16:38:04 -07001455 if (albumPath == null) {
1456 return;
1457 }
Chao Zhangeb2f1a62016-03-22 14:12:44 +08001458 boolean isClusterType = FilterUtils.isClusterPath(mOriginalSetPathString);
1459 if (!albumPath.equalsIgnoreCase(mOriginalSetPathString) && !isClusterType) {
Doris Liu0addfc72012-10-17 16:15:51 -07001460 // If the edited image is stored in a different album, we need
1461 // to start a new activity state to show the new image
1462 Bundle data = new Bundle(getData());
1463 data.putString(KEY_MEDIA_SET_PATH, albumPath.toString());
1464 data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, path.toString());
Bobby Georgescucfa7fde2012-11-05 14:12:51 -08001465 mActivity.getStateManager().startState(SinglePhotoPage.class, data);
Doris Liu0addfc72012-10-17 16:15:51 -07001466 return;
1467 }
Kedi Xu69483042016-09-02 14:05:18 +08001468 if (null != mModel) {
1469 mModel.setCurrentPhoto(path, mCurrentIndex);
Likai Dingb7c13c22017-02-16 14:54:04 +08001470 parseGDepth();
Kedi Xu69483042016-09-02 14:05:18 +08001471 }
Yuli Huangf50ce2b2012-05-02 00:50:56 +08001472 }
1473 }
1474
Owen Linf9a0a432011-08-17 22:07:43 +08001475 @Override
1476 protected void onStateResult(int requestCode, int resultCode, Intent data) {
John Reckf85d9742012-10-24 11:11:51 -07001477 if (resultCode == Activity.RESULT_CANCELED) {
1478 // This is a reset, not a canceled
1479 return;
1480 }
John Reckf85d9742012-10-24 11:11:51 -07001481 mRecenterCameraOnResume = false;
Owen Linf9a0a432011-08-17 22:07:43 +08001482 switch (requestCode) {
Yuli Huangf50ce2b2012-05-02 00:50:56 +08001483 case REQUEST_EDIT:
zhuw48efd7d2016-08-03 10:05:00 +08001484 if (data.getData() == null) {
1485 onUpPressed();
1486 } else {
1487 setCurrentPhotoByIntent(data);
1488 }
Yuli Huangf50ce2b2012-05-02 00:50:56 +08001489 break;
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301490 /*case REQUEST_CROP:
Owen Linf9a0a432011-08-17 22:07:43 +08001491 if (resultCode == Activity.RESULT_OK) {
Yuli Huangf50ce2b2012-05-02 00:50:56 +08001492 setCurrentPhotoByIntent(data);
Owen Linf9a0a432011-08-17 22:07:43 +08001493 }
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301494 break;*/
Owen Linf9a0a432011-08-17 22:07:43 +08001495 case REQUEST_CROP_PICASA: {
Yuli Huangf50ce2b2012-05-02 00:50:56 +08001496 if (resultCode == Activity.RESULT_OK) {
1497 Context context = mActivity.getAndroidContext();
Yuli Huang88cc2ca2012-05-05 17:42:32 +08001498 String message = context.getString(R.string.crop_saved,
Ruben Brunk00d64dd2012-10-18 23:39:18 -07001499 context.getString(R.string.folder_edited_online_photos));
Yuli Huangf50ce2b2012-05-02 00:50:56 +08001500 Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
1501 }
Owen Linf9a0a432011-08-17 22:07:43 +08001502 break;
1503 }
1504 case REQUEST_SLIDESHOW: {
1505 if (data == null) break;
1506 String path = data.getStringExtra(SlideshowPage.KEY_ITEM_PATH);
1507 int index = data.getIntExtra(SlideshowPage.KEY_PHOTO_INDEX, 0);
kaiyized2687a2014-10-15 10:10:13 +08001508
1509 // If RTL, the index need be revised.
1510 if (View.LAYOUT_DIRECTION_RTL == TextUtils
1511 .getLayoutDirectionFromLocale(Locale.getDefault())) {
1512 index = mMediaSet.getMediaItemCount() - index - 1;
1513 }
Owen Linf9a0a432011-08-17 22:07:43 +08001514 if (path != null) {
1515 mModel.setCurrentPhoto(Path.fromString(path), index);
Likai Dingb7c13c22017-02-16 14:54:04 +08001516 parseGDepth();
Owen Linf9a0a432011-08-17 22:07:43 +08001517 }
1518 }
1519 }
1520 }
1521
Likai Dingb7c13c22017-02-16 14:54:04 +08001522 private void parseGDepth() {
jinwu4fafa7a2017-04-07 13:27:48 +08001523 bShow3DButton = false;
Likai Dingb7c13c22017-02-16 14:54:04 +08001524 if (DualCameraEffect.isSupported()) {
1525 if (mParseGDepthTask != null
1526 && mParseGDepthTask.getStatus() != AsyncTask.Status.FINISHED) {
1527 mParseGDepthTask.cancel(true);
jinwu4fafa7a2017-04-07 13:27:48 +08001528 }
Likai Dingb7c13c22017-02-16 14:54:04 +08001529 mParseGDepthTask = new ParseGDepthTask();
1530 mParseGDepthTask.execute(mCurrentPhoto.getContentUri());
jinwu4fafa7a2017-04-07 13:27:48 +08001531 }
1532 }
1533
George Mount14d32892012-08-16 11:06:42 -07001534 @Override
Owen Linf9a0a432011-08-17 22:07:43 +08001535 public void onPause() {
Owen Lind759b7c2012-05-16 15:32:02 -07001536 super.onPause();
1537 mIsActive = false;
huiyan8782c242016-04-23 14:52:23 +08001538 showFullScreen(false);
Chih-Chung Chang253c5ae2012-05-16 17:37:10 -07001539
Ray Chen4105e222011-08-24 11:40:04 +08001540 DetailsHelper.pause();
Doris Liu4438a7c2012-10-08 16:31:00 -07001541 // Hide the detail dialog on exit
1542 if (mShowDetails) hideDetails();
Bobby Georgescud3973782012-09-12 13:48:50 -07001543 if (mModel != null) {
Bobby Georgescud3973782012-09-12 13:48:50 -07001544 mModel.pause();
1545 }
Owen Linf9a0a432011-08-17 22:07:43 +08001546 mPhotoView.pause();
Owen Linf9a0a432011-08-17 22:07:43 +08001547 mHandler.removeMessages(MSG_HIDE_BARS);
Bobby Georgescud2724f62012-10-06 15:22:03 -07001548 mHandler.removeMessages(MSG_REFRESH_BOTTOM_CONTROLS);
George Mount4b4dbd22012-10-18 14:20:39 -07001549 refreshBottomControlsWhenReady();
Owen Linf9a0a432011-08-17 22:07:43 +08001550 mActionBar.removeOnMenuVisibilityListener(mMenuVisibilityListener);
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301551 // if (mShowSpinner) {
1552 // mActionBar.disableAlbumModeMenu(true);
1553 // }
Chih-Chung Chang6b891c62012-06-07 20:09:13 +08001554 onCommitDeleteImage();
Chih-Chung Chang27859562011-09-08 11:51:11 +08001555 mMenuExecutor.pause();
Chih-Chung Chang6118af92012-06-22 20:56:04 +08001556 if (mMediaSet != null) mMediaSet.clearDeletion();
Owen Linf9a0a432011-08-17 22:07:43 +08001557 }
1558
huiyan8782c242016-04-23 14:52:23 +08001559 private void showFullScreen(boolean show) {
1560 Window win = mActivity.getWindow();
1561 WindowManager.LayoutParams winParams = win.getAttributes();
1562 if (show) {
1563 //set full screen
1564 winParams.flags |= (WindowManager.LayoutParams.FLAG_FULLSCREEN);
1565 } else {
1566 //cancel full screen
1567 winParams.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
1568 }
1569 win.setAttributes(winParams);
1570 }
1571
Yuli Huangbd7c0162012-05-15 22:36:59 +08001572
George Mountf122d562012-10-09 17:50:33 -07001573 @Override
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001574 public void onFilmModeChanged(boolean enabled) {
George Mount4b4dbd22012-10-18 14:20:39 -07001575 refreshBottomControlsWhenReady();
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301576 /*if (mShowSpinner) {
Bobby Georgescuc29588d2012-10-18 15:36:03 -07001577 if (enabled) {
1578 mActionBar.enableAlbumModeMenu(
1579 GalleryActionBar.ALBUM_FILMSTRIP_MODE_SELECTED, this);
1580 } else {
1581 mActionBar.disableAlbumModeMenu(true);
1582 }
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301583 }*/
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001584 if (enabled) {
1585 mHandler.removeMessages(MSG_HIDE_BARS);
Bobby Georgescuf37648b2013-03-12 22:45:17 -07001586 UsageStatistics.onContentViewChanged(
1587 UsageStatistics.COMPONENT_GALLERY, "FilmstripPage");
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001588 } else {
1589 refreshHidingMessage();
Bobby Georgescuf37648b2013-03-12 22:45:17 -07001590 if (mAppBridge == null || mCurrentIndex > 0) {
1591 UsageStatistics.onContentViewChanged(
1592 UsageStatistics.COMPONENT_GALLERY, "SinglePhotoPage");
1593 } else {
1594 UsageStatistics.onContentViewChanged(
1595 UsageStatistics.COMPONENT_CAMERA, "Unknown"); // TODO
1596 }
Paramanandac12b8b12015-03-24 17:51:29 +05301597
1598 // Manage DRM rights while image selection changed. this
1599 // flow will comes for both image and video, but here
1600 // we will consume rights for image files only.
1601 // Do not consume rights of a GIF image and video here.
1602 // ViewGifImage will take care of GIF rights consumption stub.
1603 // MediaPlayer will handle the video rights consumption stub.
Anand Chaudhari922a2fa2015-09-23 18:01:06 +05301604// if ((mMediaSet != null && mMediaSet.getMediaItemCount() > 1)
1605// || !(this instanceof SinglePhotoPage)) {
1606// String mime = mCurrentPhoto.getMimeType();
1607// if (!TextUtils.isEmpty(mime) && !mime.equals("image/gif")
1608// && !mime.startsWith("video/")) {
1609// DrmHelper.manageDrmLicense(mActivity.getAndroidContext(),
1610// mHandler, mCurrentPhoto.getFilePath(),
1611// mCurrentPhoto.getMimeType());
1612// }
1613// }
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001614 }
1615 }
1616
1617 private void transitionFromAlbumPageIfNeeded() {
1618 TransitionStore transitions = mActivity.getTransitionStore();
1619
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001620 int albumPageTransition = transitions.get(
1621 KEY_ALBUMPAGE_TRANSITION, MSG_ALBUMPAGE_NONE);
1622
Bobby Georgescud81b2642012-10-07 16:25:54 -07001623 if (albumPageTransition == MSG_ALBUMPAGE_NONE && mAppBridge != null
1624 && mRecenterCameraOnResume) {
Bobby Georgescu00ccf352012-09-19 16:51:05 -07001625 // Generally, resuming the PhotoPage when in Camera should
1626 // reset to the capture mode to allow quick photo taking
1627 mCurrentIndex = 0;
1628 mPhotoView.resetToFirstPicture();
1629 } else {
1630 int resumeIndex = transitions.get(KEY_INDEX_HINT, -1);
1631 if (resumeIndex >= 0) {
Bobby Georgescu3ad7bbc2012-10-23 20:29:57 -07001632 if (mHasCameraScreennailOrPlaceholder) {
Bobby Georgescu76f18812012-10-07 23:06:05 -07001633 // Account for preview/placeholder being the first item
Bobby Georgescu00ccf352012-09-19 16:51:05 -07001634 resumeIndex++;
1635 }
1636 if (resumeIndex < mMediaSet.getMediaItemCount()) {
1637 mCurrentIndex = resumeIndex;
1638 mModel.moveTo(mCurrentIndex);
1639 }
1640 }
1641 }
1642
1643 if (albumPageTransition == MSG_ALBUMPAGE_RESUMED) {
1644 mPhotoView.setFilmMode(mStartInFilmstrip || mAppBridge != null);
1645 } else if (albumPageTransition == MSG_ALBUMPAGE_PICKED) {
1646 mPhotoView.setFilmMode(false);
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001647 }
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001648 }
1649
Yuli Huangbd7c0162012-05-15 22:36:59 +08001650 @Override
Owen Linf9a0a432011-08-17 22:07:43 +08001651 protected void onResume() {
1652 super.onResume();
huiyan8782c242016-04-23 14:52:23 +08001653 //set full screen to hide the status bar
1654 showFullScreen(true);
1655
Bobby Georgescu7eea4d32012-09-06 17:14:02 -07001656 transitionFromAlbumPageIfNeeded();
1657
Owen Linf9a0a432011-08-17 22:07:43 +08001658 mIsActive = true;
1659 setContentPane(mRootPane);
Yuli Huang04ac0452012-03-20 16:37:05 +08001660
huiyane9fa3d62016-04-13 12:48:07 +08001661 //if from TimeLinePage, don't show the timeline title
1662 if (mMediaSet != null && mIsFromTimelineScreen) {
Kedi Xufece30c2016-10-21 15:13:32 +08001663 mMediaSet.setShowAlbumsetTimeTitle(false);
huiyane9fa3d62016-04-13 12:48:07 +08001664 }
Chao Zhang87888842016-05-18 17:31:21 +08001665
Wu-cheng Li898a2f42012-08-27 00:10:38 +08001666 mActionBar.setDisplayOptions(
Joey Rizzoli0a421722016-06-01 14:04:38 +02001667 (false && (mSetPathString != null)), true);
Owen Linf9a0a432011-08-17 22:07:43 +08001668 mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener);
George Mount4b4dbd22012-10-18 14:20:39 -07001669 refreshBottomControlsWhenReady();
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301670 if (((mSecureAlbum == null) && (mSetPathString != null))) {
Arne Coucheronccbf7a72017-07-13 01:36:11 +02001671 ((GalleryActivity) mActivity).toggleNavBar(false);
Bobby Georgescu9481d052012-10-02 16:28:20 -07001672 }
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301673 // if (mShowSpinner && mPhotoView.getFilmMode()) {
1674 // mActionBar.enableAlbumModeMenu(
1675 // GalleryActionBar.ALBUM_FILMSTRIP_MODE_SELECTED, this);
1676 // }
Bobby Georgescu00ccf352012-09-19 16:51:05 -07001677 if (!mShowBars) {
1678 mActionBar.hide();
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001679 }
John Reck8fe22ec2012-09-26 16:13:02 -07001680 boolean haveImageEditor = GalleryUtils.isEditorAvailable(mActivity, "image/*");
1681 if (haveImageEditor != mHaveImageEditor) {
1682 mHaveImageEditor = haveImageEditor;
1683 updateMenuOperations();
1684 }
Bobby Georgescu00ccf352012-09-19 16:51:05 -07001685
Bobby Georgescud81b2642012-10-07 16:25:54 -07001686 mRecenterCameraOnResume = true;
Chao Zhang87888842016-05-18 17:31:21 +08001687 if (mModel == null) {
1688 onBackPressed();
1689 return;
1690 }
1691 mModel.resume();
1692 mPhotoView.resume();
Owen Linf9a0a432011-08-17 22:07:43 +08001693 }
1694
Chih-Chung Chang15b351a2012-03-15 16:38:45 +08001695 @Override
1696 protected void onDestroy() {
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001697 if (mAppBridge != null) {
Chih-Chung Chang253c5ae2012-05-16 17:37:10 -07001698 mAppBridge.setServer(null);
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +08001699 mScreenNailItem.setScreenNail(null);
Chih-Chung Changbd141b52012-04-26 10:10:49 +08001700 mAppBridge.detachScreenNail();
1701 mAppBridge = null;
Chih-Chung Chang3b4a8ae2012-05-09 21:17:10 +08001702 mScreenNailSet = null;
1703 mScreenNailItem = null;
Chih-Chung Changb29a27f2012-03-22 17:42:33 +08001704 }
Chih-Chung Chang2ef46ed2012-05-08 17:57:33 +08001705 mActivity.getGLRoot().setOrientationSource(null);
Bobby Georgescuf44499d2012-09-17 18:12:11 -07001706 if (mBottomControls != null) mBottomControls.cleanup();
jinwu4fafa7a2017-04-07 13:27:48 +08001707 if (m3DButton != null) m3DButton.cleanup();
Kedi Xuf1069d52016-09-26 19:53:51 +08001708 mPhotoView.destroy();
1709 mPhotoView = null;
Chih-Chung Changaeb30622012-05-03 11:41:05 +08001710 // Remove all pending messages.
1711 mHandler.removeCallbacksAndMessages(null);
Chih-Chung Chang15b351a2012-03-15 16:38:45 +08001712 super.onDestroy();
1713 }
1714
Owen Linf9a0a432011-08-17 22:07:43 +08001715 private class MyDetailsSource implements DetailsSource {
Owen Lin6cf80742011-08-28 10:50:21 +08001716
1717 @Override
Owen Linf9a0a432011-08-17 22:07:43 +08001718 public MediaDetails getDetails() {
Owen Lin616a70f2012-05-07 16:35:53 +08001719 return mModel.getMediaItem(0).getDetails();
Owen Linf9a0a432011-08-17 22:07:43 +08001720 }
Owen Lin6cf80742011-08-28 10:50:21 +08001721
1722 @Override
Owen Linf9a0a432011-08-17 22:07:43 +08001723 public int size() {
1724 return mMediaSet != null ? mMediaSet.getMediaItemCount() : 1;
1725 }
Owen Lin6cf80742011-08-28 10:50:21 +08001726
1727 @Override
Michael Kolb995c4562012-07-20 12:23:09 -07001728 public int setIndex() {
1729 return mModel.getCurrentIndex();
Ray Chen4105e222011-08-24 11:40:04 +08001730 }
Owen Linf9a0a432011-08-17 22:07:43 +08001731 }
Bobby Georgescu3cf502a2012-10-01 15:50:11 -07001732
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301733 /*@Override
Bobby Georgescu3cf502a2012-10-01 15:50:11 -07001734 public void onAlbumModeSelected(int mode) {
1735 if (mode == GalleryActionBar.ALBUM_GRID_MODE_SELECTED) {
1736 switchToGrid();
1737 }
Ravi Banuri49f14dd2015-10-21 15:54:59 +05301738 }*/
George Mount4b4dbd22012-10-18 14:20:39 -07001739
1740 @Override
1741 public void refreshBottomControlsWhenReady() {
1742 if (mBottomControls == null) {
1743 return;
1744 }
1745 MediaObject currentPhoto = mCurrentPhoto;
1746 if (currentPhoto == null) {
1747 mHandler.obtainMessage(MSG_REFRESH_BOTTOM_CONTROLS, 0, 0, currentPhoto).sendToTarget();
1748 } else {
1749 currentPhoto.getPanoramaSupport(mRefreshBottomControlsCallback);
1750 }
1751 }
1752
1753 private void updatePanoramaUI(boolean isPanorama360) {
1754 Menu menu = mActionBar.getMenu();
1755
1756 // it could be null if onCreateActionBar has not been called yet
1757 if (menu == null) {
1758 return;
1759 }
1760
1761 MenuExecutor.updateMenuForPanorama(menu, isPanorama360, isPanorama360);
1762
1763 if (isPanorama360) {
1764 MenuItem item = menu.findItem(R.id.action_share);
1765 if (item != null) {
1766 item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
1767 item.setTitle(mActivity.getResources().getString(R.string.share_as_photo));
1768 }
1769 } else if ((mCurrentPhoto.getSupportedOperations() & MediaObject.SUPPORT_SHARE) != 0) {
1770 MenuItem item = menu.findItem(R.id.action_share);
1771 if (item != null) {
1772 item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
1773 item.setTitle(mActivity.getResources().getString(R.string.share));
1774 }
1775 }
1776 }
Bobby Georgescu94958432012-10-23 20:52:26 -07001777
1778 @Override
1779 public void onUndoBarVisibilityChanged(boolean visible) {
1780 refreshBottomControlsWhenReady();
1781 }
Flavio Lerda22513862013-04-16 09:46:07 +01001782
Flavio Lerda22513862013-04-16 09:46:07 +01001783 private static String getMediaTypeString(MediaItem item) {
1784 if (item.getMediaType() == MediaObject.MEDIA_TYPE_VIDEO) {
1785 return "Video";
1786 } else if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
1787 return "Photo";
1788 } else {
1789 return "Unknown:" + item.getMediaType();
1790 }
1791 }
1792
Likai Dingb7c13c22017-02-16 14:54:04 +08001793 private class ParseGDepthTask extends AsyncTask<Uri, Void, Boolean> {
jinwu4fafa7a2017-04-07 13:27:48 +08001794 @Override
Likai Dingb7c13c22017-02-16 14:54:04 +08001795 protected Boolean doInBackground(Uri... params) {
1796 GDepth.Parser parser = new GDepth.Parser();
1797 return parser.parse(mActivity, params[0]);
jinwu4fafa7a2017-04-07 13:27:48 +08001798 }
1799
1800 @Override
1801 protected void onPostExecute(Boolean result) {
Likai Dingb7c13c22017-02-16 14:54:04 +08001802 bShow3DButton = !isCancelled() && result;
1803 m3DButton.refresh();
jinwu4fafa7a2017-04-07 13:27:48 +08001804 }
1805 }
Likai Dingb2e91002013-08-13 14:07:48 +08001806
1807 private static void viewAnimateGif(Activity activity, Uri uri) {
1808 Intent intent = new Intent(ViewGifImage.VIEW_GIF_ACTION, uri);
1809 activity.startActivity(intent);
1810 }
Owen Linf9a0a432011-08-17 22:07:43 +08001811}