summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2013-04-09 15:26:22 -0400
committerChris Wren <cwren@android.com>2013-04-09 15:26:22 -0400
commita924553fc2a5bf5ab88ac031adf154480b970bd9 (patch)
tree5780283017f7f4c0a08871867ef495aa396a6bdf /src
parent88d80f4471c900628e2cb6eef23029b99af48e09 (diff)
downloadandroid_packages_screensavers_PhotoTable-a924553fc2a5bf5ab88ac031adf154480b970bd9.tar.gz
android_packages_screensavers_PhotoTable-a924553fc2a5bf5ab88ac031adf154480b970bd9.tar.bz2
android_packages_screensavers_PhotoTable-a924553fc2a5bf5ab88ac031adf154480b970bd9.zip
support dpads in story mode.
Bug: 8572945 Change-Id: Icabd1fc61ec7c3c5b6a2f5ef94641eb7c8deb1c3
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dreams/phototable/KeyboardInterpreter.java23
-rw-r--r--src/com/android/dreams/phototable/PhotoTable.java15
2 files changed, 25 insertions, 13 deletions
diff --git a/src/com/android/dreams/phototable/KeyboardInterpreter.java b/src/com/android/dreams/phototable/KeyboardInterpreter.java
index aa316cb..0b0d6bb 100644
--- a/src/com/android/dreams/phototable/KeyboardInterpreter.java
+++ b/src/com/android/dreams/phototable/KeyboardInterpreter.java
@@ -27,15 +27,17 @@ public class KeyboardInterpreter {
private static final boolean DEBUG = false;
private final PhotoTable mTable;
+ private final long mBounce;
+ private long mLastDeckNavigation;
public KeyboardInterpreter(PhotoTable table) {
+ mBounce = 2000; // TODO: remove this once latencies in lower layers are removed.
mTable = table;
}
-
public boolean onKeyDown(int keyCode, KeyEvent event) {
final View focus = mTable.getFocus();
boolean consumed = true;
-
+ Log.d(TAG, "down: " + keyCode);
if (mTable.hasSelection()) {
switch (keyCode) {
case KeyEvent.KEYCODE_ENTER:
@@ -44,6 +46,23 @@ public class KeyboardInterpreter {
mTable.setFocus(mTable.getSelection());
mTable.clearSelection();
break;
+
+ case KeyEvent.KEYCODE_DPAD_RIGHT:
+ case KeyEvent.KEYCODE_L:
+ if ((System.currentTimeMillis() - mLastDeckNavigation) > mBounce) {
+ mLastDeckNavigation = System.currentTimeMillis();
+ mTable.selectPrevious();
+ }
+ break;
+
+ case KeyEvent.KEYCODE_DPAD_LEFT:
+ case KeyEvent.KEYCODE_H:
+ if ((System.currentTimeMillis() - mLastDeckNavigation) > mBounce) {
+ mLastDeckNavigation = System.currentTimeMillis();
+ mTable.selectNext();
+ }
+ break;
+
default:
if (DEBUG) Log.d(TAG, "dropped unexpected: " + keyCode);
consumed = false;
diff --git a/src/com/android/dreams/phototable/PhotoTable.java b/src/com/android/dreams/phototable/PhotoTable.java
index 7d2f6b6..ddf071f 100644
--- a/src/com/android/dreams/phototable/PhotoTable.java
+++ b/src/com/android/dreams/phototable/PhotoTable.java
@@ -94,6 +94,7 @@ public class PhotoTable extends FrameLayout {
private final EdgeSwipeDetector mEdgeSwipeDetector;
private final KeyboardInterpreter mKeyboardInterpreter;
private final boolean mStoryModeEnabled;
+ private final long mPickUpDuration;
private DreamService mDream;
private PhotoLaunchTask mPhotoLaunchTask;
private LoadNaturalSiblingTask mLoadOnDeckTasks[];
@@ -120,6 +121,7 @@ public class PhotoTable extends FrameLayout {
mTableRatio = mResources.getInteger(R.integer.table_ratio) / 1000000f;
mImageRotationLimit = (float) mResources.getInteger(R.integer.max_image_rotation);
mThrowSpeed = mResources.getDimension(R.dimen.image_throw_speed);
+ mPickUpDuration = mResources.getInteger(R.integer.photo_pickup_duration);
mThrowRotation = (float) mResources.getInteger(R.integer.image_throw_rotatioan);
mTableCapacity = mResources.getInteger(R.integer.table_capacity);
mRedealCount = mResources.getInteger(R.integer.redeal_count);
@@ -604,11 +606,6 @@ public class PhotoTable extends FrameLayout {
float x = (getWidth() - photoWidth) / 2f;
float y = (getHeight() - photoHeight) / 2f;
- View selected = getSelection();
- float selectedWidth = selected.getWidth();
- float selectedHeight = selected.getHeight();
- float selectedScale = Math.min(getHeight() / photoHeight, getWidth() / photoWidth);
-
float offset = (((float) mWidth + scale * (photoWidth - 2f * mInset)) / 2f);
x += (slot == NEXT? 1f : -1f) * offset;
@@ -619,7 +616,7 @@ public class PhotoTable extends FrameLayout {
.scaleY(scale)
.x(x)
.y(y)
- .setDuration(1000)
+ .setDuration(mPickUpDuration)
.setInterpolator(new DecelerateInterpolator(2f));
}
}
@@ -784,10 +781,6 @@ public class PhotoTable extends FrameLayout {
float dx = x - x0;
float dy = y - y0;
- float dist = (float) (Math.sqrt(dx * dx + dy * dy));
- int duration = (int) (1000f * dist / 600f);
- duration = Math.max(duration, 500);
-
photo.setRotation(wrapAngle(photo.getRotation()));
log("animate it");
@@ -799,7 +792,7 @@ public class PhotoTable extends FrameLayout {
.scaleY(scale)
.x(x)
.y(y)
- .setDuration(duration)
+ .setDuration(mPickUpDuration)
.setInterpolator(new DecelerateInterpolator(2f))
.withEndAction(new Runnable() {
@Override