use of com.android.launcher3.widget.WidgetsFullSheet in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherUIScrollTest method testWidgetsListScroll.
@Test
public void testWidgetsListScroll() throws Exception {
// Install 100 widgets
for (int i = 0; i < 100; i++) {
mModelHelper.installCustomShortcut(TEST_PACKAGE + i, "shortcutProvider");
}
// Bind and open widgets
Launcher launcher = loadLauncher();
WidgetsFullSheet widgets = WidgetsFullSheet.show(launcher, false);
doLayout(launcher);
int currentScroll = widgets.getRecyclerView().getCurrentScrollY();
launcher.dispatchGenericMotionEvent(createScrollEvent(-1));
int newScroll = widgets.getRecyclerView().getCurrentScrollY();
assertNotEquals("Widgets was not scrolled", currentScroll, newScroll);
assertEquals("Workspace was scrolled", 0, launcher.getWorkspace().getNextPage());
}
use of com.android.launcher3.widget.WidgetsFullSheet in project android_packages_apps_Trebuchet by LineageOS.
the class LauncherUIScrollTest method testWidgetsListScroll.
@Test
public void testWidgetsListScroll() throws Exception {
// Install 100 widgets
for (int i = 0; i < 100; i++) {
mModelHelper.installCustomShortcut(TEST_PACKAGE + i, "shortcutProvider");
}
// Bind and open widgets
Launcher launcher = loadLauncher();
WidgetsFullSheet widgets = WidgetsFullSheet.show(launcher, false);
doLayout(launcher);
int currentScroll = widgets.getRecyclerView().getCurrentScrollY();
launcher.dispatchGenericMotionEvent(createScrollEvent(-1));
int newScroll = widgets.getRecyclerView().getCurrentScrollY();
assertNotEquals("Widgets was not scrolled", currentScroll, newScroll);
assertEquals("Workspace was scrolled", 0, launcher.getWorkspace().getNextPage());
}
use of com.android.launcher3.widget.WidgetsFullSheet in project android_packages_apps_Launcher3 by crdroidandroid.
the class SearchAndRecommendationsScrollController method updateMarginAndPadding.
/**
* Updates the margin and padding of {@link WidgetsFullSheet} to accumulate collapsible views.
*
* @return {@code true} if margins or/and padding of views in the search and recommendations
* container have been updated.
*/
public boolean updateMarginAndPadding() {
boolean hasMarginOrPaddingUpdated = false;
mCollapsibleHeightForSearch = measureHeightWithVerticalMargins(mViewHolder.mHeaderTitle);
mCollapsibleHeightForRecommendation = measureHeightWithVerticalMargins(mViewHolder.mHeaderTitle) + measureHeightWithVerticalMargins(mViewHolder.mCollapseHandle) + measureHeightWithVerticalMargins((View) mViewHolder.mSearchBarContainer) + measureHeightWithVerticalMargins(mViewHolder.mRecommendedWidgetsTable);
int topContainerHeight = measureHeightWithVerticalMargins(mViewHolder.mContainer);
int noWidgetsViewHeight = topContainerHeight - mBottomInset;
if (mHasWorkProfile) {
mCollapsibleHeightForTabs = measureHeightWithVerticalMargins(mViewHolder.mHeaderTitle) + measureHeightWithVerticalMargins(mViewHolder.mRecommendedWidgetsTable);
// In a work profile setup, the full widget sheet contains the following views:
// ------- (pinned) -|
// Widgets (collapsible) -|---> LinearLayout for search & recommendations
// Search bar (pinned) -|
// Widgets recommendation (collapsible)-|
// Personal | Work (pinned)
// View Pager
//
// Views after the search & recommendations are not bound by RelativelyLayout param.
// To position them on the expected location, padding & margin are added to these views
// Tabs should have a padding of the height of the search & recommendations container.
RelativeLayout.LayoutParams tabsLayoutParams = (RelativeLayout.LayoutParams) mPrimaryWorkTabsView.getLayoutParams();
tabsLayoutParams.topMargin = topContainerHeight;
mPrimaryWorkTabsView.setLayoutParams(tabsLayoutParams);
// Instead of setting the top offset directly, we split the top offset into two values:
// 1. topOffsetAfterAllViewsCollapsed: this is the top offset after all collapsible
// views are no longer visible on the screen.
// This value is set as the margin for the view pager.
// 2. mMaxCollapsibleDistance
// This value is set as the padding for the recycler views in order to work with
// clipToPadding="false", which is an attribute for not showing top / bottom padding
// when a recycler view has not reached the top or bottom of the list.
// e.g. a list of 10 entries, only 3 entries are visible at a time.
// case 1: recycler view is scrolled to the top. Top padding is visible/
// (top padding)
// item 1
// item 2
// item 3
//
// case 2: recycler view is scrolled to the middle. No padding is visible.
// item 4
// item 5
// item 6
//
// case 3: recycler view is scrolled to the end. bottom padding is visible.
// item 8
// item 9
// item 10
// (bottom padding): not set in this case.
//
// When the views are first inflated, the sum of topOffsetAfterAllViewsCollapsed and
// mMaxCollapsibleDistance should equal to the top container height.
int topOffsetAfterAllViewsCollapsed = topContainerHeight + mTabsHeight - mCollapsibleHeightForTabs;
if (mPrimaryWorkTabsView.getVisibility() == View.VISIBLE) {
noWidgetsViewHeight += mTabsHeight;
}
RelativeLayout.LayoutParams viewPagerLayoutParams = (RelativeLayout.LayoutParams) mPrimaryWorkViewPager.getLayoutParams();
if (viewPagerLayoutParams.topMargin != topOffsetAfterAllViewsCollapsed) {
viewPagerLayoutParams.topMargin = topOffsetAfterAllViewsCollapsed;
mPrimaryWorkViewPager.setLayoutParams(viewPagerLayoutParams);
hasMarginOrPaddingUpdated = true;
}
if (mPrimaryRecyclerView.getPaddingTop() != mCollapsibleHeightForTabs) {
mPrimaryRecyclerView.setPadding(mPrimaryRecyclerView.getPaddingLeft(), mCollapsibleHeightForTabs, mPrimaryRecyclerView.getPaddingRight(), mPrimaryRecyclerView.getPaddingBottom());
hasMarginOrPaddingUpdated = true;
}
if (mWorkRecyclerView.getPaddingTop() != mCollapsibleHeightForTabs) {
mWorkRecyclerView.setPadding(mWorkRecyclerView.getPaddingLeft(), mCollapsibleHeightForTabs, mWorkRecyclerView.getPaddingRight(), mWorkRecyclerView.getPaddingBottom());
hasMarginOrPaddingUpdated = true;
}
} else {
if (mPrimaryRecyclerView.getPaddingTop() != topContainerHeight) {
mPrimaryRecyclerView.setPadding(mPrimaryRecyclerView.getPaddingLeft(), topContainerHeight, mPrimaryRecyclerView.getPaddingRight(), mPrimaryRecyclerView.getPaddingBottom());
hasMarginOrPaddingUpdated = true;
}
}
if (mSearchRecyclerView.getPaddingTop() != topContainerHeight) {
mSearchRecyclerView.setPadding(mSearchRecyclerView.getPaddingLeft(), topContainerHeight, mSearchRecyclerView.getPaddingRight(), mSearchRecyclerView.getPaddingBottom());
hasMarginOrPaddingUpdated = true;
}
if (mNoWidgetsView.getPaddingTop() != noWidgetsViewHeight) {
mNoWidgetsView.setPadding(mNoWidgetsView.getPaddingLeft(), noWidgetsViewHeight, mNoWidgetsView.getPaddingRight(), mNoWidgetsView.getPaddingBottom());
hasMarginOrPaddingUpdated = true;
}
return hasMarginOrPaddingUpdated;
}
Aggregations