mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Merge "Unifying multiple all-apps implementations" into tm-qpr-dev
This commit is contained in:
@@ -27,40 +27,5 @@
|
||||
android:clipChildren="true"
|
||||
android:clipToPadding="false"
|
||||
android:focusable="false"
|
||||
android:saveEnabled="false"
|
||||
android:theme="?attr/allAppsTheme">
|
||||
|
||||
<include
|
||||
layout="@layout/all_apps_bottom_sheet_background"
|
||||
android:visibility="gone" />
|
||||
|
||||
<include
|
||||
layout="@layout/search_results_rv_layout"
|
||||
android:visibility="gone" />
|
||||
|
||||
<include
|
||||
layout="@layout/all_apps_rv_layout"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.android.launcher3.allapps.FloatingHeaderView
|
||||
android:id="@+id/all_apps_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/search_container_all_apps"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/floating_header_content" />
|
||||
|
||||
<include layout="@layout/all_apps_personal_work_tabs" />
|
||||
</com.android.launcher3.allapps.FloatingHeaderView>
|
||||
|
||||
<com.android.launcher3.taskbar.allapps.TaskbarAllAppsFallbackSearchContainer
|
||||
android:id="@+id/search_container_all_apps"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<include layout="@layout/all_apps_fast_scroller" />
|
||||
</com.android.launcher3.taskbar.allapps.TaskbarAllAppsContainerView>
|
||||
android:saveEnabled="false" />
|
||||
</com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView>
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.launcher3.taskbar.allapps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
@@ -42,6 +43,19 @@ public class TaskbarAllAppsContainerView extends
|
||||
return super.onApplyWindowInsets(insets);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View inflateSearchBox() {
|
||||
// Remove top padding of header, since we do not have any search
|
||||
mHeader.setPadding(mHeader.getPaddingLeft(), 0,
|
||||
mHeader.getPaddingRight(), mHeader.getPaddingBottom());
|
||||
|
||||
TaskbarAllAppsFallbackSearchContainer searchView =
|
||||
new TaskbarAllAppsFallbackSearchContainer(getContext(), null);
|
||||
searchView.setId(R.id.search_container_all_apps);
|
||||
searchView.setVisibility(GONE);
|
||||
return searchView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSearchSupported() {
|
||||
return false;
|
||||
@@ -53,4 +67,10 @@ public class TaskbarAllAppsContainerView extends
|
||||
// TODO(b/240670050): Remove this and add header protection for the taskbar entrypoint.
|
||||
mBottomSheetBackground.setBackgroundResource(R.drawable.bg_rounded_corner_bottom_sheet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInAllApps() {
|
||||
// All apps is always open
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@ import android.view.View;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
|
||||
import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.dot.DotInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.popup.PopupDataProvider;
|
||||
@@ -137,10 +134,4 @@ public class TaskbarOverlayContext extends BaseTaskbarContext {
|
||||
|
||||
@Override
|
||||
public void onPopupVisibilityChanged(boolean isVisible) {}
|
||||
|
||||
@Override
|
||||
public SearchAdapterProvider<?> createSearchAdapterProvider(
|
||||
ActivityAllAppsContainerView<?> appsView) {
|
||||
return new DefaultSearchAdapterProvider(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,6 @@
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="?attr/popupColorPrimary" />
|
||||
<corners android:radius="2dp" />
|
||||
<corners android:radius="@dimen/rounded_button_radius" />
|
||||
<stroke android:color="?attr/allappsHeaderProtectionColor" android:width=".5dp" />
|
||||
</shape>
|
||||
@@ -17,13 +17,9 @@
|
||||
will bake the left/right padding into that view's background itself. -->
|
||||
<com.android.launcher3.allapps.LauncherAllAppsContainerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/apps_view"
|
||||
android:theme="?attr/allAppsTheme"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="true"
|
||||
android:clipToPadding="false"
|
||||
android:focusable="false"
|
||||
android:saveEnabled="false">
|
||||
|
||||
<include layout="@layout/all_apps_content" />
|
||||
</com.android.launcher3.allapps.LauncherAllAppsContainerView>
|
||||
android:saveEnabled="false" />
|
||||
@@ -34,6 +34,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:layout_below="@id/search_container_all_apps"
|
||||
android:paddingTop="@dimen/all_apps_header_top_padding"
|
||||
android:paddingBottom="@dimen/all_apps_header_bottom_padding"
|
||||
android:orientation="vertical" >
|
||||
@@ -44,15 +45,5 @@
|
||||
|
||||
</com.android.launcher3.allapps.FloatingHeaderView>
|
||||
|
||||
<View
|
||||
android:id="@+id/search_protection"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
android:forceHasOverlappingRendering="false" />
|
||||
|
||||
<include layout="@layout/search_container_all_apps" />
|
||||
|
||||
<include layout="@layout/all_apps_fast_scroller" />
|
||||
|
||||
</merge>
|
||||
@@ -21,7 +21,6 @@
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="top|center_horizontal"
|
||||
android:background="@drawable/bg_all_apps_searchbox"
|
||||
android:elevation="1dp"
|
||||
android:focusableInTouchMode="true"
|
||||
android:gravity="center"
|
||||
android:hint="@string/all_apps_search_bar_hint"
|
||||
|
||||
@@ -42,8 +42,7 @@
|
||||
android:contentDescription="@string/all_apps_button_label"
|
||||
android:onClick="onAppsButtonClicked" />
|
||||
|
||||
<view
|
||||
class="com.android.launcher3.allapps.SecondaryLauncherAllAppsContainerView"
|
||||
<com.android.launcher3.allapps.SecondaryLauncherAllAppsContainerView
|
||||
android:id="@+id/apps_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -53,57 +52,5 @@
|
||||
android:saveEnabled="false"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:background="@drawable/round_rect_primary"
|
||||
android:visibility="invisible" >
|
||||
|
||||
<include
|
||||
layout="@layout/all_apps_bottom_sheet_background"
|
||||
android:visibility="gone" />
|
||||
|
||||
<include
|
||||
layout="@layout/search_results_rv_layout"
|
||||
android:visibility="gone" />
|
||||
|
||||
<include
|
||||
layout="@layout/all_apps_rv_layout"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.android.launcher3.allapps.FloatingHeaderView
|
||||
android:id="@+id/all_apps_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/search_container_all_apps"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="@dimen/all_apps_header_top_padding"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<include layout="@layout/floating_header_content" />
|
||||
<include layout="@layout/all_apps_personal_work_tabs" />
|
||||
</com.android.launcher3.allapps.FloatingHeaderView>
|
||||
|
||||
<com.android.launcher3.allapps.search.AppsSearchContainerLayout
|
||||
android:id="@id/search_container_all_apps"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/all_apps_search_bar_field_height"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="top|center_horizontal"
|
||||
android:layout_marginTop="24dp"
|
||||
android:background="@drawable/bg_all_apps_searchbox"
|
||||
android:elevation="1dp"
|
||||
android:focusableInTouchMode="true"
|
||||
android:gravity="center"
|
||||
android:hint="@string/all_apps_search_bar_hint"
|
||||
android:imeOptions="actionSearch|flagNoExtractUi"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="text|textNoSuggestions|textCapWords"
|
||||
android:maxLines="1"
|
||||
android:padding="8dp"
|
||||
android:saveEnabled="false"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textColorHint="@drawable/all_apps_search_hint"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<include layout="@layout/all_apps_fast_scroller" />
|
||||
</view>
|
||||
android:visibility="invisible" />
|
||||
</com.android.launcher3.secondarydisplay.SecondaryDragLayer>
|
||||
@@ -49,9 +49,6 @@
|
||||
<!-- View tag key used to determine if we should fade in the child views.. -->
|
||||
<string name="popup_container_iterate_children" translatable="false">popup_container_iterate_children</string>
|
||||
|
||||
<!-- config used to determine if header protection is supported in AllApps -->
|
||||
<bool name="config_header_protection_supported">false</bool>
|
||||
|
||||
<!-- Workspace -->
|
||||
<!-- The duration (in ms) of the fade animation on the object outlines, used when
|
||||
we are dragging objects around on the home screen. -->
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<resources>
|
||||
<!-- Launcher theme -->
|
||||
<style name="BaseLauncherTheme" parent="@android:style/Theme.DeviceDefault.Light">
|
||||
<item name="disabledIconAlpha">.54</item>
|
||||
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||
<item name="android:colorEdgeEffect">#FF757575</item>
|
||||
<item name="android:windowActionBar">false</item>
|
||||
@@ -33,7 +34,6 @@
|
||||
<item name="allAppsScrimColor">?android:attr/colorBackgroundFloating</item>
|
||||
<item name="allappsHeaderProtectionColor">@color/popup_color_tertiary_light</item>
|
||||
<item name="allAppsNavBarScrimColor">#66FFFFFF</item>
|
||||
<item name="allAppsTheme">@style/AllAppsTheme</item>
|
||||
<item name="popupColorPrimary">@color/popup_color_primary_light</item>
|
||||
<item name="popupColorSecondary">@color/popup_color_secondary_light</item>
|
||||
<item name="popupColorTertiary">@color/popup_color_tertiary_light</item>
|
||||
@@ -61,7 +61,6 @@
|
||||
<item name="iconOnlyShortcutColor">?android:attr/textColorSecondary</item>
|
||||
<item name="workProfileOverlayTextColor">#FF212121</item>
|
||||
<item name="eduHalfSheetBGColor">?android:attr/colorAccent</item>
|
||||
<item name="disabledIconAlpha">.54</item>
|
||||
<item name="workspaceAccentColor">@color/workspace_accent_color_light</item>
|
||||
<item name="dropTargetHoverTextColor">@color/workspace_text_color_dark</item>
|
||||
<item name="overviewScrimColor">@color/overview_scrim</item>
|
||||
@@ -73,14 +72,9 @@
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">#00000000</item>
|
||||
<item name="android:navigationBarColor">#00000000</item>
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<style name="LauncherTheme.DarkMainColor" parent="@style/LauncherTheme">
|
||||
<item name="disabledIconAlpha">.54</item>
|
||||
|
||||
</style>
|
||||
<style name="LauncherTheme.DarkMainColor" parent="@style/LauncherTheme" />
|
||||
|
||||
<style name="LauncherTheme.DarkText" parent="@style/LauncherTheme">
|
||||
<item name="workspaceTextColor">@color/workspace_text_color_dark</item>
|
||||
@@ -102,7 +96,6 @@
|
||||
<item name="android:colorPrimary">#FF212121</item>
|
||||
<item name="allAppsScrimColor">?android:attr/colorBackgroundFloating</item>
|
||||
<item name="allAppsNavBarScrimColor">#80000000</item>
|
||||
<item name="allAppsTheme">@style/AllAppsTheme.Dark</item>
|
||||
<item name="popupColorPrimary">@color/popup_color_primary_dark</item>
|
||||
<item name="popupColorSecondary">@color/popup_color_secondary_dark</item>
|
||||
<item name="popupColorTertiary">@color/popup_color_tertiary_dark</item>
|
||||
@@ -129,9 +122,7 @@
|
||||
<item name="preloadIconBackgroundColor">@color/preload_icon_background_color_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="LauncherTheme.Dark.DarkMainColor" parent="@style/LauncherTheme.Dark">
|
||||
<item name="disabledIconAlpha">.54</item>
|
||||
</style>
|
||||
<style name="LauncherTheme.Dark.DarkMainColor" parent="@style/LauncherTheme.Dark"/>
|
||||
|
||||
<style name="LauncherTheme.Dark.DarkText" parent="@style/LauncherTheme.Dark">
|
||||
<item name="android:colorControlHighlight">#19212121</item>
|
||||
@@ -207,14 +198,6 @@
|
||||
<item name="android:importantForAccessibility">no</item>
|
||||
</style>
|
||||
|
||||
<style name="AllAppsTheme">
|
||||
<item name="disabledIconAlpha">.54</item>
|
||||
</style>
|
||||
|
||||
<style name="AllAppsTheme.Dark">
|
||||
<item name="disabledIconAlpha">.54</item>
|
||||
</style>
|
||||
|
||||
<style name="BaseIconRoot" parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle"/>
|
||||
|
||||
<style name="BaseIconUnBounded" parent="BaseIconRoot">
|
||||
|
||||
@@ -34,9 +34,6 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
|
||||
import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.touch.ItemClickHandler;
|
||||
import com.android.launcher3.util.ActivityOptionsWrapper;
|
||||
@@ -212,16 +209,6 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
return new WindowBounds(new Rect(0, 0, mwSize.x, mwSize.y), new Rect());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns {@link SearchAdapterProvider} for build variant specific search result
|
||||
* views
|
||||
*/
|
||||
@Override
|
||||
public SearchAdapterProvider<?> createSearchAdapterProvider(
|
||||
ActivityAllAppsContainerView<?> allApps) {
|
||||
return new DefaultSearchAdapterProvider(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAppBlockedForSafeMode() {
|
||||
return mIsSafeModeEnabled;
|
||||
|
||||
@@ -30,7 +30,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
@@ -49,12 +48,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
// Used to animate Search results out and A-Z apps in, or vice-versa.
|
||||
private final SearchTransitionController mSearchTransitionController;
|
||||
|
||||
protected SearchUiManager mSearchUiManager;
|
||||
/**
|
||||
* View that defines the search box. Result is rendered inside the recycler view defined in the
|
||||
* base class.
|
||||
*/
|
||||
private View mSearchContainer;
|
||||
/** {@code true} when rendered view is in search state instead of the scroll state. */
|
||||
private boolean mIsSearching;
|
||||
private boolean mRebindAdaptersAfterSearchAnimation;
|
||||
@@ -73,6 +66,12 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
mSearchTransitionController = new SearchTransitionController(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mSearchUiManager.initializeSearch(this);
|
||||
}
|
||||
|
||||
public SearchUiManager getSearchUiManager() {
|
||||
return mSearchUiManager;
|
||||
}
|
||||
@@ -142,11 +141,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final SearchAdapterProvider<?> createMainAdapterProvider() {
|
||||
return mActivityContext.createSearchAdapterProvider(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldContainerScroll(MotionEvent ev) {
|
||||
// IF the MotionEvent is inside the search box, and the container keeps on receiving
|
||||
@@ -166,14 +160,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
animateToSearchState(false, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mSearchContainer = findViewById(R.id.search_container_all_apps);
|
||||
mSearchUiManager = (SearchUiManager) mSearchContainer;
|
||||
mSearchUiManager.initializeSearch(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
mSearchUiManager.preDispatchKeyEvent(event);
|
||||
@@ -278,18 +264,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
(int) (mSearchContainer.getAlpha() * 255));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeaderBottom() {
|
||||
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
|
||||
if (mActivityContext.getDeviceProfile().isTablet) {
|
||||
return super.getHeaderBottom() + mHeader.getClipTop()
|
||||
+ mBottomSheetBackground.getTop();
|
||||
}
|
||||
return super.getHeaderBottom() + mHeader.getClipTop();
|
||||
}
|
||||
return super.getHeaderBottom() + mSearchContainer.getBottom();
|
||||
}
|
||||
|
||||
private void layoutBelowSearchContainer(View v, boolean includeTabsMargin) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)) {
|
||||
return;
|
||||
@@ -364,4 +338,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
? R.dimen.all_apps_header_pill_height
|
||||
: R.dimen.all_apps_header_top_margin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInAllApps() {
|
||||
// TODO: Make this abstract
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ import com.android.launcher3.InsettableFrameLayout;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.keyboard.FocusedItemDecorator;
|
||||
@@ -105,7 +106,6 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
protected final List<AdapterHolder> mAH;
|
||||
protected final Predicate<ItemInfo> mPersonalMatcher = ItemInfoMatcher.ofUser(
|
||||
Process.myUserHandle());
|
||||
private final SearchAdapterProvider<?> mMainAdapterProvider;
|
||||
private final AllAppsStore mAllAppsStore = new AllAppsStore();
|
||||
|
||||
private final RecyclerView.OnScrollListener mScrollListener =
|
||||
@@ -123,11 +123,17 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
|
||||
protected AllAppsPagedView mViewPager;
|
||||
private SearchRecyclerView mSearchRecyclerView;
|
||||
private SearchAdapterProvider<?> mMainAdapterProvider;
|
||||
|
||||
protected FloatingHeaderView mHeader;
|
||||
protected View mBottomSheetBackground;
|
||||
private View mBottomSheetHandleArea;
|
||||
@Nullable private View mSearchBarProtection;
|
||||
|
||||
/**
|
||||
* View that defines the search box. Result is rendered inside {@link #mSearchRecyclerView}.
|
||||
*/
|
||||
protected View mSearchContainer;
|
||||
protected SearchUiManager mSearchUiManager;
|
||||
|
||||
protected boolean mUsingTabs;
|
||||
private boolean mHasWorkApps;
|
||||
@@ -135,7 +141,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
protected RecyclerViewFastScroller mTouchHandler;
|
||||
protected final Point mFastScrollerOffset = new Point();
|
||||
|
||||
private final int mScrimColor;
|
||||
protected final int mScrimColor;
|
||||
private final int mHeaderProtectionColor;
|
||||
protected final float mHeaderThreshold;
|
||||
private final Path mTmpPath = new Path();
|
||||
@@ -149,7 +155,6 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
protected BaseAllAppsContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mActivityContext = ActivityContext.lookupContext(context);
|
||||
mMainAdapterProvider = createMainAdapterProvider();
|
||||
|
||||
mScrimColor = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
|
||||
mHeaderThreshold = getResources().getDimensionPixelSize(
|
||||
@@ -160,19 +165,84 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
mActivityContext.getSystemService(UserManager.class),
|
||||
this, LauncherPrefs.getPrefs(mActivityContext));
|
||||
mAH = Arrays.asList(null, null, null);
|
||||
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN));
|
||||
mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
|
||||
mAH.set(AdapterHolder.SEARCH, new AdapterHolder(AdapterHolder.SEARCH));
|
||||
|
||||
mNavBarScrimPaint = new Paint();
|
||||
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
|
||||
|
||||
mAllAppsStore.addUpdateListener(this::onAppsUpdated);
|
||||
mActivityContext.addOnDeviceProfileChangeListener(this);
|
||||
|
||||
// This is a focus listener that proxies focus from a view into the list view. This is to
|
||||
// work around the search box from getting first focus and showing the cursor.
|
||||
setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if (hasFocus && getActiveRecyclerView() != null) {
|
||||
getActiveRecyclerView().requestFocus();
|
||||
}
|
||||
});
|
||||
initContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the view hierarchy and internal variables. Any initialization which actually uses
|
||||
* these members should be done in {@link #onFinishInflate()}.
|
||||
* In terms of subclass initialization, the following would be parallel order for activity:
|
||||
* initContent -> onPreCreate
|
||||
* constructor/init -> onCreate
|
||||
* onFinishInflate -> onPostCreate
|
||||
*/
|
||||
protected void initContent() {
|
||||
mMainAdapterProvider = createMainAdapterProvider();
|
||||
|
||||
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN));
|
||||
mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
|
||||
mAH.set(AdapterHolder.SEARCH, new AdapterHolder(AdapterHolder.SEARCH));
|
||||
|
||||
getLayoutInflater().inflate(R.layout.all_apps_content, this);
|
||||
mHeader = findViewById(R.id.all_apps_header);
|
||||
mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
|
||||
mBottomSheetHandleArea = findViewById(R.id.bottom_sheet_handle_area);
|
||||
mSearchRecyclerView = findViewById(R.id.search_results_list_view);
|
||||
|
||||
// Add the search box next to the header
|
||||
mSearchContainer = inflateSearchBox();
|
||||
addView(mSearchContainer, indexOfChild(mHeader) + 1);
|
||||
mSearchUiManager = (SearchUiManager) mSearchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
mAH.get(AdapterHolder.SEARCH).setup(mSearchRecyclerView,
|
||||
/* Filter out A-Z apps */ itemInfo -> false);
|
||||
rebindAdapters(true /* force */);
|
||||
float cornerRadius = Themes.getDialogCornerRadius(getContext());
|
||||
mBottomSheetCornerRadii = new float[]{
|
||||
cornerRadius,
|
||||
cornerRadius, // Top left radius in px
|
||||
cornerRadius,
|
||||
cornerRadius, // Top right radius in px
|
||||
0,
|
||||
0, // Bottom right
|
||||
0,
|
||||
0 // Bottom left
|
||||
};
|
||||
final TypedValue value = new TypedValue();
|
||||
getContext().getTheme().resolveAttribute(android.R.attr.colorBackground, value, true);
|
||||
mBottomSheetBackgroundColor = value.data;
|
||||
updateBackground(mActivityContext.getDeviceProfile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflates the search box
|
||||
*/
|
||||
protected View inflateSearchBox() {
|
||||
return getLayoutInflater().inflate(R.layout.search_container_all_apps, this, false);
|
||||
}
|
||||
|
||||
/** Creates the adapter provider for the main section. */
|
||||
protected abstract SearchAdapterProvider<?> createMainAdapterProvider();
|
||||
protected SearchAdapterProvider<?> createMainAdapterProvider() {
|
||||
return new DefaultSearchAdapterProvider(mActivityContext);
|
||||
}
|
||||
|
||||
/** The adapter provider for the main section. */
|
||||
public final SearchAdapterProvider<?> getMainAdapterProvider() {
|
||||
@@ -289,6 +359,13 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
// The AllAppsContainerView houses the QSB and is hence visible from the Workspace
|
||||
// Overview states. We shouldn't intercept for the scrubber in these cases.
|
||||
if (!isInAllApps()) {
|
||||
mTouchHandler = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
AllAppsRecyclerView rv = getActiveRecyclerView();
|
||||
if (rv != null && rv.getScrollbar() != null
|
||||
@@ -306,6 +383,10 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (!isInAllApps()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
AllAppsRecyclerView rv = getActiveRecyclerView();
|
||||
if (rv != null && rv.getScrollbar() != null
|
||||
@@ -375,11 +456,6 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
return mSearchRecyclerView;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public View getSearchBarProtection() {
|
||||
return mSearchBarProtection;
|
||||
}
|
||||
|
||||
protected boolean isPersonalTab() {
|
||||
return mViewPager == null || mViewPager.getNextPage() == 0;
|
||||
}
|
||||
@@ -414,49 +490,6 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
updateHeaderScroll(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
// This is a focus listener that proxies focus from a view into the list view. This is to
|
||||
// work around the search box from getting first focus and showing the cursor.
|
||||
setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if (hasFocus && getActiveRecyclerView() != null) {
|
||||
getActiveRecyclerView().requestFocus();
|
||||
}
|
||||
});
|
||||
|
||||
mHeader = findViewById(R.id.all_apps_header);
|
||||
mSearchBarProtection = findViewById(R.id.search_protection);
|
||||
if (mSearchBarProtection != null) {
|
||||
mSearchBarProtection.setBackgroundColor(mScrimColor);
|
||||
mSearchBarProtection.setVisibility(
|
||||
FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() ? VISIBLE : GONE);
|
||||
}
|
||||
mSearchRecyclerView = findViewById(R.id.search_results_list_view);
|
||||
mAH.get(AdapterHolder.SEARCH).setup(mSearchRecyclerView,
|
||||
/* Filter out A-Z apps */ itemInfo -> false);
|
||||
rebindAdapters(true /* force */);
|
||||
|
||||
mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
|
||||
mBottomSheetHandleArea = findViewById(R.id.bottom_sheet_handle_area);
|
||||
float cornerRadius = Themes.getDialogCornerRadius(getContext());
|
||||
mBottomSheetCornerRadii = new float[]{
|
||||
cornerRadius,
|
||||
cornerRadius, // Top left radius in px
|
||||
cornerRadius,
|
||||
cornerRadius, // Top right radius in px
|
||||
0,
|
||||
0, // Bottom right
|
||||
0,
|
||||
0 // Bottom left
|
||||
};
|
||||
final TypedValue value = new TypedValue();
|
||||
getContext().getTheme().resolveAttribute(android.R.attr.colorBackground, value, true);
|
||||
mBottomSheetBackgroundColor = value.data;
|
||||
updateBackground(mActivityContext.getDeviceProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDropCompleted(View target, DragObject d, boolean success) {}
|
||||
|
||||
@@ -781,9 +814,6 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
canvas.drawPath(mTmpPath, mHeaderPaint);
|
||||
}
|
||||
|
||||
if (!mHeader.isHeaderProtectionSupported()) {
|
||||
return;
|
||||
}
|
||||
if (DEBUG_HEADER_PROTECTION) {
|
||||
mHeaderPaint.setColor(Color.MAGENTA);
|
||||
mHeaderPaint.setAlpha(255);
|
||||
@@ -796,10 +826,6 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
}
|
||||
int bottom = getHeaderBottom();
|
||||
FloatingHeaderView headerView = getFloatingHeaderView();
|
||||
if (!mUsingTabs && !FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
|
||||
// Add protection which is otherwise added when tabs scroll up.
|
||||
bottom += headerView.getTabsAdditionalPaddingTop();
|
||||
}
|
||||
if (isTablet) {
|
||||
// Start adding header protection if search bar or tabs will attach to the top.
|
||||
if (!FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() || mUsingTabs) {
|
||||
@@ -836,7 +862,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
* redraws header protection
|
||||
*/
|
||||
public void invalidateHeader() {
|
||||
if (mScrimView != null && mHeader.isHeaderProtectionSupported()) {
|
||||
if (mScrimView != null) {
|
||||
mScrimView.invalidate();
|
||||
}
|
||||
}
|
||||
@@ -863,7 +889,14 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
BaseAdapterProvider[] adapterProviders);
|
||||
|
||||
public int getHeaderBottom() {
|
||||
return (int) getTranslationY();
|
||||
int bottom = (int) getTranslationY() + mHeader.getClipTop();
|
||||
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
|
||||
if (mActivityContext.getDeviceProfile().isTablet) {
|
||||
return bottom + mBottomSheetBackground.getTop();
|
||||
}
|
||||
return bottom;
|
||||
}
|
||||
return bottom + mHeader.getTop();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -877,6 +910,12 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
rv.addOnScrollListener(mScrollListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} the All Apps UI is currently being displayed on the target surface and
|
||||
* is interactive.
|
||||
*/
|
||||
public abstract boolean isInAllApps();
|
||||
|
||||
/** Holds a {@link BaseAllAppsAdapter} and related fields. */
|
||||
public class AdapterHolder {
|
||||
public static final int MAIN = 0;
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.android.launcher3.allapps;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.util.ArrayMap;
|
||||
@@ -85,7 +84,6 @@ public class FloatingHeaderView extends LinearLayout implements
|
||||
// These two values are necessary to ensure that the header protection is drawn correctly.
|
||||
private final int mTabsAdditionalPaddingTop;
|
||||
private final int mTabsAdditionalPaddingBottom;
|
||||
private boolean mHeaderProtectionSupported;
|
||||
|
||||
protected ViewGroup mTabLayout;
|
||||
private AllAppsRecyclerView mMainRV;
|
||||
@@ -115,7 +113,6 @@ public class FloatingHeaderView extends LinearLayout implements
|
||||
// enabled or disabled, and represent the current set of all rows.
|
||||
private FloatingHeaderRow[] mAllRows = FloatingHeaderRow.NO_ROWS;
|
||||
|
||||
|
||||
public FloatingHeaderView(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -126,15 +123,6 @@ public class FloatingHeaderView extends LinearLayout implements
|
||||
.getDimensionPixelSize(R.dimen.all_apps_header_top_adjustment);
|
||||
mTabsAdditionalPaddingBottom = context.getResources()
|
||||
.getDimensionPixelSize(R.dimen.all_apps_header_bottom_adjustment);
|
||||
mHeaderProtectionSupported = context.getResources().getBoolean(
|
||||
R.bool.config_header_protection_supported);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
mHeaderProtectionSupported = getContext().getResources().getBoolean(
|
||||
R.bool.config_header_protection_supported);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -410,10 +398,6 @@ public class FloatingHeaderView extends LinearLayout implements
|
||||
return mFloatingRowsHeight;
|
||||
}
|
||||
|
||||
int getTabsAdditionalPaddingTop() {
|
||||
return mTabsAdditionalPaddingTop;
|
||||
}
|
||||
|
||||
int getTabsAdditionalPaddingBottom() {
|
||||
return mTabsAdditionalPaddingBottom;
|
||||
}
|
||||
@@ -454,10 +438,6 @@ public class FloatingHeaderView extends LinearLayout implements
|
||||
p.y = getTop() - mCurrentRV.getTop() - ((ViewGroup) mCurrentRV.getParent()).getTop();
|
||||
}
|
||||
|
||||
public boolean isHeaderProtectionSupported() {
|
||||
return mHeaderProtectionSupported;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
@@ -483,10 +463,6 @@ public class FloatingHeaderView extends LinearLayout implements
|
||||
* Returns visible height of FloatingHeaderView contents requiring header protection
|
||||
*/
|
||||
int getPeripheralProtectionHeight() {
|
||||
if (!mHeaderProtectionSupported) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// we only want to show protection when work tab is available and header is either
|
||||
// collapsed or animating to/from collapsed state
|
||||
if (mTabsHidden || mFloatingRowsCollapsed || !mHeaderCollapsed) {
|
||||
|
||||
@@ -16,61 +16,18 @@
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.launcher3.ExtendedEditText;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
|
||||
/**
|
||||
* AllAppsContainerView with launcher specific callbacks
|
||||
*/
|
||||
public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView<Launcher> {
|
||||
|
||||
private final RecyclerView.OnScrollListener mActivityScrollListener =
|
||||
new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
int scrolledOffset = recyclerView.computeVerticalScrollOffset();
|
||||
ExtendedEditText input = mSearchUiManager.getEditText();
|
||||
if (input != null) {
|
||||
// Save the input box state on scroll down
|
||||
if (dy > 0) {
|
||||
input.saveFocusedStateAndUpdateToUnfocusedState();
|
||||
}
|
||||
|
||||
// Scroll up and scroll to top
|
||||
if (dy < 0 && scrolledOffset == 0) {
|
||||
// Show keyboard
|
||||
boolean isImeEnabledOnSwipeUp = Launcher.getLauncher(mActivityContext)
|
||||
.getSearchConfig().isImeEnabledOnSwipeUp();
|
||||
if (isImeEnabledOnSwipeUp || !TextUtils.isEmpty(input.getText())) {
|
||||
input.showKeyboard();
|
||||
}
|
||||
|
||||
// Restore state in input box
|
||||
input.restoreToFocusedState();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onInitializeRecyclerView(RecyclerView rv) {
|
||||
super.onInitializeRecyclerView(rv);
|
||||
if (FeatureFlags.SCROLL_TOP_TO_RESET.get()) {
|
||||
rv.addOnScrollListener(mActivityScrollListener);
|
||||
}
|
||||
}
|
||||
|
||||
public LauncherAllAppsContainerView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -83,26 +40,6 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView<L
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
// The AllAppsContainerView houses the QSB and is hence visible from the Workspace
|
||||
// Overview states. We shouldn't intercept for the scrubber in these cases.
|
||||
if (!mActivityContext.isInState(LauncherState.ALL_APPS)) {
|
||||
mTouchHandler = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (!mActivityContext.isInState(LauncherState.ALL_APPS)) {
|
||||
return false;
|
||||
}
|
||||
return super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNavBarScrimHeight(WindowInsets insets) {
|
||||
if (Utilities.ATLEAST_Q) {
|
||||
@@ -111,4 +48,9 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView<L
|
||||
return insets.getStableInsetBottom();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInAllApps() {
|
||||
return mActivityContext.getStateManager().isInStableState(LauncherState.ALL_APPS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ import android.view.ViewGroup;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
@@ -109,9 +107,7 @@ public class SearchTransitionController {
|
||||
}
|
||||
|
||||
mSearchToAzAnimator = ObjectAnimator.ofFloat(this, SEARCH_TO_AZ_PROGRESS, targetProgress);
|
||||
boolean inAllApps = Launcher.getLauncher(
|
||||
mAllAppsContainerView.getContext()).getStateManager().isInStableState(
|
||||
LauncherState.ALL_APPS);
|
||||
boolean inAllApps = mAllAppsContainerView.isInAllApps();
|
||||
if (!inAllApps) {
|
||||
duration = 0; // Don't want to animate when coming from QSB.
|
||||
}
|
||||
|
||||
@@ -42,4 +42,9 @@ public class SecondaryLauncherAllAppsContainerView extends
|
||||
|
||||
@Override
|
||||
protected void updateBackground(DeviceProfile deviceProfile) {}
|
||||
|
||||
@Override
|
||||
public boolean isInAllApps() {
|
||||
return mActivityContext.isAppDrawerShown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.dot.DotInfo;
|
||||
import com.android.launcher3.dragndrop.DragController;
|
||||
import com.android.launcher3.folder.FolderIcon;
|
||||
@@ -228,16 +227,6 @@ public interface ActivityContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns {@link SearchAdapterProvider} for build variant specific search result
|
||||
* views.
|
||||
*/
|
||||
@Nullable
|
||||
default SearchAdapterProvider<?> createSearchAdapterProvider(
|
||||
ActivityAllAppsContainerView<?> appsView) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the keyboard if it is visible
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user