OSDN Git Service

Merge "Import translations. DO NOT MERGE"
authorBaligh Uddin <baligh@google.com>
Tue, 1 Oct 2013 04:35:19 +0000 (04:35 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Tue, 1 Oct 2013 04:35:19 +0000 (04:35 +0000)
25 files changed:
AndroidManifest.xml
res/values-am/strings.xml
res/values-et-rEE/strings.xml
res/values-hr/strings.xml
res/values-lo-rLA/strings.xml
res/values-ms-rMY/strings.xml
res/values-sr/strings.xml
res/values-vi/strings.xml
res/values-zh-rCN/strings.xml
src/com/android/camera/CameraActivity.java
src/com/android/gallery3d/app/AlbumPage.java
src/com/android/gallery3d/app/AlbumPicker.java
src/com/android/gallery3d/app/AlbumSetPage.java
src/com/android/gallery3d/app/DialogPicker.java
src/com/android/gallery3d/app/Gallery.java
src/com/android/gallery3d/app/GalleryActivity.java [new file with mode: 0644]
src/com/android/gallery3d/app/MovieActivity.java
src/com/android/gallery3d/app/PhotoPage.java
src/com/android/gallery3d/data/LocalSource.java
src/com/android/gallery3d/gadget/WidgetClickHandler.java
src/com/android/gallery3d/util/GalleryUtils.java
src/com/android/gallery3d/util/PrintJob.java
src/com/android/photos/AlbumFragment.java
src/com/android/photos/PhotoSetFragment.java
src_pd/com/android/gallery3d/util/IntentHelper.java [moved from src_pd/com/android/gallery3d/util/CameraHelper.java with 80% similarity]

index 41eb461..8f48edf 100644 (file)
@@ -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" />
             </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>
index 8461376..b372dd6 100644 (file)
@@ -55,7 +55,7 @@
     <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>
index 8b67802..057fa98 100644 (file)
     <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>
index ab733b4..09d8478 100644 (file)
     <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>
index a640de8..618cc29 100644 (file)
     <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>
index 32443c1..b9aeaf4 100644 (file)
   </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>
index e1b8d17..54d2b83 100644 (file)
     <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>
index fe8addc..f199482 100644 (file)
     <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>
index 3e8ac7c..725c767 100644 (file)
     <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>
index f2402af..533bbe8 100644 (file)
  */
 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.
index 658abbb..44f2404 100644 (file)
@@ -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 {
index 65eb772..8c2d09a 100644 (file)
@@ -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);
index dd9d8ec..d56b5b8 100644 (file)
@@ -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);
index 7ca86e5..1de3324 100644 (file)
@@ -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);
index 510542a..0c1ef79 100644 (file)
@@ -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.
  * 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 (file)
index 0000000..bb2a6b8
--- /dev/null
@@ -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);
+    }
+}
index 8bf9b55..8dec2d4 100644 (file)
@@ -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;
index c4a9d1b..3359888 100644 (file)
@@ -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();
index a2e3d14..810aef4 100644 (file)
@@ -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;
index 37ee1a6..e66a2a6 100644 (file)
@@ -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(
index c25a2fc..83cc055 100644 (file)
@@ -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);
index a593c2d..bd85773 100644 (file)
@@ -44,16 +44,27 @@ public class PrintJob {
     // 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;
         }
@@ -119,7 +130,7 @@ public class PrintJob {
                                         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);
index 406fd2a..886ca68 100644 (file)
@@ -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);
     }
 
index 961fd0b..7ce876f 100644 (file)
@@ -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);
     }
 
@@ -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");
 }