summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2011-05-27 16:27:15 -0700
committerMichael Jurka <mikejurka@google.com>2011-05-27 17:16:17 -0700
commit7593662b2ea083c7092b25e1d984cca1caf56ac7 (patch)
tree58454b4d52ded9b4e01996a4f60298570fcbcb5b /src
parent2c30c8596e615f6995d5e48be8b59bd612e63510 (diff)
downloadandroid_packages_apps_Trebuchet-7593662b2ea083c7092b25e1d984cca1caf56ac7.tar.gz
android_packages_apps_Trebuchet-7593662b2ea083c7092b25e1d984cca1caf56ac7.tar.bz2
android_packages_apps_Trebuchet-7593662b2ea083c7092b25e1d984cca1caf56ac7.zip
Fix issue with missing row/column on workspace
Change-Id: I7b750f66ef1fd5c9b5501763fa1e371b104d03ea
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/CellLayout.java27
-rw-r--r--src/com/android/launcher2/Workspace.java43
2 files changed, 14 insertions, 56 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index d0fe5951c..0d026b8aa 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -282,33 +282,6 @@ public class CellLayout extends ViewGroup {
return widthGap * (numCells - 1) + cellWidth * numCells + crosshairsSize;
}
- static int widthInLandscape(Resources r, int numCells) {
- // We use this method from Workspace to figure out how many rows/columns Launcher should
- // have. We ignore the left/right padding on CellLayout because it turns out in our design
- // the padding extends outside the visible screen size, but it looked fine anyway.
- // However, we make sure there's at least enough space for the crosshairs at either
- // edge to be rendered (half the crosshair is sticking out on either side)
- int cellWidth = r.getDimensionPixelSize(R.dimen.workspace_cell_width);
- int widthGap = r.getDimensionPixelSize(R.dimen.workspace_width_gap_land);
- int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicWidth();
-
- return widthGap * (numCells - 1) + cellWidth * numCells + crosshairsSize;
- }
-
- static int heightInPortrait(Resources r, int numCells) {
- // We use this method from Workspace to figure out how many rows/columns Launcher should
- // have. We ignore the left/right padding on CellLayout because it turns out in our design
- // the padding extends outside the visible screen size, but it looked fine anyway.
- // However, we make sure there's at least enough space for the crosshairs at the bottom
- // to be rendered (half the crosshair is sticking out); we don't worry about the top
- // crosshair since it can bleed into the action bar space
- int cellHeight = r.getDimensionPixelSize(R.dimen.workspace_cell_height);
- int heightGap = r.getDimensionPixelSize(R.dimen.workspace_height_gap_port);
- int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicHeight();
-
- return heightGap * (numCells - 1) + cellHeight * numCells + (crosshairsSize + 1) / 2;
- }
-
static int heightInLandscape(Resources r, int numCells) {
// We use this method from Workspace to figure out how many rows/columns Launcher should
// have. We ignore the left/right padding on CellLayout because it turns out in our design
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index a0eb4a503..d570b8ba3 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -53,7 +53,6 @@ import android.net.Uri;
import android.os.IBinder;
import android.os.Parcelable;
import android.util.AttributeSet;
-import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Pair;
import android.view.Display;
@@ -259,42 +258,28 @@ public class Workspace extends SmoothPagedView
R.styleable.Workspace, defStyle, 0);
if (LauncherApplication.isScreenXLarge()) {
+ // Determine number of rows/columns dynamically
+ // TODO: This code currently fails on tablets with an aspect ratio < 1.3.
+ // Around that ratio we should make cells the same size in portrait and
+ // landscape
final Resources res = context.getResources();
- final DisplayMetrics dm = res.getDisplayMetrics();
- float widthDp = dm.widthPixels / dm.density;
- float heightDp = dm.heightPixels / dm.density;
- final float statusBarHeight = res.getDimension(R.dimen.status_bar_height);
TypedArray actionBarSizeTypedArray =
context.obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
- float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f);
+ final float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f);
+ final float systemBarHeight = res.getDimension(R.dimen.status_bar_height);
+ final float smallestScreenDim = res.getConfiguration().smallestScreenWidthDp;
- if (heightDp > widthDp) {
- float temp = widthDp;
- widthDp = heightDp;
- heightDp = temp;
+ cellCountX = 1;
+ while (CellLayout.widthInPortrait(res, cellCountX + 1) <= smallestScreenDim) {
+ cellCountX++;
}
- int cellCountXLand = 1;
- int cellCountXPort = 1;
- while (2*mPageSpacing + CellLayout.widthInLandscape(res, cellCountXLand + 1) <= widthDp) {
- cellCountXLand++;
- }
- while (CellLayout.widthInPortrait(res, cellCountXPort + 1) <= heightDp) {
- cellCountXPort++;
- }
- cellCountX = Math.min(cellCountXLand, cellCountXPort);
- int cellCountYLand = 1;
- int cellCountYPort = 1;
- while (statusBarHeight + actionBarHeight +
- CellLayout.heightInLandscape(res, cellCountYLand + 1) <= heightDp) {
- cellCountYLand++;
- }
- while (statusBarHeight + actionBarHeight +
- CellLayout.heightInPortrait(res, cellCountYPort + 1) <= widthDp) {
- cellCountYPort++;
+ cellCountY = 1;
+ while (actionBarHeight + CellLayout.heightInLandscape(res, cellCountY + 1)
+ <= smallestScreenDim - systemBarHeight) {
+ cellCountY++;
}
- cellCountY = Math.min(cellCountYLand, cellCountYPort);
}
// if the value is manually specified, use that instead