mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Merge "Check the feature flag before showing bubbles shortcut widget" into main
This commit is contained in:
@@ -42,6 +42,7 @@ import com.android.launcher3.widget.WidgetSections;
|
||||
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
|
||||
import com.android.launcher3.widget.model.WidgetsListContentEntry;
|
||||
import com.android.launcher3.widget.model.WidgetsListHeaderEntry;
|
||||
import com.android.wm.shell.Flags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -218,6 +219,7 @@ public class WidgetsModel {
|
||||
// add and update.
|
||||
mWidgetsList.putAll(rawWidgetsShortcuts.stream()
|
||||
.filter(new WidgetValidityCheck(app))
|
||||
.filter(new WidgetFlagCheck())
|
||||
.flatMap(widgetItem -> getPackageUserKeys(app.getContext(), widgetItem).stream()
|
||||
.map(key -> new Pair<>(packageItemInfoCache.getOrCreate(key), widgetItem)))
|
||||
.collect(groupingBy(pair -> pair.first, mapping(pair -> pair.second, toList()))));
|
||||
@@ -377,6 +379,21 @@ public class WidgetsModel {
|
||||
}
|
||||
}
|
||||
|
||||
private static class WidgetFlagCheck implements Predicate<WidgetItem> {
|
||||
|
||||
private static final String BUBBLES_SHORTCUT_WIDGET =
|
||||
"com.android.systemui/com.android.wm.shell.bubbles.shortcut"
|
||||
+ ".CreateBubbleShortcutActivity";
|
||||
|
||||
@Override
|
||||
public boolean test(WidgetItem widgetItem) {
|
||||
if (BUBBLES_SHORTCUT_WIDGET.equals(widgetItem.componentName.flattenToString())) {
|
||||
return Flags.enableRetrievableBubbles();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class PackageItemInfoCache {
|
||||
private final Map<PackageUserKey, PackageItemInfo> mMap = new ArrayMap<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user