Search support for widgets with config activity

Shows widget preview in search if widget requires config.

preview: https://drive.google.com/file/d/1q1ROu7-OUGfskDMRxXPNQMdr3T-WMMkv/view?usp=sharing
Bug: 168321831
Test: Manual
Change-Id: I6c1c168ebac4ce33a4234e8a417eba789f664f43
This commit is contained in:
Samuel Fufa
2020-11-09 19:04:43 -06:00
parent bbaf9ff6f8
commit ffd2b6d25e
4 changed files with 176 additions and 12 deletions

View File

@@ -42,7 +42,7 @@ import com.android.launcher3.views.AbstractSlideInView;
/**
* Base class for various widgets popup
*/
abstract class BaseWidgetSheet extends AbstractSlideInView
public abstract class BaseWidgetSheet extends AbstractSlideInView
implements OnClickListener, OnLongClickListener, DragSource,
PopupDataProvider.PopupDataChangeListener {
@@ -74,16 +74,7 @@ abstract class BaseWidgetSheet extends AbstractSlideInView
@Override
public final void onClick(View v) {
// Let the user know that they have to long press to add a widget
if (mWidgetInstructionToast != null) {
mWidgetInstructionToast.cancel();
}
CharSequence msg = Utilities.wrapForTts(
getContext().getText(R.string.long_press_widget_to_add),
getContext().getString(R.string.long_accessible_way_to_add));
mWidgetInstructionToast = Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT);
mWidgetInstructionToast.show();
mWidgetInstructionToast = showWidgetToast(getContext(), mWidgetInstructionToast);
}
@Override
@@ -146,4 +137,21 @@ abstract class BaseWidgetSheet extends AbstractSlideInView
protected SystemUiController getSystemUiController() {
return mLauncher.getSystemUiController();
}
/**
* Show Widget tap toast prompting user to drag instead
*/
public static Toast showWidgetToast(Context context, Toast toast) {
// Let the user know that they have to long press to add a widget
if (toast != null) {
toast.cancel();
}
CharSequence msg = Utilities.wrapForTts(
context.getText(R.string.long_press_widget_to_add),
context.getString(R.string.long_accessible_way_to_add));
toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
toast.show();
return toast;
}
}