Update the title and description provided by intent params.

Bug: 347288851
Flag: EXEMPT flagged in sys ui
Test: Manual (automated covered in b/339716822)
Change-Id: I71f21bc48fd03dbbe2b3804b7fcade5940606917
This commit is contained in:
Shamali P
2024-07-02 22:22:48 +00:00
parent 10923a2985
commit 96ebf67b9f
9 changed files with 80 additions and 17 deletions

View File

@@ -44,7 +44,6 @@ import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.popup.PopupDataProvider;
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.WidgetsListContentEntry;
@@ -80,6 +79,15 @@ public class WidgetPickerActivity extends BaseActivity {
* <p>This allows widget picker to exclude existing widgets from suggestions.</p>
*/
private static final String EXTRA_ADDED_APP_WIDGETS = "added_app_widgets";
/**
* Intent extra for the string representing the title displayed within the picker header.
*/
private static final String EXTRA_PICKER_TITLE = "picker_title";
/**
* Intent extra for the string representing the description displayed within the picker header.
*/
private static final String EXTRA_PICKER_DESCRIPTION = "picker_description";
/**
* A unique identifier of the surface hosting the widgets;
* <p>"widgets" is reserved for home screen surface.</p>
@@ -108,6 +116,10 @@ public class WidgetPickerActivity extends BaseActivity {
// Widgets existing on the host surface.
@NonNull
private List<AppWidgetProviderInfo> mAddedWidgets = new ArrayList<>();
@Nullable
private String mTitle;
@Nullable
private String mDescription;
/** A set of user ids that should be filtered out from the selected widgets. */
@NonNull
@@ -137,6 +149,9 @@ public class WidgetPickerActivity extends BaseActivity {
}
private void parseIntentExtras() {
mTitle = getIntent().getStringExtra(EXTRA_PICKER_TITLE);
mDescription = getIntent().getStringExtra(EXTRA_PICKER_DESCRIPTION);
// A value of 0 for either size means that no filtering will occur in that dimension. If
// both values are 0, then no size filtering will occur.
mDesiredWidgetWidth =
@@ -241,7 +256,7 @@ public class WidgetPickerActivity extends BaseActivity {
/** Updates the model with widgets, applies filters and launches the widgets sheet once
* widgets are available */
private void refreshAndBindWidgets() {
MODEL_EXECUTOR.getHandler().postDelayed(() -> {
MODEL_EXECUTOR.execute(() -> {
LauncherAppState app = LauncherAppState.getInstance(this);
mModel.update(app, null);
final List<WidgetsListBaseEntry> allWidgets =
@@ -271,7 +286,7 @@ public class WidgetPickerActivity extends BaseActivity {
mUiSurface, allWidgetItems);
mWidgetPredictionsRequester.request(mAddedWidgets, this::bindRecommendedWidgets);
}
}, mDeviceProfile.bottomSheetOpenDuration);
});
}
private void bindWidgets(List<WidgetsListBaseEntry> widgets) {
@@ -280,7 +295,8 @@ public class WidgetPickerActivity extends BaseActivity {
private void openWidgetsSheet() {
MAIN_EXECUTOR.execute(() -> {
BaseWidgetSheet widgetSheet = WidgetsFullSheet.show(this, true);
WidgetsFullSheet widgetSheet = WidgetsFullSheet.show(this, true);
widgetSheet.mayUpdateTitleAndDescription(mTitle, mDescription);
widgetSheet.disableNavBarScrim(true);
widgetSheet.addOnCloseListener(this::finish);
});