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
This commit is contained in:
Winson Chung 2013-09-03 17:48:37 -07:00
parent 2d8de5845b
commit c58497ee61
28 changed files with 434 additions and 347 deletions

View File

@ -30,7 +30,8 @@
android:layout_width="wrap_content"
android:layout_height="@dimen/apps_customize_tab_bar_height"
android:layout_marginTop="@dimen/apps_customize_tab_bar_margin_top"
android:layout_gravity="center_horizontal">
android:layout_gravity="center_horizontal"
android:visibility="gone">
<com.android.launcher3.FocusOnlyTabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
@ -55,18 +56,7 @@
android:id="@+id/apps_customize_pane_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/apps_customize_page_indicator_height"
android:layout_gravity="center"
launcher:maxAppCellCountX="@integer/apps_customize_maxCellCountX"
launcher:maxAppCellCountY="@integer/apps_customize_maxCellCountY"
launcher:pageLayoutWidthGap="@dimen/apps_customize_pageLayoutWidthGap"
launcher:pageLayoutHeightGap="@dimen/apps_customize_pageLayoutHeightGap"
launcher:pageLayoutPaddingTop="@dimen/apps_customize_pageLayoutPaddingTop"
launcher:pageLayoutPaddingBottom="@dimen/apps_customize_pageLayoutPaddingBottom"
launcher:pageLayoutPaddingLeft="@dimen/apps_customize_pageLayoutPaddingLeft"
launcher:pageLayoutPaddingRight="@dimen/apps_customize_pageLayoutPaddingRight"
launcher:widgetCellWidthGap="@dimen/apps_customize_widget_cell_width_gap"
launcher:widgetCellHeightGap="@dimen/apps_customize_widget_cell_height_gap"
android:layout_marginBottom="@dimen/apps_customize_page_indicator_offset"
launcher:widgetCountX="@integer/apps_customize_widget_cell_count_x"
launcher:widgetCountY="@integer/apps_customize_widget_cell_count_y"
launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"

View File

@ -25,18 +25,7 @@
<dimen name="workspace_page_spacing">-1dp</dimen>
<!-- AppsCustomize -->
<dimen name="apps_customize_cell_width">80dp</dimen>
<!-- The width can be 76dp because we don't have B padding -->
<dimen name="apps_customize_cell_height">76dp</dimen>
<dimen name="apps_customize_pageLayoutWidthGap">-1dp</dimen>
<dimen name="apps_customize_pageLayoutHeightGap">-1dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingTop">5dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingBottom">5dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingLeft">5dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingRight">5dp</dimen>
<dimen name="apps_customize_tab_bar_height">42dp</dimen>
<dimen name="apps_customize_widget_cell_width_gap">30dp</dimen>
<dimen name="apps_customize_widget_cell_height_gap">5dp</dimen>
<integer name="apps_customize_widget_cell_count_x">3</integer>
<integer name="apps_customize_widget_cell_count_y">2</integer>
<integer name="apps_customize_cling_focused_x">2</integer>

View File

@ -19,17 +19,9 @@
<dimen name="workspace_page_spacing">-1dp</dimen>
<!-- AppsCustomize -->
<dimen name="apps_customize_pageLayoutWidthGap">-1dp</dimen>
<dimen name="apps_customize_pageLayoutHeightGap">-1dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingTop">10dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingBottom">10dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingLeft">5dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingRight">5dp</dimen>
<integer name="apps_customize_cling_focused_x">1</integer>
<integer name="apps_customize_cling_focused_y">1</integer>
<dimen name="apps_customize_widget_cell_width_gap">20dp</dimen>
<dimen name="apps_customize_widget_cell_height_gap">10dp</dimen>
<integer name="apps_customize_widget_cell_count_x">2</integer>
<integer name="apps_customize_widget_cell_count_y">3</integer>
</resources>

View File

@ -17,12 +17,4 @@
<resources>
<!-- Clings -->
<dimen name="folderClingMarginTop">70dp</dimen>
<!-- AppsCustomize -->
<dimen name="apps_customize_pageLayoutPaddingTop">16dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingBottom">20dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingLeft">8dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingRight">8dp</dimen>
<dimen name="apps_customize_cell_height">92dp</dimen>
<dimen name="apps_customize_widget_cell_height_gap">16dp</dimen>
</resources>

View File

@ -29,15 +29,4 @@
<style name="TabIndicator.AppsCustomize">
<item name="android:maxWidth">150dp</item>
</style>
<style name="WorkspaceIcon.Portrait.AppsCustomize">
<item name="android:shadowRadius">0.0</item> <!-- Don't use text shadow -->
<item name="android:singleLine">false</item>
<item name="android:maxLines">2</item>
<item name="android:background">@null</item>
<item name="android:paddingTop">4dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:paddingStart">0dp</item>
<item name="android:paddingEnd">0dp</item>
<item name="android:drawablePadding">6dp</item>
</style>
</resources>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 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.
-->
<resources>
<!-- AppsCustomize -->
<dimen name="apps_customize_cell_width">96dp</dimen>
<dimen name="apps_customize_cell_height">108dp</dimen>
<dimen name="apps_customize_pageLayoutWidthGap">24dp</dimen>
<dimen name="apps_customize_pageLayoutHeightGap">24dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingTop">25dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingBottom">10dp</dimen>
</resources>

View File

@ -18,14 +18,8 @@
<dimen name="app_icon_size">64dp</dimen>
<!-- AppsCustomize -->
<dimen name="apps_customize_cell_width">96dp</dimen>
<dimen name="apps_customize_cell_height">96dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingLeft">12dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingRight">12dp</dimen>
<dimen name="apps_customize_tab_bar_height">60dp</dimen>
<dimen name="apps_customize_tab_bar_margin_top">8dp</dimen>
<dimen name="apps_customize_widget_cell_width_gap">20dp</dimen>
<dimen name="apps_customize_widget_cell_height_gap">24dp</dimen>
<dimen name="app_widget_preview_label_margin_top">8dp</dimen>
<dimen name="app_widget_preview_label_margin_left">@dimen/app_widget_preview_padding_left</dimen>
<dimen name="app_widget_preview_label_margin_right">@dimen/app_widget_preview_padding_right</dimen>

View File

@ -16,10 +16,10 @@
<resources>
<!-- AppsCustomize -->
<dimen name="apps_customize_pageLayoutWidthGap">28dp</dimen>
<dimen name="apps_customize_pageLayoutHeightGap">16dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingLeft">16dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingRight">16dp</dimen>
<integer name="apps_customize_widget_cell_count_x">4</integer>
<integer name="apps_customize_widget_cell_count_y">2</integer>
<integer name="apps_customize_cling_focused_x">4</integer>
<integer name="apps_customize_cling_focused_y">2</integer>
<!-- Workspace -->
<dimen name="workspace_page_spacing">50dp</dimen>
@ -28,11 +28,6 @@
or right while you're dragging. -->
<dimen name="scroll_zone">100dip</dimen>
<integer name="apps_customize_widget_cell_count_x">4</integer>
<integer name="apps_customize_widget_cell_count_y">2</integer>
<integer name="apps_customize_cling_focused_x">4</integer>
<integer name="apps_customize_cling_focused_y">2</integer>
<!-- Cling -->
<!-- The offset for the text in the cling -->
<dimen name="cling_text_block_offset_x">140dp</dimen>

View File

@ -15,18 +15,6 @@
-->
<resources>
<!-- AppsCustomize -->
<integer name="apps_customize_maxCellCountX">-1</integer>
<integer name="apps_customize_maxCellCountY">7</integer>
<dimen name="apps_customize_pageLayoutWidthGap">36dp</dimen>
<dimen name="apps_customize_pageLayoutHeightGap">36dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingLeft">24dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingRight">24dp</dimen>
<!-- We can also afford to have a slightly wider portrait layout in
xlarge -->
<integer name="apps_customize_widget_cell_count_x">3</integer>
<integer name="apps_customize_widget_cell_count_y">3</integer>
<!-- Workspace -->
<!-- the area at the edge of the screen that makes the workspace go left
or right while you're dragging. -->

View File

@ -21,12 +21,6 @@
<dimen name="toolbar_button_vertical_padding">8dip</dimen>
<dimen name="toolbar_button_horizontal_padding">8dip</dimen>
<!-- AppsCustomize -->
<dimen name="apps_customize_cell_width">96dp</dimen>
<dimen name="apps_customize_cell_height">96dp</dimen>
<integer name="apps_customize_maxCellCountX">-1</integer>
<integer name="apps_customize_maxCellCountY">-1</integer>
<!-- dimensions for the wallpaper picker wallpaper thumbnail width -->
<dimen name="wallpaper_chooser_grid_width">196dp</dimen>
<dimen name="wallpaper_chooser_grid_height">140dp</dimen>

View File

@ -55,24 +55,6 @@
<item name="android:windowActionModeOverlay">true</item>
</style>
<style name="WorkspaceIcon.Portrait.AppsCustomize">
<item name="android:shadowRadius">0.0</item> <!-- Don't use text shadow -->
<item name="android:background">@null</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:paddingStart">0dp</item>
<item name="android:paddingEnd">0dp</item>
<item name="android:drawablePadding">4dp</item>
<item name="android:textSize">13sp</item>
</style>
<style name="WorkspaceIcon.Landscape.AppsCustomize">
<item name="android:shadowRadius">0.0</item> <!-- Don't use text shadow -->
<item name="android:background">@null</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:drawablePadding">4dp</item>
<item name="android:textSize">13sp</item>
</style>
<style name="TabIndicator.AppsCustomize">
<item name="android:paddingStart">32dp</item>
<item name="android:paddingEnd">32dp</item>

View File

@ -30,4 +30,6 @@
<color name="workspace_all_apps_and_delete_zone_text_color">#CCFFFFFF</color>
<color name="workspace_all_apps_and_delete_zone_text_shadow_color">#A0000000</color>
<color name="workspace_icon_text_color">#FFF</color>
<color name="apps_customize_icon_text_color">#FFF</color>
</resources>

View File

@ -51,23 +51,16 @@
<dimen name="toolbar_external_icon_height">36dp</dimen>
<!-- AllApps/Customize/AppsCustomize -->
<integer name="apps_customize_maxCellCountX">-1</integer>
<integer name="apps_customize_maxCellCountY">-1</integer>
<!-- The height of the tab bar - if this changes, we should update the
external icon width/height above to compensate -->
<dimen name="apps_customize_tab_bar_height">52dp</dimen>
<dimen name="apps_customize_tab_bar_margin_top">0dp</dimen>
<dimen name="app_icon_size">48dp</dimen>
<!-- The width can be 72dp because we don't have L/R padding -->
<dimen name="apps_customize_cell_width">74dp</dimen>
<dimen name="apps_customize_cell_height">82dp</dimen>
<dimen name="apps_customize_max_gap">18dp</dimen>
<dimen name="apps_customize_widget_cell_width_gap">10dp</dimen>
<dimen name="apps_customize_widget_cell_height_gap">8dp</dimen>
<!-- The AppsCustomize page indicator -->
<dimen name="apps_customize_page_indicator_height">12dp</dimen>
<dimen name="apps_customize_page_indicator_margin">4dp</dimen>
<dimen name="apps_customize_page_indicator_offset">16dp</dimen>
<!-- Drag padding to add to the bottom of drop targets -->
<dimen name="drop_target_drag_padding">14dp</dimen>

View File

@ -83,21 +83,13 @@
<style name="WorkspaceIcon.Portrait.AppsCustomize">
<item name="android:shadowRadius">0.0</item> <!-- Don't use text shadow -->
<item name="android:singleLine">false</item>
<item name="android:maxLines">2</item>
<item name="android:background">@null</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:paddingStart">0dp</item>
<item name="android:paddingEnd">0dp</item>
<item name="android:drawablePadding">2dp</item>
<item name="android:textColor">@color/apps_customize_icon_text_color</item>
</style>
<style name="WorkspaceIcon.Landscape.AppsCustomize">
<item name="android:shadowRadius">0.0</item> <!-- Don't use text shadow -->
<item name="android:background">@null</item>
<item name="android:paddingTop">4dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:drawablePadding">6dp</item>
<item name="android:textColor">@color/apps_customize_icon_text_color</item>
</style>
<style name="QSBBar">

View File

@ -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);
}
}
}

View File

@ -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) {
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,10 +1303,20 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
@Override
public void syncPages() {
disablePagedViewAnimations();
removeAllViews();
cancelAllTasks();
Context context = getContext();
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);
@ -1341,20 +1324,19 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
addView(layout, new PagedView.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
}
for (int i = 0; i < mNumAppsPages; ++i) {
PagedViewCellLayout layout = new PagedViewCellLayout(context);
setupPage(layout);
addView(layout);
} else {
throw new RuntimeException("Invalid ContentType");
}
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);
}
}
@ -1699,13 +1681,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
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);

View File

@ -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();
}

View File

@ -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));

View File

@ -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();

View File

@ -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) {
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,11 +113,55 @@ 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) {
if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
FolderInfo fi = new FolderInfo();
fi.cellX = getCellXFromOrder(mAllAppsButtonRank);
@ -133,8 +188,10 @@ public class Hotseat extends FrameLayout {
}
}
}
}
void addAppsToAllAppsFolder(ArrayList<AppInfo> apps) {
if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
View v = mContent.getChildAt(getCellXFromOrder(mAllAppsButtonRank), getCellYFromOrder(mAllAppsButtonRank));
FolderIcon fi = null;
@ -150,4 +207,5 @@ public class Hotseat extends FrameLayout {
info.add(si);
}
}
}
}

View File

@ -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);
}
}
}

View File

@ -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,6 +3891,7 @@ public class Launcher extends Activity
* Implementation of the method from LauncherModel.Callbacks.
*/
public void bindAllApplications(final ArrayList<AppInfo> apps) {
if (AppsCustomizePagedView.DISABLE_ALL_APPS) {
if (mIntentsOnWorkspaceFromUpgradePath != null) {
if (LauncherModel.UPGRADE_USE_MORE_APPS_FOLDER) {
getHotseat().addAllAppsFolder(mIconCache, apps,
@ -3882,6 +3899,12 @@ public class Launcher extends Activity
}
mIntentsOnWorkspaceFromUpgradePath = null;
}
} else {
if (!AppsCustomizePagedView.DISABLE_ALL_APPS &&
mAppsCustomizeContent != null) {
mAppsCustomizeContent.setApps(apps);
}
}
}
/**
@ -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);
}
}

View File

@ -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,14 +1479,16 @@ public class LauncherModel extends BroadcastReceiver {
sBgDbIconCache.clear();
}
// Ensure that all the applications that are in the system are represented on the home
// screen.
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
// callback runnables are done.
@ -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;

View File

@ -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);
}
}

View File

@ -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;
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();

View File

@ -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 {
@ -494,11 +492,3 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
}
}
}
interface Page {
public int getPageChildCount();
public View getChildOnPageAt(int i);
public void removeAllViewsOnPage();
public void removeViewOnPageAt(int i);
public int indexOfChildOnPage(View v);
}

View File

@ -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;

View File

@ -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) {