Search in sources :

Example 1 with WidgetSizes

use of com.android.launcher3.widget.util.WidgetSizes in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetsTableUtilsTest method initTestWidgets.

private void initTestWidgets() {
    List<Point> widgetSizes = List.of(new Point(1, 1), new Point(2, 2), new Point(2, 3), new Point(2, 4), new Point(4, 4));
    ArrayList<WidgetItem> widgetItems = new ArrayList<>();
    widgetSizes.stream().forEach(widgetSize -> {
        ShadowPackageManager packageManager = shadowOf(mContext.getPackageManager());
        AppWidgetProviderInfo info = new AppWidgetProviderInfo();
        info.provider = ComponentName.createRelative(TEST_PACKAGE, ".WidgetProvider_" + widgetSize.x + "x" + widgetSize.y);
        LauncherAppWidgetProviderInfo widgetInfo = LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
        widgetInfo.spanX = widgetSize.x;
        widgetInfo.spanY = widgetSize.y;
        ReflectionHelpers.setField(widgetInfo, "providerInfo", packageManager.addReceiverIfNotPresent(widgetInfo.provider));
        widgetItems.add(new WidgetItem(widgetInfo, mTestProfile, mIconCache));
    });
    mWidget1x1 = widgetItems.get(0);
    mWidget2x2 = widgetItems.get(1);
    mWidget2x3 = widgetItems.get(2);
    mWidget2x4 = widgetItems.get(3);
    mWidget4x4 = widgetItems.get(4);
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) ArrayList(java.util.ArrayList) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) WidgetItem(com.android.launcher3.model.WidgetItem) Point(android.graphics.Point)

Aggregations

AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)1 Point (android.graphics.Point)1 WidgetItem (com.android.launcher3.model.WidgetItem)1 LauncherAppWidgetProviderInfo (com.android.launcher3.widget.LauncherAppWidgetProviderInfo)1 ArrayList (java.util.ArrayList)1 ShadowPackageManager (org.robolectric.shadows.ShadowPackageManager)1