diff options
author | Chris Wren <cwren@android.com> | 2013-04-09 14:25:52 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-04-09 14:25:52 -0700 |
commit | e76587197a77d556dc3e706361497b3f04bc8e95 (patch) | |
tree | ff11afe51dffa75b36797b85b75c17d3f02b2f4a | |
parent | 863df3538a60922cb94a3e23e2805aaeb140157d (diff) | |
parent | b268ccad2d16b7db6dcafb62ed97a06b9a18baae (diff) | |
download | android_packages_screensavers_PhotoTable-e76587197a77d556dc3e706361497b3f04bc8e95.tar.gz android_packages_screensavers_PhotoTable-e76587197a77d556dc3e706361497b3f04bc8e95.tar.bz2 android_packages_screensavers_PhotoTable-e76587197a77d556dc3e706361497b3f04bc8e95.zip |
am b268ccad: am a924553f: support dpads in story mode.
* commit 'b268ccad2d16b7db6dcafb62ed97a06b9a18baae':
support dpads in story mode.
-rw-r--r-- | res/values/config.xml | 3 | ||||
-rw-r--r-- | src/com/android/dreams/phototable/KeyboardInterpreter.java | 23 | ||||
-rw-r--r-- | src/com/android/dreams/phototable/PhotoTable.java | 15 |
3 files changed, 28 insertions, 13 deletions
diff --git a/res/values/config.xml b/res/values/config.xml index e20ac68..c8d419c 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -100,5 +100,8 @@ <!-- Enable story mode. --> <bool name="enable_story_mode">true</bool> + <!-- Duration ion milliseconds for the pickup animation. --> + <integer name="photo_pickup_duration">1000</integer> + </resources> 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 |