Search in sources :

Example 11 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.

the class Launcher method startBinding.

/**
 * Refreshes the shortcuts shown on the workspace.
 *
 * Implementation of the method from LauncherModel.Callbacks.
 */
public void startBinding() {
    Object traceToken = TraceHelper.INSTANCE.beginSection("startBinding");
    // Floating panels (except the full widget sheet) are associated with individual icons. If
    // we are starting a fresh bind, close all such panels as all the icons are about
    // to go away.
    AbstractFloatingView.closeOpenViews(this, true, TYPE_ALL & ~TYPE_REBIND_SAFE);
    setWorkspaceLoading(true);
    // Clear the workspace because it's going to be rebound
    mDragController.cancelDrag();
    mWorkspace.clearDropTargets();
    mWorkspace.removeAllWorkspaceScreens();
    mAppWidgetHost.clearViews();
    if (mHotseat != null) {
        mHotseat.resetLayout(getDeviceProfile().isVerticalBarLayout());
    }
    TraceHelper.INSTANCE.endSection(traceToken);
}
Also used : DragObject(com.android.launcher3.DropTarget.DragObject)

Example 12 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.

the class Launcher method completeRestoreAppWidget.

/**
 * Restores a pending widget.
 *
 * @param appWidgetId The app widget id
 */
private LauncherAppWidgetInfo completeRestoreAppWidget(int appWidgetId, int finalRestoreFlag) {
    LauncherAppWidgetHostView view = mWorkspace.getWidgetForAppWidgetId(appWidgetId);
    if ((view == null) || !(view instanceof PendingAppWidgetHostView)) {
        Log.e(TAG, "Widget update called, when the widget no longer exists.");
        return null;
    }
    LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag();
    info.restoreStatus = finalRestoreFlag;
    if (info.restoreStatus == LauncherAppWidgetInfo.RESTORE_COMPLETED) {
        info.pendingItemInfo = null;
    }
    if (((PendingAppWidgetHostView) view).isReinflateIfNeeded()) {
        view.reInflate();
    }
    getModelWriter().updateItemInDatabase(info);
    return info;
}
Also used : LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView)

Example 13 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.

the class SecondaryDropTarget method getReconfigurableWidgetId.

/**
 * Verifies that the view is an reconfigurable widget and returns the corresponding widget Id,
 * otherwise return {@code INVALID_APPWIDGET_ID}
 */
private int getReconfigurableWidgetId(View view) {
    if (!(view instanceof AppWidgetHostView)) {
        return INVALID_APPWIDGET_ID;
    }
    AppWidgetHostView hostView = (AppWidgetHostView) view;
    AppWidgetProviderInfo widgetInfo = hostView.getAppWidgetInfo();
    if (widgetInfo == null || widgetInfo.configure == null) {
        return INVALID_APPWIDGET_ID;
    }
    if ((LauncherAppWidgetProviderInfo.fromProviderInfo(getContext(), widgetInfo).getWidgetFeatures() & WIDGET_FEATURE_RECONFIGURABLE) == 0) {
        return INVALID_APPWIDGET_ID;
    }
    return hostView.getAppWidgetId();
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo)

Example 14 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.

the class ShortcutAndWidgetContainer method layoutChild.

/**
 * Core logic to layout a child for this ViewGroup.
 */
public void layoutChild(View child) {
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
    if (child instanceof NavigableAppWidgetHostView) {
        NavigableAppWidgetHostView nahv = (NavigableAppWidgetHostView) child;
        // Scale and center the widget to fit within its cells.
        DeviceProfile profile = mActivity.getDeviceProfile();
        float scaleX = profile.appWidgetScale.x;
        float scaleY = profile.appWidgetScale.y;
        nahv.setScaleToFit(Math.min(scaleX, scaleY));
        nahv.setTranslationForCentering(-(lp.width - (lp.width * scaleX)) / 2.0f, -(lp.height - (lp.height * scaleY)) / 2.0f);
    }
    int childLeft = lp.x;
    int childTop = lp.y;
    child.layout(childLeft, childTop, childLeft + lp.width, childTop + lp.height);
    if (lp.dropped) {
        lp.dropped = false;
        final int[] cellXY = mTmpCellXY;
        getLocationOnScreen(cellXY);
        mWallpaperManager.sendWallpaperCommand(getWindowToken(), WallpaperManager.COMMAND_DROP, cellXY[0] + childLeft + lp.width / 2, cellXY[1] + childTop + lp.height / 2, 0, null);
    }
}
Also used : NavigableAppWidgetHostView(com.android.launcher3.widget.NavigableAppWidgetHostView)

Example 15 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by crdroidandroid.

the class AppsSearchContainerLayout method onLayout.

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);
    // Shift the widget horizontally so that its centered in the parent (b/63428078)
    View parent = (View) getParent();
    int availableWidth = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight();
    int myWidth = right - left;
    int expectedLeft = parent.getPaddingLeft() + (availableWidth - myWidth) / 2;
    int shift = expectedLeft - left;
    setTranslationX(shift);
    offsetTopAndBottom(mContentOverlap);
}
Also used : View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView)

Aggregations

LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)105 Test (org.junit.Test)87 LauncherAppWidgetProviderInfo (com.android.launcher3.widget.LauncherAppWidgetProviderInfo)71 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)66 Point (android.graphics.Point)62 ArrayList (java.util.ArrayList)60 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)56 View (android.view.View)55 LargeTest (androidx.test.filters.LargeTest)55 ComponentName (android.content.ComponentName)53 AppWidgetHostView (android.appwidget.AppWidgetHostView)52 Bundle (android.os.Bundle)50 WidgetItem (com.android.launcher3.model.WidgetItem)49 AbstractLauncherUiTest (com.android.launcher3.ui.AbstractLauncherUiTest)49 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)47 ItemInfo (com.android.launcher3.model.data.ItemInfo)44 PackageUserKey (com.android.launcher3.util.PackageUserKey)41 PendingAddWidgetInfo (com.android.launcher3.widget.PendingAddWidgetInfo)41 Context (android.content.Context)31 WidgetManagerHelper (com.android.launcher3.widget.WidgetManagerHelper)31