Merge "Improve screen on/off logic in slideshow." into ics-mr1
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 798a46e..c24279c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -72,7 +72,9 @@
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
+ <category android:name="android.intent.category.APP_GALLERY" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
index cca5104..b0b2178 100644
--- a/res/values-es/strings.xml
+++ b/res/values-es/strings.xml
@@ -155,7 +155,7 @@
<string name="widget_type" msgid="1364653978966343448">"Seleccionar imágenes"</string>
<string name="slideshow_dream_name" msgid="6915963319933437083">"Presentación"</string>
<string name="albums" msgid="7320787705180057947">"Álbumes"</string>
- <string name="times" msgid="2023033894889499219">"Horas"</string>
+ <string name="times" msgid="2023033894889499219">"Fecha"</string>
<string name="locations" msgid="6649297994083130305">"Ubicaciones"</string>
<string name="people" msgid="4114003823747292747">"Personas"</string>
<string name="tags" msgid="5539648765482935955">"Etiquetas"</string>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
index 8eb5829..1212a91 100644
--- a/res/values-ru/strings.xml
+++ b/res/values-ru/strings.xml
@@ -36,11 +36,11 @@
<string name="saving_image" msgid="7270334453636349407">"Сохранение картинки..."</string>
<string name="save_error" msgid="6857408774183654970">"Изображение не сохранено."</string>
<string name="crop_label" msgid="521114301871349328">"Обрезать фотографию"</string>
- <string name="select_image" msgid="7841406150484742140">"Выберите фото"</string>
- <string name="select_video" msgid="4859510992798615076">"Выберите видео"</string>
- <string name="select_item" msgid="2816923896202086390">"Выберите файл"</string>
- <string name="select_album" msgid="1557063764849434077">"Выберите альбом"</string>
- <string name="select_group" msgid="6744208543323307114">"Выберите группу"</string>
+ <string name="select_image" msgid="7841406150484742140">"Выбрать фото"</string>
+ <string name="select_video" msgid="4859510992798615076">"Выбрать видео"</string>
+ <string name="select_item" msgid="2816923896202086390">"Выбрать файлы"</string>
+ <string name="select_album" msgid="1557063764849434077">"Выбрать альбомы"</string>
+ <string name="select_group" msgid="6744208543323307114">"Выбрать группы"</string>
<string name="set_image" msgid="2331476809308010401">"Установить картинку как"</string>
<string name="wallpaper" msgid="140165383777262070">"Установка обоев..."</string>
<string name="camera_setas_wallpaper" msgid="797463183863414289">"Обои"</string>
@@ -81,10 +81,10 @@
<string name="crop_action" msgid="3427470284074377001">"Кадрировать"</string>
<string name="set_as" msgid="3636764710790507868">"Установить как"</string>
<string name="video_err" msgid="7003051631792271009">"Не удалось воспроизвести видео."</string>
- <string name="group_by_location" msgid="316641628989023253">"По местоположению"</string>
- <string name="group_by_time" msgid="9046168567717963573">"По времени"</string>
+ <string name="group_by_location" msgid="316641628989023253">"По месту съемки"</string>
+ <string name="group_by_time" msgid="9046168567717963573">"По времени создания"</string>
<string name="group_by_tags" msgid="3568731317210676160">"По тегам"</string>
- <string name="group_by_faces" msgid="1566351636227274906">"По людям"</string>
+ <string name="group_by_faces" msgid="1566351636227274906">"По именам"</string>
<string name="group_by_album" msgid="1532818636053818958">"По альбомам"</string>
<string name="group_by_size" msgid="153766174950394155">"По размеру"</string>
<string name="untagged" msgid="7281481064509590402">"Без тегов"</string>
@@ -102,14 +102,14 @@
<string name="no_albums_alert" msgid="4111744447491690896">"Нет доступных альбомов."</string>
<string name="empty_album" msgid="4542880442593595494">"Нет фото/видео"</string>
<string name="picasa_posts" msgid="1497721615718760613">"Записи"</string>
- <string name="make_available_offline" msgid="5157950985488297112">"Сделать доступным офлайн"</string>
+ <string name="make_available_offline" msgid="5157950985488297112">"Офлайн-доступ"</string>
<string name="sync_picasa_albums" msgid="8522572542111169872">"Обновить"</string>
<string name="done" msgid="217672440064436595">"Готово"</string>
<string name="sequence_in_set" msgid="7235465319919457488">"%1$d из %2$d:"</string>
<string name="title" msgid="7622928349908052569">"Название"</string>
<string name="description" msgid="3016729318096557520">"Описание"</string>
<string name="time" msgid="1367953006052876956">"Время"</string>
- <string name="location" msgid="3432705876921618314">"Местоположение"</string>
+ <string name="location" msgid="3432705876921618314">"Место съемки"</string>
<string name="path" msgid="4725740395885105824">"Путь"</string>
<string name="width" msgid="9215847239714321097">"Ширина"</string>
<string name="height" msgid="3648885449443787772">"Высота"</string>
@@ -155,11 +155,11 @@
<string name="widget_type" msgid="1364653978966343448">"Выбор изображений"</string>
<string name="slideshow_dream_name" msgid="6915963319933437083">"Слайд-шоу"</string>
<string name="albums" msgid="7320787705180057947">"Альбомы"</string>
- <string name="times" msgid="2023033894889499219">"По времени"</string>
+ <string name="times" msgid="2023033894889499219">"Даты"</string>
<string name="locations" msgid="6649297994083130305">"Места"</string>
<string name="people" msgid="4114003823747292747">"Люди"</string>
<string name="tags" msgid="5539648765482935955">"Теги"</string>
- <string name="group_by" msgid="4308299657902209357">"Группировать по"</string>
+ <string name="group_by" msgid="4308299657902209357">"Сгруппировать"</string>
<string name="settings" msgid="1534847740615665736">"Настройки"</string>
<string name="add_account" msgid="4271217504968243974">"Добавить аккаунт"</string>
</resources>
diff --git a/res/values-vi/photoeditor_strings.xml b/res/values-vi/photoeditor_strings.xml
index 79a2ce0..1f1b93f 100644
--- a/res/values-vi/photoeditor_strings.xml
+++ b/res/values-vi/photoeditor_strings.xml
@@ -31,12 +31,12 @@
<string name="documentary" msgid="50396326708699797">"Phim tài liệu"</string>
<string name="doodle" msgid="1686409894518940990">"Hình vẽ nguệch ngoạc"</string>
<string name="duotone" msgid="8145893940788467106">"Có hai màu"</string>
- <string name="facelift" msgid="6205748523156172637">"Hiệu ứng làm bừng sáng khuôn mặt"</string>
+ <string name="facelift" msgid="6205748523156172637">"Làm sáng mặt"</string>
<string name="facetan" msgid="4412831806626044111">"Hiệu ứng làm rám nắng khuôn mặt"</string>
<string name="filllight" msgid="2644989991700022526">"Tô sáng"</string>
<string name="fisheye" msgid="6037488646928998921">"Mắt cá"</string>
<string name="flip" msgid="2357692401826287480">"Lật"</string>
- <string name="grain" msgid="7487585304579789098">"Hiệu ứng hạt mỏng"</string>
+ <string name="grain" msgid="7487585304579789098">"Hạt mỏng"</string>
<string name="grayscale" msgid="7641563843060945228">"Đen&Trắng"</string>
<string name="highlight" msgid="3902653944386623972">"Thêm điểm sáng"</string>
<string name="lomoish" msgid="1270032154357186736">"Lomo"</string>
diff --git a/src/com/android/gallery3d/app/AlbumDataAdapter.java b/src/com/android/gallery3d/app/AlbumDataAdapter.java
index 42388ea..6711786 100644
--- a/src/com/android/gallery3d/app/AlbumDataAdapter.java
+++ b/src/com/android/gallery3d/app/AlbumDataAdapter.java
@@ -16,6 +16,9 @@
package com.android.gallery3d.app;
+import android.os.Handler;
+import android.os.Message;
+
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.ContentListener;
import com.android.gallery3d.data.DataManager;
@@ -25,9 +28,6 @@
import com.android.gallery3d.ui.AlbumView;
import com.android.gallery3d.ui.SynchronizedHandler;
-import android.os.Handler;
-import android.os.Message;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.Callable;
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index 10c2b67..6fb4143 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -325,12 +325,16 @@
super.onResume();
mIsActive = true;
setContentPane(mRootPane);
+
+ // Set the reload bit here to prevent it exit this page in clearLoadingBit().
+ setLoadingBit(BIT_LOADING_RELOAD);
mAlbumDataAdapter.resume();
+
mAlbumView.resume();
mActionModeHandler.resume();
if (!mInitialSynced) {
- mSyncTask = mMediaSet.requestSync(this);
setLoadingBit(BIT_LOADING_SYNC);
+ mSyncTask = mMediaSet.requestSync(this);
}
}
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index fb26fc6..e1dcade 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -337,7 +337,11 @@
super.onResume();
mIsActive = true;
setContentPane(mRootPane);
+
+ // Set the reload bit here to prevent it exit this page in clearLoadingBit().
+ setLoadingBit(BIT_LOADING_RELOAD);
mAlbumSetDataAdapter.resume();
+
mAlbumSetView.resume();
mEyePosition.resume();
mActionModeHandler.resume();
@@ -346,8 +350,8 @@
actionBar.showClusterMenu(mSelectedAction, this);
}
if (!mInitialSynced) {
- mSyncTask = mMediaSet.requestSync(AlbumSetPage.this);
setLoadingBit(BIT_LOADING_SYNC);
+ mSyncTask = mMediaSet.requestSync(AlbumSetPage.this);
}
}
diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java
index ebfa984..253af2b 100644
--- a/src/com/android/gallery3d/app/Gallery.java
+++ b/src/com/android/gallery3d/app/Gallery.java
@@ -16,7 +16,10 @@
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;
@@ -35,7 +38,7 @@
import com.android.gallery3d.ui.GLRoot;
import com.android.gallery3d.util.GalleryUtils;
-public final class Gallery extends AbstractGalleryActivity {
+public final class Gallery extends AbstractGalleryActivity implements OnCancelListener {
public static final String EXTRA_SLIDESHOW = "slideshow";
public static final String EXTRA_CROP = "crop";
@@ -47,6 +50,7 @@
private static final String TAG = "Gallery";
private GalleryActionBar mActionBar;
+ private Dialog mVersionCheckDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -96,6 +100,10 @@
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) {
@@ -243,10 +251,28 @@
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 GalleryActionBar getGalleryActionBar() {
return mActionBar;
}
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ if (dialog == mVersionCheckDialog) {
+ mVersionCheckDialog = null;
+ }
+ }
}
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index 95e0c74..099e9f5 100644
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -26,6 +26,7 @@
import android.os.Bundle;
import android.provider.MediaStore;
import android.provider.MediaStore.Video.VideoColumns;
+import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -170,4 +171,16 @@
mPlayer.onDestroy();
super.onDestroy();
}
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ return mPlayer.onKeyDown(keyCode, event)
+ || super.onKeyDown(keyCode, event);
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ return mPlayer.onKeyUp(keyCode, event)
+ || super.onKeyUp(keyCode, event);
+ }
}
diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java
index 9c81c79..3de534b 100644
--- a/src/com/android/gallery3d/app/MoviePlayer.java
+++ b/src/com/android/gallery3d/app/MoviePlayer.java
@@ -30,6 +30,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
+import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -333,6 +334,55 @@
startVideo();
}
+ // Below are key events passed from MovieActivity.
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+
+ // Some headsets will fire off 7-10 events on a single click
+ if (event.getRepeatCount() > 0) {
+ return isMediaKey(keyCode);
+ }
+
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_HEADSETHOOK:
+ case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
+ if (mVideoView.isPlaying()) {
+ pauseVideo();
+ } else {
+ playVideo();
+ }
+ return true;
+ case KeyEvent.KEYCODE_MEDIA_PAUSE:
+ if (mVideoView.isPlaying()) {
+ pauseVideo();
+ }
+ return true;
+ case KeyEvent.KEYCODE_MEDIA_PLAY:
+ if (!mVideoView.isPlaying()) {
+ playVideo();
+ }
+ return true;
+ case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
+ case KeyEvent.KEYCODE_MEDIA_NEXT:
+ // TODO: Handle next / previous accordingly, for now we're
+ // just consuming the events.
+ return true;
+ }
+ return false;
+ }
+
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ return isMediaKey(keyCode);
+ }
+
+ private static boolean isMediaKey(int keyCode) {
+ return keyCode == KeyEvent.KEYCODE_HEADSETHOOK
+ || keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS
+ || keyCode == KeyEvent.KEYCODE_MEDIA_NEXT
+ || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
+ || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY
+ || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE;
+ }
+
// We want to pause when the headset is unplugged.
private class AudioBecomingNoisyReceiver extends BroadcastReceiver {
diff --git a/src/com/android/gallery3d/data/ComboAlbum.java b/src/com/android/gallery3d/data/ComboAlbum.java
index 1918453..6d22311 100644
--- a/src/com/android/gallery3d/data/ComboAlbum.java
+++ b/src/com/android/gallery3d/data/ComboAlbum.java
@@ -93,6 +93,6 @@
@Override
public Future<Integer> requestSync(SyncListener listener) {
- return requestSyncOnEmptySets(mSets, listener);
+ return requestSyncOnMultipleSets(mSets, listener);
}
}
diff --git a/src/com/android/gallery3d/data/ComboAlbumSet.java b/src/com/android/gallery3d/data/ComboAlbumSet.java
index 16adc12..916b163 100644
--- a/src/com/android/gallery3d/data/ComboAlbumSet.java
+++ b/src/com/android/gallery3d/data/ComboAlbumSet.java
@@ -81,6 +81,6 @@
@Override
public Future<Integer> requestSync(SyncListener listener) {
- return requestSyncOnEmptySets(mSets, listener);
+ return requestSyncOnMultipleSets(mSets, listener);
}
}
diff --git a/src/com/android/gallery3d/data/MediaSet.java b/src/com/android/gallery3d/data/MediaSet.java
index 5094195..ff9b8c3 100644
--- a/src/com/android/gallery3d/data/MediaSet.java
+++ b/src/com/android/gallery3d/data/MediaSet.java
@@ -20,7 +20,6 @@
import com.android.gallery3d.util.Future;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.WeakHashMap;
// MediaSet is a directory-like data structure.
@@ -33,6 +32,8 @@
// getTotalMediaItemCount() returns the number of all MediaItems, including
// those in sub-MediaSets.
public abstract class MediaSet extends MediaObject {
+ private static final String TAG = "MediaSet";
+
public static final int MEDIAITEM_BATCH_FETCH_COUNT = 500;
public static final int INDEX_NOT_FOUND = -1;
@@ -229,6 +230,7 @@
* SYNC_RESULT_SUCCESS by get().
*/
public Future<Integer> requestSync(SyncListener listener) {
+ listener.onSyncDone(this, SYNC_RESULT_SUCCESS);
return FUTURE_STUB;
}
@@ -255,46 +257,39 @@
public void waitDone() {}
};
- protected Future<Integer> requestSyncOnEmptySets(MediaSet[] sets, SyncListener listener) {
- MultiSetSyncFuture future = new MultiSetSyncFuture(listener);
- future.requestSyncOnEmptySets(sets);
- return future;
+ protected Future<Integer> requestSyncOnMultipleSets(MediaSet[] sets, SyncListener listener) {
+ return new MultiSetSyncFuture(sets, listener);
}
private class MultiSetSyncFuture implements Future<Integer>, SyncListener {
private static final String TAG = "Gallery.MultiSetSync";
- private final HashMap<MediaSet, Future<Integer>> mMediaSetMap =
- new HashMap<MediaSet, Future<Integer>>();
private final SyncListener mListener;
+ private final Future<Integer> mFutures[];
private boolean mIsCancelled = false;
private int mResult = -1;
+ private int mPendingCount;
- MultiSetSyncFuture(SyncListener listener) {
+ @SuppressWarnings("unchecked")
+ MultiSetSyncFuture(MediaSet[] sets, SyncListener listener) {
mListener = listener;
- }
+ mPendingCount = sets.length;
+ mFutures = new Future[sets.length];
- synchronized void requestSyncOnEmptySets(MediaSet[] sets) {
- for (MediaSet set : sets) {
- if ((set.getMediaItemCount() == 0) && !mMediaSetMap.containsKey(set)) {
- // Sync results are handled in this.onSyncDone().
- Future<Integer> future = set.requestSync(this);
- if (!future.isDone()) {
- mMediaSetMap.put(set, future);
- Log.d(TAG, " request sync: " + Utils.maskDebugInfo(set.getName()));
- }
+ synchronized (this) {
+ for (int i = 0, n = sets.length; i < n; ++i) {
+ mFutures[i] = sets[i].requestSync(this);
+ Log.d(TAG, " request sync: " + Utils.maskDebugInfo(sets[i].getName()));
}
}
- Log.d(TAG, "requestSyncOnEmptySets actual=" + mMediaSetMap.size());
}
@Override
public synchronized void cancel() {
if (mIsCancelled) return;
mIsCancelled = true;
- for (Future<Integer> future : mMediaSetMap.values()) future.cancel();
- mMediaSetMap.clear();
+ for (Future<Integer> future : mFutures) future.cancel();
if (mResult < 0) mResult = SYNC_RESULT_CANCELLED;
}
@@ -305,7 +300,7 @@
@Override
public synchronized boolean isDone() {
- return mMediaSetMap.isEmpty();
+ return mPendingCount == 0;
}
@Override
@@ -328,18 +323,14 @@
public void onSyncDone(MediaSet mediaSet, int resultCode) {
SyncListener listener = null;
synchronized (this) {
- if (mMediaSetMap.remove(mediaSet) != null) {
- Log.d(TAG, "onSyncDone: " + Utils.maskDebugInfo(mediaSet.getName())
- + " #pending=" + mMediaSetMap.size());
- if (resultCode == SYNC_RESULT_ERROR) {
- mResult = SYNC_RESULT_ERROR;
- }
- if (mMediaSetMap.isEmpty()) {
- if (mResult < 0) mResult = SYNC_RESULT_SUCCESS;
- notifyAll();
- listener = mListener;
- }
+ if (resultCode == SYNC_RESULT_ERROR) mResult = SYNC_RESULT_ERROR;
+ --mPendingCount;
+ if (mPendingCount == 0) {
+ listener = mListener;
+ notifyAll();
}
+ Log.d(TAG, "onSyncDone: " + Utils.maskDebugInfo(mediaSet.getName())
+ + " #pending=" + mPendingCount);
}
if (listener != null) listener.onSyncDone(MediaSet.this, mResult);
}
diff --git a/src_pd/com/android/gallery3d/picasasource/PicasaSource.java b/src_pd/com/android/gallery3d/picasasource/PicasaSource.java
index a4f9621..ce0c0b8 100644
--- a/src_pd/com/android/gallery3d/picasasource/PicasaSource.java
+++ b/src_pd/com/android/gallery3d/picasasource/PicasaSource.java
@@ -16,6 +16,12 @@
package com.android.gallery3d.picasasource;
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.media.ExifInterface;
+import android.os.ParcelFileDescriptor;
+
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
@@ -24,11 +30,6 @@
import com.android.gallery3d.data.Path;
import com.android.gallery3d.data.PathMatcher;
-import android.app.Activity;
-import android.content.Context;
-import android.media.ExifInterface;
-import android.os.ParcelFileDescriptor;
-
import java.io.FileNotFoundException;
public class PicasaSource extends MediaSource {
@@ -133,4 +134,8 @@
public static void onPackageRemoved(Context context, String packageName) {/*do nothing*/}
public static void extractExifValues(MediaObject item, ExifInterface exif) {/*do nothing*/}
+
+ public static Dialog getVersionCheckDialog(Activity activity){
+ return null;
+ }
}