diff options
author | Hyunyoung Song <hyunyoungs@google.com> | 2015-04-14 00:49:16 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-14 00:49:16 +0000 |
commit | 9d07e3d561b4b9819e7bc8778dd3e2b45b0344d9 (patch) | |
tree | 432fbf70b5648d8b7bb16064cf5956bd6653eb35 /src/com/android/launcher3/util | |
parent | be5c4ae5a4ddedf78c50317338e323e3bf1a5aec (diff) | |
parent | ada50984dc149c1f4337f965fbb59bdeaac8d09f (diff) | |
download | android_packages_apps_Trebuchet-9d07e3d561b4b9819e7bc8778dd3e2b45b0344d9.tar.gz android_packages_apps_Trebuchet-9d07e3d561b4b9819e7bc8778dd3e2b45b0344d9.tar.bz2 android_packages_apps_Trebuchet-9d07e3d561b4b9819e7bc8778dd3e2b45b0344d9.zip |
Merge "Focus handling - RTL support" into ub-launcher3-burnaby
Diffstat (limited to 'src/com/android/launcher3/util')
-rw-r--r-- | src/com/android/launcher3/util/FocusLogic.java | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/com/android/launcher3/util/FocusLogic.java b/src/com/android/launcher3/util/FocusLogic.java index 6e80c2f21..8a08a4e72 100644 --- a/src/com/android/launcher3/util/FocusLogic.java +++ b/src/com/android/launcher3/util/FocusLogic.java @@ -16,12 +16,13 @@ package com.android.launcher3.util; -import android.content.res.Configuration; import android.util.Log; import android.view.KeyEvent; import android.view.ViewGroup; import com.android.launcher3.CellLayout; +import com.android.launcher3.DeviceProfile; +import com.android.launcher3.LauncherAppState; /** * Calculates the next item that a {@link KeyEvent} should change the focus to. @@ -42,7 +43,7 @@ import com.android.launcher3.CellLayout; */ public class FocusLogic { - private static final String TAG = "Focus"; + private static final String TAG = "FocusLogic"; private static final boolean DEBUG = false; // Item and page index related constant used by {@link #handleKeyEvent}. @@ -51,12 +52,14 @@ public class FocusLogic { public static final int PREVIOUS_PAGE_RIGHT_COLUMN = -2; public static final int PREVIOUS_PAGE_FIRST_ITEM = -3; public static final int PREVIOUS_PAGE_LAST_ITEM = -4; + public static final int PREVIOUS_PAGE_LEFT_COLUMN = -5; - public static final int CURRENT_PAGE_FIRST_ITEM = -5; - public static final int CURRENT_PAGE_LAST_ITEM = -6; + public static final int CURRENT_PAGE_FIRST_ITEM = -6; + public static final int CURRENT_PAGE_LAST_ITEM = -7; - public static final int NEXT_PAGE_FIRST_ITEM = -7; - public static final int NEXT_PAGE_LEFT_COLUMN = -8; + public static final int NEXT_PAGE_FIRST_ITEM = -8; + public static final int NEXT_PAGE_LEFT_COLUMN = -9; + public static final int NEXT_PAGE_RIGHT_COLUMN = -10; // Matrix related constant. public static final int EMPTY = -1; @@ -85,18 +88,24 @@ public class FocusLogic { cntX, cntY, iconIdx, pageIndex, pageCount)); } + DeviceProfile profile = LauncherAppState.getInstance().getDynamicGrid() + .getDeviceProfile(); int newIndex = NOOP; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, -1 /*increment*/); - if (newIndex == NOOP && pageIndex > 0) { + if (!profile.isLayoutRtl && newIndex == NOOP && pageIndex > 0) { newIndex = PREVIOUS_PAGE_RIGHT_COLUMN; + } else if (profile.isLayoutRtl && newIndex == NOOP && pageIndex < pageCount - 1) { + newIndex = NEXT_PAGE_RIGHT_COLUMN; } break; case KeyEvent.KEYCODE_DPAD_RIGHT: newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, 1 /*increment*/); - if (newIndex == NOOP && pageIndex < pageCount - 1) { + if (!profile.isLayoutRtl && newIndex == NOOP && pageIndex < pageCount - 1) { newIndex = NEXT_PAGE_LEFT_COLUMN; + } else if (profile.isLayoutRtl && newIndex == NOOP && pageIndex > 0) { + newIndex = PREVIOUS_PAGE_LEFT_COLUMN; } break; case KeyEvent.KEYCODE_DPAD_DOWN: @@ -140,11 +149,18 @@ public class FocusLogic { */ // TODO: get rid of dynamic matrix creation. public static int[][] createFullMatrix(int m, int n, boolean incrementOrder) { + DeviceProfile profile = LauncherAppState.getInstance().getDynamicGrid() + .getDeviceProfile(); int[][] matrix = new int [m][n]; + for (int i=0; i < m;i++) { for (int j=0; j < n; j++) { if (incrementOrder) { - matrix[i][j] = j * m + i; + if (!profile.isLayoutRtl) { + matrix[i][j] = j * m + i; + } else { + matrix[i][j] = j * m + m - i -1; + } } else { matrix[i][j] = EMPTY; } |