private void reloadCurrentPage() { if (!LauncherApplication.isScreenLarge()) { mAppsCustomizePane.flashScrollingIndicator(true); } mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage()); mAppsCustomizePane.requestFocus(); }
public void onWindowVisible() { if (getVisibility() == VISIBLE) { mContent.setVisibility(VISIBLE); // We unload the widget previews when the UI is hidden, so need to reload pages // Load the current page synchronously, and the neighboring pages asynchronously mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true); mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage()); } }
void reset() { if (mInTransition) { // Defer to after the transition to reset mResetAfterTransition = true; } else { // Reset immediately mAppsCustomizePane.reset(); } }
@Override public void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace) { mAppsCustomizePane.onLauncherTransitionEnd(l, animated, toWorkspace); mInTransition = false; if (animated) { setLayerType(LAYER_TYPE_NONE, null); /* YUNOS BEGIN */ // ##date:2014/3/20 ##author:xindong.zxd // improve fluency that widget slide mAppsCustomizePane.setLayerType(LAYER_TYPE_NONE, null); /* YUNOS END */ } if (!toWorkspace) { // Dismiss the workspace cling l.dismissWorkspaceCling(null); /* YUNOS BEGIN */ // ##date:2013/11/27 ##author:zhangqiang.zq // remove cling // Show the all apps cling (if not already shown) // mAppsCustomizePane.showAllAppsCling(); // Make sure adjacent pages are loaded (we wait until after the transition to // prevent slowing down the animation) /* YUNOS END */ mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage()); if (!LauncherApplication.isScreenLarge()) { mAppsCustomizePane.hideScrollingIndicator(false); } // Going from Workspace -> All Apps // NOTE: We should do this at the end since we check visibility state in some of the // cling initialization/dismiss code above. setVisibilityOfSiblingsWithLowerZOrder(INVISIBLE); } }
@Override public boolean onTouchEvent(MotionEvent event) { // Allow touch events to fall through to the workspace if we are transitioning there if (mInTransition && mTransitioningToWorkspace) { return super.onTouchEvent(event); } // Intercept all touch events up to the bottom of the AppsCustomizePane so they do not fall // through to the workspace and trigger showWorkspace() if (event.getY() < mAppsCustomizePane.getBottom()) { return true; } return super.onTouchEvent(event); }
private void enableAndBuildHardwareLayer() { // isHardwareAccelerated() checks if we're attached to a window and if that // window is HW accelerated-- we were sometimes not attached to a window // and buildLayer was throwing an IllegalStateException /*YUNOS BEGIN*/ // ##date:2013/12/5 ##author:xindong.zxd // memory leak when add or delete widget on launcher if (isHardwareAccelerated()) { // Turn on hardware layers for performance setLayerType(LAYER_TYPE_HARDWARE, null); // force building the layer, so you don't get a blip early in an animation // when the layer is created layer buildLayer(); /* YUNOS BEGIN */ // ##date:2014/3/20 ##author:xindong.zxd // improve fluency that widget slide mAppsCustomizePane.setLayerType(LAYER_TYPE_HARDWARE, null); mAppsCustomizePane.buildLayer(); /* YUNOS END */ } /*YUNOS END*/ }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { boolean remeasureTabWidth = (mTabs.getLayoutParams().width <= 0); super.onMeasure(widthMeasureSpec, heightMeasureSpec); // Set the width of the tab list to the content width if (remeasureTabWidth) { int contentWidth = mAppsCustomizePane.getPageContentWidth(); if (contentWidth > 0 && mTabs.getLayoutParams().width != contentWidth) { // Set the width and show the tab bar mTabs.getLayoutParams().width = contentWidth; mRelayoutAndMakeVisible.run(); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
/* LauncherTransitionable overrides */ @Override public void onLauncherTransitionPrepare(Launcher l, boolean animated, boolean toWorkspace) { mAppsCustomizePane.onLauncherTransitionPrepare(l, animated, toWorkspace); mInTransition = true; mTransitioningToWorkspace = toWorkspace; if (toWorkspace) { // Going from All Apps -> Workspace setVisibilityOfSiblingsWithLowerZOrder(VISIBLE); // Stop the scrolling indicator - we don't want All Apps to be invalidating itself // during the transition, especially since it has a hardware layer set on it mAppsCustomizePane.cancelScrollingIndicatorAnimations(); } else { // Going from Workspace -> All Apps mContent.setVisibility(VISIBLE); // YUNOS BEGIN // ##date:2014/8/27 ##author:hongchao.ghc ##BugID:5208929 int currentPage = mAppsCustomizePane.getCurrentPage(); if (currentPage >= mAppsCustomizePane.getPageCount()) { mAppsCustomizePane.setCurrentPage(0); } // YUNOS END // Make sure the current page is loaded (we start loading the side pages after the // transition to prevent slowing down the animation) mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true); if (!LauncherApplication.isScreenLarge()) { mAppsCustomizePane.showScrollingIndicator(true); } } if (mResetAfterTransition) { mAppsCustomizePane.reset(); mResetAfterTransition = false; } }
public void onTrimMemory() { mContent.setVisibility(GONE); // Clear the widget pages of all their subviews - this will trigger the widget previews // to delete their bitmaps mAppsCustomizePane.clearAllWidgetPages(); }
private void onTabChangedEnd(AppsCustomizePagedView.ContentType type) { mAppsCustomizePane.setContentType(type); }
private void onTabChangedStart() { mAppsCustomizePane.hideScrollingIndicator(false); }
public void layout(Launcher launcher) { FrameLayout.LayoutParams lp; Resources res = launcher.getResources(); boolean hasVerticalBarLayout = isVerticalBarLayout(); // Layout the search bar space View searchBar = launcher.getSearchBar(); lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams(); if (hasVerticalBarLayout) { // Vertical search bar space lp.gravity = Gravity.TOP | Gravity.LEFT; lp.width = searchBarSpaceHeightPx; lp.height = LayoutParams.WRAP_CONTENT; LinearLayout targets = (LinearLayout) searchBar.findViewById(R.id.drag_target_bar); targets.setOrientation(LinearLayout.VERTICAL); } else { // Horizontal search bar space lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; lp.width = searchBarSpaceWidthPx; lp.height = searchBarSpaceHeightPx; } searchBar.setLayoutParams(lp); // Layout the workspace PagedView workspace = (PagedView) launcher.findViewById(R.id.workspace); lp = (FrameLayout.LayoutParams) workspace.getLayoutParams(); lp.gravity = Gravity.CENTER; int orientation = isLandscape ? CellLayout.LANDSCAPE : CellLayout.PORTRAIT; Rect padding = getWorkspacePadding(orientation); workspace.setLayoutParams(lp); workspace.setPadding(padding.left, padding.top, padding.right, padding.bottom); workspace.setPageSpacing(getWorkspacePageSpacing(orientation)); // Layout the hotseat View hotseat = launcher.findViewById(R.id.hotseat); lp = (FrameLayout.LayoutParams) hotseat.getLayoutParams(); if (hasVerticalBarLayout) { // Vertical hotseat lp.gravity = Gravity.END; lp.width = hotseatBarHeightPx; lp.height = LayoutParams.MATCH_PARENT; hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx); } else if (isTablet()) { // Pad the hotseat with the workspace padding calculated above lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; lp.height = hotseatBarHeightPx; hotseat.setPadding( edgeMarginPx + padding.left, 0, edgeMarginPx + padding.right, 2 * edgeMarginPx); } else { // For phones, layout the hotseat without any bottom margin // to ensure that we have space for the folders lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; lp.height = hotseatBarHeightPx; hotseat.findViewById(R.id.layout).setPadding(2 * edgeMarginPx, 0, 2 * edgeMarginPx, 0); } hotseat.setLayoutParams(lp); // Layout the page indicators View pageIndicator = launcher.findViewById(R.id.page_indicator); if (pageIndicator != null) { if (hasVerticalBarLayout) { // Hide the page indicators when we have vertical search/hotseat pageIndicator.setVisibility(View.GONE); } else { // Put the page indicators above the hotseat lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams(); lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; lp.width = LayoutParams.WRAP_CONTENT; lp.height = LayoutParams.WRAP_CONTENT; lp.bottomMargin = hotseatBarHeightPx; pageIndicator.setLayoutParams(lp); } } // Layout AllApps AppsCustomizeTabHost host = (AppsCustomizeTabHost) launcher.findViewById(R.id.apps_customize_pane); if (host != null) { // Center the all apps page indicator int pageIndicatorHeight = (int) (pageIndicatorHeightPx * Math.min(1f, (allAppsIconSizePx / DynamicGrid.DEFAULT_ICON_SIZE_PX))); pageIndicator = host.findViewById(R.id.apps_customize_page_indicator); if (pageIndicator != null) { LinearLayout.LayoutParams lllp = (LinearLayout.LayoutParams) pageIndicator.getLayoutParams(); lllp.width = LayoutParams.WRAP_CONTENT; lllp.height = pageIndicatorHeight; pageIndicator.setLayoutParams(lllp); } AppsCustomizePagedView pagedView = (AppsCustomizePagedView) host.findViewById(R.id.apps_customize_pane_content); FrameLayout fakePageContainer = (FrameLayout) host.findViewById(R.id.fake_page_container); FrameLayout fakePage = (FrameLayout) host.findViewById(R.id.fake_page); padding = new Rect(); if (pagedView != null) { // Constrain the dimensions of all apps so that it does not span the full width int paddingLR = (availableWidthPx - (allAppsCellWidthPx * allAppsNumCols)) / (2 * (allAppsNumCols + 1)); int paddingTB = (availableHeightPx - (allAppsCellHeightPx * allAppsNumRows)) / (2 * (allAppsNumRows + 1)); paddingLR = Math.min(paddingLR, (int) ((paddingLR + paddingTB) * 0.75f)); paddingTB = Math.min(paddingTB, (int) ((paddingLR + paddingTB) * 0.75f)); int maxAllAppsWidth = (allAppsNumCols * (allAppsCellWidthPx + 2 * paddingLR)); int gridPaddingLR = (availableWidthPx - maxAllAppsWidth) / 2; // Only adjust the side paddings on landscape phones, or tablets if ((isTablet() || isLandscape) && gridPaddingLR > (allAppsCellWidthPx / 4)) { padding.left = padding.right = gridPaddingLR; } // The icons are centered, so we can't just offset by the page indicator height // because the empty space will actually be pageIndicatorHeight + paddingTB padding.bottom = Math.max(0, pageIndicatorHeight - paddingTB); pagedView.setWidgetsPageIndicatorPadding(pageIndicatorHeight); fakePage.setBackground(res.getDrawable(R.drawable.quantum_panel)); // Horizontal padding for the whole paged view int pagedFixedViewPadding = res.getDimensionPixelSize(R.dimen.apps_customize_horizontal_padding); padding.left += pagedFixedViewPadding; padding.right += pagedFixedViewPadding; pagedView.setPadding(padding.left, padding.top, padding.right, padding.bottom); fakePageContainer.setPadding(padding.left, padding.top, padding.right, padding.bottom); } } // Layout the Overview Mode ViewGroup overviewMode = launcher.getOverviewPanel(); if (overviewMode != null) { Rect r = getOverviewModeButtonBarRect(); lp = (FrameLayout.LayoutParams) overviewMode.getLayoutParams(); lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; int visibleChildCount = getVisibleChildCount(overviewMode); int totalItemWidth = visibleChildCount * overviewModeBarItemWidthPx; int maxWidth = totalItemWidth + (visibleChildCount - 1) * overviewModeBarSpacerWidthPx; lp.width = Math.min(availableWidthPx, maxWidth); lp.height = r.height(); overviewMode.setLayoutParams(lp); if (lp.width > totalItemWidth && visibleChildCount > 1) { // We have enough space. Lets add some margin too. int margin = (lp.width - totalItemWidth) / (visibleChildCount - 1); View lastChild = null; // Set margin of all visible children except the last visible child for (int i = 0; i < visibleChildCount; i++) { if (lastChild != null) { MarginLayoutParams clp = (MarginLayoutParams) lastChild.getLayoutParams(); if (isLayoutRtl) { clp.leftMargin = margin; } else { clp.rightMargin = margin; } lastChild.setLayoutParams(clp); lastChild = null; } View thisChild = overviewMode.getChildAt(i); if (thisChild.getVisibility() != View.GONE) { lastChild = thisChild; } } } } }