Search in sources :

Example 36 with LauncherAppWidgetInfo

use of com.android.launcher3.model.data.LauncherAppWidgetInfo in project android_packages_apps_Trebuchet by LineageOS.

the class LauncherAccessibilityDelegate method getSupportedResizeActions.

private IntArray getSupportedResizeActions(View host, LauncherAppWidgetInfo info) {
    IntArray actions = new IntArray();
    AppWidgetProviderInfo providerInfo = ((LauncherAppWidgetHostView) host).getAppWidgetInfo();
    if (providerInfo == null) {
        return actions;
    }
    CellLayout layout = (CellLayout) host.getParent().getParent();
    if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0) {
        if (layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY) || layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) {
            actions.add(R.string.action_increase_width);
        }
        if (info.spanX > info.minSpanX && info.spanX > 1) {
            actions.add(R.string.action_decrease_width);
        }
    }
    if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0) {
        if (layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1) || layout.isRegionVacant(info.cellX, info.cellY - 1, info.spanX, 1)) {
            actions.add(R.string.action_increase_height);
        }
        if (info.spanY > info.minSpanY && info.spanY > 1) {
            actions.add(R.string.action_decrease_height);
        }
    }
    return actions;
}
Also used : IntArray(com.android.launcher3.util.IntArray) CellLayout(com.android.launcher3.CellLayout) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

Example 37 with LauncherAppWidgetInfo

use of com.android.launcher3.model.data.LauncherAppWidgetInfo 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);
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.LauncherAppWidgetProviderInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 38 with LauncherAppWidgetInfo

use of com.android.launcher3.model.data.LauncherAppWidgetInfo in project android_packages_apps_Trebuchet by LineageOS.

the class BindWidgetTest method testPendingWidget_autoRestored.

@Test
public void testPendingWidget_autoRestored() {
    // A non-restored widget with no config screen gets restored automatically.
    LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(this, false);
    // Do not bind the widget
    LauncherAppWidgetInfo item = createWidgetInfo(info, getTargetContext(), false);
    item.restoreStatus = LauncherAppWidgetInfo.FLAG_ID_NOT_VALID;
    addItemToScreen(item);
    verifyWidgetPresent(info);
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.LauncherAppWidgetProviderInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 39 with LauncherAppWidgetInfo

use of com.android.launcher3.model.data.LauncherAppWidgetInfo in project android_packages_apps_Trebuchet by LineageOS.

the class BindWidgetTest method testPendingWidget_withConfigScreen.

@Test
public void testPendingWidget_withConfigScreen() {
    // A non-restored widget with config screen get bound and shows a 'Click to setup' UI.
    LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(this, true);
    // Do not bind the widget
    LauncherAppWidgetInfo item = createWidgetInfo(info, getTargetContext(), false);
    item.restoreStatus = LauncherAppWidgetInfo.FLAG_ID_NOT_VALID;
    addItemToScreen(item);
    verifyPendingWidgetPresent();
    // Item deleted from db
    mCursor = mResolver.query(LauncherSettings.Favorites.getContentUri(item.id), null, null, null, null, null);
    mCursor.moveToNext();
    // Widget has a valid Id now.
    assertEquals(0, mCursor.getInt(mCursor.getColumnIndex(LauncherSettings.Favorites.RESTORED)) & LauncherAppWidgetInfo.FLAG_ID_NOT_VALID);
    assertNotNull(AppWidgetManager.getInstance(mTargetContext).getAppWidgetInfo(mCursor.getInt(mCursor.getColumnIndex(LauncherSettings.Favorites.APPWIDGET_ID))));
    // send OPTION_APPWIDGET_RESTORE_COMPLETED
    int appWidgetId = mCursor.getInt(mCursor.getColumnIndex(LauncherSettings.Favorites.APPWIDGET_ID));
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mTargetContext);
    Bundle b = new Bundle();
    b.putBoolean(WidgetManagerHelper.WIDGET_OPTION_RESTORE_COMPLETED, true);
    RemoteViews remoteViews = new RemoteViews(mTargetPackage, R.layout.appwidget_not_ready);
    appWidgetManager.updateAppWidgetOptions(appWidgetId, b);
    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
    // verify changes are reflected
    waitForLauncherCondition("App widget options did not update", l -> appWidgetManager.getAppWidgetOptions(appWidgetId).getBoolean(WidgetManagerHelper.WIDGET_OPTION_RESTORE_COMPLETED));
    executeOnLauncher(l -> l.getAppWidgetHost().startListening());
    verifyWidgetPresent(info);
    assertNull(mLauncher.getWorkspace().tryGetPendingWidget(DEFAULT_UI_TIMEOUT));
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.LauncherAppWidgetProviderInfo) RemoteViews(android.widget.RemoteViews) Bundle(android.os.Bundle) AppWidgetManager(android.appwidget.AppWidgetManager) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 40 with LauncherAppWidgetInfo

use of com.android.launcher3.model.data.LauncherAppWidgetInfo in project android_packages_apps_Trebuchet by LineageOS.

the class BindWidgetTest method testBindNormalWidget_withConfig.

@Test
public void testBindNormalWidget_withConfig() {
    LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(this, true);
    LauncherAppWidgetInfo item = createWidgetInfo(info, getTargetContext(), true);
    addItemToScreen(item);
    verifyWidgetPresent(info);
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.LauncherAppWidgetProviderInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Aggregations

LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)201 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)73 LargeTest (androidx.test.filters.LargeTest)70 AbstractLauncherUiTest (com.android.launcher3.ui.AbstractLauncherUiTest)70 Test (org.junit.Test)70 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)68 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)61 ItemInfo (com.android.launcher3.model.data.ItemInfo)56 LauncherAppWidgetProviderInfo (com.android.launcher3.widget.LauncherAppWidgetProviderInfo)55 ArrayList (java.util.ArrayList)54 AppWidgetHostView (android.appwidget.AppWidgetHostView)53 View (android.view.View)50 FolderInfo (com.android.launcher3.model.data.FolderInfo)48 DragView (com.android.launcher3.dragndrop.DragView)41 HashSet (java.util.HashSet)38 AppInfo (com.android.launcher3.model.data.AppInfo)37 ComponentName (android.content.ComponentName)33 IntArray (com.android.launcher3.util.IntArray)31 Point (android.graphics.Point)30 Bundle (android.os.Bundle)30