use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by AOSPA.
the class AddItemActivity method setupWidget.
private boolean setupWidget() {
LauncherAppWidgetProviderInfo widgetInfo = LauncherAppWidgetProviderInfo.fromProviderInfo(this, mRequest.getAppWidgetProviderInfo(this));
if (widgetInfo.minSpanX > mIdp.numColumns || widgetInfo.minSpanY > mIdp.numRows) {
// Cannot add widget
return false;
}
mWidgetCell.setRemoteViewsPreview(PinItemDragListener.getPreview(mRequest));
mAppWidgetManager = new WidgetManagerHelper(this);
mAppWidgetHost = new LauncherAppWidgetHost(this);
PendingAddWidgetInfo pendingInfo = new PendingAddWidgetInfo(widgetInfo, CONTAINER_PIN_WIDGETS);
pendingInfo.spanX = Math.min(mIdp.numColumns, widgetInfo.spanX);
pendingInfo.spanY = Math.min(mIdp.numRows, widgetInfo.spanY);
mWidgetOptions = pendingInfo.getDefaultSizeOptions(this);
mWidgetCell.getWidgetView().setTag(pendingInfo);
applyWidgetItemAsync(() -> new WidgetItem(widgetInfo, mIdp, mApp.getIconCache()));
return true;
}
use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by AOSPA.
the class LauncherPreviewRenderer method inflateAndAddWidgets.
private void inflateAndAddWidgets(LauncherAppWidgetInfo info, LauncherAppWidgetProviderInfo providerInfo) {
AppWidgetHostView view;
if (FeatureFlags.WIDGETS_IN_LAUNCHER_PREVIEW.get()) {
view = mAppWidgetHost.createView(mContext, info.appWidgetId, providerInfo);
} else {
view = new NavigableAppWidgetHostView(this) {
@Override
protected boolean shouldAllowDirectClick() {
return false;
}
};
view.setAppWidget(-1, providerInfo);
view.updateAppWidget(null);
}
if (mWallpaperColorResources != null) {
view.setColorResources(mWallpaperColorResources);
}
view.setTag(info);
addInScreenFromBind(view, info);
}
use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Trebuchet by LineageOS.
the class LauncherAppWidgetHost method createView.
public AppWidgetHostView createView(Context context, int appWidgetId, LauncherAppWidgetProviderInfo appWidget) {
if (appWidget.isCustomWidget()) {
LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
lahv.setAppWidget(0, appWidget);
CustomWidgetManager.INSTANCE.get(context).onViewCreated(lahv);
return lahv;
} else if ((mFlags & FLAG_LISTENING) == 0) {
DeferredAppWidgetHostView view = new DeferredAppWidgetHostView(context);
view.setAppWidget(appWidgetId, appWidget);
mViews.put(appWidgetId, view);
return view;
} else {
try {
return super.createView(context, appWidgetId, appWidget);
} catch (Exception e) {
if (!Utilities.isBinderSizeError(e)) {
throw new RuntimeException(e);
}
// If the exception was thrown while fetching the remote views, let the view stay.
// This will ensure that if the widget posts a valid update later, the view
// will update.
LauncherAppWidgetHostView view = mViews.get(appWidgetId);
if (view == null) {
view = onCreateView(mContext, appWidgetId, appWidget);
}
view.setAppWidget(appWidgetId, appWidget);
view.switchToErrorView();
return view;
}
}
}
use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Trebuchet by LineageOS.
the class BindWidgetTest method verifyWidgetPresent.
private void verifyWidgetPresent(LauncherAppWidgetProviderInfo info) {
final Widget widget = mLauncher.getWorkspace().tryGetWidget(info.label, DEFAULT_UI_TIMEOUT);
assertTrue("Widget is not present", widget != null);
}
use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Trebuchet by LineageOS.
the class BindWidgetTest method testBindNormalWidget_withoutConfig.
@Test
public void testBindNormalWidget_withoutConfig() {
LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(this, false);
LauncherAppWidgetInfo item = createWidgetInfo(info, getTargetContext(), true);
addItemToScreen(item);
verifyWidgetPresent(info);
}
Aggregations