summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2013-06-19 16:37:06 -0400
committerChris Wren <cwren@android.com>2013-06-19 16:40:06 -0400
commit7170112b066301a1fc302a159aa8857a70f83883 (patch)
treea6277b7c73745ee8da12930783aea28a30a789b6 /src
parent23ab8f3366a5eeecd36c5f489a47eb6b8f03bc56 (diff)
downloadandroid_packages_screensavers_PhotoTable-7170112b066301a1fc302a159aa8857a70f83883.tar.gz
android_packages_screensavers_PhotoTable-7170112b066301a1fc302a159aa8857a70f83883.tar.bz2
android_packages_screensavers_PhotoTable-7170112b066301a1fc302a159aa8857a70f83883.zip
quick fix for jank on touch devices.
optimizations for notouch devices caused jank on touch. The best solution is difficult, so for the time being, let's just disable that optimiztion on touch devices. Bug: 9462757 Change-Id: I4e574eb23d0764267e5b5efea01230feba5114d1
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dreams/phototable/PhotoTable.java74
1 files changed, 52 insertions, 22 deletions
diff --git a/src/com/android/dreams/phototable/PhotoTable.java b/src/com/android/dreams/phototable/PhotoTable.java
index 7e7f92e..2837309 100644
--- a/src/com/android/dreams/phototable/PhotoTable.java
+++ b/src/com/android/dreams/phototable/PhotoTable.java
@@ -105,6 +105,7 @@ public class PhotoTable extends FrameLayout {
private final EdgeSwipeDetector mEdgeSwipeDetector;
private final KeyboardInterpreter mKeyboardInterpreter;
private final boolean mStoryModeEnabled;
+ private final boolean mBackgroudOptimization;
private final long mPickUpDuration;
private final int mMaxSelectionTime;
private final int mMaxFocusTime;
@@ -125,6 +126,7 @@ public class PhotoTable extends FrameLayout {
private int mHighlightColor;
private ViewGroup mBackground;
private ViewGroup mStageLeft;
+ private View mScrim;
public PhotoTable(Context context, AttributeSet as) {
super(context, as);
@@ -143,6 +145,7 @@ public class PhotoTable extends FrameLayout {
mRedealCount = mResources.getInteger(R.integer.redeal_count);
mTapToExit = mResources.getBoolean(R.bool.enable_tap_to_exit);
mStoryModeEnabled = mResources.getBoolean(R.bool.enable_story_mode);
+ mBackgroudOptimization = mResources.getBoolean(R.bool.enable_background_optimization);
mHighlightColor = mResources.getColor(R.color.highlight_color);
mMaxSelectionTime = mResources.getInteger(R.integer.max_selection_time);
mMaxFocusTime = mResources.getInteger(R.integer.max_focus_time);
@@ -170,6 +173,7 @@ public class PhotoTable extends FrameLayout {
public void onFinishInflate() {
mBackground = (ViewGroup) findViewById(R.id.background);
mStageLeft = (ViewGroup) findViewById(R.id.stageleft);
+ mScrim = findViewById(R.id.scrim);
}
public void setDream(DreamService dream) {
@@ -603,29 +607,55 @@ public class PhotoTable extends FrameLayout {
/** De-emphasize the other photos on the table. */
public void fadeOutBackground(final View photo) {
- mBackground.animate()
- .withLayer()
- .setDuration(mPickUpDuration)
- .alpha(0f);
+ if (mBackgroudOptimization) {
+ mBackground.animate()
+ .withLayer()
+ .setDuration(mPickUpDuration)
+ .alpha(0f);
+ } else {
+ mScrim.setAlpha(0f);
+ mScrim.setVisibility(View.VISIBLE);
+ bringChildToFront(mScrim);
+ bringChildToFront(photo);
+ mScrim.animate()
+ .withLayer()
+ .setDuration(mPickUpDuration)
+ .alpha(1f);
+ }
}
/** Return the other photos to foreground status. */
public void fadeInBackground(final View photo) {
- mAnimating.add(photo);
- mBackground.animate()
- .withLayer()
- .setDuration(mPickUpDuration)
- .alpha(1f)
- .withEndAction(new Runnable() {
- @Override
- public void run() {
- mAnimating.remove(photo);
- if (!mAnimating.contains(photo)) {
- moveToBackground(photo);
- }
- }
- });
+ if (mBackgroudOptimization) {
+ mAnimating.add(photo);
+ mBackground.animate()
+ .withLayer()
+ .setDuration(mPickUpDuration)
+ .alpha(1f)
+ .withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ mAnimating.remove(photo);
+ if (!mAnimating.contains(photo)) {
+ moveToBackground(photo);
+ }
+ }
+ });
+ } else {
+ bringChildToFront(mScrim);
+ bringChildToFront(photo);
+ mScrim.animate()
+ .withLayer()
+ .setDuration(mPickUpDuration)
+ .alpha(0f)
+ .withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ mScrim.setVisibility(View.GONE);
+ }
+ });
+ }
}
/** Dispose of the photo gracefully, in case we can see some of it. */
@@ -846,7 +876,7 @@ public class PhotoTable extends FrameLayout {
}
private void moveToBackground(View photo) {
- if (!isInBackground(photo)) {
+ if (mBackgroudOptimization && !isInBackground(photo)) {
removeView(photo);
mBackground.addView(photo, new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
@@ -864,7 +894,7 @@ public class PhotoTable extends FrameLayout {
}
private void moveToForeground(View photo) {
- if (isInBackground(photo)) {
+ if (mBackgroudOptimization && isInBackground(photo)) {
mBackground.removeView(photo);
addView(photo, new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
@@ -872,7 +902,7 @@ public class PhotoTable extends FrameLayout {
}
private boolean isInBackground(View photo) {
- return mBackground.indexOfChild(photo) != -1;
+ return mBackgroudOptimization && mBackground.indexOfChild(photo) != -1;
}
/** wrap all orientations to the interval [-180, 180). */
@@ -883,7 +913,7 @@ public class PhotoTable extends FrameLayout {
return result;
}
- /** Animate the selected photo to the foregound: zooming in to bring it foreward. */
+ /** Animate the selected photo to the foreground: zooming in to bring it forward. */
private void pickUp(final View photo) {
float photoWidth = photo.getWidth();
float photoHeight = photo.getHeight();