Consider WidgetSections for suggestions in standalone picker

This cl address the problem for standalone picker (follow up to match
ag/27720721) to ensure widgets that aren't in section of their owning
package didn't appear in suggestions

Bug: 345520128
Test: Unit tests
Flag: EXEMPT bugfix
Change-Id: Ia0ef96c5be77db56b84c76ace498125d07f4be42
This commit is contained in:
Shamali P
2024-06-06 20:02:52 +00:00
committed by Shamali Patwa
parent 66d18b98dd
commit 77e42868da
3 changed files with 26 additions and 39 deletions

View File

@@ -43,17 +43,18 @@ import com.android.launcher3.model.WidgetPredictionsRequester;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.widget.BaseWidgetSheet;
import com.android.launcher3.widget.WidgetCell;
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
import com.android.launcher3.widget.model.WidgetsListHeaderEntry;
import com.android.launcher3.widget.model.WidgetsListContentEntry;
import com.android.launcher3.widget.picker.WidgetsFullSheet;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -240,14 +241,16 @@ public class WidgetPickerActivity extends BaseActivity {
);
bindWidgets(allWidgets);
if (mUiSurface != null) {
Map<PackageUserKey, List<WidgetItem>> allWidgetsMap = allWidgets.stream()
.filter(WidgetsListHeaderEntry.class::isInstance)
Map<ComponentKey, WidgetItem> allWidgetItems = allWidgets.stream()
.filter(entry -> entry instanceof WidgetsListContentEntry)
.flatMap(entry -> entry.mWidgets.stream())
.distinct()
.collect(Collectors.toMap(
entry -> PackageUserKey.fromPackageItemInfo(entry.mPkgItem),
entry -> entry.mWidgets)
);
widget -> new ComponentKey(widget.componentName, widget.user),
Function.identity()
));
mWidgetPredictionsRequester = new WidgetPredictionsRequester(app.getContext(),
mUiSurface, allWidgetsMap);
mUiSurface, allWidgetItems);
mWidgetPredictionsRequester.request(mAddedWidgets, this::bindRecommendedWidgets);
}
});