From fd3385fe9e0f034b04f99d5d59a58d74fe040da4 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 15 Jun 2011 19:51:24 -0700 Subject: [PATCH] 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 --- res/drawable-hdpi/apps_customize_bg.png | Bin 0 -> 108 bytes res/drawable-hdpi/widget_info_bg.9.png | Bin 0 -> 168 bytes res/drawable-mdpi/apps_customize_bg.png | Bin 0 -> 108 bytes res/drawable-mdpi/widget_info_bg.9.png | Bin 0 -> 178 bytes res/drawable-nodpi/all_apps_bg_gradient.9.png | Bin 2946 -> 0 bytes res/layout/apps_customize_pane.xml | 1 + res/layout/apps_customize_widget.xml | 87 +++++++++--------- .../launcher2/AppsCustomizePagedView.java | 18 ++-- .../launcher2/AppsCustomizeTabHost.java | 17 +++- .../launcher2/PagedViewGridLayout.java | 10 +- .../android/launcher2/PagedViewWidget.java | 13 +-- src/com/android/launcher2/Workspace.java | 9 +- 12 files changed, 83 insertions(+), 72 deletions(-) create mode 100644 res/drawable-hdpi/apps_customize_bg.png create mode 100644 res/drawable-hdpi/widget_info_bg.9.png create mode 100644 res/drawable-mdpi/apps_customize_bg.png create mode 100644 res/drawable-mdpi/widget_info_bg.9.png delete mode 100644 res/drawable-nodpi/all_apps_bg_gradient.9.png diff --git a/res/drawable-hdpi/apps_customize_bg.png b/res/drawable-hdpi/apps_customize_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..81768d71e3a73ce30c27fb46de9f6bb61c091775 GIT binary patch literal 108 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1SBVv2j2ryk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5X_&i-4Ln>}1J$Uedfy01-!Gu9Fdh2RApbUejtDnm{r-UW| DQH&go literal 0 HcmV?d00001 diff --git a/res/drawable-hdpi/widget_info_bg.9.png b/res/drawable-hdpi/widget_info_bg.9.png new file mode 100644 index 0000000000000000000000000000000000000000..217b35cb4f0209ce4d3b4db02b2ebc61930688cd GIT binary patch literal 168 zcmeAS@N?(olHy`uVBq!ia0vp^B0$W>!3HD`Pv18eNJ*BsMwA5Sr}1J$Uedfy01-!Gu9Fdh2RApbUejtDnm{r-UW| DQH&go literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/widget_info_bg.9.png b/res/drawable-mdpi/widget_info_bg.9.png new file mode 100644 index 0000000000000000000000000000000000000000..7fd1c20e007b4793257f00bc9d4b83a841cba77d GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngc!3HE{ZXRg@Qj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS>Jib6bH978H@we%n4Jz&7WZ1~D$!+(x5E`?M5X9xUYP*Ju} zHh!wYVB)Yp&GPNaFNdry>BZ>0`)4IBIKffna_jca8EN0X=*^mDSoibjzof7p!I^Kx a5*WVKC@fi#yd)K9K7*&LpUXO@geCy<1V6L@ literal 0 HcmV?d00001 diff --git a/res/drawable-nodpi/all_apps_bg_gradient.9.png b/res/drawable-nodpi/all_apps_bg_gradient.9.png deleted file mode 100644 index 3f4b5b58c5f9364cdaa6dc82d9211a7b28b08876..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2946 zcmV-|3w`v7P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;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jgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00023NklPdFI5Dn5SZLXkrx{;0wG8OkR&`fz9;Yj zS|MH4hKzHTF6Td)EbIHL{g~dliYsaLL5BAy^S1F@AZyKzF&$zqF2KJTsa5*w# diff --git a/res/layout/apps_customize_widget.xml b/res/layout/apps_customize_widget.xml index 38973b564f..44f6ae1b74 100644 --- a/res/layout/apps_customize_widget.xml +++ b/res/layout/apps_customize_widget.xml @@ -28,58 +28,53 @@ android:background="@drawable/focusable_view_bg" android:focusable="true"> + + + + + + + + - - - - - - - - - diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index da6e7de3b1..fd8678d133 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 87c154b472..587a3eb5fb 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 c6d39fd5fb..a2ab7634c2 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 d6f665691a..365965d138 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 c0439ddc90..fcf8d662ee 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(); + } } }