summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMangesh Ghiware <mghiware@google.com>2013-09-11 15:59:59 -0700
committerMangesh Ghiware <mghiware@google.com>2013-09-26 17:32:12 -0700
commit06c027675948259368a902fd6f8c2ecac5db5167 (patch)
treebcd3c500b5d3d470a8132f40cb704ffcaa2453af
parent641be74bd9d3f96d8665b23121f40efb8df2ea83 (diff)
downloadandroid_packages_apps_Gallery2-06c027675948259368a902fd6f8c2ecac5db5167.tar.gz
android_packages_apps_Gallery2-06c027675948259368a902fd6f8c2ecac5db5167.tar.bz2
android_packages_apps_Gallery2-06c027675948259368a902fd6f8c2ecac5db5167.zip
Rename Gallery activity and add trampoline
Bug: 10807861 Change-Id: Iaaf17b579db2fe09900e9817f766f43dd66dea61
-rw-r--r--AndroidManifest.xml15
-rw-r--r--src/com/android/camera/CameraActivity.java6
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java6
-rw-r--r--src/com/android/gallery3d/app/AlbumPicker.java2
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java6
-rw-r--r--src/com/android/gallery3d/app/DialogPicker.java2
-rw-r--r--src/com/android/gallery3d/app/Gallery.java266
-rw-r--r--src/com/android/gallery3d/app/GalleryActivity.java275
-rw-r--r--src/com/android/gallery3d/app/MovieActivity.java2
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java4
-rw-r--r--src/com/android/gallery3d/data/LocalSource.java4
-rw-r--r--src/com/android/gallery3d/gadget/WidgetClickHandler.java4
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java4
-rw-r--r--src/com/android/photos/AlbumFragment.java4
-rw-r--r--src/com/android/photos/PhotoSetFragment.java4
-rw-r--r--src_pd/com/android/gallery3d/util/IntentHelper.java (renamed from src_pd/com/android/gallery3d/util/CameraHelper.java)5
16 files changed, 330 insertions, 279 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 41eb461ba..8f48edf20 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -85,7 +85,7 @@
</intent-filter>
</activity>
- <activity android:name="com.android.gallery3d.app.Gallery" android:label="@string/app_name"
+ <activity android:name="com.android.gallery3d.app.GalleryActivity" android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -161,10 +161,21 @@
</intent-filter>
</activity>
+ <!-- This activity acts as a trampoline to the new Gallery activity,
+ so that existing shortcuts are preserved. -->
+ <activity android:name="com.android.gallery3d.app.Gallery"
+ android:excludeFromRecents="true"
+ android:theme="@style/android:Theme.NoDisplay">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
<!-- we add this activity-alias for shortcut backward compatibility -->
<!-- Note: The alias must put after the target activity -->
<activity-alias android:name="com.cooliris.media.Gallery"
- android:targetActivity="com.android.gallery3d.app.Gallery"
+ android:targetActivity="com.android.gallery3d.app.GalleryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name">
<intent-filter>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index f2402af7d..533bbe878 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -15,18 +15,18 @@
*/
package com.android.camera;
-import com.android.gallery3d.util.CameraHelper;
+import com.android.gallery3d.util.IntentHelper;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
-/** Trampoline activity that launches the new Camera activity defined in CameraHelper. */
+/** Trampoline activity that launches the new Camera activity defined in IntentHelper. */
public class CameraActivity extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- Intent intent = CameraHelper.CAMERA_LAUNCHER_INTENT;
+ Intent intent = IntentHelper.CAMERA_LAUNCHER_INTENT;
// Since this is being launched from a homescreen shorcut,
// it's already in a new task. Start Camera activity and
// reset the task to its initial state if needed.
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index 658abbbd4..44f24043b 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -316,7 +316,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
private void onGetContent(final MediaItem item) {
DataManager dm = mActivity.getDataManager();
Activity activity = mActivity;
- if (mData.getString(Gallery.EXTRA_CROP) != null) {
+ if (mData.getString(GalleryActivity.EXTRA_CROP) != null) {
Uri uri = dm.getContentUri(item.getPath());
Intent intent = new Intent(CropActivity.CROP_ACTION, uri)
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
@@ -367,7 +367,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
mUserDistance = GalleryUtils.meterToPixel(USER_DISTANCE_METER);
initializeViews();
initializeData(data);
- mGetContent = data.getBoolean(Gallery.KEY_GET_CONTENT, false);
+ mGetContent = data.getBoolean(GalleryActivity.KEY_GET_CONTENT, false);
mShowClusterMenu = data.getBoolean(KEY_SHOW_CLUSTER_MENU, false);
mDetailsSource = new MyDetailsSource();
Context context = mActivity.getAndroidContext();
@@ -544,7 +544,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
MenuInflater inflator = getSupportMenuInflater();
if (mGetContent) {
inflator.inflate(R.menu.pickup, menu);
- int typeBits = mData.getInt(Gallery.KEY_TYPE_BITS,
+ int typeBits = mData.getInt(GalleryActivity.KEY_TYPE_BITS,
DataManager.INCLUDE_IMAGE);
actionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
} else {
diff --git a/src/com/android/gallery3d/app/AlbumPicker.java b/src/com/android/gallery3d/app/AlbumPicker.java
index 65eb77291..8c2d09a0e 100644
--- a/src/com/android/gallery3d/app/AlbumPicker.java
+++ b/src/com/android/gallery3d/app/AlbumPicker.java
@@ -32,7 +32,7 @@ public class AlbumPicker extends PickerActivity {
Bundle extras = intent.getExtras();
Bundle data = extras == null ? new Bundle() : new Bundle(extras);
- data.putBoolean(Gallery.KEY_GET_ALBUM, true);
+ data.putBoolean(GalleryActivity.KEY_GET_ALBUM, true);
data.putString(AlbumSetPage.KEY_MEDIA_PATH,
getDataManager().getTopSetPath(DataManager.INCLUDE_IMAGE));
getStateManager().startState(AlbumSetPage.class, data);
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index dd9d8ec41..d56b5b85d 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -322,8 +322,8 @@ public class AlbumSetPage extends ActivityState implements
initializeViews();
initializeData(data);
Context context = mActivity.getAndroidContext();
- mGetContent = data.getBoolean(Gallery.KEY_GET_CONTENT, false);
- mGetAlbum = data.getBoolean(Gallery.KEY_GET_ALBUM, false);
+ mGetContent = data.getBoolean(GalleryActivity.KEY_GET_CONTENT, false);
+ mGetAlbum = data.getBoolean(GalleryActivity.KEY_GET_ALBUM, false);
mTitle = data.getString(AlbumSetPage.KEY_SET_TITLE);
mSubtitle = data.getString(AlbumSetPage.KEY_SET_SUBTITLE);
mEyePosition = new EyePosition(context, this);
@@ -534,7 +534,7 @@ public class AlbumSetPage extends ActivityState implements
if (mGetContent) {
inflater.inflate(R.menu.pickup, menu);
int typeBits = mData.getInt(
- Gallery.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE);
+ GalleryActivity.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE);
mActionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
} else if (mGetAlbum) {
inflater.inflate(R.menu.pickup, menu);
diff --git a/src/com/android/gallery3d/app/DialogPicker.java b/src/com/android/gallery3d/app/DialogPicker.java
index 7ca86e5b4..1de3324b0 100644
--- a/src/com/android/gallery3d/app/DialogPicker.java
+++ b/src/com/android/gallery3d/app/DialogPicker.java
@@ -33,7 +33,7 @@ public class DialogPicker extends PickerActivity {
Bundle extras = intent.getExtras();
Bundle data = extras == null ? new Bundle() : new Bundle(extras);
- data.putBoolean(Gallery.KEY_GET_CONTENT, true);
+ data.putBoolean(GalleryActivity.KEY_GET_CONTENT, true);
data.putString(AlbumSetPage.KEY_MEDIA_PATH,
getDataManager().getTopSetPath(typeBits));
getStateManager().startState(AlbumSetPage.class, data);
diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java
index 510542a23..0c1ef7999 100644
--- a/src/com/android/gallery3d/app/Gallery.java
+++ b/src/com/android/gallery3d/app/Gallery.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,263 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.android.gallery3d.app;
-import android.app.Dialog;
-import android.content.ContentResolver;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnCancelListener;
+import com.android.gallery3d.util.IntentHelper;
+
+import android.app.Activity;
import android.content.Intent;
-import android.net.Uri;
import android.os.Bundle;
-import android.view.InputDevice;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.Toast;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.data.Path;
-import com.android.gallery3d.picasasource.PicasaSource;
-import com.android.gallery3d.util.GalleryUtils;
-
-public final class Gallery extends AbstractGalleryActivity implements OnCancelListener {
- public static final String EXTRA_SLIDESHOW = "slideshow";
- public static final String EXTRA_DREAM = "dream";
- public static final String EXTRA_CROP = "crop";
-
- public static final String ACTION_REVIEW = "com.android.camera.action.REVIEW";
- public static final String KEY_GET_CONTENT = "get-content";
- public static final String KEY_GET_ALBUM = "get-album";
- public static final String KEY_TYPE_BITS = "type-bits";
- public static final String KEY_MEDIA_TYPES = "mediaTypes";
- public static final String KEY_DISMISS_KEYGUARD = "dismiss-keyguard";
-
- private static final String TAG = "Gallery";
- private Dialog mVersionCheckDialog;
+/** Trampoline activity that launches the Gallery activity defined in IntentHelper. */
+public class Gallery extends Activity {
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_ACTION_BAR);
- requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
-
- if (getIntent().getBooleanExtra(KEY_DISMISS_KEYGUARD, false)) {
- getWindow().addFlags(
- WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
- }
-
- setContentView(R.layout.main);
-
- if (savedInstanceState != null) {
- getStateManager().restoreFromState(savedInstanceState);
- } else {
- initializeByIntent();
- }
- }
-
- private void initializeByIntent() {
- Intent intent = getIntent();
- String action = intent.getAction();
-
- if (Intent.ACTION_GET_CONTENT.equalsIgnoreCase(action)) {
- startGetContent(intent);
- } else if (Intent.ACTION_PICK.equalsIgnoreCase(action)) {
- // We do NOT really support the PICK intent. Handle it as
- // the GET_CONTENT. However, we need to translate the type
- // in the intent here.
- Log.w(TAG, "action PICK is not supported");
- String type = Utils.ensureNotNull(intent.getType());
- if (type.startsWith("vnd.android.cursor.dir/")) {
- if (type.endsWith("/image")) intent.setType("image/*");
- if (type.endsWith("/video")) intent.setType("video/*");
- }
- startGetContent(intent);
- } else if (Intent.ACTION_VIEW.equalsIgnoreCase(action)
- || ACTION_REVIEW.equalsIgnoreCase(action)){
- startViewAction(intent);
- } else {
- startDefaultPage();
- }
- }
-
- public void startDefaultPage() {
- PicasaSource.showSignInReminder(this);
- Bundle data = new Bundle();
- data.putString(AlbumSetPage.KEY_MEDIA_PATH,
- getDataManager().getTopSetPath(DataManager.INCLUDE_ALL));
- getStateManager().startState(AlbumSetPage.class, data);
- mVersionCheckDialog = PicasaSource.getVersionCheckDialog(this);
- if (mVersionCheckDialog != null) {
- mVersionCheckDialog.setOnCancelListener(this);
- }
- }
-
- private void startGetContent(Intent intent) {
- Bundle data = intent.getExtras() != null
- ? new Bundle(intent.getExtras())
- : new Bundle();
- data.putBoolean(KEY_GET_CONTENT, true);
- int typeBits = GalleryUtils.determineTypeBits(this, intent);
- data.putInt(KEY_TYPE_BITS, typeBits);
- data.putString(AlbumSetPage.KEY_MEDIA_PATH,
- getDataManager().getTopSetPath(typeBits));
- getStateManager().startState(AlbumSetPage.class, data);
- }
-
- private String getContentType(Intent intent) {
- String type = intent.getType();
- if (type != null) {
- return GalleryUtils.MIME_TYPE_PANORAMA360.equals(type)
- ? MediaItem.MIME_TYPE_JPEG : type;
- }
-
- Uri uri = intent.getData();
- try {
- return getContentResolver().getType(uri);
- } catch (Throwable t) {
- Log.w(TAG, "get type fail", t);
- return null;
- }
- }
-
- private void startViewAction(Intent intent) {
- Boolean slideshow = intent.getBooleanExtra(EXTRA_SLIDESHOW, false);
- if (slideshow) {
- getActionBar().hide();
- DataManager manager = getDataManager();
- Path path = manager.findPathByUri(intent.getData(), intent.getType());
- if (path == null || manager.getMediaObject(path)
- instanceof MediaItem) {
- path = Path.fromString(
- manager.getTopSetPath(DataManager.INCLUDE_IMAGE));
- }
- Bundle data = new Bundle();
- data.putString(SlideshowPage.KEY_SET_PATH, path.toString());
- data.putBoolean(SlideshowPage.KEY_RANDOM_ORDER, true);
- data.putBoolean(SlideshowPage.KEY_REPEAT, true);
- if (intent.getBooleanExtra(EXTRA_DREAM, false)) {
- data.putBoolean(SlideshowPage.KEY_DREAM, true);
- }
- getStateManager().startState(SlideshowPage.class, data);
- } else {
- Bundle data = new Bundle();
- DataManager dm = getDataManager();
- Uri uri = intent.getData();
- String contentType = getContentType(intent);
- if (contentType == null) {
- Toast.makeText(this,
- R.string.no_such_item, Toast.LENGTH_LONG).show();
- finish();
- return;
- }
- if (uri == null) {
- int typeBits = GalleryUtils.determineTypeBits(this, intent);
- data.putInt(KEY_TYPE_BITS, typeBits);
- data.putString(AlbumSetPage.KEY_MEDIA_PATH,
- getDataManager().getTopSetPath(typeBits));
- getStateManager().startState(AlbumSetPage.class, data);
- } else if (contentType.startsWith(
- ContentResolver.CURSOR_DIR_BASE_TYPE)) {
- int mediaType = intent.getIntExtra(KEY_MEDIA_TYPES, 0);
- if (mediaType != 0) {
- uri = uri.buildUpon().appendQueryParameter(
- KEY_MEDIA_TYPES, String.valueOf(mediaType))
- .build();
- }
- Path setPath = dm.findPathByUri(uri, null);
- MediaSet mediaSet = null;
- if (setPath != null) {
- mediaSet = (MediaSet) dm.getMediaObject(setPath);
- }
- if (mediaSet != null) {
- if (mediaSet.isLeafAlbum()) {
- data.putString(AlbumPage.KEY_MEDIA_PATH, setPath.toString());
- data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH,
- dm.getTopSetPath(DataManager.INCLUDE_ALL));
- getStateManager().startState(AlbumPage.class, data);
- } else {
- data.putString(AlbumSetPage.KEY_MEDIA_PATH, setPath.toString());
- getStateManager().startState(AlbumSetPage.class, data);
- }
- } else {
- startDefaultPage();
- }
- } else {
- Path itemPath = dm.findPathByUri(uri, contentType);
- Path albumPath = dm.getDefaultSetOf(itemPath);
-
- data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString());
- data.putBoolean(PhotoPage.KEY_READONLY, true);
-
- // TODO: Make the parameter "SingleItemOnly" public so other
- // activities can reference it.
- boolean singleItemOnly = (albumPath == null)
- || intent.getBooleanExtra("SingleItemOnly", false);
- if (!singleItemOnly) {
- data.putString(PhotoPage.KEY_MEDIA_SET_PATH, albumPath.toString());
- // when FLAG_ACTIVITY_NEW_TASK is set, (e.g. when intent is fired
- // from notification), back button should behave the same as up button
- // rather than taking users back to the home screen
- if (intent.getBooleanExtra(PhotoPage.KEY_TREAT_BACK_AS_UP, false)
- || ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0)) {
- data.putBoolean(PhotoPage.KEY_TREAT_BACK_AS_UP, true);
- }
- }
-
- getStateManager().startState(SinglePhotoPage.class, data);
- }
- }
- }
-
- @Override
- protected void onResume() {
- Utils.assertTrue(getStateManager().getStateCount() > 0);
- super.onResume();
- if (mVersionCheckDialog != null) {
- mVersionCheckDialog.show();
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- if (mVersionCheckDialog != null) {
- mVersionCheckDialog.dismiss();
- }
- }
-
- @Override
- public void onCancel(DialogInterface dialog) {
- if (dialog == mVersionCheckDialog) {
- mVersionCheckDialog = null;
- }
- }
-
- @Override
- public boolean onGenericMotionEvent(MotionEvent event) {
- final boolean isTouchPad = (event.getSource()
- & InputDevice.SOURCE_CLASS_POSITION) != 0;
- if (isTouchPad) {
- float maxX = event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax();
- float maxY = event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax();
- View decor = getWindow().getDecorView();
- float scaleX = decor.getWidth() / maxX;
- float scaleY = decor.getHeight() / maxY;
- float x = event.getX() * scaleX;
- //x = decor.getWidth() - x; // invert x
- float y = event.getY() * scaleY;
- //y = decor.getHeight() - y; // invert y
- MotionEvent touchEvent = MotionEvent.obtain(event.getDownTime(),
- event.getEventTime(), event.getAction(), x, y, event.getMetaState());
- return dispatchTouchEvent(touchEvent);
- }
- return super.onGenericMotionEvent(event);
+ Intent intent = IntentHelper.GALLERY_LAUNCHER_INTENT;
+ // Since this is being launched from a homescreen shortcut,
+ // it's already in a new task. Start Gallery activity and
+ // reset the task to its initial state if needed.
+ intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ startActivity(intent);
+ finish();
}
}
diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java
new file mode 100644
index 000000000..bb2a6b8f1
--- /dev/null
+++ b/src/com/android/gallery3d/app/GalleryActivity.java
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.app;
+
+import android.app.Dialog;
+import android.content.ContentResolver;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnCancelListener;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.InputDevice;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Toast;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.data.DataManager;
+import com.android.gallery3d.data.MediaItem;
+import com.android.gallery3d.data.MediaSet;
+import com.android.gallery3d.data.Path;
+import com.android.gallery3d.picasasource.PicasaSource;
+import com.android.gallery3d.util.GalleryUtils;
+
+public final class GalleryActivity extends AbstractGalleryActivity implements OnCancelListener {
+ public static final String EXTRA_SLIDESHOW = "slideshow";
+ public static final String EXTRA_DREAM = "dream";
+ public static final String EXTRA_CROP = "crop";
+
+ public static final String ACTION_REVIEW = "com.android.camera.action.REVIEW";
+ public static final String KEY_GET_CONTENT = "get-content";
+ public static final String KEY_GET_ALBUM = "get-album";
+ public static final String KEY_TYPE_BITS = "type-bits";
+ public static final String KEY_MEDIA_TYPES = "mediaTypes";
+ public static final String KEY_DISMISS_KEYGUARD = "dismiss-keyguard";
+
+ private static final String TAG = "GalleryActivity";
+ private Dialog mVersionCheckDialog;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_ACTION_BAR);
+ requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
+
+ if (getIntent().getBooleanExtra(KEY_DISMISS_KEYGUARD, false)) {
+ getWindow().addFlags(
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
+ }
+
+ setContentView(R.layout.main);
+
+ if (savedInstanceState != null) {
+ getStateManager().restoreFromState(savedInstanceState);
+ } else {
+ initializeByIntent();
+ }
+ }
+
+ private void initializeByIntent() {
+ Intent intent = getIntent();
+ String action = intent.getAction();
+
+ if (Intent.ACTION_GET_CONTENT.equalsIgnoreCase(action)) {
+ startGetContent(intent);
+ } else if (Intent.ACTION_PICK.equalsIgnoreCase(action)) {
+ // We do NOT really support the PICK intent. Handle it as
+ // the GET_CONTENT. However, we need to translate the type
+ // in the intent here.
+ Log.w(TAG, "action PICK is not supported");
+ String type = Utils.ensureNotNull(intent.getType());
+ if (type.startsWith("vnd.android.cursor.dir/")) {
+ if (type.endsWith("/image")) intent.setType("image/*");
+ if (type.endsWith("/video")) intent.setType("video/*");
+ }
+ startGetContent(intent);
+ } else if (Intent.ACTION_VIEW.equalsIgnoreCase(action)
+ || ACTION_REVIEW.equalsIgnoreCase(action)){
+ startViewAction(intent);
+ } else {
+ startDefaultPage();
+ }
+ }
+
+ public void startDefaultPage() {
+ PicasaSource.showSignInReminder(this);
+ Bundle data = new Bundle();
+ data.putString(AlbumSetPage.KEY_MEDIA_PATH,
+ getDataManager().getTopSetPath(DataManager.INCLUDE_ALL));
+ getStateManager().startState(AlbumSetPage.class, data);
+ mVersionCheckDialog = PicasaSource.getVersionCheckDialog(this);
+ if (mVersionCheckDialog != null) {
+ mVersionCheckDialog.setOnCancelListener(this);
+ }
+ }
+
+ private void startGetContent(Intent intent) {
+ Bundle data = intent.getExtras() != null
+ ? new Bundle(intent.getExtras())
+ : new Bundle();
+ data.putBoolean(KEY_GET_CONTENT, true);
+ int typeBits = GalleryUtils.determineTypeBits(this, intent);
+ data.putInt(KEY_TYPE_BITS, typeBits);
+ data.putString(AlbumSetPage.KEY_MEDIA_PATH,
+ getDataManager().getTopSetPath(typeBits));
+ getStateManager().startState(AlbumSetPage.class, data);
+ }
+
+ private String getContentType(Intent intent) {
+ String type = intent.getType();
+ if (type != null) {
+ return GalleryUtils.MIME_TYPE_PANORAMA360.equals(type)
+ ? MediaItem.MIME_TYPE_JPEG : type;
+ }
+
+ Uri uri = intent.getData();
+ try {
+ return getContentResolver().getType(uri);
+ } catch (Throwable t) {
+ Log.w(TAG, "get type fail", t);
+ return null;
+ }
+ }
+
+ private void startViewAction(Intent intent) {
+ Boolean slideshow = intent.getBooleanExtra(EXTRA_SLIDESHOW, false);
+ if (slideshow) {
+ getActionBar().hide();
+ DataManager manager = getDataManager();
+ Path path = manager.findPathByUri(intent.getData(), intent.getType());
+ if (path == null || manager.getMediaObject(path)
+ instanceof MediaItem) {
+ path = Path.fromString(
+ manager.getTopSetPath(DataManager.INCLUDE_IMAGE));
+ }
+ Bundle data = new Bundle();
+ data.putString(SlideshowPage.KEY_SET_PATH, path.toString());
+ data.putBoolean(SlideshowPage.KEY_RANDOM_ORDER, true);
+ data.putBoolean(SlideshowPage.KEY_REPEAT, true);
+ if (intent.getBooleanExtra(EXTRA_DREAM, false)) {
+ data.putBoolean(SlideshowPage.KEY_DREAM, true);
+ }
+ getStateManager().startState(SlideshowPage.class, data);
+ } else {
+ Bundle data = new Bundle();
+ DataManager dm = getDataManager();
+ Uri uri = intent.getData();
+ String contentType = getContentType(intent);
+ if (contentType == null) {
+ Toast.makeText(this,
+ R.string.no_such_item, Toast.LENGTH_LONG).show();
+ finish();
+ return;
+ }
+ if (uri == null) {
+ int typeBits = GalleryUtils.determineTypeBits(this, intent);
+ data.putInt(KEY_TYPE_BITS, typeBits);
+ data.putString(AlbumSetPage.KEY_MEDIA_PATH,
+ getDataManager().getTopSetPath(typeBits));
+ getStateManager().startState(AlbumSetPage.class, data);
+ } else if (contentType.startsWith(
+ ContentResolver.CURSOR_DIR_BASE_TYPE)) {
+ int mediaType = intent.getIntExtra(KEY_MEDIA_TYPES, 0);
+ if (mediaType != 0) {
+ uri = uri.buildUpon().appendQueryParameter(
+ KEY_MEDIA_TYPES, String.valueOf(mediaType))
+ .build();
+ }
+ Path setPath = dm.findPathByUri(uri, null);
+ MediaSet mediaSet = null;
+ if (setPath != null) {
+ mediaSet = (MediaSet) dm.getMediaObject(setPath);
+ }
+ if (mediaSet != null) {
+ if (mediaSet.isLeafAlbum()) {
+ data.putString(AlbumPage.KEY_MEDIA_PATH, setPath.toString());
+ data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH,
+ dm.getTopSetPath(DataManager.INCLUDE_ALL));
+ getStateManager().startState(AlbumPage.class, data);
+ } else {
+ data.putString(AlbumSetPage.KEY_MEDIA_PATH, setPath.toString());
+ getStateManager().startState(AlbumSetPage.class, data);
+ }
+ } else {
+ startDefaultPage();
+ }
+ } else {
+ Path itemPath = dm.findPathByUri(uri, contentType);
+ Path albumPath = dm.getDefaultSetOf(itemPath);
+
+ data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString());
+ data.putBoolean(PhotoPage.KEY_READONLY, true);
+
+ // TODO: Make the parameter "SingleItemOnly" public so other
+ // activities can reference it.
+ boolean singleItemOnly = (albumPath == null)
+ || intent.getBooleanExtra("SingleItemOnly", false);
+ if (!singleItemOnly) {
+ data.putString(PhotoPage.KEY_MEDIA_SET_PATH, albumPath.toString());
+ // when FLAG_ACTIVITY_NEW_TASK is set, (e.g. when intent is fired
+ // from notification), back button should behave the same as up button
+ // rather than taking users back to the home screen
+ if (intent.getBooleanExtra(PhotoPage.KEY_TREAT_BACK_AS_UP, false)
+ || ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0)) {
+ data.putBoolean(PhotoPage.KEY_TREAT_BACK_AS_UP, true);
+ }
+ }
+
+ getStateManager().startState(SinglePhotoPage.class, data);
+ }
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ Utils.assertTrue(getStateManager().getStateCount() > 0);
+ super.onResume();
+ if (mVersionCheckDialog != null) {
+ mVersionCheckDialog.show();
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ if (mVersionCheckDialog != null) {
+ mVersionCheckDialog.dismiss();
+ }
+ }
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ if (dialog == mVersionCheckDialog) {
+ mVersionCheckDialog = null;
+ }
+ }
+
+ @Override
+ public boolean onGenericMotionEvent(MotionEvent event) {
+ final boolean isTouchPad = (event.getSource()
+ & InputDevice.SOURCE_CLASS_POSITION) != 0;
+ if (isTouchPad) {
+ float maxX = event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax();
+ float maxY = event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax();
+ View decor = getWindow().getDecorView();
+ float scaleX = decor.getWidth() / maxX;
+ float scaleY = decor.getHeight() / maxY;
+ float x = event.getX() * scaleX;
+ //x = decor.getWidth() - x; // invert x
+ float y = event.getY() * scaleY;
+ //y = decor.getHeight() - y; // invert y
+ MotionEvent touchEvent = MotionEvent.obtain(event.getDownTime(),
+ event.getEventTime(), event.getAction(), x, y, event.getMetaState());
+ return dispatchTouchEvent(touchEvent);
+ }
+ return super.onGenericMotionEvent(event);
+ }
+}
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index 8bf9b55df..8dec2d463 100644
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -199,7 +199,7 @@ public class MovieActivity extends Activity {
if (mTreatUpAsBack) {
finish();
} else {
- startActivity(new Intent(this, Gallery.class));
+ startActivity(new Intent(this, GalleryActivity.class));
finish();
}
return true;
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index c4a9d1b96..33598887d 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -1160,8 +1160,8 @@ public abstract class PhotoPage extends ActivityState implements
} else if (goBack) {
onBackPressed();
} else if (unlock) {
- Intent intent = new Intent(mActivity, Gallery.class);
- intent.putExtra(Gallery.KEY_DISMISS_KEYGUARD, true);
+ Intent intent = new Intent(mActivity, GalleryActivity.class);
+ intent.putExtra(GalleryActivity.KEY_DISMISS_KEYGUARD, true);
mActivity.startActivity(intent);
} else if (launchCamera) {
launchCamera();
diff --git a/src/com/android/gallery3d/data/LocalSource.java b/src/com/android/gallery3d/data/LocalSource.java
index a2e3d1443..810aef474 100644
--- a/src/com/android/gallery3d/data/LocalSource.java
+++ b/src/com/android/gallery3d/data/LocalSource.java
@@ -22,7 +22,7 @@ import android.content.UriMatcher;
import android.net.Uri;
import android.provider.MediaStore;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.data.MediaSet.ItemConsumer;
@@ -130,7 +130,7 @@ class LocalSource extends MediaSource {
private Path getAlbumPath(Uri uri, int defaultType) {
int mediaType = getMediaType(
- uri.getQueryParameter(Gallery.KEY_MEDIA_TYPES),
+ uri.getQueryParameter(GalleryActivity.KEY_MEDIA_TYPES),
defaultType);
String bucketId = uri.getQueryParameter(KEY_BUCKET_ID);
int id = 0;
diff --git a/src/com/android/gallery3d/gadget/WidgetClickHandler.java b/src/com/android/gallery3d/gadget/WidgetClickHandler.java
index 37ee1a651..e66a2a66f 100644
--- a/src/com/android/gallery3d/gadget/WidgetClickHandler.java
+++ b/src/com/android/gallery3d/gadget/WidgetClickHandler.java
@@ -27,7 +27,7 @@ import android.util.Log;
import android.widget.Toast;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.app.PhotoPage;
import com.android.gallery3d.common.ApiHelper;
@@ -63,7 +63,7 @@ public class WidgetClickHandler extends Activity {
} else {
Toast.makeText(this,
R.string.no_such_item, Toast.LENGTH_LONG).show();
- intent = new Intent(this, Gallery.class);
+ intent = new Intent(this, GalleryActivity.class);
}
if (tediousBack) {
intent.setFlags(
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index c25a2fc66..83cc055c9 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -37,7 +37,7 @@ import android.util.Log;
import android.view.WindowManager;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.app.PackagesMonitor;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.data.DataManager;
@@ -250,7 +250,7 @@ public class GalleryUtils {
}
public static void startGalleryActivity(Context context) {
- Intent intent = new Intent(context, Gallery.class)
+ Intent intent = new Intent(context, GalleryActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
diff --git a/src/com/android/photos/AlbumFragment.java b/src/com/android/photos/AlbumFragment.java
index 406fd2a29..886ca68a3 100644
--- a/src/com/android/photos/AlbumFragment.java
+++ b/src/com/android/photos/AlbumFragment.java
@@ -31,7 +31,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.photos.adapters.PhotoThumbnailAdapter;
import com.android.photos.data.PhotoSetLoader;
import com.android.photos.shims.LoaderCompatShim;
@@ -108,7 +108,7 @@ public class AlbumFragment extends MultiSelectGridFragment implements LoaderCall
Cursor item = (Cursor) getItemAtPosition(position);
Uri uri = mLoaderCompatShim.uriForItem(item);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- intent.setClass(getActivity(), Gallery.class);
+ intent.setClass(getActivity(), GalleryActivity.class);
startActivity(intent);
}
diff --git a/src/com/android/photos/PhotoSetFragment.java b/src/com/android/photos/PhotoSetFragment.java
index 961fd0bf2..7ce876fd4 100644
--- a/src/com/android/photos/PhotoSetFragment.java
+++ b/src/com/android/photos/PhotoSetFragment.java
@@ -28,7 +28,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.photos.adapters.PhotoThumbnailAdapter;
import com.android.photos.data.PhotoSetLoader;
import com.android.photos.shims.LoaderCompatShim;
@@ -74,7 +74,7 @@ public class PhotoSetFragment extends MultiSelectGridFragment implements LoaderC
Cursor item = (Cursor) getItemAtPosition(position);
Uri uri = mLoaderCompatShim.uriForItem(item);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- intent.setClass(getActivity(), Gallery.class);
+ intent.setClass(getActivity(), GalleryActivity.class);
startActivity(intent);
}
diff --git a/src_pd/com/android/gallery3d/util/CameraHelper.java b/src_pd/com/android/gallery3d/util/IntentHelper.java
index 87ca038bc..843a39f4c 100644
--- a/src_pd/com/android/gallery3d/util/CameraHelper.java
+++ b/src_pd/com/android/gallery3d/util/IntentHelper.java
@@ -17,8 +17,11 @@ package com.android.gallery3d.util;
import android.content.Intent;
-public class CameraHelper {
+public class IntentHelper {
public static final Intent CAMERA_LAUNCHER_INTENT = new Intent(Intent.ACTION_MAIN)
.setClassName("com.android.camera2", "com.android.camera.CameraActivity");
+
+ public static final Intent GALLERY_LAUNCHER_INTENT = new Intent(Intent.ACTION_MAIN)
+ .setClassName("com.android.gallery3d", "com.android.gallery3d.app.GalleryActivity");
}