</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>
<item quantity="other" msgid="5874316486520635333">"የተመረጡት ንጥሎች ይሰረዙ?"</item>
</plurals>
<string name="confirm" msgid="8646870096527848520">"አረጋግጥ"</string>
- <string name="cancel" msgid="3637516880917356226">"á\8bá\89\85á\88"</string>
+ <string name="cancel" msgid="3637516880917356226">"á\88°á\88á\8b\9d"</string>
<string name="share" msgid="3619042788254195341">"አጋራ"</string>
<string name="share_panorama" msgid="2569029972820978718">"ፓኖራማ አጋራ"</string>
<string name="share_as_photo" msgid="8959225188897026149">"እንደ ፎቶ አጋራ"</string>
<string name="preparing_sd" product="default" msgid="2914969119574812666">"የ SD ካርድ በማዘጋጀት ላይ..."</string>
<string name="access_sd_fail" product="nosdcard" msgid="8147993984037859354">"USB ማከማችን መድረስ አልተቻለም፡፡"</string>
<string name="access_sd_fail" product="default" msgid="1584968646870054352">"SD ካርድን መድረስ አልተቻለም፡፡"</string>
- <string name="review_cancel" msgid="8188009385853399254">"á\8bá\89\85á\88"</string>
+ <string name="review_cancel" msgid="8188009385853399254">"á\88°á\88á\8b\9d"</string>
<string name="review_ok" msgid="1156261588693116433">"ተከናውኗል"</string>
<string name="time_lapse_title" msgid="4360632427760662691">"በመቅዳት የሚፈጀውን ጊዜ"</string>
<string name="pref_camera_id_title" msgid="4040791582294635851">"ካሜራ ምረጥ"</string>
<string name="ffx_bleach" msgid="8946700451603478453">"Pleekimine"</string>
<string name="ffx_blue_crush" msgid="6034283412305561226">"Sinine"</string>
<string name="ffx_bw_contrast" msgid="517988490066217206">"Mustvalge"</string>
- <string name="ffx_punch" msgid="1343475517872562639">"Punch"</string>
+ <string name="ffx_punch" msgid="1343475517872562639">"Punš"</string>
<string name="ffx_x_process" msgid="4779398678661811765">"X-töötlus"</string>
<string name="ffx_washout" msgid="4594160692176642735">"Latte"</string>
<string name="ffx_washout_color" msgid="8034075742195795219">"Litorgaafia"</string>
<string name="ffx_bleach" msgid="8946700451603478453">"Bleach"</string>
<string name="ffx_blue_crush" msgid="6034283412305561226">"Plavo"</string>
<string name="ffx_bw_contrast" msgid="517988490066217206">"Crno-bijelo"</string>
- <string name="ffx_punch" msgid="1343475517872562639">"Punch"</string>
+ <string name="ffx_punch" msgid="1343475517872562639">"Žućkasto"</string>
<string name="ffx_x_process" msgid="4779398678661811765">"X Process"</string>
<string name="ffx_washout" msgid="4594160692176642735">"Bijela kava"</string>
<string name="ffx_washout_color" msgid="8034075742195795219">"Litografija"</string>
<string name="pref_camera_id_title" msgid="4040791582294635851">"ເລືອກກ້ອງ"</string>
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"ກັບ"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"ໜ້າ"</string>
- <string name="pref_camera_recordlocation_title" msgid="371208839215448917">"ສະàº\96າàº\99àº\97ີà»\88àº\88ັàº\94à»\80àº\81ັàº\9a"</string>
+ <string name="pref_camera_recordlocation_title" msgid="371208839215448917">"àº\9aັàº\99àº\97ຶàº\81ສະàº\96າàº\99àº\97ີà»\88"</string>
<string name="pref_camera_location_label" msgid="2254270920298609161">"ສະຖານທີ່"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"ໂຕນັບເວລາຖອຍຫຼັງ"</string>
<plurals name="pref_camera_timer_entry">
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"ໄຟຟລູອໍເຣສເຊນ"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"ຟ້າຄຶ້ມ"</string>
<string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"ອັດຕະໂນມັດ"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"à»\81ສàº\87àº\81à»\89າ"</string>
+ <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ຫຼàºàº\94à»\84àº\9fສົà»\89ມ"</string>
<string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"ກາງເວັນ"</string>
<string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ໄຟຟລູອໍເຣສເຊນ"</string>
<string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ຟ້າບົດ"</string>
</plurals>
<!-- no translation found for pref_camera_timer_sound_default (7066624532144402253) -->
<skip />
- <string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"Bip semasa kira detik"</string>
+ <string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"Bip kira detik"</string>
<string name="setting_off" msgid="4480039384202951946">"Matikan"</string>
<string name="setting_on" msgid="8602246224465348901">"Hidupkan"</string>
<string name="pref_video_quality_title" msgid="8245379279801096922">"Kualiti video"</string>
<string name="pref_video_quality_entry_high" msgid="8664038216234805914">"Tinggi"</string>
<string name="pref_video_quality_entry_low" msgid="7258507152393173784">"Rendah"</string>
- <string name="pref_video_time_lapse_frame_interval_title" msgid="6245716906744079302">"Selang masa"</string>
+ <string name="pref_video_time_lapse_frame_interval_title" msgid="6245716906744079302">"Sela masa"</string>
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Tetapan kamera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Tetapan kamkorder"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Saiz gambar"</string>
<string name="ffx_bleach" msgid="8946700451603478453">"Bleach"</string>
<string name="ffx_blue_crush" msgid="6034283412305561226">"Плаво"</string>
<string name="ffx_bw_contrast" msgid="517988490066217206">"Црно-бело"</string>
- <string name="ffx_punch" msgid="1343475517872562639">"Punch"</string>
+ <string name="ffx_punch" msgid="1343475517872562639">"Пунч"</string>
<string name="ffx_x_process" msgid="4779398678661811765">"X Process"</string>
<string name="ffx_washout" msgid="4594160692176642735">"Испрано"</string>
<string name="ffx_washout_color" msgid="8034075742195795219">"Литографски"</string>
<string name="ffx_bleach" msgid="8946700451603478453">"Làm phai màu"</string>
<string name="ffx_blue_crush" msgid="6034283412305561226">"Màu xanh dương"</string>
<string name="ffx_bw_contrast" msgid="517988490066217206">"Đen/trắng"</string>
- <string name="ffx_punch" msgid="1343475517872562639">"Punch"</string>
+ <string name="ffx_punch" msgid="1343475517872562639">"Hơi vàng"</string>
<string name="ffx_x_process" msgid="4779398678661811765">"Quá trình X"</string>
<string name="ffx_washout" msgid="4594160692176642735">"Latte"</string>
<string name="ffx_washout_color" msgid="8034075742195795219">"Litho"</string>
<string name="pref_video_time_lapse_frame_interval_title" msgid="6245716906744079302">"延时"</string>
<string name="pref_camera_settings_category" msgid="2576236450859613120">"相机设置"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"摄像机设置"</string>
- <string name="pref_camera_picturesize_title" msgid="4333724936665883006">"ç\85§ç\89\87大å°\8f"</string>
+ <string name="pref_camera_picturesize_title" msgid="4333724936665883006">"ç\85§ç\89\87尺寸"</string>
<string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"1300万像素"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"800 万像素"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"500 万像素"</string>
*/
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);
// will be <= 300 dpi on A4 (8.3×11.7) paper
// with a worst case of 150 dpi
private final static int MAX_PRINT_SIZE = 3500;
+ static Boolean sNoPrint = null;
/**
* @return true if the system supports print
*/
public static boolean systemSupportsPrint() {
- return (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2);
+ // TODO change the code to call a support library
+ if (sNoPrint != null) {
+ return sNoPrint;
+ }
+ try {
+ Class c = Class.forName("android.print.PrintManager");
+ sNoPrint = true;
+ } catch (ClassNotFoundException e) {
+ sNoPrint = false;
+ }
+ return sNoPrint;
}
public static void printBitmap(final Context context, final String jobName,
- final Bitmap bitmap) {
+ final Bitmap bitmap) {
if (bitmap == null) {
return;
}
fileDescriptor.getFileDescriptor()));
// Done.
writeResultCallback.onWriteFinished(
- new PageRange[] { PageRange.ALL_PAGES });
+ new PageRange[]{PageRange.ALL_PAGES});
} catch (IOException ioe) {
// Failed.
Log.e(LOG_TAG, "Error writing printed content", ioe);
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");
}