summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout-large-land/workspace.xml30
-rw-r--r--res/layout-large-land/workspace_screen.xml13
-rw-r--r--res/layout-large-port/workspace.xml30
-rw-r--r--res/layout-large-port/workspace_screen.xml13
-rw-r--r--res/layout-large/launcher.xml21
-rw-r--r--res/values-large-land/dimens.xml6
-rw-r--r--res/values-large-port/dimens.xml6
-rw-r--r--res/values-large/dimens.xml24
-rw-r--r--src/com/android/launcher2/CellLayout.java54
-rw-r--r--src/com/android/launcher2/Workspace.java49
10 files changed, 200 insertions, 46 deletions
diff --git a/res/layout-large-land/workspace.xml b/res/layout-large-land/workspace.xml
new file mode 100644
index 000000000..e8ea782ee
--- /dev/null
+++ b/res/layout-large-land/workspace.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- The workspace contains 5 screens of cells -->
+<com.android.launcher2.Workspace
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ android:paddingTop="?android:attr/actionBarSize"
+ android:paddingBottom="10dp"
+ launcher:defaultScreen="2"
+ launcher:pageSpacing="@dimen/workspace_page_spacing_land">
+ <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
+ <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
+ <include android:id="@+id/cell3" layout="@layout/workspace_screen" />
+ <include android:id="@+id/cell4" layout="@layout/workspace_screen" />
+ <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
+</com.android.launcher2.Workspace> \ No newline at end of file
diff --git a/res/layout-large-land/workspace_screen.xml b/res/layout-large-land/workspace_screen.xml
index e983b7920..25b05e903 100644
--- a/res/layout-large-land/workspace_screen.xml
+++ b/res/layout-large-land/workspace_screen.xml
@@ -24,9 +24,10 @@
launcher:cellWidth="@dimen/workspace_cell_width"
launcher:cellHeight="@dimen/workspace_cell_height"
- launcher:widthGap="@dimen/workspace_width_gap"
- launcher:heightGap="@dimen/workspace_height_gap"
- launcher:yAxisStartPadding="15dip"
- launcher:yAxisEndPadding="15dip"
- launcher:xAxisStartPadding="25dip"
- launcher:xAxisEndPadding="25dip" />
+ launcher:widthGap="@dimen/workspace_width_gap_land"
+ launcher:heightGap="@dimen/workspace_height_gap_land"
+
+ launcher:xAxisStartPadding="@dimen/workspace_x_axis_start_padding_land"
+ launcher:xAxisEndPadding="@dimen/workspace_x_axis_end_padding_land"
+ launcher:yAxisStartPadding="@dimen/workspace_y_axis_start_padding_land"
+ launcher:yAxisEndPadding="@dimen/workspace_y_axis_end_padding_land" />
diff --git a/res/layout-large-port/workspace.xml b/res/layout-large-port/workspace.xml
new file mode 100644
index 000000000..ccd7d3312
--- /dev/null
+++ b/res/layout-large-port/workspace.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- The workspace contains 5 screens of cells -->
+<com.android.launcher2.Workspace
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ android:paddingTop="?android:attr/actionBarSize"
+ android:paddingBottom="10dp"
+ launcher:defaultScreen="2"
+ launcher:pageSpacing="@dimen/workspace_page_spacing_port">
+ <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
+ <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
+ <include android:id="@+id/cell3" layout="@layout/workspace_screen" />
+ <include android:id="@+id/cell4" layout="@layout/workspace_screen" />
+ <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
+</com.android.launcher2.Workspace> \ No newline at end of file
diff --git a/res/layout-large-port/workspace_screen.xml b/res/layout-large-port/workspace_screen.xml
index 406441d00..e33c6123e 100644
--- a/res/layout-large-port/workspace_screen.xml
+++ b/res/layout-large-port/workspace_screen.xml
@@ -24,9 +24,10 @@
launcher:cellWidth="@dimen/workspace_cell_width"
launcher:cellHeight="@dimen/workspace_cell_height"
- launcher:widthGap="@dimen/workspace_width_gap"
- launcher:heightGap="@dimen/workspace_height_gap"
- launcher:yAxisStartPadding="25dip"
- launcher:yAxisEndPadding="25dip"
- launcher:xAxisStartPadding="15dip"
- launcher:xAxisEndPadding="15dip"/>
+ launcher:widthGap="@dimen/workspace_width_gap_port"
+ launcher:heightGap="@dimen/workspace_height_gap_port"
+
+ launcher:xAxisStartPadding="@dimen/workspace_x_axis_start_padding_port"
+ launcher:xAxisEndPadding="@dimen/workspace_x_axis_end_padding_port"
+ launcher:yAxisStartPadding="@dimen/workspace_y_axis_start_padding_port"
+ launcher:yAxisEndPadding="@dimen/workspace_y_axis_end_padding_port" />
diff --git a/res/layout-large/launcher.xml b/res/layout-large/launcher.xml
index 6c6fecf82..6a16eb530 100644
--- a/res/layout-large/launcher.xml
+++ b/res/layout-large/launcher.xml
@@ -23,24 +23,10 @@
android:layout_height="match_parent"
android:focusable="false">
- <!-- The workspace contains 5 screens of cells -->
- <com.android.launcher2.Workspace
+ <include layout="@layout/workspace"
android:id="@+id/workspace"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="?android:attr/actionBarSize"
- android:paddingBottom="10dp"
- launcher:defaultScreen="2"
- launcher:cellCountX="8"
- launcher:cellCountY="7"
- launcher:pageSpacing="@dimen/workspace_page_spacing">
-
- <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell3" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell4" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
- </com.android.launcher2.Workspace>
+ android:layout_height="match_parent" />
<include layout="@layout/button_bar"
android:id="@+id/all_apps_button_cluster"
@@ -48,8 +34,7 @@
android:layout_height="?android:attr/actionBarSize"
android:layout_gravity="top" />
- <include
- layout="@layout/all_apps_tabbed"
+ <include layout="@layout/all_apps_tabbed"
android:id="@+id/all_apps_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/res/values-large-land/dimens.xml b/res/values-large-land/dimens.xml
index 8d255557e..196cdb0a4 100644
--- a/res/values-large-land/dimens.xml
+++ b/res/values-large-land/dimens.xml
@@ -19,12 +19,6 @@
or right while you're dragging. -->
<dimen name="scroll_zone">100dip</dimen>
- <!-- Width/height gap overrides for the workspace -->
- <dimen name="workspace_width_gap">32dp</dimen>
- <dimen name="workspace_height_gap">2dp</dimen>
-
- <dimen name="workspace_page_spacing">50dp</dimen>
-
<dimen name="customization_drawer_height">480dp</dimen>
<dimen name="customization_drawer_content_height">420dp</dimen>
diff --git a/res/values-large-port/dimens.xml b/res/values-large-port/dimens.xml
index e696e3449..47cac78e8 100644
--- a/res/values-large-port/dimens.xml
+++ b/res/values-large-port/dimens.xml
@@ -19,12 +19,6 @@
or right while you're dragging. -->
<dimen name="scroll_zone">40dp</dimen>
- <!-- Width/height gap overrides for the workspace -->
- <dimen name="workspace_width_gap">0dp</dimen>
- <dimen name="workspace_height_gap">32dp</dimen>
-
- <dimen name="workspace_page_spacing">64dp</dimen>
-
<dimen name="customization_drawer_height">800dp</dimen>
<dimen name="customization_drawer_content_height">420dp</dimen>
diff --git a/res/values-large/dimens.xml b/res/values-large/dimens.xml
index 11f85ab92..241610917 100644
--- a/res/values-large/dimens.xml
+++ b/res/values-large/dimens.xml
@@ -20,9 +20,23 @@
<dimen name="workspace_cell_width">96dip</dimen>
<dimen name="workspace_cell_height">96dip</dimen>
+ <dimen name="workspace_x_axis_start_padding_land">25dip</dimen>
+ <dimen name="workspace_x_axis_end_padding_land">25dip</dimen>
+ <dimen name="workspace_y_axis_start_padding_land">15dip</dimen>
+ <dimen name="workspace_y_axis_end_padding_land">15dip</dimen>
+ <dimen name="workspace_x_axis_start_padding_port">15dip</dimen>
+ <dimen name="workspace_x_axis_end_padding_port">15dip</dimen>
+ <dimen name="workspace_y_axis_start_padding_port">25dip</dimen>
+ <dimen name="workspace_y_axis_end_padding_port">25dip</dimen>
+
<!-- Width/height gap overrides for the workspace -->
- <dimen name="workspace_width_gap">0dp</dimen>
- <dimen name="workspace_height_gap">0dp</dimen>
+ <dimen name="workspace_width_gap_land">32dp</dimen>
+ <dimen name="workspace_height_gap_land">2dp</dimen>
+ <dimen name="workspace_width_gap_port">0dp</dimen>
+ <dimen name="workspace_height_gap_port">32dp</dimen>
+
+ <dimen name="workspace_page_spacing_land">50dp</dimen>
+ <dimen name="workspace_page_spacing_port">64dp</dimen>
<!-- The corner radius to draw the external drop icon rounded rect -->
<dimen name="external_drop_icon_rect_radius">10dp</dimen>
@@ -45,6 +59,9 @@
<dimen name="all_apps_button_drawable_padding">0dip</dimen>
<dimen name="all_apps_button_vertical_padding">4dip</dimen>
+ <integer name="land_all_apps_view_cellCountX">7</integer>
+ <integer name="land_all_apps_view_cellCountY">5</integer>
+
<dimen name="toolbar_button_vertical_padding">12dip</dimen>
<dimen name="toolbar_button_horizontal_padding">16dip</dimen>
@@ -52,6 +69,9 @@
<dimen name="delete_zone_vertical_drag_padding">20dip</dimen>
<dimen name="delete_zone_horizontal_drag_padding">20dip</dimen>
+ <!-- roughly a status bar (for determining how many rows of icons are in home) -->
+ <dimen name="status_bar_height">48dip</dimen>
+
<!-- dimensions for the wallpaper picker wallpaper thumbnail width -->
<dimen name="wallpaper_chooser_grid_width">196dp</dimen>
<dimen name="wallpaper_chooser_grid_height">140dp</dimen>
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 8efb6ce7c..fdef18da4 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -267,6 +267,60 @@ public class CellLayout extends ViewGroup {
addView(mChildren);
}
+ static int widthInPortrait(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_port);
+ int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicWidth();
+
+ 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
+ // 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_land);
+ int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicHeight();
+
+ return heightGap * (numCells - 1) + cellHeight * numCells + (crosshairsSize + 1) / 2;
+ }
+
private void invalidateBubbleTextView(BubbleTextView icon) {
final int padding = icon.getPressedOrFocusedBackgroundPadding();
invalidate(icon.getLeft() + getLeftPadding() - padding,
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 1373996aa..70de0a4f7 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -52,6 +52,7 @@ import android.graphics.drawable.Drawable;
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;
@@ -255,10 +256,54 @@ public class Workspace extends SmoothPagedView
mWallpaperManager = WallpaperManager.getInstance(context);
+ int cellCountX = DEFAULT_CELL_COUNT_X;
+ int cellCountY = DEFAULT_CELL_COUNT_Y;
+
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.Workspace, defStyle, 0);
- int cellCountX = a.getInt(R.styleable.Workspace_cellCountX, DEFAULT_CELL_COUNT_X);
- int cellCountY = a.getInt(R.styleable.Workspace_cellCountY, DEFAULT_CELL_COUNT_Y);
+
+ if (LauncherApplication.isScreenLarge()) {
+ 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);
+
+ if (heightDp > widthDp) {
+ float temp = widthDp;
+ widthDp = heightDp;
+ heightDp = temp;
+ }
+ 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 = Math.min(cellCountYLand, cellCountYPort);
+ }
+
+ // if the value is manually specified, use that instead
+ cellCountX = a.getInt(R.styleable.Workspace_cellCountX, cellCountX);
+ cellCountY = a.getInt(R.styleable.Workspace_cellCountY, cellCountY);
mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
a.recycle();