summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2018-12-09 19:25:48 -0800
committerLinux Build Service Account <lnxbuild@localhost>2018-12-09 19:25:48 -0800
commitad07a5dad0df3d6f8b334288149828ce002cfe60 (patch)
tree671e347fda9a9cdb366641ff0ecb146e62066b2b
parent45f68c4bd617ed1f25c116bd6b26c195fa6c9dfb (diff)
parent0e13f5a5b5098b78d6c446e201f0ef7be8db2d0e (diff)
downloadandroid_packages_apps_Gallery2-ad07a5dad0df3d6f8b334288149828ce002cfe60.tar.gz
android_packages_apps_Gallery2-ad07a5dad0df3d6f8b334288149828ce002cfe60.tar.bz2
android_packages_apps_Gallery2-ad07a5dad0df3d6f8b334288149828ce002cfe60.zip
Merge 0e13f5a5b5098b78d6c446e201f0ef7be8db2d0e on remote branch
Change-Id: I02c670e385625c9eef7dd6b6dd7032d23a7a47c1
-rwxr-xr-xsrc/com/android/gallery3d/app/GalleryActivity.java17
-rwxr-xr-xsrc/com/android/gallery3d/app/MovieActivity.java12
-rwxr-xr-xsrc/com/android/gallery3d/app/TimeLinePage.java29
-rwxr-xr-x[-rw-r--r--]src/com/android/gallery3d/data/LocalMergeAlbum.java7
-rwxr-xr-x[-rw-r--r--]src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java11
5 files changed, 69 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java
index 16920b942..c4b9564d1 100755
--- a/src/com/android/gallery3d/app/GalleryActivity.java
+++ b/src/com/android/gallery3d/app/GalleryActivity.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.UriMatcher;
import android.content.pm.PackageManager;
import android.graphics.Color;
@@ -618,4 +619,20 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
}
return super.onGenericMotionEvent(event);
}
+
+ public void registerHomeButtonReceiver(TimeLinePage.HomeIconActionReceiver receiver) {
+ IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+ registerReceiver(receiver, filter);
+ }
+
+ public void unregisterHomeButtonReceiver(TimeLinePage.HomeIconActionReceiver receiver) {
+ if (receiver == null) {
+ return;
+ }
+ try {
+ unregisterReceiver(receiver);
+ } catch (Exception e) {
+ Log.w(TAG, "unregister HomeIconActionReceiver failed");
+ }
+ }
}
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index 376338863..62ffa753f 100755
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -52,6 +52,7 @@ import android.os.Bundle;
import android.os.SystemProperties;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
+import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -109,7 +110,6 @@ public class MovieActivity extends AbstractPermissionActivity {
private boolean mIsHeadsetOn = false;
private boolean mVirtualizerSupported = false;
private boolean mBassBoostSupported = false;
- private boolean mUserPresentReceived = false;
static enum Key {
global_enabled, bb_strength, virt_strength
@@ -746,21 +746,21 @@ public class MovieActivity extends AbstractPermissionActivity {
@Override
public void onReceive(Context context, Intent intent) {
+ Display display = getWindowManager().getDefaultDisplay();
if (LOG) {
Log.v(TAG, "onReceive(" + intent.getAction() + ") mControlResumed="
+ mControlResumed);
}
- if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
+ if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction()) &&
+ display.getState() == Display.STATE_OFF) {
// Only stop video.
- if (mControlResumed && mUserPresentReceived) {
+ if (mControlResumed) {
mPlayer.onStop();
- mUserPresentReceived = false;
mControlResumed = false;
}
} else if (Intent.ACTION_USER_PRESENT.equals(intent.getAction())) {
- if (!mControlResumed && !mUserPresentReceived) {
+ if (!mControlResumed) {
mPlayer.onResume();
- mUserPresentReceived = true;
mControlResumed = true;
}
}
diff --git a/src/com/android/gallery3d/app/TimeLinePage.java b/src/com/android/gallery3d/app/TimeLinePage.java
index c3c08650b..dad1ef265 100755
--- a/src/com/android/gallery3d/app/TimeLinePage.java
+++ b/src/com/android/gallery3d/app/TimeLinePage.java
@@ -20,8 +20,10 @@
package com.android.gallery3d.app;
import android.app.Activity;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
@@ -124,6 +126,7 @@ public class TimeLinePage extends ActivityState implements
private int mSyncResult;
private boolean mLoadingFailed;
private RelativePosition mOpenCenter = new RelativePosition();
+ private HomeIconActionReceiver mHomeIconActionReceiver;
private Handler mHandler;
private static final int MSG_PICK_PHOTO = 0;
@@ -433,6 +436,7 @@ public class TimeLinePage extends ActivityState implements
}
}
};
+ registerHomeReceiver();
}
@Override
@@ -499,6 +503,7 @@ public class TimeLinePage extends ActivityState implements
mAlbumDataAdapter.setLoadingListener(null);
}
mActionModeHandler.destroy();
+ ((GalleryActivity) mActivity).unregisterHomeButtonReceiver(mHomeIconActionReceiver);
}
private void initializeViews() {
@@ -896,4 +901,28 @@ public class TimeLinePage extends ActivityState implements
tvEmptyAlbum.setVisibility(View.GONE);
}
}
+
+ public class HomeIconActionReceiver extends BroadcastReceiver {
+ private static final String SYSTEM_DIALOG_REASON_KEY = "reason";
+ private static final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (TextUtils.equals(intent.getAction(), Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
+ String reasonHomeKey = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
+ if (TextUtils.equals(SYSTEM_DIALOG_REASON_HOME_KEY, reasonHomeKey)) {
+ StateManager manager = mActivity.getStateManager();
+ int stateCount = manager.getStateCount();
+ if (stateCount == 1 && manager.getTopState() instanceof TimeLinePage) {
+ manager.finishState(manager.getTopState());
+ }
+ }
+ }
+ }
+ }
+
+ private void registerHomeReceiver() {
+ mHomeIconActionReceiver = new HomeIconActionReceiver();
+ ((GalleryActivity) mActivity).registerHomeButtonReceiver(mHomeIconActionReceiver);
+ }
}
diff --git a/src/com/android/gallery3d/data/LocalMergeAlbum.java b/src/com/android/gallery3d/data/LocalMergeAlbum.java
index db981c3d7..40e8b8ef0 100644..100755
--- a/src/com/android/gallery3d/data/LocalMergeAlbum.java
+++ b/src/com/android/gallery3d/data/LocalMergeAlbum.java
@@ -121,7 +121,12 @@ public class LocalMergeAlbum extends MediaSet implements ContentListener {
// First find the nearest mark position <= start.
SortedMap<Integer, int[]> head = mIndex.headMap(start + 1);
- int markPos = head.lastKey();
+ int markPos;
+ try {
+ markPos = head.lastKey();
+ } catch (NoSuchElementException e) {
+ return new ArrayList<MediaItem>();
+ }
int[] subPos = head.get(markPos).clone();
MediaItem[] slot = new MediaItem[mSources.length];
diff --git a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java
index 6b5a9bef0..0768e78fc 100644..100755
--- a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java
+++ b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java
@@ -461,6 +461,17 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr
clearVideoInfo();
if (mUri == null || mSurfaceHolder == null || mTargetState == STATE_ERROR) {
// not ready for playback just yet, will try again later
+ if (mSurfaceHolder == null) {
+ setVisibility(GONE);
+ getHolder().removeCallback(mSHCallback);
+ getHolder().addCallback(mSHCallback);
+ postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ setVisibility(VISIBLE);
+ }
+ },500);
+ }
return;
}