Search in sources :

Example 56 with Workspace

use of com.android.launcher3.tapl.Workspace in project android_packages_apps_Launcher3 by AOSPA.

the class Launcher method dump.

/**
 * $ adb shell dumpsys activity com.android.launcher3.Launcher [--all]
 */
@Override
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
    super.dump(prefix, fd, writer, args);
    if (args.length > 0 && TextUtils.equals(args[0], "--all")) {
        writer.println(prefix + "Workspace Items");
        for (int i = 0; i < mWorkspace.getPageCount(); i++) {
            writer.println(prefix + "  Homescreen " + i);
            ViewGroup layout = ((CellLayout) mWorkspace.getPageAt(i)).getShortcutsAndWidgets();
            for (int j = 0; j < layout.getChildCount(); j++) {
                Object tag = layout.getChildAt(j).getTag();
                if (tag != null) {
                    writer.println(prefix + "    " + tag.toString());
                }
            }
        }
        writer.println(prefix + "  Hotseat");
        ViewGroup layout = mHotseat.getShortcutsAndWidgets();
        for (int j = 0; j < layout.getChildCount(); j++) {
            Object tag = layout.getChildAt(j).getTag();
            if (tag != null) {
                writer.println(prefix + "    " + tag.toString());
            }
        }
    }
    writer.println(prefix + "Misc:");
    dumpMisc(prefix + "\t", writer);
    writer.println(prefix + "\tmWorkspaceLoading=" + mWorkspaceLoading);
    writer.println(prefix + "\tmPendingRequestArgs=" + mPendingRequestArgs + " mPendingActivityResult=" + mPendingActivityResult);
    writer.println(prefix + "\tmRotationHelper: " + mRotationHelper);
    writer.println(prefix + "\tmAppWidgetHost.isListening: " + mAppWidgetHost.isListening());
    // Extra logging for general debugging
    mDragLayer.dump(prefix, writer);
    mStateManager.dump(prefix, writer);
    mPopupDataProvider.dump(prefix, writer);
    mDeviceProfile.dump(prefix, writer);
    try {
        FileLog.flushAll(writer);
    } catch (Exception e) {
    // Ignore
    }
    mModel.dumpState(prefix, fd, writer, args);
    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.dump(prefix, fd, writer, args);
    }
    mOverlayManager.dump(prefix, writer);
}
Also used : ViewGroup(android.view.ViewGroup) DragObject(com.android.launcher3.DropTarget.DragObject) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 57 with Workspace

use of com.android.launcher3.tapl.Workspace in project android_packages_apps_Launcher3 by AOSPA.

the class Launcher method handleActivityResult.

private void handleActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (isWorkspaceLoading()) {
        // process the result once the workspace has loaded.
        mPendingActivityResult = new ActivityResultInfo(requestCode, resultCode, data);
        return;
    }
    mPendingActivityResult = null;
    // Reset the startActivity waiting flag
    final PendingRequestArgs requestArgs = mPendingRequestArgs;
    setWaitingForResult(null);
    if (requestArgs == null) {
        return;
    }
    final int pendingAddWidgetId = requestArgs.getWidgetId();
    Runnable exitSpringLoaded = new Runnable() {

        @Override
        public void run() {
            mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
        }
    };
    if (requestCode == REQUEST_BIND_APPWIDGET) {
        // This is called only if the user did not previously have permissions to bind widgets
        final int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;
        if (resultCode == RESULT_CANCELED) {
            completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId, requestArgs);
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, exitSpringLoaded);
        } else if (resultCode == RESULT_OK) {
            addAppWidgetImpl(appWidgetId, requestArgs, null, requestArgs.getWidgetHandler(), ON_ACTIVITY_RESULT_ANIMATION_DELAY);
        }
        return;
    }
    boolean isWidgetDrop = (requestCode == REQUEST_PICK_APPWIDGET || requestCode == REQUEST_CREATE_APPWIDGET);
    // We have special handling for widgets
    if (isWidgetDrop) {
        final int appWidgetId;
        int widgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;
        if (widgetId < 0) {
            appWidgetId = pendingAddWidgetId;
        } else {
            appWidgetId = widgetId;
        }
        final int result;
        if (appWidgetId < 0 || resultCode == RESULT_CANCELED) {
            Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not " + "returned from the widget configuration activity.");
            result = RESULT_CANCELED;
            completeTwoStageWidgetDrop(result, appWidgetId, requestArgs);
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, () -> getStateManager().goToState(NORMAL));
        } else {
            if (requestArgs.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
                // When the screen id represents an actual screen (as opposed to a rank)
                // we make sure that the drop page actually exists.
                requestArgs.screenId = ensurePendingDropLayoutExists(requestArgs.screenId);
            }
            final CellLayout dropLayout = mWorkspace.getScreenWithId(requestArgs.screenId);
            dropLayout.setDropPending(true);
            final Runnable onComplete = new Runnable() {

                @Override
                public void run() {
                    completeTwoStageWidgetDrop(resultCode, appWidgetId, requestArgs);
                    dropLayout.setDropPending(false);
                }
            };
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, onComplete);
        }
        return;
    }
    if (requestCode == REQUEST_RECONFIGURE_APPWIDGET || requestCode == REQUEST_BIND_PENDING_APPWIDGET) {
        if (resultCode == RESULT_OK) {
            // Update the widget view.
            completeAdd(requestCode, data, pendingAddWidgetId, requestArgs);
        }
        // Leave the widget in the pending state if the user canceled the configure.
        return;
    }
    if (requestCode == REQUEST_CREATE_SHORTCUT) {
        // Handle custom shortcuts created using ACTION_CREATE_SHORTCUT.
        if (resultCode == RESULT_OK && requestArgs.container != ItemInfo.NO_ID) {
            completeAdd(requestCode, data, -1, requestArgs);
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, exitSpringLoaded);
        } else if (resultCode == RESULT_CANCELED) {
            mWorkspace.removeExtraEmptyScreenDelayed(ON_ACTIVITY_RESULT_ANIMATION_DELAY, false, exitSpringLoaded);
        }
    }
    mDragLayer.clearAnimatedView();
}
Also used : ActivityResultInfo(com.android.launcher3.util.ActivityResultInfo) PendingRequestArgs(com.android.launcher3.util.PendingRequestArgs)

Example 58 with Workspace

use of com.android.launcher3.tapl.Workspace in project android_packages_apps_Launcher3 by AOSPA.

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 59 with Workspace

use of com.android.launcher3.tapl.Workspace in project android_packages_apps_Launcher3 by AOSPA.

the class ShortcutAndWidgetContainer method measureChild.

public void measureChild(View child) {
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
    final DeviceProfile dp = mActivity.getDeviceProfile();
    if (child instanceof NavigableAppWidgetHostView) {
        ((NavigableAppWidgetHostView) child).getWidgetInset(dp, mTempRect);
        lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY, dp.appWidgetScale.x, dp.appWidgetScale.y, mBorderSpace, mTempRect);
    } else {
        lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY, mBorderSpace, null);
        // Center the icon/folder
        int cHeight = getCellContentHeight();
        int cellPaddingY = dp.isScalableGrid && mContainerType == WORKSPACE ? dp.cellYPaddingPx : (int) Math.max(0, ((lp.height - cHeight) / 2f));
        // No need to add padding when cell layout border spacing is present.
        boolean noPaddingX = (dp.cellLayoutBorderSpacePx.x > 0 && mContainerType == WORKSPACE) || (dp.folderCellLayoutBorderSpacePx.x > 0 && mContainerType == FOLDER);
        int cellPaddingX = noPaddingX ? 0 : mContainerType == WORKSPACE ? dp.workspaceCellPaddingXPx : (int) (dp.edgeMarginPx / 2f);
        child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0);
    }
    int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
    int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY);
    child.measure(childWidthMeasureSpec, childheightMeasureSpec);
}
Also used : NavigableAppWidgetHostView(com.android.launcher3.widget.NavigableAppWidgetHostView) Point(android.graphics.Point)

Example 60 with Workspace

use of com.android.launcher3.tapl.Workspace in project android_packages_apps_Launcher3 by AOSPA.

the class LauncherProvider method loadDefaultFavoritesIfNecessary.

/**
 * Loads the default workspace based on the following priority scheme:
 *   1) From the app restrictions
 *   2) From a package provided by play store
 *   3) From a partner configuration APK, already in the system image
 *   4) The default configuration for the particular device
 */
private synchronized void loadDefaultFavoritesIfNecessary() {
    SharedPreferences sp = Utilities.getPrefs(getContext());
    if (sp.getBoolean(mOpenHelper.getKey(EMPTY_DATABASE_CREATED), false)) {
        Log.d(TAG, "loading default workspace");
        AppWidgetHost widgetHost = mOpenHelper.newLauncherWidgetHost();
        AutoInstallsLayout loader = createWorkspaceLoaderFromAppRestriction(widgetHost);
        if (loader == null) {
            loader = AutoInstallsLayout.get(getContext(), widgetHost, mOpenHelper);
        }
        if (loader == null) {
            final Partner partner = Partner.get(getContext().getPackageManager());
            if (partner != null && partner.hasDefaultLayout()) {
                final Resources partnerRes = partner.getResources();
                int workspaceResId = partnerRes.getIdentifier(Partner.RES_DEFAULT_LAYOUT, "xml", partner.getPackageName());
                if (workspaceResId != 0) {
                    loader = new DefaultLayoutParser(getContext(), widgetHost, mOpenHelper, partnerRes, workspaceResId);
                }
            }
        }
        final boolean usingExternallyProvidedLayout = loader != null;
        if (loader == null) {
            loader = getDefaultLayoutParser(widgetHost);
        }
        // There might be some partially restored DB items, due to buggy restore logic in
        // previous versions of launcher.
        mOpenHelper.createEmptyDB(mOpenHelper.getWritableDatabase());
        // Populate favorites table with initial favorites
        if ((mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), loader) <= 0) && usingExternallyProvidedLayout) {
            // Unable to load external layout. Cleanup and load the internal layout.
            mOpenHelper.createEmptyDB(mOpenHelper.getWritableDatabase());
            mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), getDefaultLayoutParser(widgetHost));
        }
        clearFlagEmptyDbCreated();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) AppWidgetHost(android.appwidget.AppWidgetHost) LauncherAppWidgetHost(com.android.launcher3.widget.LauncherAppWidgetHost) Resources(android.content.res.Resources)

Aggregations

View (android.view.View)143 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)124 Point (android.graphics.Point)115 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)97 Rect (android.graphics.Rect)93 ArrayList (java.util.ArrayList)91 ItemInfo (com.android.launcher3.model.data.ItemInfo)86 DragView (com.android.launcher3.dragndrop.DragView)77 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)73 AppWidgetHostView (android.appwidget.AppWidgetHostView)72 Workspace (com.android.launcher3.Workspace)63 SuppressLint (android.annotation.SuppressLint)58 DraggableView (com.android.launcher3.dragndrop.DraggableView)58 Test (org.junit.Test)57 FolderInfo (com.android.launcher3.model.data.FolderInfo)55 CellLayout (com.android.launcher3.CellLayout)51 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)47 IntArray (com.android.launcher3.util.IntArray)45 Intent (android.content.Intent)43 ValueAnimator (android.animation.ValueAnimator)41