diff options
author | Michael Jurka <mikejurka@google.com> | 2012-04-27 15:07:07 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-27 15:07:07 -0700 |
commit | d2a9194b6119051962edab14cc26d12706867c72 (patch) | |
tree | e5927f3dd9072cb9e86f8abc174743d094d0d6f1 | |
parent | 873ad10401bede22aa72339996e70710a4807c32 (diff) | |
parent | f4bd5792d505a83ef35b30e4fa4e786ac0df58a3 (diff) | |
download | packages_apps_trebuchet-d2a9194b6119051962edab14cc26d12706867c72.zip packages_apps_trebuchet-d2a9194b6119051962edab14cc26d12706867c72.tar.gz packages_apps_trebuchet-d2a9194b6119051962edab14cc26d12706867c72.tar.bz2 |
Merge "Refactoring dimens for cell size / gap" into jb-dev
-rw-r--r-- | res/values-land/dimens.xml | 8 | ||||
-rw-r--r-- | res/values-port/dimens.xml | 6 | ||||
-rw-r--r-- | res/values-sw340dp/dimens.xml | 26 | ||||
-rw-r--r-- | res/values-sw600dp-land/dimens.xml | 6 | ||||
-rw-r--r-- | res/values-sw600dp-port/dimens.xml | 2 | ||||
-rw-r--r-- | res/values-sw600dp/dimens.xml | 15 | ||||
-rw-r--r-- | res/values-sw720dp-land/dimens.xml | 2 | ||||
-rw-r--r-- | res/values-sw720dp-port/dimens.xml | 2 | ||||
-rw-r--r-- | res/values-sw720dp/dimens.xml | 28 | ||||
-rw-r--r-- | res/values/dimens.xml | 13 | ||||
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 64 |
11 files changed, 118 insertions, 54 deletions
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml index 69d68be..e94d780 100644 --- a/res/values-land/dimens.xml +++ b/res/values-land/dimens.xml @@ -20,8 +20,6 @@ <dimen name="toolbar_button_horizontal_padding">4dip</dimen> <!-- Workspace --> - <dimen name="workspace_cell_width">106dp</dimen> - <dimen name="workspace_cell_height">74dp</dimen> <dimen name="hotseat_cell_width">64dp</dimen> <dimen name="hotseat_cell_height">58dp</dimen> <!-- We really want the page spacing to be the max of either the button bar @@ -77,4 +75,10 @@ <!-- Folders --> <!-- The size of the image which sits behind the preview of the folder contents --> <dimen name="folder_preview_size">58dp</dimen> + +<!-- Workspace cell size --> + <dimen name="workspace_cell_width">@dimen/workspace_cell_width_land</dimen> + <dimen name="workspace_cell_height">@dimen/workspace_cell_height_land</dimen> + <dimen name="workspace_width_gap">@dimen/workspace_width_gap_land</dimen> + <dimen name="workspace_height_gap">@dimen/workspace_height_gap_land</dimen> </resources> diff --git a/res/values-port/dimens.xml b/res/values-port/dimens.xml index 193f331..969d335 100644 --- a/res/values-port/dimens.xml +++ b/res/values-port/dimens.xml @@ -50,4 +50,10 @@ <dimen name="apps_customize_widget_cell_height_gap">10dp</dimen> <integer name="apps_customize_widget_cell_count_x">2</integer> <integer name="apps_customize_widget_cell_count_y">3</integer> + +<!-- Workspace cell size --> + <dimen name="workspace_cell_width">@dimen/workspace_cell_width_port</dimen> + <dimen name="workspace_cell_height">@dimen/workspace_cell_height_port</dimen> + <dimen name="workspace_width_gap">@dimen/workspace_width_gap_port</dimen> + <dimen name="workspace_height_gap">@dimen/workspace_height_gap_port</dimen> </resources> diff --git a/res/values-sw340dp/dimens.xml b/res/values-sw340dp/dimens.xml index 8f5a367..42fbb47 100644 --- a/res/values-sw340dp/dimens.xml +++ b/res/values-sw340dp/dimens.xml @@ -18,10 +18,6 @@ <!-- Drag padding to add to the bottom of drop targets --> <dimen name="drop_target_drag_padding">20dp</dimen> -<!-- Workspace --> - <dimen name="workspace_width_gap">0dp</dimen> - <dimen name="workspace_height_gap">0dp</dimen> - <!-- Hotseat --> <dimen name="hotseat_width_gap">0dp</dimen> <dimen name="hotseat_height_gap">0dp</dimen> @@ -35,12 +31,18 @@ <dimen name="button_bar_height_plus_padding">80dp</dimen> <!-- CellLayout padding land / port--> - <dimen name="cell_layout_left_padding_portrait">8dp</dimen> - <dimen name="cell_layout_left_padding_landscape">8dp</dimen> - <dimen name="cell_layout_right_padding_portrait">8dp</dimen> - <dimen name="cell_layout_right_padding_landscape">8dp</dimen> - <dimen name="cell_layout_top_padding_portrait">8dp</dimen> - <dimen name="cell_layout_top_padding_landscape">8dp</dimen> - <dimen name="cell_layout_bottom_padding_portrait">8dp</dimen> - <dimen name="cell_layout_bottom_padding_landscape">8dp</dimen> + <dimen name="cell_layout_left_padding_port">8dp</dimen> + <dimen name="cell_layout_left_padding_land">8dp</dimen> + <dimen name="cell_layout_right_padding_port">8dp</dimen> + <dimen name="cell_layout_right_padding_land">8dp</dimen> + <dimen name="cell_layout_top_padding_port">8dp</dimen> + <dimen name="cell_layout_top_padding_land">8dp</dimen> + <dimen name="cell_layout_bottom_padding_port">8dp</dimen> + <dimen name="cell_layout_bottom_padding_land">8dp</dimen> + +<!-- Workspace cell size --> + <dimen name="workspace_width_gap_land">0dp</dimen> + <dimen name="workspace_width_gap_port">0dp</dimen> + <dimen name="workspace_height_gap_land">0dp</dimen> + <dimen name="workspace_height_gap_port">0dp</dimen> </resources> diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml index 7db0a8a..3e18417 100644 --- a/res/values-sw600dp-land/dimens.xml +++ b/res/values-sw600dp-land/dimens.xml @@ -22,12 +22,6 @@ <!-- Hotseat --> <dimen name="hotseat_cell_width">75dp</dimen> <dimen name="hotseat_cell_height">75dp</dimen> - -<!-- Workspace --> - <dimen name="workspace_cell_width">96dp</dimen> - <dimen name="workspace_cell_height">86dp</dimen> - <dimen name="workspace_width_gap">32dp</dimen> - <dimen name="workspace_height_gap">0dp</dimen> <dimen name="workspace_icon_text_size">11sp</dimen> <!-- Folders --> diff --git a/res/values-sw600dp-port/dimens.xml b/res/values-sw600dp-port/dimens.xml index 9565992..c813725 100644 --- a/res/values-sw600dp-port/dimens.xml +++ b/res/values-sw600dp-port/dimens.xml @@ -17,8 +17,6 @@ <resources> <!-- Workspace --> <integer name="app_icon_scale_percent">-1</integer> - <dimen name="workspace_width_gap">0dp</dimen> - <dimen name="workspace_height_gap">32dp</dimen> <!-- AppsCustomize --> <dimen name="apps_customize_cell_width">96dp</dimen> diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml index a0d7ec8..0797632 100644 --- a/res/values-sw600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml @@ -20,10 +20,6 @@ <dimen name="app_icon_drawable_padding">3dp</dimen> <dimen name="app_icon_padding_top">4dp</dimen> -<!-- Workspace --> - <dimen name="workspace_cell_width">96dp</dimen> - <dimen name="workspace_cell_height">96dp</dimen> - <!-- Hotseat --> <dimen name="hotseat_width_gap">-1dp</dimen> <dimen name="hotseat_height_gap">-1dp</dimen> @@ -50,4 +46,15 @@ <dimen name="apps_customize_tab_bar_margin_top">8dp</dimen> <dimen name="apps_customize_widget_cell_width_gap">36dp</dimen> <dimen name="apps_customize_widget_cell_height_gap">36dp</dimen> + +<!-- Workspace cell size --> + <dimen name="workspace_cell_width_land">96dp</dimen> + <dimen name="workspace_cell_width_port">96dp</dimen> + <dimen name="workspace_cell_height_land">86dp</dimen> + <dimen name="workspace_cell_height_port">96dp</dimen> + <dimen name="workspace_width_gap_land">32dp</dimen> + <dimen name="workspace_width_gap_port">0dp</dimen> + <dimen name="workspace_height_gap_land">0dp</dimen> + <dimen name="workspace_height_gap_port">32dp</dimen> + </resources> diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml index 2d39fc7..8252450 100644 --- a/res/values-sw720dp-land/dimens.xml +++ b/res/values-sw720dp-land/dimens.xml @@ -22,8 +22,6 @@ <dimen name="apps_customize_pageLayoutPaddingRight">16dp</dimen> <!-- Workspace --> - <dimen name="workspace_width_gap">32dp</dimen> - <dimen name="workspace_height_gap">2dp</dimen> <dimen name="workspace_page_spacing">50dp</dimen> <!-- the area at the edge of the screen that makes the workspace go left diff --git a/res/values-sw720dp-port/dimens.xml b/res/values-sw720dp-port/dimens.xml index 9a0261b..9cf37ff 100644 --- a/res/values-sw720dp-port/dimens.xml +++ b/res/values-sw720dp-port/dimens.xml @@ -31,8 +31,6 @@ <!-- the area at the edge of the screen that makes the workspace go left or right while you're dragging. --> <dimen name="scroll_zone">40dp</dimen> - <dimen name="workspace_width_gap">0dp</dimen> - <dimen name="workspace_height_gap">32dp</dimen> <dimen name="workspace_page_spacing">24dp</dimen> <integer name="apps_customize_cling_focused_x">2</integer> diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml index dc1c65a..37f62b8 100644 --- a/res/values-sw720dp/dimens.xml +++ b/res/values-sw720dp/dimens.xml @@ -24,8 +24,6 @@ <!-- This should be @dimen/qsb_bar_height - @dimen/workspace_top_padding to fix the extra space given to draw portals --> <dimen name="workspace_content_large_only_top_margin">36dp</dimen> - <dimen name="workspace_cell_width">96dip</dimen> - <dimen name="workspace_cell_height">96dip</dimen> <dimen name="folder_cell_width">96dp</dimen> <dimen name="folder_cell_height">96dp</dimen> @@ -55,14 +53,14 @@ <dimen name="dragViewOffsetY">0dp</dimen> <!-- CellLayout padding land / port--> - <dimen name="cell_layout_left_padding_portrait">15dp</dimen> - <dimen name="cell_layout_left_padding_landscape">24dp</dimen> - <dimen name="cell_layout_right_padding_portrait">15dp</dimen> - <dimen name="cell_layout_right_padding_landscape">24dp</dimen> - <dimen name="cell_layout_top_padding_portrait">25dp</dimen> - <dimen name="cell_layout_top_padding_landscape">12dp</dimen> - <dimen name="cell_layout_bottom_padding_portrait">25dp</dimen> - <dimen name="cell_layout_bottom_padding_landscape">12dp</dimen> + <dimen name="cell_layout_left_padding_port">15dp</dimen> + <dimen name="cell_layout_left_padding_land">24dp</dimen> + <dimen name="cell_layout_right_padding_port">15dp</dimen> + <dimen name="cell_layout_right_padding_land">24dp</dimen> + <dimen name="cell_layout_top_padding_port">25dp</dimen> + <dimen name="cell_layout_top_padding_land">12dp</dimen> + <dimen name="cell_layout_bottom_padding_port">25dp</dimen> + <dimen name="cell_layout_bottom_padding_land">12dp</dimen> <!-- Workspace padding --> <dimen name="workspace_left_padding_port">0dp</dimen> @@ -73,4 +71,14 @@ <dimen name="workspace_top_padding_land">@dimen/workspace_content_large_only_top_margin</dimen> <dimen name="workspace_bottom_padding_port">0dp</dimen> <dimen name="workspace_bottom_padding_land">0dp</dimen> + +<!-- Workspace cell size --> + <dimen name="workspace_cell_width_land">96dp</dimen> + <dimen name="workspace_cell_width_port">96dp</dimen> + <dimen name="workspace_cell_height_land">96dp</dimen> + <dimen name="workspace_cell_height_port">96dp</dimen> + <dimen name="workspace_width_gap_land">32dp</dimen> + <dimen name="workspace_width_gap_port">0dp</dimen> + <dimen name="workspace_height_gap_land">2dp</dimen> + <dimen name="workspace_height_gap_port">32dp</dimen> </resources> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index ff17ec4..d3b9c1e 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -30,10 +30,6 @@ <dimen name="qsb_padding_left">0dp</dimen> <dimen name="qsb_padding_right">0dp</dimen> <dimen name="search_bar_height">40dp</dimen> - <dimen name="workspace_cell_width">80dp</dimen> - <dimen name="workspace_cell_height">100dp</dimen> - <dimen name="workspace_width_gap">-1dp</dimen> - <dimen name="workspace_height_gap">-1dp</dimen> <dimen name="workspace_max_gap">16dp</dimen> <dimen name="folder_cell_width">74dp</dimen> <dimen name="folder_cell_height">82dp</dimen> @@ -140,4 +136,13 @@ <dimen name="workspace_bottom_padding_port">@dimen/button_bar_height</dimen> <dimen name="workspace_bottom_padding_land">0dp</dimen> +<!-- Workspace cell size --> + <dimen name="workspace_cell_width_land">106dp</dimen> + <dimen name="workspace_cell_width_port">80dp</dimen> + <dimen name="workspace_cell_height_land">74dp</dimen> + <dimen name="workspace_cell_height_port">100dp</dimen> + <dimen name="workspace_width_gap_land">-1dp</dimen> + <dimen name="workspace_width_gap_port">-1dp</dimen> + <dimen name="workspace_height_gap_land">-1dp</dimen> + <dimen name="workspace_height_gap_port">-1dp</dimen> </resources> diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 10eb8f8..24e4047 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -58,8 +58,6 @@ public class CellLayout extends ViewGroup { static final String TAG = "CellLayout"; private Launcher mLauncher; - private int mOriginalCellWidth; - private int mOriginalCellHeight; private int mCellWidth; private int mCellHeight; @@ -178,10 +176,8 @@ public class CellLayout extends ViewGroup { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0); - mOriginalCellWidth = - mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10); - mOriginalCellHeight = - mCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10); + mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10); + mCellHeight = 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); @@ -914,6 +910,54 @@ public class CellLayout extends ViewGroup { return r; } + final int LANDSCAPE = 0; + final int PORTRAIT = 1; + void getCellLayoutMetrics(int measureWidth, int measureHeight, int orientation, Rect metrics) { + int numWidthGaps = mCountX - 1; + int numHeightGaps = mCountY - 1; + + int widthGap; + int heightGap; + int cellWidth; + int cellHeight; + int paddingLeft; + int paddingRight; + int paddingTop; + int paddingBottom; + + Resources res = getContext().getResources(); + if (orientation == LANDSCAPE) { + cellWidth = res.getDimensionPixelSize(R.dimen.workspace_cell_width_land); + cellHeight = res.getDimensionPixelSize(R.dimen.workspace_cell_height_land); + widthGap = res.getDimensionPixelSize(R.dimen.workspace_width_gap_land); + heightGap = res.getDimensionPixelSize(R.dimen.workspace_height_gap_land); + paddingLeft = res.getDimensionPixelSize(R.dimen.cell_layout_left_padding_land); + paddingRight = res.getDimensionPixelSize(R.dimen.cell_layout_right_padding_land); + paddingTop = res.getDimensionPixelSize(R.dimen.cell_layout_top_padding_land); + paddingBottom = res.getDimensionPixelSize(R.dimen.cell_layout_bottom_padding_land); + } else { + // PORTRAIT + cellWidth = res.getDimensionPixelSize(R.dimen.workspace_cell_width_port); + cellHeight = res.getDimensionPixelSize(R.dimen.workspace_cell_height_port); + widthGap = res.getDimensionPixelSize(R.dimen.workspace_width_gap_port); + heightGap = res.getDimensionPixelSize(R.dimen.workspace_height_gap_port); + paddingLeft = res.getDimensionPixelSize(R.dimen.cell_layout_left_padding_port); + paddingRight = res.getDimensionPixelSize(R.dimen.cell_layout_right_padding_port); + paddingTop = res.getDimensionPixelSize(R.dimen.cell_layout_top_padding_port); + paddingBottom = res.getDimensionPixelSize(R.dimen.cell_layout_bottom_padding_port); + } + + if (widthGap < 0 || heightGap < 0) { + int hSpace = measureWidth - paddingLeft - paddingRight; + int vSpace = measureHeight - paddingTop - paddingBottom; + int hFreeSpace = hSpace - (mCountX * cellWidth); + int vFreeSpace = vSpace - (mCountY * cellHeight); + widthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0); + heightGap = Math.min(mMaxGap, numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0); + } + metrics.set(cellWidth, cellHeight, widthGap, heightGap); + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // TODO: currently ignoring padding @@ -932,10 +976,10 @@ public class CellLayout extends ViewGroup { int numHeightGaps = mCountY - 1; if (mOriginalWidthGap < 0 || mOriginalHeightGap < 0) { - int hSpace = widthSpecSize - getPaddingLeft() - getPaddingRight(); - int vSpace = heightSpecSize - getPaddingTop() - getPaddingBottom(); - int hFreeSpace = hSpace - (mCountX * mOriginalCellWidth); - int vFreeSpace = vSpace - (mCountY * mOriginalCellHeight); + int hSpace = widthSpecSize - mPaddingLeft - mPaddingRight; + int vSpace = heightSpecSize - mPaddingTop - mPaddingBottom; + int hFreeSpace = hSpace - (mCountX * mCellWidth); + 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); |