Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 527b4537 authored by Alan Viverette's avatar Alan Viverette Committed by Android Git Automerger
Browse files

am 3a79e434: am a0d3d003: am 5fc9b336: Merge "Consider RTL layout in DPAD navigation in Gallery"

* commit '3a79e434':
  Consider RTL layout in DPAD navigation in Gallery
parents 7eb1c210 3a79e434
Loading
Loading
Loading
Loading
+7 −13
Original line number Diff line number Diff line
@@ -1209,13 +1209,13 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList
        switch (keyCode) {
            
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (movePrevious()) {
            if (moveDirection(-1)) {
                playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT);
                return true;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (moveNext()) {
            if (moveDirection(1)) {
                playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT);
                return true;
            }
@@ -1255,18 +1255,12 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList
        return super.onKeyUp(keyCode, event);
    }
    
    boolean movePrevious() {
        if (mItemCount > 0 && mSelectedPosition > 0) {
            scrollToChild(mSelectedPosition - mFirstPosition - 1);
            return true;
        } else {
            return false;
        }
    }
    boolean moveDirection(int direction) {
        direction = isLayoutRtl() ? -direction : direction;
        int targetPosition = mSelectedPosition + direction;

    boolean moveNext() {
        if (mItemCount > 0 && mSelectedPosition < mItemCount - 1) {
            scrollToChild(mSelectedPosition - mFirstPosition + 1);
        if (mItemCount > 0 && targetPosition >= 0 && targetPosition < mItemCount) {
            scrollToChild(targetPosition - mFirstPosition);
            return true;
        } else {
            return false;