summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--res/layout-sw800dp/table.xml9
-rw-r--r--res/layout/table.xml9
-rw-r--r--res/values-land-notouch/config.xml2
-rw-r--r--res/values-sw800dp/config.xml9
-rw-r--r--res/values/config.xml3
-rw-r--r--src/com/android/dreams/phototable/PhotoTable.java74
6 files changed, 83 insertions, 23 deletions
diff --git a/res/layout-sw800dp/table.xml b/res/layout-sw800dp/table.xml
index e063cd5..c40ee48 100644
--- a/res/layout-sw800dp/table.xml
+++ b/res/layout-sw800dp/table.xml
@@ -23,6 +23,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
+ <View
+ android:id="@+id/scrim"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@+drawable/table"
+ android:alpha="0"
+ android:visibility="gone"
+ />
+
<FrameLayout
android:id="@+id/stageleft"
android:layout_width="match_parent"
diff --git a/res/layout/table.xml b/res/layout/table.xml
index 7cdb51a..10622f5 100644
--- a/res/layout/table.xml
+++ b/res/layout/table.xml
@@ -26,6 +26,15 @@
android:background="@+drawable/table"
android:focusable="true" >
+ <View
+ android:id="@+id/scrim"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@+drawable/table"
+ android:alpha="0"
+ android:visibility="gone"
+ />
+
<FrameLayout
android:id="@+id/stageleft"
android:layout_width="match_parent"
diff --git a/res/values-land-notouch/config.xml b/res/values-land-notouch/config.xml
index d125dd1..5e088e4 100644
--- a/res/values-land-notouch/config.xml
+++ b/res/values-land-notouch/config.xml
@@ -27,4 +27,6 @@
<!-- Duration in milliseconds for the pickup animation. -->
<integer name="photo_pickup_duration">1500</integer>
+ <!-- Enable hardware layer optimization (interferes with dragging). -->
+ <bool name="enable_background_optimization">true</bool>
</resources> \ No newline at end of file
diff --git a/res/values-sw800dp/config.xml b/res/values-sw800dp/config.xml
index ec6a85f..8af15bc 100644
--- a/res/values-sw800dp/config.xml
+++ b/res/values-sw800dp/config.xml
@@ -14,13 +14,20 @@
limitations under the License.
-->
<resources>
+
+ <!-- Maximum number of photos to leave on the table.-->
+ <integer name="table_capacity">8</integer>
+
<!-- Milliseconds between drops. -->
<integer name="table_drop_period">75000</integer>
<!-- Milliseconds to wait before the next fast drop.-->
<integer name="fast_drop">5000</integer>
- <!-- Duration in milliseconds for the pickup animation. -->
+ <!-- Parts per million ratio between image size and screen size. -->
+ <integer name="image_ratio">500000</integer>
+
+ <!-- Duration in milliseconds for the pickup animation. -->
<integer name="photo_pickup_duration">1500</integer>
</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index c3a6e65..9087266 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -109,5 +109,8 @@
<!-- Milliseconds that the focus will remain without user interaction. -->
<integer name="max_focus_time">5000</integer>
+ <!-- Enable hardware layer optimization (interferes with dragging). -->
+ <bool name="enable_background_optimization">false</bool>
+
</resources>
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();