Search in sources :

Example 6 with DeviceProfile

use of com.android.launcher3.DeviceProfile in project android_packages_apps_Launcher3 by crdroidandroid.

the class AllAppsRecyclerView method updatePoolSize.

private void updatePoolSize() {
    DeviceProfile grid = BaseDraggingActivity.fromContext(getContext()).getDeviceProfile();
    RecyclerView.RecycledViewPool pool = getRecycledViewPool();
    int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
    pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
    pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER, 1);
    pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET, 1);
    pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, approxRows * (mNumAppsPerRow + 1));
    mViewHeights.clear();
    mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_ICON, grid.allAppsCellHeightPx);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) RecyclerView(androidx.recyclerview.widget.RecyclerView) BaseRecyclerView(com.android.launcher3.BaseRecyclerView)

Example 7 with DeviceProfile

use of com.android.launcher3.DeviceProfile in project android_packages_apps_Launcher3 by crdroidandroid.

the class AllAppsRecyclerView method getTabWidth.

/**
 * Returns distance between left and right app icons
 */
public int getTabWidth() {
    DeviceProfile grid = BaseDraggingActivity.fromContext(getContext()).getDeviceProfile();
    int totalWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
    int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx;
    return totalWidth - iconPadding - grid.allAppsIconDrawablePaddingPx;
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile)

Example 8 with DeviceProfile

use of com.android.launcher3.DeviceProfile 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 9 with DeviceProfile

use of com.android.launcher3.DeviceProfile in project android_packages_apps_Launcher3 by crdroidandroid.

the class AppsSearchContainerLayout method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // Update the width to match the grid padding
    DeviceProfile dp = mLauncher.getDeviceProfile();
    int myRequestedWidth = getSize(widthMeasureSpec);
    int rowWidth = myRequestedWidth - mAppsView.getActiveRecyclerView().getPaddingLeft() - mAppsView.getActiveRecyclerView().getPaddingRight();
    int cellWidth = DeviceProfile.calculateCellWidth(rowWidth, dp.cellLayoutBorderSpacingPx, dp.numShownHotseatIcons);
    int iconVisibleSize = Math.round(ICON_VISIBLE_AREA_FACTOR * dp.iconSizePx);
    int iconPadding = cellWidth - iconVisibleSize;
    int myWidth = rowWidth - iconPadding + getPaddingLeft() + getPaddingRight();
    super.onMeasure(makeMeasureSpec(myWidth, EXACTLY), heightMeasureSpec);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile)

Example 10 with DeviceProfile

use of com.android.launcher3.DeviceProfile in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetsListAdapter method ensureAllPreviewsReady.

/**
 * Checks that all preview images are loaded and starts loading for those that aren't ready.
 *
 * @return true if all previews are ready and the data can be updated, false otherwise.
 */
private boolean ensureAllPreviewsReady() {
    boolean allReady = true;
    BaseActivity activity = BaseActivity.fromContext(mContext);
    for (WidgetsListBaseEntry entry : mAllEntries) {
        if (!(entry instanceof WidgetsListContentEntry))
            continue;
        WidgetsListContentEntry contentEntry = (WidgetsListContentEntry) entry;
        if (!matchesKey(entry, mWidgetsContentVisiblePackageUserKey)) {
            // If the entry isn't visible, clear any loaded previews.
            mCachingPreviewLoader.clearPreviews(contentEntry.mWidgets);
            continue;
        }
        for (int i = 0; i < entry.mWidgets.size(); i++) {
            WidgetItem widgetItem = entry.mWidgets.get(i);
            DeviceProfile deviceProfile = activity.getDeviceProfile();
            Size widgetSize = WidgetSizes.getWidgetItemSizePx(mContext, deviceProfile, widgetItem);
            if (widgetItem.isShortcut()) {
                widgetSize = new Size(widgetSize.getWidth() + mShortcutPreviewPadding, widgetSize.getHeight() + mShortcutPreviewPadding);
            }
            if (widgetItem.hasPreviewLayout() || mCachingPreviewLoader.isPreviewLoaded(widgetItem, widgetSize)) {
                // preview bitmap is in the cache.
                continue;
            }
            // If we've reached this point, we should load the preview for the widget.
            allReady = false;
            mCachingPreviewLoader.loadPreview(activity, widgetItem, widgetSize, mPreviewLoadedCallback);
        }
    }
    return allReady;
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Size(android.util.Size) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) BaseActivity(com.android.launcher3.BaseActivity) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetItem(com.android.launcher3.model.WidgetItem)

Aggregations

DeviceProfile (com.android.launcher3.DeviceProfile)52 Rect (android.graphics.Rect)19 Point (android.graphics.Point)13 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)10 ArrayList (java.util.ArrayList)7 Paint (android.graphics.Paint)5 Size (android.util.Size)5 SuppressLint (android.annotation.SuppressLint)4 Drawable (android.graphics.drawable.Drawable)4 View (android.view.View)4 Context (android.content.Context)3 Resources (android.content.res.Resources)3 RectF (android.graphics.RectF)3 FrameLayout (android.widget.FrameLayout)3 PendingAnimation (com.android.launcher3.anim.PendingAnimation)3 Animator (android.animation.Animator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 ObjectAnimator (android.animation.ObjectAnimator)2 ComponentName (android.content.ComponentName)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2