Creating landscape and portrait device profiles at app initialization

Change-Id: Ide9d007adc36b348e19b05cdf49e87f8b02db60e
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index fe50e3a..46e4902 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -92,13 +92,12 @@
 
             final int pageIndex = pagedView.indexOfChild(cellLayout);
             final int pageCount = pagedView.getPageCount();
-            Launcher launcher  = (Launcher) v.getContext();
+            final boolean isLayoutRtl = Utilities.isRtl(v.getResources());
 
             int[][] matrix = FocusLogic.createSparseMatrix(cellLayout);
             // Process focus.
             int newIconIndex = FocusLogic.handleKeyEvent(keyCode, countX,
-                    countY, matrix, iconIndex, pageIndex, pageCount,
-                    launcher.getDeviceProfile().isLayoutRtl);
+                    countY, matrix, iconIndex, pageIndex, pageCount, isLayoutRtl);
             if (newIconIndex == FocusLogic.NOOP) {
                 handleNoopKey(keyCode, v);
                 return consume;
@@ -252,7 +251,7 @@
 
         // Process the focus.
         int newIconIndex = FocusLogic.handleKeyEvent(keyCode, countX,
-                countY, matrix, iconIndex, pageIndex, pageCount, profile.isLayoutRtl);
+                countY, matrix, iconIndex, pageIndex, pageCount, Utilities.isRtl(v.getResources()));
 
         View newIcon = null;
         if (newIconIndex == FocusLogic.NEXT_PAGE_FIRST_ITEM) {
@@ -335,7 +334,7 @@
 
         // Process the focus.
         int newIconIndex = FocusLogic.handleKeyEvent(keyCode, countX,
-                countY, matrix, iconIndex, pageIndex, pageCount, profile.isLayoutRtl);
+                countY, matrix, iconIndex, pageIndex, pageCount, Utilities.isRtl(v.getResources()));
         View newIcon = null;
         switch (newIconIndex) {
             case FocusLogic.NOOP:
@@ -358,7 +357,8 @@
                     matrix = FocusLogic.createSparseMatrix(iconLayout,
                         iconLayout.getCountX(), row);
                     newIconIndex = FocusLogic.handleKeyEvent(keyCode, countX + 1, countY,
-                            matrix, FocusLogic.PIVOT, newPageIndex, pageCount, profile.isLayoutRtl);
+                            matrix, FocusLogic.PIVOT, newPageIndex, pageCount,
+                            Utilities.isRtl(v.getResources()));
                     newIcon = parent.getChildAt(newIconIndex);
                 }
                 break;
@@ -391,7 +391,8 @@
                     iconLayout = (CellLayout) parent.getParent();
                     matrix = FocusLogic.createSparseMatrix(iconLayout, -1, row);
                     newIconIndex = FocusLogic.handleKeyEvent(keyCode, countX + 1, countY,
-                            matrix, FocusLogic.PIVOT, newPageIndex, pageCount, profile.isLayoutRtl);
+                            matrix, FocusLogic.PIVOT, newPageIndex, pageCount,
+                            Utilities.isRtl(v.getResources()));
                     newIcon = parent.getChildAt(newIconIndex);
                 }
                 break;