summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2013-09-03 17:48:37 -0700
committerWinson Chung <winsonc@google.com>2013-09-05 12:14:28 -0700
commitc58497ee619416c4949b16eb43486c11618b69e5 (patch)
treeb8bfd3ec331885a25f42c69fb41dbfd861a4763a /src
parent2d8de5845be5f49d3767b8354f0d5479a0715abe (diff)
downloadandroid_packages_apps_Trebuchet-c58497ee619416c4949b16eb43486c11618b69e5.tar.gz
android_packages_apps_Trebuchet-c58497ee619416c4949b16eb43486c11618b69e5.tar.bz2
android_packages_apps_Trebuchet-c58497ee619416c4949b16eb43486c11618b69e5.zip
Initial changes to restore AllApps.
- Removes unused all apps code due to dynamic grid/spacing - Attempts to use CellLayout instead of PagedViewCellLayout Change-Id: I3c49bca9fc35dfeaf250591fd63bc7f36119968f
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/AppsCustomizeCellLayout.java68
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java169
-rw-r--r--src/com/android/launcher3/AppsCustomizeTabHost.java8
-rw-r--r--src/com/android/launcher3/DynamicGrid.java38
-rw-r--r--src/com/android/launcher3/FocusHelper.java10
-rw-r--r--src/com/android/launcher3/Hotseat.java132
-rw-r--r--src/com/android/launcher3/InstallShortcutReceiver.java2
-rw-r--r--src/com/android/launcher3/Launcher.java62
-rw-r--r--src/com/android/launcher3/LauncherModel.java32
-rw-r--r--src/com/android/launcher3/PageIndicator.java16
-rw-r--r--src/com/android/launcher3/PagedView.java54
-rw-r--r--src/com/android/launcher3/PagedViewCellLayout.java16
-rw-r--r--src/com/android/launcher3/PagedViewIcon.java10
-rw-r--r--src/com/android/launcher3/PagedViewWidget.java13
14 files changed, 425 insertions, 205 deletions
diff --git a/src/com/android/launcher3/AppsCustomizeCellLayout.java b/src/com/android/launcher3/AppsCustomizeCellLayout.java
new file mode 100644
index 000000000..a2acb6459
--- /dev/null
+++ b/src/com/android/launcher3/AppsCustomizeCellLayout.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package com.android.launcher3;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewDebug;
+import android.view.ViewGroup;
+
+public class AppsCustomizeCellLayout extends CellLayout implements Page {
+ public AppsCustomizeCellLayout(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void removeAllViewsOnPage() {
+ removeAllViews();
+ setLayerType(LAYER_TYPE_NONE, null);
+ }
+
+ @Override
+ public void removeViewOnPageAt(int index) {
+ removeViewAt(index);
+ }
+
+ @Override
+ public int getPageChildCount() {
+ return getChildCount();
+ }
+
+ @Override
+ public View getChildOnPageAt(int i) {
+ return getChildAt(i);
+ }
+
+ @Override
+ public int indexOfChildOnPage(View v) {
+ return indexOfChild(v);
+ }
+
+ /**
+ * Clears all the key listeners for the individual icons.
+ */
+ public void resetChildrenOnKeyListeners() {
+ ShortcutAndWidgetContainer children = getShortcutsAndWidgets();
+ int childCount = children.getChildCount();
+ for (int j = 0; j < childCount; ++j) {
+ children.getChildAt(j).setOnKeyListener(null);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 34fec46bf..0d5d4fc43 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -156,6 +156,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
Applications,
Widgets
}
+ private ContentType mContentType = ContentType.Applications;
// Refs
private Launcher mLauncher;
@@ -181,8 +182,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private IconCache mIconCache;
// Dimens
- private int mContentWidth;
- private int mMaxAppCellCountX, mMaxAppCellCountY;
+ private int mContentWidth, mContentHeight;
private int mWidgetCountX, mWidgetCountY;
private int mWidgetWidthGap, mWidgetHeightGap;
private PagedViewCellLayout mWidgetSpacingLayout;
@@ -199,7 +199,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
- public static boolean DISABLE_ALL_APPS = true;
+ public static boolean DISABLE_ALL_APPS = false;
// Previews & outlines
ArrayList<AppsCustomizeAsyncTask> mRunningTasks;
@@ -255,12 +255,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Save the default widget preview background
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0);
- mMaxAppCellCountX = a.getInt(R.styleable.AppsCustomizePagedView_maxAppCellCountX, -1);
- mMaxAppCellCountY = a.getInt(R.styleable.AppsCustomizePagedView_maxAppCellCountY, -1);
- mWidgetWidthGap =
- a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellWidthGap, 0);
- mWidgetHeightGap =
- a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellHeightGap, 0);
+ LauncherAppState app = LauncherAppState.getInstance();
+ DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
+ mWidgetWidthGap = mWidgetHeightGap = grid.edgeMarginPx;
mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2);
mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2);
mClingFocusedX = a.getInt(R.styleable.AppsCustomizePagedView_clingFocusedX, 0);
@@ -288,29 +285,40 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold)/100f);
}
+ public void onFinishInflate() {
+ super.onFinishInflate();
+
+ LauncherAppState app = LauncherAppState.getInstance();
+ DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
+ setPadding(grid.edgeMarginPx, 2 * grid.edgeMarginPx,
+ grid.edgeMarginPx, 2 * grid.edgeMarginPx);
+ }
+
/** Returns the item index of the center item on this page so that we can restore to this
* item index when we rotate. */
private int getMiddleComponentIndexOnCurrentPage() {
int i = -1;
if (getPageCount() > 0) {
int currentPage = getCurrentPage();
- if (currentPage < mNumAppsPages) {
- PagedViewCellLayout layout = (PagedViewCellLayout) getPageAt(currentPage);
- PagedViewCellLayoutChildren childrenLayout = layout.getChildrenLayout();
+ if (mContentType == ContentType.Applications) {
+ AppsCustomizeCellLayout layout = (AppsCustomizeCellLayout) getPageAt(currentPage);
+ ShortcutAndWidgetContainer childrenLayout = layout.getShortcutsAndWidgets();
int numItemsPerPage = mCellCountX * mCellCountY;
int childCount = childrenLayout.getChildCount();
if (childCount > 0) {
i = (currentPage * numItemsPerPage) + (childCount / 2);
}
- } else {
+ } else if (mContentType == ContentType.Widgets) {
int numApps = mApps.size();
PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(currentPage);
int numItemsPerPage = mWidgetCountX * mWidgetCountY;
int childCount = layout.getChildCount();
if (childCount > 0) {
i = numApps +
- ((currentPage - mNumAppsPages) * numItemsPerPage) + (childCount / 2);
+ (currentPage * numItemsPerPage) + (childCount / 2);
}
+ } else {
+ throw new RuntimeException("Invalid ContentType");
}
}
return i;
@@ -334,7 +342,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
return (index / numItemsPerPage);
} else {
int numItemsPerPage = mWidgetCountX * mWidgetCountY;
- return mNumAppsPages + ((index - mApps.size()) / numItemsPerPage);
+ return (index - mApps.size()) / numItemsPerPage;
}
}
@@ -355,33 +363,22 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mWidgetPreviewLoader = new WidgetPreviewLoader(mLauncher);
}
- int maxCellCountX = Integer.MAX_VALUE;
- int maxCellCountY = Integer.MAX_VALUE;
- if (mMaxAppCellCountX > -1) {
- maxCellCountX = Math.min(maxCellCountX, mMaxAppCellCountX);
- }
- // Temp hack for now: only use the max cell count Y for widget layout
- int maxWidgetCellCountY = maxCellCountY;
- if (mMaxAppCellCountY > -1) {
- maxWidgetCellCountY = Math.min(maxWidgetCellCountY, mMaxAppCellCountY);
- }
-
// Now that the data is ready, we can calculate the content width, the number of cells to
// use for each page
- mWidgetSpacingLayout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
+ LauncherAppState app = LauncherAppState.getInstance();
+ DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
mWidgetSpacingLayout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
- mWidgetSpacingLayout.calculateCellCount(width, height, maxCellCountX, maxCellCountY);
- mCellCountX = mWidgetSpacingLayout.getCellCountX();
- mCellCountY = mWidgetSpacingLayout.getCellCountY();
+ mCellCountX = (int) grid.allAppsNumCols;
+ mCellCountY = (int) grid.allAppsNumRows;
updatePageCounts();
// Force a measure to update recalculate the gaps
- int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
- int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
- mWidgetSpacingLayout.calculateCellCount(width, height, maxCellCountX, maxWidgetCellCountY);
+ mContentWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
+ mContentHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom();
+ int widthSpec = MeasureSpec.makeMeasureSpec(mContentWidth, MeasureSpec.AT_MOST);
+ int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST);
mWidgetSpacingLayout.measure(widthSpec, heightSpec);
- mContentWidth = mWidgetSpacingLayout.getContentWidth();
AppsCustomizeTabHost host = (AppsCustomizeTabHost) getTabHost();
final boolean hostIsTransitioning = host.isTransitioning();
@@ -945,16 +942,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
public void setContentType(ContentType type) {
- if (type == ContentType.Widgets) {
- invalidatePageData(mNumAppsPages, true);
- } else if (type == ContentType.Applications) {
- invalidatePageData(0, true);
- }
+ mContentType = type;
+ invalidatePageData(0, true);
+ }
+
+ public ContentType getContentType() {
+ return mContentType;
}
protected void snapToPage(int whichPage, int delta, int duration) {
super.snapToPage(whichPage, delta, duration);
- updateCurrentTab(whichPage);
// Update the thread priorities given the direction lookahead
Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
@@ -970,22 +967,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
- private void updateCurrentTab(int currentPage) {
- AppsCustomizeTabHost tabHost = getTabHost();
- if (tabHost != null) {
- String tag = tabHost.getCurrentTabTag();
- if (tag != null) {
- if (currentPage >= mNumAppsPages &&
- !tag.equals(tabHost.getTabTagForContentType(ContentType.Widgets))) {
- tabHost.setCurrentTabFromContent(ContentType.Widgets);
- } else if (currentPage < mNumAppsPages &&
- !tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) {
- tabHost.setCurrentTabFromContent(ContentType.Applications);
- }
- }
- }
- }
-
/*
* Apps PagedView implementation
*/
@@ -995,19 +976,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
layout.getChildAt(i).setVisibility(visibility);
}
}
- private void setupPage(PagedViewCellLayout layout) {
- layout.setCellCount(mCellCountX, mCellCountY);
- layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
- layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
- mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
+ private void setupPage(AppsCustomizeCellLayout layout) {
+ layout.setGridSize(mCellCountX, mCellCountY);
// Note: We force a measure here to get around the fact that when we do layout calculations
// immediately after syncing, we don't have a proper width. That said, we already know the
// 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 heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
+ int widthSpec = MeasureSpec.makeMeasureSpec(mContentWidth, MeasureSpec.AT_MOST);
+ int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST);
layout.setMinimumWidth(getPageContentWidth());
layout.measure(widthSpec, heightSpec);
setVisibilityOnChildren(layout, View.VISIBLE);
@@ -1019,7 +997,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int numCells = mCellCountX * mCellCountY;
int startIndex = page * numCells;
int endIndex = Math.min(startIndex + numCells, mApps.size());
- PagedViewCellLayout layout = (PagedViewCellLayout) getPageAt(page);
+ AppsCustomizeCellLayout layout = (AppsCustomizeCellLayout) getPageAt(page);
layout.removeAllViewsOnPage();
ArrayList<Object> items = new ArrayList<Object>();
@@ -1040,7 +1018,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
if (isRtl) {
x = mCellCountX - x - 1;
}
- layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
+ layout.addViewToCellLayout(icon, -1, i, new CellLayout.LayoutParams(x,y, 1,1), false);
items.add(info);
images.add(info.iconBitmap);
@@ -1151,15 +1129,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
* Widgets PagedView implementation
*/
private void setupPage(PagedViewGridLayout layout) {
- layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
- mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
-
// Note: We force a measure here to get around the fact that when we do layout calculations
// immediately after syncing, we don't have a proper width.
- int workspaceWidth = mLauncher.getWorkspace().getMeasuredWidth();
- int widthSpec = MeasureSpec.makeMeasureSpec(Math.min(getMeasuredWidth(), workspaceWidth),
- MeasureSpec.AT_MOST);
- int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
+ int widthSpec = MeasureSpec.makeMeasureSpec(mContentWidth, MeasureSpec.AT_MOST);
+ int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST);
layout.setMinimumWidth(getPageContentWidth());
layout.measure(widthSpec, heightSpec);
}
@@ -1169,15 +1142,15 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Calculate the dimensions of each cell we are giving to each widget
final ArrayList<Object> items = new ArrayList<Object>();
- int contentWidth = mWidgetSpacingLayout.getContentWidth();
+ int contentWidth = mContentWidth;
final int cellWidth = ((contentWidth - mPageLayoutPaddingLeft - mPageLayoutPaddingRight
- ((mWidgetCountX - 1) * mWidgetWidthGap)) / mWidgetCountX);
- int contentHeight = mWidgetSpacingLayout.getContentHeight();
+ int contentHeight = mContentHeight;
final int cellHeight = ((contentHeight - mPageLayoutPaddingTop - mPageLayoutPaddingBottom
- ((mWidgetCountY - 1) * mWidgetHeightGap)) / mWidgetCountY);
// Prepare the set of widgets to load previews for in the background
- int offset = (page - mNumAppsPages) * numItemsPerPage;
+ int offset = page * numItemsPerPage;
for (int i = offset; i < Math.min(offset + numItemsPerPage, mWidgets.size()); ++i) {
items.add(mWidgets.get(i));
}
@@ -1330,31 +1303,40 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
@Override
public void syncPages() {
+ disablePagedViewAnimations();
+
removeAllViews();
cancelAllTasks();
Context context = getContext();
- for (int j = 0; j < mNumWidgetPages; ++j) {
- PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX,
- mWidgetCountY);
- setupPage(layout);
- addView(layout, new PagedView.LayoutParams(LayoutParams.MATCH_PARENT,
- LayoutParams.MATCH_PARENT));
+ if (mContentType == ContentType.Applications) {
+ for (int i = 0; i < mNumAppsPages; ++i) {
+ AppsCustomizeCellLayout layout = new AppsCustomizeCellLayout(context);
+ setupPage(layout);
+ addView(layout, new PagedView.LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.MATCH_PARENT));
+ }
+ } else if (mContentType == ContentType.Widgets) {
+ for (int j = 0; j < mNumWidgetPages; ++j) {
+ PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX,
+ mWidgetCountY);
+ setupPage(layout);
+ addView(layout, new PagedView.LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.MATCH_PARENT));
+ }
+ } else {
+ throw new RuntimeException("Invalid ContentType");
}
- for (int i = 0; i < mNumAppsPages; ++i) {
- PagedViewCellLayout layout = new PagedViewCellLayout(context);
- setupPage(layout);
- addView(layout);
- }
+ enablePagedViewAnimations();
}
@Override
public void syncPageItems(int page, boolean immediate) {
- if (page < mNumAppsPages) {
- syncAppsPageItems(page, immediate);
- } else {
+ if (mContentType == ContentType.Widgets) {
syncWidgetPageItems(page, immediate);
+ } else {
+ syncAppsPageItems(page, immediate);
}
}
@@ -1698,14 +1680,15 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
int stringId = R.string.default_scroll_format;
int count = 0;
-
- if (page < mNumAppsPages) {
+
+ if (mContentType == ContentType.Applications) {
stringId = R.string.apps_customize_apps_scroll_format;
count = mNumAppsPages;
- } else {
- page -= mNumAppsPages;
+ } else if (mContentType == ContentType.Widgets) {
stringId = R.string.apps_customize_widgets_scroll_format;
count = mNumWidgetPages;
+ } else {
+ throw new RuntimeException("Invalid ContentType");
}
return String.format(getContext().getString(stringId), page + 1, count);
diff --git a/src/com/android/launcher3/AppsCustomizeTabHost.java b/src/com/android/launcher3/AppsCustomizeTabHost.java
index 9868e8ba5..71219cd57 100644
--- a/src/com/android/launcher3/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher3/AppsCustomizeTabHost.java
@@ -79,6 +79,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
setOnTabChangedListener(this);
}
+ void selectAppsTab() {
+ setContentTypeImmediate(AppsCustomizePagedView.ContentType.Applications);
+ }
void selectWidgetsTab() {
setContentTypeImmediate(AppsCustomizePagedView.ContentType.Widgets);
}
@@ -117,6 +120,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
tabView.setText(label);
tabView.setContentDescription(label);
+ addTab(newTabSpec(APPS_TAB_TAG).setIndicator(tabView).setContent(contentFactory));
label = getContext().getString(R.string.widgets_tab_label);
tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
tabView.setText(label);
@@ -232,8 +236,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
// add the pages to mAnimationBuffer in reverse order to match that behavior
for (int i = visiblePages.size() - 1; i >= 0; i--) {
View child = visiblePages.get(i);
- if (child instanceof PagedViewCellLayout) {
- ((PagedViewCellLayout) child).resetChildrenOnKeyListeners();
+ if (child instanceof AppsCustomizeCellLayout) {
+ ((AppsCustomizeCellLayout) child).resetChildrenOnKeyListeners();
} else if (child instanceof PagedViewGridLayout) {
((PagedViewGridLayout) child).resetChildrenOnKeyListeners();
}
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index 3fbb40c6b..f43af615f 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -82,6 +82,9 @@ class DeviceProfile {
int hotseatCellHeightPx;
int hotseatIconSizePx;
int hotseatBarHeightPx;
+ int hotseatAllAppsRank;
+ int allAppsNumRows;
+ int allAppsNumCols;
int searchBarSpaceWidthPx;
int searchBarSpaceMaxWidthPx;
int searchBarSpaceHeightPx;
@@ -90,6 +93,11 @@ class DeviceProfile {
DeviceProfile(String n, float w, float h, float r, float c,
float is, float its, float hs, float his) {
+ // Ensure that we have an odd number of hotseat items (since we need to place all apps)
+ if (!AppsCustomizePagedView.DISABLE_ALL_APPS && hs % 2 == 0) {
+ throw new RuntimeException("All Device Profiles must have an odd number of hotseat spaces");
+ }
+
name = n;
minWidthDps = w;
minHeightDps = h;
@@ -158,6 +166,7 @@ class DeviceProfile {
// Hotseat
hotseatIconSize = invDistWeightedInterpolate(minWidth, minHeight, points);
hotseatIconSizePx = DynamicGrid.pxFromDp(hotseatIconSize, dm);
+ hotseatAllAppsRank = (int) (numColumns / 2);
// Calculate other vars based on Configuration
updateFromConfiguration(resources, wPx, hPx, awPx, ahPx);
@@ -213,6 +222,20 @@ class DeviceProfile {
heightPx = hPx;
availableWidthPx = awPx;
availableHeightPx = ahPx;
+
+ if (isLandscape) {
+ allAppsNumRows = (int) numRows - 1;
+ } else {
+ allAppsNumRows = (int) numRows + 1;
+ }
+ Rect padding = getWorkspacePadding(isLandscape ?
+ CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
+ int pageIndicatorOffset =
+ resources.getDimensionPixelSize(R.dimen.apps_customize_page_indicator_offset);
+ allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) /
+ (iconSizePx + iconTextSizePx + 2 * edgeMarginPx);
+ allAppsNumCols = (availableWidthPx - padding.left - padding.right - 2 * edgeMarginPx) /
+ (iconSizePx + 2 * edgeMarginPx);
}
private float dist(PointF p0, PointF p1) {
@@ -457,19 +480,20 @@ public class DynamicGrid {
DisplayMetrics dm = resources.getDisplayMetrics();
ArrayList<DeviceProfile> deviceProfiles =
new ArrayList<DeviceProfile>();
+ boolean hasAA = !AppsCustomizePagedView.DISABLE_ALL_APPS;
// Our phone profiles include the bar sizes in each orientation
deviceProfiles.add(new DeviceProfile("Super Short Stubby",
- 255, 300, 2, 3, 48, 12, 4, 48));
+ 255, 300, 2, 3, 48, 12, (hasAA ? 5 : 4), 48));
deviceProfiles.add(new DeviceProfile("Shorter Stubby",
- 255, 400, 3, 3, 48, 12, 4, 48));
+ 255, 400, 3, 3, 48, 12, (hasAA ? 5 : 4), 48));
deviceProfiles.add(new DeviceProfile("Short Stubby",
- 275, 420, 3, 4, 48, 12, 4, 48));
+ 275, 420, 3, 4, 48, 12, (hasAA ? 5 : 4), 48));
deviceProfiles.add(new DeviceProfile("Stubby",
- 255, 450, 3, 4, 48, 12, 4, 48));
+ 255, 450, 3, 4, 48, 12, (hasAA ? 5 : 4), 48));
deviceProfiles.add(new DeviceProfile("Nexus S",
- 296, 491.33f, 4, 4, 48, 12, 4, 48));
+ 296, 491.33f, 4, 4, 48, 12, (hasAA ? 5 : 4), 48));
deviceProfiles.add(new DeviceProfile("Nexus 4",
- 359, 518, 4, 4, 60, 12, 5, 56));
+ 359, 518, 4, 4, 60, 12, (hasAA ? 5 : 4), 56));
// The tablet profile is odd in that the landscape orientation
// also includes the nav bar on the side
deviceProfiles.add(new DeviceProfile("Nexus 7",
@@ -481,7 +505,7 @@ public class DynamicGrid {
deviceProfiles.add(new DeviceProfile("Nexus 7",
600, 960, 5, 5, 72, 14.4f, 5, 60));
deviceProfiles.add(new DeviceProfile("Nexus 10",
- 800, 1280, 5, 5, 80, 14.4f, 6, 64));
+ 800, 1280, 5, 5, 80, 14.4f, (hasAA ? 7 : 6), 64));
*/
deviceProfiles.add(new DeviceProfile("20-inch Tablet",
1527, 2527, 7, 7, 100, 20, 7, 72));
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index 1acaf3e3b..4600985c4 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -119,9 +119,9 @@ public class FocusHelper {
*/
private static ViewGroup getAppsCustomizePage(ViewGroup container, int index) {
ViewGroup page = (ViewGroup) ((PagedView) container).getPageAt(index);
- if (page instanceof PagedViewCellLayout) {
+ if (page instanceof CellLayout) {
// There are two layers, a PagedViewCellLayout and PagedViewCellLayoutChildren
- page = (ViewGroup) page.getChildAt(0);
+ page = ((CellLayout) page).getShortcutsAndWidgets();
}
return page;
}
@@ -280,11 +280,11 @@ public class FocusHelper {
ViewGroup itemContainer;
int countX;
int countY;
- if (v.getParent() instanceof PagedViewCellLayoutChildren) {
+ if (v.getParent() instanceof ShortcutAndWidgetContainer) {
itemContainer = (ViewGroup) v.getParent();
parentLayout = (ViewGroup) itemContainer.getParent();
- countX = ((PagedViewCellLayout) parentLayout).getCellCountX();
- countY = ((PagedViewCellLayout) parentLayout).getCellCountY();
+ countX = ((CellLayout) parentLayout).getCountX();
+ countY = ((CellLayout) parentLayout).getCountY();
} else {
itemContainer = parentLayout = (ViewGroup) v.getParent();
countX = ((PagedViewGridLayout) parentLayout).getCellCountX();
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index ccdc56bc2..ec787614d 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -20,8 +20,12 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
@@ -32,6 +36,8 @@ public class Hotseat extends FrameLayout {
private CellLayout mContent;
+ private Launcher mLauncher;
+
private int mAllAppsButtonRank;
private boolean mTransposeLayoutWithOrientation;
@@ -56,6 +62,7 @@ public class Hotseat extends FrameLayout {
}
public void setup(Launcher launcher) {
+ mLauncher = launcher;
setOnKeyListener(new HotseatIconKeyEventListener());
}
@@ -79,7 +86,11 @@ public class Hotseat extends FrameLayout {
return hasVerticalHotseat() ? (mContent.getCountY() - (rank + 1)) : 0;
}
public boolean isAllAppsButtonRank(int rank) {
- return false;
+ if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
+ return false;
+ } else {
+ return rank == mAllAppsButtonRank;
+ }
}
@Override
@@ -88,7 +99,7 @@ public class Hotseat extends FrameLayout {
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
- mAllAppsButtonRank = (int) (grid.numHotseatIcons / 2);
+ mAllAppsButtonRank = grid.hotseatAllAppsRank;
mContent = (CellLayout) findViewById(R.id.layout);
if (grid.isLandscape && !grid.isLargeTablet()) {
mContent.setGridSize(1, (int) grid.numHotseatIcons);
@@ -102,52 +113,99 @@ public class Hotseat extends FrameLayout {
void resetLayout() {
mContent.removeAllViewsInLayout();
+
+ if (!AppsCustomizePagedView.DISABLE_ALL_APPS) {
+ // Add the Apps button
+ Context context = getContext();
+
+ Drawable rawIcon =
+ context.getResources().getDrawable(R.drawable.all_apps_button_icon);
+ Bitmap icon = Utilities.createIconBitmap(rawIcon, context);
+
+ LayoutInflater inflater = LayoutInflater.from(context);
+ BubbleTextView allAppsButton = (BubbleTextView)
+ inflater.inflate(R.layout.application, mContent, false);
+ allAppsButton.setCompoundDrawablesWithIntrinsicBounds(null,
+ new FastBitmapDrawable(icon), null, null);
+ allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
+ allAppsButton.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (mLauncher != null &&
+ (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
+ mLauncher.onTouchDownAllAppsButton(v);
+ }
+ return false;
+ }
+ });
+
+ allAppsButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(android.view.View v) {
+ if (mLauncher != null) {
+ mLauncher.onClickAllAppsButton(v);
+ }
+ }
+ });
+
+ // Note: We do this to ensure that the hotseat is always laid out in the orientation of
+ // the hotseat in order regardless of which orientation they were added
+ int x = getCellXFromOrder(mAllAppsButtonRank);
+ int y = getCellYFromOrder(mAllAppsButtonRank);
+ CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x,y,1,1);
+ lp.canReorder = false;
+ mContent.addViewToCellLayout(allAppsButton, -1, 0, lp, true);
+ }
}
void addAllAppsFolder(IconCache iconCache,
ArrayList<AppInfo> allApps, ArrayList<ComponentName> onWorkspace,
Launcher launcher, Workspace workspace) {
- FolderInfo fi = new FolderInfo();
-
- fi.cellX = getCellXFromOrder(mAllAppsButtonRank);
- fi.cellY = getCellYFromOrder(mAllAppsButtonRank);
- fi.spanX = 1;
- fi.spanY = 1;
- fi.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT;
- fi.screenId = mAllAppsButtonRank;
- fi.itemType = LauncherSettings.Favorites.ITEM_TYPE_FOLDER;
- fi.title = "More Apps";
- LauncherModel.addItemToDatabase(launcher, fi, fi.container, fi.screenId, fi.cellX,
- fi.cellY, false);
- FolderIcon folder = FolderIcon.fromXml(R.layout.folder_icon, launcher,
- getLayout(), fi, iconCache);
- workspace.addInScreen(folder, fi.container, fi.screenId, fi.cellX, fi.cellY,
- fi.spanX, fi.spanY);
-
- for (AppInfo info: allApps) {
- ComponentName cn = info.intent.getComponent();
- if (!onWorkspace.contains(cn)) {
- Log.d(TAG, "Adding to 'more apps': " + info.intent);
- ShortcutInfo si = info.makeShortcut();
- fi.add(si);
+ if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
+ FolderInfo fi = new FolderInfo();
+
+ fi.cellX = getCellXFromOrder(mAllAppsButtonRank);
+ fi.cellY = getCellYFromOrder(mAllAppsButtonRank);
+ fi.spanX = 1;
+ fi.spanY = 1;
+ fi.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT;
+ fi.screenId = mAllAppsButtonRank;
+ fi.itemType = LauncherSettings.Favorites.ITEM_TYPE_FOLDER;
+ fi.title = "More Apps";
+ LauncherModel.addItemToDatabase(launcher, fi, fi.container, fi.screenId, fi.cellX,
+ fi.cellY, false);
+ FolderIcon folder = FolderIcon.fromXml(R.layout.folder_icon, launcher,
+ getLayout(), fi, iconCache);
+ workspace.addInScreen(folder, fi.container, fi.screenId, fi.cellX, fi.cellY,
+ fi.spanX, fi.spanY);
+
+ for (AppInfo info: allApps) {
+ ComponentName cn = info.intent.getComponent();
+ if (!onWorkspace.contains(cn)) {
+ Log.d(TAG, "Adding to 'more apps': " + info.intent);
+ ShortcutInfo si = info.makeShortcut();
+ fi.add(si);
+ }
}
}
}
void addAppsToAllAppsFolder(ArrayList<AppInfo> apps) {
- View v = mContent.getChildAt(getCellXFromOrder(mAllAppsButtonRank), getCellYFromOrder(mAllAppsButtonRank));
- FolderIcon fi = null;
-
- if (v instanceof FolderIcon) {
- fi = (FolderIcon) v;
- } else {
- return;
- }
+ if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
+ View v = mContent.getChildAt(getCellXFromOrder(mAllAppsButtonRank), getCellYFromOrder(mAllAppsButtonRank));
+ FolderIcon fi = null;
+
+ if (v instanceof FolderIcon) {
+ fi = (FolderIcon) v;
+ } else {
+ return;
+ }
- FolderInfo info = fi.getFolderInfo();
- for (AppInfo a: apps) {
- ShortcutInfo si = a.makeShortcut();
- info.add(si);
+ FolderInfo info = fi.getFolderInfo();
+ for (AppInfo a: apps) {
+ ShortcutInfo si = a.makeShortcut();
+ info.add(si);
+ }
}
}
}
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index 5cfecb7ed..3ab3a68ba 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -255,7 +255,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
// Add the new apps to the model and bind them
if (!addShortcuts.isEmpty()) {
LauncherAppState app = LauncherAppState.getInstance();
- app.getModel().addAndBindAddedApps(context, addShortcuts);
+ app.getModel().addAndBindAddedApps(context, addShortcuts, null);
}
}
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 81a962d0c..ec84a9ac0 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -795,7 +795,7 @@ public class Launcher extends Activity
if (mOnResumeState == State.WORKSPACE) {
showWorkspace(false);
} else if (mOnResumeState == State.APPS_CUSTOMIZE) {
- showAllApps(false);
+ showAllApps(false, AppsCustomizePagedView.ContentType.Applications);
}
mOnResumeState = State.NONE;
@@ -1118,7 +1118,7 @@ public class Launcher extends Activity
findViewById(R.id.widget_button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
- showAllApps(true);
+ showAllApps(true, AppsCustomizePagedView.ContentType.Widgets);
}
});
findViewById(R.id.wallpaper_button).setOnClickListener(new OnClickListener() {
@@ -2183,7 +2183,7 @@ public class Launcher extends Activity
final String shortcutClass = intent.getComponent().getClassName();
if (shortcutClass.equals(WidgetAdder.class.getName())) {
- showAllApps(true);
+ showAllApps(true, AppsCustomizePagedView.ContentType.Widgets);
return;
} else if (shortcutClass.equals(MemoryDumpActivity.class.getName())) {
MemoryDumpActivity.startDump(this);
@@ -2273,7 +2273,7 @@ public class Launcher extends Activity
* @param v The view that was clicked.
*/
public void onClickAllAppsButton(View v) {
- showAllApps(true);
+ showAllApps(true, AppsCustomizePagedView.ContentType.Applications);
}
public void onTouchDownAllAppsButton(View v) {
@@ -2742,6 +2742,11 @@ public class Launcher extends Activity
* of the screen.
*/
private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded) {
+ AppsCustomizePagedView.ContentType contentType = mAppsCustomizeContent.getContentType();
+ showAppsCustomizeHelper(animated, springLoaded, contentType);
+ }
+ private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded,
+ final AppsCustomizePagedView.ContentType contentType) {
if (mStateAnimation != null) {
mStateAnimation.setDuration(0);
mStateAnimation.cancel();
@@ -2762,6 +2767,10 @@ public class Launcher extends Activity
// Shrink workspaces away if going to AppsCustomize from workspace
Animator workspaceAnim =
mWorkspace.getChangeStateAnimation(Workspace.State.SMALL, animated);
+ if (!AppsCustomizePagedView.DISABLE_ALL_APPS) {
+ // Set the content type for the all apps space
+ mAppsCustomizeTabHost.setContentTypeImmediate(contentType);
+ }
if (animated) {
toView.setScaleX(scale);
@@ -3053,10 +3062,11 @@ public class Launcher extends Activity
public void onWorkspaceShown(boolean animated) {
}
- void showAllApps(boolean animated) {
+ void showAllApps(boolean animated,
+ AppsCustomizePagedView.ContentType contentType) {
if (mState != State.WORKSPACE) return;
- showAppsCustomizeHelper(animated, false);
+ showAppsCustomizeHelper(animated, false, contentType);
mAppsCustomizeTabHost.requestFocus();
// Change the state *after* we've called all the transition code
@@ -3609,10 +3619,11 @@ public class Launcher extends Activity
public void bindAppsAdded(final ArrayList<Long> newScreens,
final ArrayList<ItemInfo> addNotAnimated,
- final ArrayList<ItemInfo> addAnimated) {
+ final ArrayList<ItemInfo> addAnimated,
+ final ArrayList<AppInfo> addedApps) {
Runnable r = new Runnable() {
public void run() {
- bindAppsAdded(newScreens, addNotAnimated, addAnimated);
+ bindAppsAdded(newScreens, addNotAnimated, addAnimated, addedApps);
}
};
if (waitUntilResume(r)) {
@@ -3634,6 +3645,11 @@ public class Launcher extends Activity
bindItems(addAnimated, 0,
addAnimated.size(), true);
}
+
+ if (!AppsCustomizePagedView.DISABLE_ALL_APPS &&
+ addedApps != null && mAppsCustomizeContent != null) {
+ mAppsCustomizeContent.addApps(addedApps);
+ }
}
/**
@@ -3875,12 +3891,19 @@ public class Launcher extends Activity
* Implementation of the method from LauncherModel.Callbacks.
*/
public void bindAllApplications(final ArrayList<AppInfo> apps) {
- if (mIntentsOnWorkspaceFromUpgradePath != null) {
- if (LauncherModel.UPGRADE_USE_MORE_APPS_FOLDER) {
- getHotseat().addAllAppsFolder(mIconCache, apps,
- mIntentsOnWorkspaceFromUpgradePath, Launcher.this, mWorkspace);
+ if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
+ if (mIntentsOnWorkspaceFromUpgradePath != null) {
+ if (LauncherModel.UPGRADE_USE_MORE_APPS_FOLDER) {
+ getHotseat().addAllAppsFolder(mIconCache, apps,
+ mIntentsOnWorkspaceFromUpgradePath, Launcher.this, mWorkspace);
+ }
+ mIntentsOnWorkspaceFromUpgradePath = null;
+ }
+ } else {
+ if (!AppsCustomizePagedView.DISABLE_ALL_APPS &&
+ mAppsCustomizeContent != null) {
+ mAppsCustomizeContent.setApps(apps);
}
- mIntentsOnWorkspaceFromUpgradePath = null;
}
}
@@ -3902,6 +3925,11 @@ public class Launcher extends Activity
if (mWorkspace != null) {
mWorkspace.updateShortcuts(apps);
}
+
+ if (!AppsCustomizePagedView.DISABLE_ALL_APPS &&
+ mAppsCustomizeContent != null) {
+ mAppsCustomizeContent.updateApps(apps);
+ }
}
/**
@@ -3933,6 +3961,11 @@ public class Launcher extends Activity
// Notify the drag controller
mDragController.onAppsRemoved(appInfos, this);
+
+ if (!AppsCustomizePagedView.DISABLE_ALL_APPS &&
+ mAppsCustomizeContent != null) {
+ mAppsCustomizeContent.removeApps(appInfos);
+ }
}
/**
@@ -3953,7 +3986,8 @@ public class Launcher extends Activity
}
// Update the widgets pane
- if (mAppsCustomizeContent != null) {
+ if (!AppsCustomizePagedView.DISABLE_ALL_APPS &&
+ mAppsCustomizeContent != null) {
mAppsCustomizeContent.onPackagesUpdated(widgetsAndShortcuts);
}
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 0ebeec32d..9081e23b2 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -159,7 +159,8 @@ public class LauncherModel extends BroadcastReceiver {
public void bindAllApplications(ArrayList<AppInfo> apps);
public void bindAppsAdded(ArrayList<Long> newScreens,
ArrayList<ItemInfo> addNotAnimated,
- ArrayList<ItemInfo> addAnimated);
+ ArrayList<ItemInfo> addAnimated,
+ ArrayList<AppInfo> addedApps);
public void bindAppsUpdated(ArrayList<AppInfo> apps);
public void bindComponentsRemoved(ArrayList<String> packageNames,
ArrayList<AppInfo> appInfos,
@@ -276,12 +277,13 @@ public class LauncherModel extends BroadcastReceiver {
return null;
}
- public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> added) {
+ public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> added,
+ final ArrayList<AppInfo> addedApps) {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
- addAndBindAddedApps(context, added, cb);
+ addAndBindAddedApps(context, added, cb, addedApps);
}
public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> added,
- final Callbacks callbacks) {
+ final Callbacks callbacks, final ArrayList<AppInfo> addedApps) {
Launcher.addDumpLog(TAG, "10249126 - addAndBindAddedApps()", true);
if (added.isEmpty()) {
return;
@@ -383,7 +385,7 @@ public class LauncherModel extends BroadcastReceiver {
}
}
callbacks.bindAppsAdded(addedWorkspaceScreensFinal,
- addNotAnimated, addAnimated);
+ addNotAnimated, addAnimated, addedApps);
}
}
});
@@ -1477,13 +1479,15 @@ public class LauncherModel extends BroadcastReceiver {
sBgDbIconCache.clear();
}
- // Ensure that all the applications that are in the system are represented on the home
- // screen.
- Launcher.addDumpLog(TAG, "10249126 - verifyApplications - useMoreApps="
- + UPGRADE_USE_MORE_APPS_FOLDER + " isUpgrade=" + isUpgrade, true);
- if (!UPGRADE_USE_MORE_APPS_FOLDER || !isUpgrade) {
- Launcher.addDumpLog(TAG, "10249126 - verifyApplications(" + isUpgrade + ")", true);
- verifyApplications();
+ if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
+ // Ensure that all the applications that are in the system are
+ // represented on the home screen.
+ Launcher.addDumpLog(TAG, "10249126 - verifyApplications - useMoreApps="
+ + UPGRADE_USE_MORE_APPS_FOLDER + " isUpgrade=" + isUpgrade, true);
+ if (!UPGRADE_USE_MORE_APPS_FOLDER || !isUpgrade) {
+ Launcher.addDumpLog(TAG, "10249126 - verifyApplications(" + isUpgrade + ")", true);
+ verifyApplications();
+ }
}
// Clear out this reference, otherwise we end up holding it until all of the
@@ -1557,7 +1561,7 @@ public class LauncherModel extends BroadcastReceiver {
}
if (!added.isEmpty()) {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
- addAndBindAddedApps(context, added, cb);
+ addAndBindAddedApps(context, added, cb, null);
}
}
@@ -2582,7 +2586,7 @@ public class LauncherModel extends BroadcastReceiver {
// Ensure that we add all the workspace applications to the db
final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
- addAndBindAddedApps(context, addedInfos, cb);
+ addAndBindAddedApps(context, addedInfos, cb, added);
}
if (modified != null) {
final ArrayList<AppInfo> modifiedFinal = modified;
diff --git a/src/com/android/launcher3/PageIndicator.java b/src/com/android/launcher3/PageIndicator.java
index ce9814505..110d6d9c3 100644
--- a/src/com/android/launcher3/PageIndicator.java
+++ b/src/com/android/launcher3/PageIndicator.java
@@ -161,30 +161,30 @@ public class PageIndicator extends LinearLayout {
mWindowRange[1] = windowEnd;
}
- void addMarker(int index, int layoutId) {
+ void addMarker(int index, int layoutId, boolean allowAnimations) {
index = Math.max(0, Math.min(index, mMarkers.size()));
PageIndicatorMarker marker =
(PageIndicatorMarker) mLayoutInflater.inflate(layoutId, this, false);
mMarkers.add(index, marker);
- offsetWindowCenterTo(mActiveMarkerIndex, true);
+ offsetWindowCenterTo(mActiveMarkerIndex, allowAnimations);
}
- void addMarkers(ArrayList<Integer> layoutIds) {
+ void addMarkers(ArrayList<Integer> layoutIds, boolean allowAnimations) {
for (int i = 0; i < layoutIds.size(); ++i) {
- addMarker(Integer.MAX_VALUE, layoutIds.get(i));
+ addMarker(Integer.MAX_VALUE, layoutIds.get(i), allowAnimations);
}
}
- void removeMarker(int index) {
+ void removeMarker(int index, boolean allowAnimations) {
if (mMarkers.size() > 0) {
index = Math.max(0, Math.min(mMarkers.size() - 1, index));
mMarkers.remove(index);
- offsetWindowCenterTo(mActiveMarkerIndex, true);
+ offsetWindowCenterTo(mActiveMarkerIndex, allowAnimations);
}
}
- void removeAllMarkers() {
+ void removeAllMarkers(boolean allowAnimations) {
while (mMarkers.size() > 0) {
- removeMarker(Integer.MAX_VALUE);
+ removeMarker(Integer.MAX_VALUE, allowAnimations);
}
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 514ce931f..76c9a3205 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -54,6 +54,14 @@ import android.widget.Scroller;
import java.util.ArrayList;
+interface Page {
+ public int getPageChildCount();
+ public View getChildOnPageAt(int i);
+ public void removeAllViewsOnPage();
+ public void removeViewOnPageAt(int i);
+ public int indexOfChildOnPage(View v);
+}
+
/**
* An abstraction of the original Workspace which supports browsing through a
* sequential list of "pages"
@@ -196,6 +204,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Page Indicator
private int mPageIndicatorViewId;
private PageIndicator mPageIndicator;
+ private boolean mAllowPagedViewAnimations = true;
// The viewport whether the pages are to be contained (the actual view may be larger than the
// viewport)
@@ -209,6 +218,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected int REORDERING_ZOOM_IN_OUT_DURATION = 250;
private int REORDERING_SIDE_PAGE_HOVER_TIMEOUT = 80;
private float mMinScale = 1f;
+ private boolean mUseMinScale = false;
protected View mDragView;
protected AnimatorSet mZoomInOutAnim;
private Runnable mSidePageHoverRunnable;
@@ -321,14 +331,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
ViewGroup parent = (ViewGroup) getParent();
if (mPageIndicator == null && mPageIndicatorViewId > -1) {
mPageIndicator = (PageIndicator) parent.findViewById(mPageIndicatorViewId);
- mPageIndicator.removeAllMarkers();
+ mPageIndicator.removeAllMarkers(mAllowPagedViewAnimations);
ArrayList<Integer> markers = new ArrayList<Integer>();
for (int i = 0; i < getChildCount(); ++i) {
markers.add(getPageIndicatorMarker(i));
}
- mPageIndicator.addMarkers(markers);
+ mPageIndicator.addMarkers(markers, mAllowPagedViewAnimations);
mPageIndicator.setOnClickListener((Launcher) getContext());
}
}
@@ -374,6 +384,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
public void setMinScale(float f) {
mMinScale = f;
+ mUseMinScale = true;
requestLayout();
}
@@ -723,10 +734,17 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// viewport, we can be at most one and a half screens offset once we scale down
DisplayMetrics dm = getResources().getDisplayMetrics();
int maxSize = Math.max(dm.widthPixels, dm.heightPixels);
- int parentWidthSize = (int) (1.5f * maxSize);
- int parentHeightSize = maxSize;
- int scaledWidthSize = (int) (parentWidthSize / mMinScale);
- int scaledHeightSize = (int) (parentHeightSize / mMinScale);
+ int parentWidthSize, parentHeightSize;
+ int scaledWidthSize, scaledHeightSize;
+ if (mUseMinScale) {
+ parentWidthSize = (int) (1.5f * maxSize);
+ parentHeightSize = maxSize;
+ scaledWidthSize = (int) (parentWidthSize / mMinScale);
+ scaledHeightSize = (int) (parentHeightSize / mMinScale);
+ } else {
+ scaledWidthSize = widthSize;
+ scaledHeightSize = heightSize;
+ }
mViewport.set(0, 0, widthSize, heightSize);
if (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED) {
@@ -786,8 +804,13 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
childWidthMode = MeasureSpec.EXACTLY;
childHeightMode = MeasureSpec.EXACTLY;
- childWidth = getViewportWidth();
- childHeight = getViewportHeight();
+ if (mUseMinScale) {
+ childWidth = getViewportWidth();
+ childHeight = getViewportHeight();
+ } else {
+ childWidth = widthSize - getPaddingLeft() - getPaddingRight();
+ childHeight = heightSize - getPaddingTop() - getPaddingBottom();
+ }
}
final int childWidthMeasureSpec =
@@ -930,13 +953,22 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
+ protected void enablePagedViewAnimations() {
+ mAllowPagedViewAnimations = true;
+
+ }
+ protected void disablePagedViewAnimations() {
+ mAllowPagedViewAnimations = false;
+ }
+
@Override
public void onChildViewAdded(View parent, View child) {
// Update the page indicator, we don't update the page indicator as we
// add/remove pages
if (mPageIndicator != null && !isReordering(false)) {
int pageIndex = indexOfChild(child);
- mPageIndicator.addMarker(pageIndex, getPageIndicatorMarker(pageIndex));
+ mPageIndicator.addMarker(pageIndex, getPageIndicatorMarker(pageIndex),
+ mAllowPagedViewAnimations);
}
// This ensures that when children are added, they get the correct transforms / alphas
@@ -957,7 +989,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Update the page indicator, we don't update the page indicator as we
// add/remove pages
if (mPageIndicator != null && !isReordering(false)) {
- mPageIndicator.removeMarker(index);
+ mPageIndicator.removeMarker(index, mAllowPagedViewAnimations);
}
}
@@ -987,7 +1019,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Update the page indicator, we don't update the page indicator as we
// add/remove pages
if (mPageIndicator != null) {
- mPageIndicator.removeAllMarkers();
+ mPageIndicator.removeAllMarkers(mAllowPagedViewAnimations);
}
super.removeAllViewsInLayout();
diff --git a/src/com/android/launcher3/PagedViewCellLayout.java b/src/com/android/launcher3/PagedViewCellLayout.java
index 51699e9ac..75d3aeef8 100644
--- a/src/com/android/launcher3/PagedViewCellLayout.java
+++ b/src/com/android/launcher3/PagedViewCellLayout.java
@@ -42,7 +42,6 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
private int mOriginalHeightGap;
private int mWidthGap;
private int mHeightGap;
- private int mMaxGap;
protected PagedViewCellLayoutChildren mChildren;
public PagedViewCellLayout(Context context) {
@@ -67,7 +66,6 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
mCellCountX = (int) grid.numColumns;
mCellCountY = (int) grid.numRows;
mOriginalWidthGap = mOriginalHeightGap = mWidthGap = mHeightGap = -1;
- mMaxGap = resources.getDimensionPixelSize(R.dimen.apps_customize_max_gap);
mChildren = new PagedViewCellLayoutChildren(context);
mChildren.setCellDimensions(mCellWidth, mCellHeight);
@@ -184,8 +182,8 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
int vSpace = heightSpecSize - getPaddingTop() - getPaddingBottom();
int hFreeSpace = hSpace - (mCellCountX * mOriginalCellWidth);
int vFreeSpace = vSpace - (mCellCountY * mOriginalCellHeight);
- mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
- mHeightGap = Math.min(mMaxGap,numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
+ mWidthGap = numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0;
+ mHeightGap = numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0;
mChildren.setGap(mWidthGap, mHeightGap);
} else {
@@ -493,12 +491,4 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
this.cellHSpan + ", " + this.cellVSpan + ")";
}
}
-}
-
-interface Page {
- public int getPageChildCount();
- public View getChildOnPageAt(int i);
- public void removeAllViewsOnPage();
- public void removeViewOnPageAt(int i);
- public int indexOfChildOnPage(View v);
-}
+} \ No newline at end of file
diff --git a/src/com/android/launcher3/PagedViewIcon.java b/src/com/android/launcher3/PagedViewIcon.java
index 501bc8f0b..fa9ec5a15 100644
--- a/src/com/android/launcher3/PagedViewIcon.java
+++ b/src/com/android/launcher3/PagedViewIcon.java
@@ -19,6 +19,7 @@ package com.android.launcher3;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
+import android.util.TypedValue;
import android.widget.TextView;
/**
@@ -52,6 +53,15 @@ public class PagedViewIcon extends TextView {
super(context, attrs, defStyle);
}
+ public void onFinishInflate() {
+ super.onFinishInflate();
+
+ // Ensure we are using the right text size
+ LauncherAppState app = LauncherAppState.getInstance();
+ DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.iconTextSize);
+ }
+
public void applyFromApplicationInfo(AppInfo info, boolean scaleUp,
PagedViewIcon.PressedCallback cb) {
mIcon = info.iconBitmap;
diff --git a/src/com/android/launcher3/PagedViewWidget.java b/src/com/android/launcher3/PagedViewWidget.java
index 220a9f75f..45320a484 100644
--- a/src/com/android/launcher3/PagedViewWidget.java
+++ b/src/com/android/launcher3/PagedViewWidget.java
@@ -23,6 +23,7 @@ import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.Rect;
import android.util.AttributeSet;
+import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
@@ -77,6 +78,18 @@ public class PagedViewWidget extends LinearLayout {
mOriginalImagePadding.top = image.getPaddingTop();
mOriginalImagePadding.right = image.getPaddingRight();
mOriginalImagePadding.bottom = image.getPaddingBottom();
+
+ // Ensure we are using the right text size
+ LauncherAppState app = LauncherAppState.getInstance();
+ DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
+ TextView name = (TextView) findViewById(R.id.widget_name);
+ if (name != null) {
+ name.setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.iconTextSize);
+ }
+ TextView dims = (TextView) findViewById(R.id.widget_dims);
+ if (dims != null) {
+ dims.setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.iconTextSize);
+ }
}
public static void setDeletePreviewsWhenDetachedFromWindow(boolean value) {