Skip to content

Commit 63257c1

Browse files
author
Winson Chung
committed
Minor changes to help address some hiccups when panning, changing tabs and rotating in AppsCustomize.
- Also removing references to old all-apps 2d/3d Change-Id: Ibe07ad8b4facc5c57b3c82ccf0b55260be61a31b
1 parent 563ed71 commit 63257c1

16 files changed

+89
-227
lines changed

CleanSpec.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@
4444
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
4545
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
4646

47+
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Launcher2_intermediates)
4748
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Launcher2_intermediates)
4849
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Launcher2_intermediates)
4950

5051
# ************************************************
5152
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
52-
# ************************************************
53+
# ************************************************

res/layout-land/all_apps_2d.xml

-63
This file was deleted.

res/layout-port/all_apps_2d.xml

-63
This file was deleted.

res/layout/all_apps.xml

-20
This file was deleted.

res/layout/all_apps_3d.xml

-33
This file was deleted.

src/com/android/launcher2/AllAppsPagedView.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ public void syncPages() {
508508
@Override
509509
public void syncPageItems(int page) {
510510
// Ensure that we have the right number of items on the pages
511+
final int numPages = getPageCount();
511512
final int cellsPerPage = mCellCountX * mCellCountY;
512513
final int startIndex = page * cellsPerPage;
513514
final int endIndex = Math.min(startIndex + cellsPerPage, mFilteredApps.size());
@@ -540,24 +541,25 @@ public void syncPageItems(int page) {
540541

541542
// Add any necessary items
542543
for (int i = curNumPageItems; i < numPageItems; ++i) {
544+
final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1);
543545
TextView text = (TextView) mInflater.inflate(
544546
R.layout.all_apps_paged_view_application, layout, false);
545547
text.setOnClickListener(this);
546548
text.setOnLongClickListener(this);
547549
text.setOnTouchListener(this);
548550

549551
layout.addViewToCellLayout(text, -1, i,
550-
new PagedViewCellLayout.LayoutParams(0, 0, 1, 1));
552+
new PagedViewCellLayout.LayoutParams(0, 0, 1, 1), createHolographicOutlines);
551553
}
552554

553555
// Actually reapply to the existing text views
554-
final int numPages = getPageCount();
555556
for (int i = startIndex; i < endIndex; ++i) {
556557
final int index = i - startIndex;
557558
final ApplicationInfo info = mFilteredApps.get(i);
559+
final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1);
558560
PagedViewIcon icon = (PagedViewIcon) layout.getChildOnPageAt(index);
559561
icon.applyFromApplicationInfo(
560-
info, mPageViewIconCache, true, isHardwareAccelerated() && (numPages > 1));
562+
info, mPageViewIconCache, true, createHolographicOutlines);
561563

562564
PagedViewCellLayout.LayoutParams params =
563565
(PagedViewCellLayout.LayoutParams) icon.getLayoutParams();
@@ -579,10 +581,11 @@ public void syncPageItems(int page) {
579581
}
580582

581583
// Center-align the message
584+
final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1);
582585
layout.enableCenteredContent(true);
583586
layout.removeAllViewsOnPage();
584587
layout.addViewToCellLayout(icon, -1, 0,
585-
new PagedViewCellLayout.LayoutParams(0, 0, 4, 1));
588+
new PagedViewCellLayout.LayoutParams(0, 0, 4, 1), createHolographicOutlines);
586589
}
587590
layout.createHardwareLayers();
588591
}

src/com/android/launcher2/AppsCustomizePagedView.java

+26-4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import android.view.Gravity;
4545
import android.view.LayoutInflater;
4646
import android.view.View;
47+
import android.view.ViewGroup;
4748
import android.view.animation.DecelerateInterpolator;
4849
import android.view.animation.LinearInterpolator;
4950
import android.widget.FrameLayout;
@@ -471,17 +472,28 @@ public void setContentType(ContentType type) {
471472
/*
472473
* Apps PagedView implementation
473474
*/
475+
private void setVisibilityOnChildren(ViewGroup layout, int visibility) {
476+
int childCount = layout.getChildCount();
477+
for (int i = 0; i < childCount; ++i) {
478+
layout.getChildAt(i).setVisibility(visibility);
479+
}
480+
}
474481
private void setupPage(PagedViewCellLayout layout) {
475482
layout.setCellCount(mCellCountX, mCellCountY);
476483
layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
477484
layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
478485
mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
479486

480-
// We force a measure here to get around the fact that when we do layout calculations
481-
// immediately after syncing, we don't have a proper width.
487+
// Note: We force a measure here to get around the fact that when we do layout calculations
488+
// immediately after syncing, we don't have a proper width. That said, we already know the
489+
// expected page width, so we can actually optimize by hiding all the TextView-based
490+
// children that are expensive to measure, and let that happen naturally later.
491+
setVisibilityOnChildren(layout, View.GONE);
482492
int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
483493
int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
494+
layout.setMinimumWidth(getPageContentWidth());
484495
layout.measure(widthSpec, heightSpec);
496+
setVisibilityOnChildren(layout, View.VISIBLE);
485497
}
486498
public void syncAppsPages() {
487499
// Ensure that we have the right number of pages
@@ -514,8 +526,8 @@ public void syncAppsPageItems(int page) {
514526
int index = i - startIndex;
515527
int x = index % mCellCountX;
516528
int y = index / mCellCountX;
517-
setupPage(layout);
518-
layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
529+
layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1),
530+
isHardwareAccelerated() && (numPages > 1));
519531
}
520532
}
521533
/*
@@ -525,7 +537,17 @@ private void setupPage(PagedViewExtendedLayout layout) {
525537
layout.setGravity(Gravity.LEFT);
526538
layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
527539
mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
540+
541+
// Note: We force a measure here to get around the fact that when we do layout calculations
542+
// immediately after syncing, we don't have a proper width. That said, we already know the
543+
// expected page width, so we can actually optimize by hiding all the TextView-based
544+
// children that are expensive to measure, and let that happen naturally later.
545+
setVisibilityOnChildren(layout, View.GONE);
546+
int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
547+
int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
528548
layout.setMinimumWidth(getPageContentWidth());
549+
layout.measure(widthSpec, heightSpec);
550+
setVisibilityOnChildren(layout, View.VISIBLE);
529551
}
530552
private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h,
531553
float scaleX, float scaleY) {

src/com/android/launcher2/CellLayout.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public class CellLayout extends ViewGroup {
103103

104104
// These arrays are used to implement the drag visualization on x-large screens.
105105
// They are used as circular arrays, indexed by mDragOutlineCurrent.
106-
private Point[] mDragOutlines = new Point[8];
106+
private Point[] mDragOutlines = new Point[4];
107107
private float[] mDragOutlineAlphas = new float[mDragOutlines.length];
108108
private InterruptibleInOutAnimator[] mDragOutlineAnims =
109109
new InterruptibleInOutAnimator[mDragOutlines.length];

src/com/android/launcher2/CustomizePagedView.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -929,12 +929,13 @@ private void syncWidgetPageItems(int page) {
929929
final int[] cellSpans = CellLayout.rectToCell(getResources(), info.minWidth,
930930
info.minHeight, null);
931931
final FastBitmapDrawable icon = getWidgetPreview(info);
932+
final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1);
932933

933934
PagedViewWidget l = (PagedViewWidget) mInflater.inflate(
934935
R.layout.customize_paged_view_widget, layout, false);
935936

936937
l.applyFromAppWidgetProviderInfo(info, icon, mMaxWidgetWidth, cellSpans,
937-
mPageViewIconCache, (numPages > 1));
938+
mPageViewIconCache, createHolographicOutlines);
938939
l.setTag(createItemInfo);
939940
l.setOnClickListener(this);
940941
l.setOnTouchListener(this);
@@ -975,11 +976,12 @@ private void syncWallpaperPageItems(int page) {
975976
for (int i = startIndex; i < endIndex; ++i) {
976977
final ResolveInfo info = mWallpaperList.get(i);
977978
final FastBitmapDrawable icon = getWallpaperPreview(info);
979+
final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1);
978980

979981
PagedViewWidget l = (PagedViewWidget) mInflater.inflate(
980982
R.layout.customize_paged_view_wallpaper, layout, false);
981983
l.applyFromWallpaperInfo(info, mPackageManager, icon, mMaxWidgetWidth,
982-
mPageViewIconCache, (numPages > 1));
984+
mPageViewIconCache, createHolographicOutlines);
983985
l.setTag(info);
984986
l.setOnClickListener(this);
985987

@@ -1012,12 +1014,13 @@ private void syncListPageItems(int page, List<ResolveInfo> list) {
10121014
for (int i = startIndex; i < endIndex; ++i) {
10131015
ResolveInfo info = list.get(i);
10141016
PendingAddItemInfo createItemInfo = new PendingAddItemInfo();
1017+
final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1);
10151018

10161019
PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
10171020
R.layout.customize_paged_view_item, layout, false);
10181021
icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache,
10191022
((LauncherApplication) mLauncher.getApplication()).getIconCache(),
1020-
(numPages > 1));
1023+
createHolographicOutlines);
10211024
switch (mCustomizationType) {
10221025
case WallpaperCustomization:
10231026
icon.setOnClickListener(this);
@@ -1039,7 +1042,8 @@ private void syncListPageItems(int page, List<ResolveInfo> list) {
10391042
final int x = index % mCellCountX;
10401043
final int y = index / mCellCountX;
10411044
setupPage(layout);
1042-
layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
1045+
layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1),
1046+
createHolographicOutlines);
10431047
}
10441048
}
10451049

@@ -1071,10 +1075,11 @@ private void syncAppPageItems(int page) {
10711075
layout.removeAllViewsOnPage();
10721076
for (int i = startIndex; i < endIndex; ++i) {
10731077
final ApplicationInfo info = mApps.get(i);
1078+
final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1);
10741079
PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
10751080
R.layout.all_apps_paged_view_application, layout, false);
10761081
icon.applyFromApplicationInfo(
1077-
info, mPageViewIconCache, true, isHardwareAccelerated() && (numPages > 1));
1082+
info, mPageViewIconCache, true, createHolographicOutlines);
10781083
icon.setOnClickListener(this);
10791084
icon.setOnTouchListener(this);
10801085
icon.setOnLongClickListener(this);
@@ -1083,7 +1088,8 @@ private void syncAppPageItems(int page) {
10831088
final int x = index % mCellCountX;
10841089
final int y = index / mCellCountX;
10851090
setupPage(layout);
1086-
layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
1091+
layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1),
1092+
createHolographicOutlines);
10871093
}
10881094
}
10891095

0 commit comments

Comments
 (0)