summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-06-15 19:51:24 -0700
committerWinson Chung <winsonc@google.com>2011-06-24 10:49:03 -0700
commitfd3385fe9e0f034b04f99d5d59a58d74fe040da4 (patch)
tree6ea22637ec38883c8cef8318d4a6e312f32b8656 /src/com/android/launcher2
parent4e076545e4ccdbd3c045a3fa33869a2b7519a0cc (diff)
downloadandroid_packages_apps_Trebuchet-fd3385fe9e0f034b04f99d5d59a58d74fe040da4.tar.gz
android_packages_apps_Trebuchet-fd3385fe9e0f034b04f99d5d59a58d74fe040da4.tar.bz2
android_packages_apps_Trebuchet-fd3385fe9e0f034b04f99d5d59a58d74fe040da4.zip
Using GridLayout in AppsCustomize widgets tab.
- Starting to implement new widgets design - Hiding outlines in phone ui while dragging - Making the tab bar show only when we have items as well Change-Id: Ic027f9ba83fc0982f2f92a90412f050a8e248f9c
Diffstat (limited to 'src/com/android/launcher2')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java18
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java17
-rw-r--r--src/com/android/launcher2/PagedViewGridLayout.java10
-rw-r--r--src/com/android/launcher2/PagedViewWidget.java13
-rw-r--r--src/com/android/launcher2/Workspace.java9
5 files changed, 41 insertions, 26 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index da6e7de3b..fd8678d13 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -43,6 +43,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
+import android.widget.GridLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@@ -237,7 +238,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
* This differs from isDataReady as this is the test done if isDataReady is not set.
*/
private boolean testDataReady() {
- return !mApps.isEmpty() && !mWidgets.isEmpty();
+ // We only do this test once, and we default to the Applications page, so we only really
+ // have to wait for there to be apps.
+ return !mApps.isEmpty();
}
protected void onDataReady(int width, int height) {
@@ -512,7 +515,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// expected page width, so we can actually optimize by hiding all the TextView-based
// children that are expensive to measure, and let that happen naturally later.
setVisibilityOnChildren(layout, View.GONE);
- int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
+ int widthSpec = MeasureSpec.makeMeasureSpec(getPageContentWidth(), MeasureSpec.AT_MOST);
int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
layout.setMinimumWidth(getPageContentWidth());
layout.measure(widthSpec, heightSpec);
@@ -892,10 +895,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Layout each widget
int ix = i % mWidgetCountX;
int iy = i / mWidgetCountX;
- PagedViewGridLayout.LayoutParams lp = new PagedViewGridLayout.LayoutParams(cellWidth,
- cellHeight);
- lp.leftMargin = (ix * cellWidth) + (ix * mWidgetWidthGap);
- lp.topMargin = (iy * cellHeight) + (iy * mWidgetHeightGap);
+ GridLayout.LayoutParams lp = new GridLayout.LayoutParams(
+ new GridLayout.Group(iy, 1, GridLayout.LEFT),
+ new GridLayout.Group(ix, 1, GridLayout.TOP));
+ lp.width = cellWidth;
+ lp.height = cellHeight;
+ if (ix > 0) lp.leftMargin = mWidgetWidthGap;
+ if (iy > 0) lp.topMargin = mWidgetHeightGap;
layout.addView(widget, lp);
}
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 87c154b47..587a3eb5f 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -39,9 +39,11 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private static final String APPS_TAB_TAG = "APPS";
private static final String WIDGETS_TAB_TAG = "WIDGETS";
+ private static final int sTabBarFadeInDuration = 150;
private final LayoutInflater mLayoutInflater;
private ViewGroup mTabs;
+ private ViewGroup mTabsContainer;
private AppsCustomizePagedView mAppsCustomizePane;
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
@@ -67,10 +69,12 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
// Setup the tab host
setup();
+ final ViewGroup tabsContainer = (ViewGroup) findViewById(R.id.tabs_container);
final TabWidget tabs = (TabWidget) findViewById(com.android.internal.R.id.tabs);
final AppsCustomizePagedView appsCustomizePane = (AppsCustomizePagedView)
findViewById(R.id.apps_customize_pane_content);
mTabs = tabs;
+ mTabsContainer = tabsContainer;
mAppsCustomizePane = appsCustomizePane;
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();
@@ -98,6 +102,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
lastTab.setOnKeyListener(keyListener);
View shopButton = findViewById(R.id.market_button);
shopButton.setOnKeyListener(keyListener);
+
+ // Hide the tab bar until we measure
+ mTabsContainer.setAlpha(0f);
}
@Override
@@ -107,9 +114,15 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
// Set the width of the tab list to the content width
if (remeasureTabWidth) {
- mTabs.getLayoutParams().width = mAppsCustomizePane.getPageContentWidth();
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int contentWidth = mAppsCustomizePane.getPageContentWidth();
+ if (contentWidth > 0) {
+ // Set the width and show the tab bar (if we have a loading graphic, we can switch
+ // it off here)
+ mTabs.getLayoutParams().width = contentWidth;
+ mTabsContainer.animate().alpha(1f).setDuration(sTabBarFadeInDuration);
+ }
}
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
diff --git a/src/com/android/launcher2/PagedViewGridLayout.java b/src/com/android/launcher2/PagedViewGridLayout.java
index c6d39fd5f..a2ab7634c 100644
--- a/src/com/android/launcher2/PagedViewGridLayout.java
+++ b/src/com/android/launcher2/PagedViewGridLayout.java
@@ -19,14 +19,13 @@ package com.android.launcher2;
import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
-import android.view.View.MeasureSpec;
import android.widget.FrameLayout;
-import android.widget.LinearLayout;
+import android.widget.GridLayout;
/**
* The grid based layout used strictly for the widget/wallpaper tab of the AppsCustomize pane
*/
-public class PagedViewGridLayout extends FrameLayout implements Page {
+public class PagedViewGridLayout extends GridLayout implements Page {
static final String TAG = "PagedViewGridLayout";
private int mCellCountX;
@@ -36,6 +35,7 @@ public class PagedViewGridLayout extends FrameLayout implements Page {
super(context, null, 0);
mCellCountX = cellCountX;
mCellCountY = cellCountY;
+ setColumnCount(mCellCountX);
}
int getCellCountX() {
@@ -50,9 +50,9 @@ public class PagedViewGridLayout extends FrameLayout implements Page {
// offset of each page to scroll to before it updates the actual size of each page
// (which can change depending on the content if the contents aren't a fixed size).
// We work around this by having a minimum size on each widget page).
- int widthSpecSize = Math.max(getSuggestedMinimumWidth(),
+ int widthSpecSize = Math.min(getSuggestedMinimumWidth(),
MeasureSpec.getSize(widthMeasureSpec));
- int widthSpecMode = MeasureSpec.AT_MOST;
+ int widthSpecMode = MeasureSpec.EXACTLY;
super.onMeasure(MeasureSpec.makeMeasureSpec(widthSpecSize, widthSpecMode),
heightMeasureSpec);
}
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index d6f665691..365965d13 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -112,11 +112,6 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
final TextView dims = (TextView) findViewById(R.id.widget_dims);
dims.setText(String.format(mDimensionsFormatString, cellSpan[0], cellSpan[1]));
dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-
- // Hide the divider in the Phone UI.
- if (!LauncherApplication.isScreenLarge()) {
- findViewById(R.id.divider).setVisibility(View.GONE);
- }
}
public void applyFromResolveInfo(PackageManager pm, ResolveInfo info,
@@ -133,11 +128,6 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
dims.setText(String.format(mDimensionsFormatString, 1, 1));
dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
-
- // Hide the divider in the Phone UI.
- if (!LauncherApplication.isScreenLarge()) {
- findViewById(R.id.divider).setVisibility(View.GONE);
- }
}
public void setHolographicOutline(Bitmap holoOutline) {
@@ -184,7 +174,8 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
mPaint.setAlpha(mHolographicAlpha);
canvas.save();
canvas.scale(mTmpScaleRect.right, mTmpScaleRect.bottom);
- canvas.drawBitmap(mHolographicOutline, 0, 0, mPaint);
+ canvas.drawBitmap(mHolographicOutline, mPreviewImageView.getLeft(),
+ mPreviewImageView.getTop(), mPaint);
canvas.restore();
}
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index c0439ddc9..fcf8d662e 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -323,7 +323,7 @@ public class Workspace extends SmoothPagedView
try {
final Resources res = getResources();
- mBackground = res.getDrawable(R.drawable.all_apps_bg_gradient);
+ mBackground = res.getDrawable(R.drawable.apps_customize_bg);
} catch (Resources.NotFoundException e) {
// In this case, we will skip drawing background protection
}
@@ -2549,7 +2549,12 @@ public class Workspace extends SmoothPagedView
if (!mIsSmall) {
mDragTargetLayout = getCurrentDropLayout();
mDragTargetLayout.onDragEnter();
- showOutlines();
+
+ // Because we don't have space in the Phone UI (the CellLayouts run to the edge) we
+ // don't need to show the outlines
+ if (!LauncherApplication.isScreenLarge()) {
+ showOutlines();
+ }
}
}