</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" />
</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>
*/
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.
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)
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();
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 {
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);
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);
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);
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);
/*
- * 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.
* 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();
}
}
--- /dev/null
+/*
+ * 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);
+ }
+}
if (mTreatUpAsBack) {
finish();
} else {
- startActivity(new Intent(this, Gallery.class));
+ startActivity(new Intent(this, GalleryActivity.class));
finish();
}
return true;
} 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();
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;
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;
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;
} 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(
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;
}
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);
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;
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);
}
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;
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);
}
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");
}