summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-12-04 18:00:29 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-12-04 22:39:49 +0000
commit50ace94242b72cb5a8f9b37c0a40fceb7df15752 (patch)
treeb3f037b02017975e41f4ed4df0958049bb7baf2c
parentd2f8f8f41f5d625e4db3503d1fb042b615939278 (diff)
downloadpackages_apps_trebuchet-50ace94242b72cb5a8f9b37c0a40fceb7df15752.zip
packages_apps_trebuchet-50ace94242b72cb5a8f9b37c0a40fceb7df15752.tar.gz
packages_apps_trebuchet-50ace94242b72cb5a8f9b37c0a40fceb7df15752.tar.bz2
Fix various cell size/placement failures
Restore the original L2 Shortcut/widget sizing logic, adapted to the device's (default or user-configured) grid size at the time of cell creation. Using onMeasure + padding doesn't look as good, and renders different results depending on the device density. This results in the same workspace peripheral padding as L2, regardless of grid size. Change-Id: Ic220b63df31322365d48a7fb593d7d9a170057f3
-rw-r--r--res/values/dimens.xml8
-rw-r--r--src/com/cyanogenmod/trebuchet/CellLayout.java28
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java18
3 files changed, 34 insertions, 20 deletions
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 190cfdc..eb4e2cd 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -142,14 +142,14 @@
<dimen name="cell_layout_bottom_padding_land">0dp</dimen>
<!-- Workspace padding -->
- <dimen name="workspace_left_padding_port">16dp</dimen>
+ <dimen name="workspace_left_padding_port">0dp</dimen>
<dimen name="workspace_left_padding_land">@dimen/qsb_bar_height</dimen>
- <dimen name="workspace_right_padding_port">16dp</dimen>
+ <dimen name="workspace_right_padding_port">0dp</dimen>
<dimen name="workspace_right_padding_land">@dimen/button_bar_height</dimen>
<dimen name="workspace_top_padding_port">@dimen/qsb_bar_height_inset</dimen>
- <dimen name="workspace_top_padding_land">16dp</dimen>
+ <dimen name="workspace_top_padding_land">0dp</dimen>
<dimen name="workspace_bottom_padding_port">@dimen/button_bar_height</dimen>
- <dimen name="workspace_bottom_padding_land">16dp</dimen>
+ <dimen name="workspace_bottom_padding_land">0dp</dimen>
<!-- Workspace cell size -->
<dimen name="workspace_cell_width_land">106dp</dimen>
diff --git a/src/com/cyanogenmod/trebuchet/CellLayout.java b/src/com/cyanogenmod/trebuchet/CellLayout.java
index 7a71ea5..0b12255 100644
--- a/src/com/cyanogenmod/trebuchet/CellLayout.java
+++ b/src/com/cyanogenmod/trebuchet/CellLayout.java
@@ -63,6 +63,9 @@ public class CellLayout extends ViewGroup {
private Launcher mLauncher;
private int mCellWidth;
private int mCellHeight;
+ // Save values before applying grid-size related changes. We may need to reset it.
+ private int mOriginalCellWidth;
+ private int mOriginalCellHeight;
private int mCountX;
private int mCountY;
@@ -184,8 +187,8 @@ public class CellLayout extends ViewGroup {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);
- mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10);
- mCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10);
+ mCellWidth = mOriginalCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10);
+ mCellHeight =mOriginalCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10);
mWidthGap = mOriginalWidthGap = a.getDimensionPixelSize(R.styleable.CellLayout_widthGap, 0);
mHeightGap = mOriginalHeightGap = a.getDimensionPixelSize(R.styleable.CellLayout_heightGap, 0);
mMaxGap = a.getDimensionPixelSize(R.styleable.CellLayout_maxGap, 0);
@@ -281,6 +284,13 @@ public class CellLayout extends ViewGroup {
mForegroundRect = new Rect();
mShortcutsAndWidgets = new ShortcutAndWidgetContainer(context);
+
+ if (!LauncherApplication.isScreenLarge()){
+ mCellWidth = (mCellWidth * 4) / mCountX;
+ mCellHeight = (mCellHeight * 4) / mCountY;
+ }
+
+ mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
addView(mShortcutsAndWidgets);
}
@@ -328,6 +338,12 @@ public class CellLayout extends ViewGroup {
mOccupied = new boolean[mCountX][mCountY];
mTmpOccupied = new boolean[mCountX][mCountY];
mTempRectStack.clear();
+
+ // Reset scaling if the grid has been modified. This is a folder or the hotseat
+ mCellWidth = mOriginalCellWidth;
+ mCellHeight = mOriginalCellHeight;
+ mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
+
requestLayout();
}
@@ -975,12 +991,6 @@ public class CellLayout extends ViewGroup {
int numWidthGaps = mCountX - 1;
int numHeightGaps = mCountY - 1;
- if (!LauncherApplication.isScreenLarge()){
- Resources res = getResources();
- mCellWidth = widthSpecSize / mCountX;
- mCellHeight = heightSpecSize / mCountY;
- }
-
if (mOriginalWidthGap < 0 || mOriginalHeightGap < 0) {
int hSpace = widthSpecSize - getPaddingLeft() - getPaddingRight();
int vSpace = heightSpecSize - getPaddingTop() - getPaddingBottom();
@@ -988,12 +998,12 @@ public class CellLayout extends ViewGroup {
int vFreeSpace = vSpace - (mCountY * mCellHeight);
mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
mHeightGap = Math.min(mMaxGap,numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
+ mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
} else {
mWidthGap = mOriginalWidthGap;
mHeightGap = mOriginalHeightGap;
}
- mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
// Initial values correspond to widthSpecMode == MeasureSpec.EXACTLY
int newWidth = widthSpecSize;
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index b3771cb..5e407e1 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -621,13 +621,11 @@ public class Workspace extends SmoothPagedView
layout = mLauncher.getHotseat().getLayout();
child.setOnKeyListener(null);
- if (!mHideIconLabels) {
- // Hide titles in the hotseat
- if (child instanceof FolderIcon) {
- ((FolderIcon) child).setTextVisible(false);
- } else if (child instanceof BubbleTextView) {
- ((BubbleTextView) child).setTextVisible(false);
- }
+ // Hide titles in the hotseat
+ if (child instanceof FolderIcon) {
+ ((FolderIcon) child).setTextVisible(false);
+ } else if (child instanceof BubbleTextView) {
+ ((BubbleTextView) child).setTextVisible(false);
}
if (screen < 0) {
@@ -646,6 +644,12 @@ public class Workspace extends SmoothPagedView
} else if (child instanceof BubbleTextView) {
((BubbleTextView) child).setTextVisible(true);
}
+ } else {
+ if (child instanceof FolderIcon) {
+ ((FolderIcon) child).setTextVisible(false);
+ } else if (child instanceof BubbleTextView) {
+ ((BubbleTextView) child).setTextVisible(false);
+ }
}
layout = (CellLayout) getChildAt(screen);