diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index fc8465d59d..1b58987500 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -95,6 +95,7 @@ import com.android.launcher3.views.RecyclerViewFastScroller; import com.android.launcher3.views.ScrimView; import com.android.launcher3.views.SpringRelativeLayout; import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip; +import com.android.systemui.plugins.AllAppsRow; import java.util.ArrayList; import java.util.Arrays; @@ -152,6 +153,7 @@ public class ActivityAllAppsContainerView private final RectF mTmpRectF = new RectF(); protected AllAppsPagedView mViewPager; protected FloatingHeaderView mHeader; + protected final List mAdditionalHeaderRows = new ArrayList<>(); protected View mBottomSheetBackground; protected RecyclerViewFastScroller mFastScroller; private ConstraintLayout mFastScrollLetterLayout; @@ -262,6 +264,8 @@ public class ActivityAllAppsContainerView getLayoutInflater().inflate(R.layout.all_apps_content, this); mHeader = findViewById(R.id.all_apps_header); + mAdditionalHeaderRows.clear(); + mAdditionalHeaderRows.addAll(getAdditionalHeaderRows()); mBottomSheetBackground = findViewById(R.id.bottom_sheet_background); mBottomSheetHandleArea = findViewById(R.id.bottom_sheet_handle_area); mSearchRecyclerView = findViewById(R.id.search_results_list_view); @@ -288,6 +292,10 @@ public class ActivityAllAppsContainerView mSearchUiManager = (SearchUiManager) mSearchContainer; } + public List getAdditionalHeaderRows() { + return List.of(); + } + @Override protected void onFinishInflate() { super.onFinishInflate(); @@ -714,6 +722,8 @@ public class ActivityAllAppsContainerView } void setupHeader() { + mAdditionalHeaderRows.forEach(row -> mHeader.onPluginDisconnected(row)); + mHeader.setVisibility(View.VISIBLE); boolean tabsHidden = !mUsingTabs; mHeader.setup( @@ -731,6 +741,7 @@ public class ActivityAllAppsContainerView adapterHolder.mRecyclerView.scrollToTop(); } }); + mAdditionalHeaderRows.forEach(row -> mHeader.onPluginConnected(row, mActivityContext)); removeCustomRules(mHeader); if (isSearchBarFloating()) { diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java index ac06ab40e0..81935119ef 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderView.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.allapps; +import static com.android.launcher3.allapps.FloatingHeaderRow.NO_ROWS; + import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Point; @@ -109,11 +111,11 @@ public class FloatingHeaderView extends LinearLayout implements // This is initialized once during inflation and stays constant after that. Fixed views // cannot be added or removed dynamically. - private FloatingHeaderRow[] mFixedRows = FloatingHeaderRow.NO_ROWS; + private FloatingHeaderRow[] mFixedRows = NO_ROWS; // Array of all fixed rows and plugin rows. This is initialized every time a plugin is // enabled or disabled, and represent the current set of all rows. - private FloatingHeaderRow[] mAllRows = FloatingHeaderRow.NO_ROWS; + private FloatingHeaderRow[] mAllRows = NO_ROWS; public FloatingHeaderView(@NonNull Context context) { this(context, null); @@ -180,6 +182,10 @@ public class FloatingHeaderView extends LinearLayout implements @Override public void onPluginConnected(AllAppsRow allAppsRowPlugin, Context context) { + if (mPluginRows.containsKey(allAppsRowPlugin)) { + // Plugin has already been connected + return; + } PluginHeaderRow headerRow = new PluginHeaderRow(allAppsRowPlugin, this); addView(headerRow.mView, indexOfChild(mTabLayout)); mPluginRows.put(allAppsRowPlugin, headerRow); @@ -211,6 +217,9 @@ public class FloatingHeaderView extends LinearLayout implements @Override public void onPluginDisconnected(AllAppsRow plugin) { PluginHeaderRow row = mPluginRows.get(plugin); + if (row == null) { + return; + } removeView(row.mView); mPluginRows.remove(plugin); recreateAllRowsArray();