Search in sources :

Example 6 with LauncherAppWidgetHostView

use of com.android.launcher3.widget.LauncherAppWidgetHostView 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 7 with LauncherAppWidgetHostView

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

the class QuickstepInteractionHandler method onInteraction.

@SuppressWarnings("NewApi")
@Override
public boolean onInteraction(View view, PendingIntent pendingIntent, RemoteViews.RemoteResponse remoteResponse) {
    LauncherAppWidgetHostView hostView = findHostViewAncestor(view);
    if (hostView == null) {
        Log.e(TAG, "View did not have a LauncherAppWidgetHostView ancestor.");
        return RemoteViews.startPendingIntent(hostView, pendingIntent, remoteResponse.getLaunchOptions(view));
    }
    Pair<Intent, ActivityOptions> options = remoteResponse.getLaunchOptions(view);
    ActivityOptionsWrapper activityOptions = mLauncher.getAppTransitionManager().getActivityLaunchOptions(hostView);
    if (Utilities.ATLEAST_S && !pendingIntent.isActivity()) {
        // use the Quickstep transition animation.
        try {
            ActivityTaskManager.getService().registerRemoteAnimationForNextActivityStart(pendingIntent.getCreatorPackage(), activityOptions.options.getRemoteAnimationAdapter());
        } catch (RemoteException e) {
        // Do nothing.
        }
    }
    activityOptions.options.setPendingIntentLaunchFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activityOptions.options.setSplashscreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_EMPTY);
    Object itemInfo = hostView.getTag();
    if (itemInfo instanceof ItemInfo) {
        mLauncher.addLaunchCookie((ItemInfo) itemInfo, activityOptions.options);
    }
    options = Pair.create(options.first, activityOptions.options);
    if (pendingIntent.isActivity()) {
        logAppLaunch(itemInfo);
    }
    return RemoteViews.startPendingIntent(hostView, pendingIntent, options);
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) ActivityOptionsWrapper(com.android.launcher3.util.ActivityOptionsWrapper) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RemoteException(android.os.RemoteException) ActivityOptions(android.app.ActivityOptions)

Example 8 with LauncherAppWidgetHostView

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

the class CellLayout method applyColorExtractionOnWidget.

/**
 * Applies the local color extraction to a dragging widget object.
 */
private void applyColorExtractionOnWidget(DropTarget.DragObject dragObject, int[] targetCell, int spanX, int spanY) {
    // Apply local extracted color if the DragView is an AppWidgetHostViewDrawable.
    View view = dragObject.dragView.getContentView();
    if (view instanceof LauncherAppWidgetHostView) {
        Launcher launcher = Launcher.getLauncher(dragObject.dragView.getContext());
        Workspace workspace = launcher.getWorkspace();
        int screenId = workspace.getIdForScreen(this);
        int pageId = workspace.getPageIndexForScreenId(screenId);
        cellToRect(targetCell[0], targetCell[1], spanX, spanY, mTempRect);
        // Now get the rect in drag layer coordinates.
        getBoundsForViewInDragLayer(launcher.getDragLayer(), this, mTempRect, true, mTmpFloatArray, mTempRectF);
        Utilities.setRect(mTempRectF, mTempRect);
        ((LauncherAppWidgetHostView) view).handleDrag(mTempRect, pageId);
    }
}
Also used : LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 9 with LauncherAppWidgetHostView

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

the class AppWidgetResizeFrame method showForWidget.

public static void showForWidget(LauncherAppWidgetHostView widget, CellLayout cellLayout) {
    Launcher launcher = Launcher.getLauncher(cellLayout.getContext());
    AbstractFloatingView.closeAllOpenViews(launcher);
    DragLayer dl = launcher.getDragLayer();
    AppWidgetResizeFrame frame = (AppWidgetResizeFrame) launcher.getLayoutInflater().inflate(R.layout.app_widget_resize_frame, dl, false);
    if (widget.hasEnforcedCornerRadius()) {
        float enforcedCornerRadius = widget.getEnforcedCornerRadius();
        ImageView imageView = frame.findViewById(R.id.widget_resize_frame);
        Drawable d = imageView.getDrawable();
        if (d instanceof GradientDrawable) {
            GradientDrawable gd = (GradientDrawable) d.mutate();
            gd.setCornerRadius(enforcedCornerRadius);
        }
    }
    frame.setupForWidget(widget, cellLayout, dl);
    ((DragLayer.LayoutParams) frame.getLayoutParams()).customPosition = true;
    dl.addView(frame);
    frame.mIsOpen = true;
    frame.snapToWidget(false);
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) Drawable(android.graphics.drawable.Drawable) GradientDrawable(android.graphics.drawable.GradientDrawable) ImageView(android.widget.ImageView) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 10 with LauncherAppWidgetHostView

use of com.android.launcher3.widget.LauncherAppWidgetHostView in project android_packages_apps_Launcher3 by AOSPA.

the class Workspace method updateWorkspaceWidgetsSizes.

private void updateWorkspaceWidgetsSizes() {
    int numberOfScreens = mScreenOrder.size();
    for (int i = 0; i < numberOfScreens; i++) {
        ShortcutAndWidgetContainer shortcutAndWidgetContainer = mWorkspaceScreens.get(mScreenOrder.get(i)).getShortcutsAndWidgets();
        int shortcutsAndWidgetCount = shortcutAndWidgetContainer.getChildCount();
        for (int j = 0; j < shortcutsAndWidgetCount; j++) {
            View view = shortcutAndWidgetContainer.getChildAt(j);
            if (view instanceof LauncherAppWidgetHostView && view.getTag() instanceof LauncherAppWidgetInfo) {
                LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) view.getTag();
                WidgetSizes.updateWidgetSizeRanges((LauncherAppWidgetHostView) view, mLauncher, launcherAppWidgetInfo.spanX, launcherAppWidgetInfo.spanY);
            }
        }
    }
}
Also used : LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) DraggableView(com.android.launcher3.dragndrop.DraggableView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Aggregations

LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)89 Point (android.graphics.Point)46 View (android.view.View)44 DraggableView (com.android.launcher3.dragndrop.DraggableView)34 SuppressLint (android.annotation.SuppressLint)32 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)30 Rect (android.graphics.Rect)28 DragView (com.android.launcher3.dragndrop.DragView)27 ItemInfo (com.android.launcher3.model.data.ItemInfo)26 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)25 AppWidgetHostView (android.appwidget.AppWidgetHostView)22 Drawable (android.graphics.drawable.Drawable)21 Paint (android.graphics.Paint)17 FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)15 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)14 CellLayout (com.android.launcher3.CellLayout)14 Launcher (com.android.launcher3.Launcher)12 DragLayer (com.android.launcher3.dragndrop.DragLayer)12 Thunk (com.android.launcher3.util.Thunk)12 BubbleTextView (com.android.launcher3.BubbleTextView)11