summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/util
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2015-05-06 11:42:25 -0700
committerAdam Cohen <adamcohen@google.com>2015-05-21 16:16:40 -0700
commit2e6da1539bc7286336b3c24d96ab76434939ce4d (patch)
tree38c7387dc9a5f6f084c4998aac88495189423d3b /src/com/android/launcher3/util
parenta9d012c6e67b644498e07c63f36617c1b8915e02 (diff)
downloadandroid_packages_apps_Trebuchet-2e6da1539bc7286336b3c24d96ab76434939ce4d.tar.gz
android_packages_apps_Trebuchet-2e6da1539bc7286336b3c24d96ab76434939ce4d.tar.bz2
android_packages_apps_Trebuchet-2e6da1539bc7286336b3c24d96ab76434939ce4d.zip
Refactoring DeviceProfile
-> Pulling out the parts of device profile which can (and need to be) initialized and accessed without access to an Activity context, ie. the invariant bits. -> The invariant bits are stored in InvariantDeviceProfile which is initialized statically from LauncherAppState. -> The DeviceProfile contains the Activity context-dependent bits, and we will create one of these for each Activity instance, and this instance is accessed through the Launcher activity. -> It's possible that we can continue to refactor this such that all appropriate dimensions can be computed without an Activity context (by only specifying orientation). This would be an extension of this CL and allow us to know exactly how launcher will look in both orientations from any context. Sets the stage for some improvements around b/19514688 Change-Id: Ia7daccf14d8ca2b9cb340b8780b684769e9f1892
Diffstat (limited to 'src/com/android/launcher3/util')
-rw-r--r--src/com/android/launcher3/util/FocusLogic.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/com/android/launcher3/util/FocusLogic.java b/src/com/android/launcher3/util/FocusLogic.java
index a84e7df03..696eabe00 100644
--- a/src/com/android/launcher3/util/FocusLogic.java
+++ b/src/com/android/launcher3/util/FocusLogic.java
@@ -23,6 +23,7 @@ import android.view.ViewGroup;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.ShortcutAndWidgetContainer;
@@ -80,8 +81,8 @@ public class FocusLogic {
keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL);
}
- public static int handleKeyEvent(int keyCode, int cntX, int cntY, int [][] map,
- int iconIdx, int pageIndex, int pageCount) {
+ public static int handleKeyEvent(int keyCode, int cntX, int cntY,
+ int [][] map, int iconIdx, int pageIndex, int pageCount, boolean isRtl) {
if (DEBUG) {
Log.v(TAG, String.format(
@@ -89,23 +90,21 @@ 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 (!profile.isLayoutRtl && newIndex == NOOP && pageIndex > 0) {
+ if (isRtl && newIndex == NOOP && pageIndex > 0) {
newIndex = PREVIOUS_PAGE_RIGHT_COLUMN;
- } else if (profile.isLayoutRtl && newIndex == NOOP && pageIndex < pageCount - 1) {
+ } else if (isRtl && 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 (!profile.isLayoutRtl && newIndex == NOOP && pageIndex < pageCount - 1) {
+ if (isRtl && newIndex == NOOP && pageIndex < pageCount - 1) {
newIndex = NEXT_PAGE_LEFT_COLUMN;
- } else if (profile.isLayoutRtl && newIndex == NOOP && pageIndex > 0) {
+ } else if (isRtl && newIndex == NOOP && pageIndex > 0) {
newIndex = PREVIOUS_PAGE_LEFT_COLUMN;
}
break;