Search in sources :

Example 21 with DeviceProfile

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

the class LauncherAppWidgetProviderInfoTest method createIDP.

private InvariantDeviceProfile createIDP() {
    DeviceProfile profile = Mockito.mock(DeviceProfile.class);
    doAnswer(i -> {
        ((Point) i.getArgument(0)).set(CELL_SIZE, CELL_SIZE);
        return null;
    }).when(profile).getCellSize(any(Point.class));
    Mockito.when(profile.getCellSize()).thenReturn(new Point(CELL_SIZE, CELL_SIZE));
    InvariantDeviceProfile idp = new InvariantDeviceProfile();
    List<DeviceProfile> supportedProfiles = new ArrayList<>(idp.supportedProfiles);
    supportedProfiles.add(profile);
    idp.supportedProfiles = Collections.unmodifiableList(supportedProfiles);
    idp.numColumns = NUM_OF_COLS;
    idp.numRows = NUM_OF_ROWS;
    return idp;
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) ArrayList(java.util.ArrayList) Point(android.graphics.Point)

Example 22 with DeviceProfile

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

the class LauncherUIScrollTest method createScrollEvent.

private static MotionEvent createScrollEvent(int scroll) {
    DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(RuntimeEnvironment.application).supportedProfiles.get(0);
    final PointerProperties[] pointerProperties = new PointerProperties[1];
    pointerProperties[0] = new PointerProperties();
    pointerProperties[0].id = 0;
    final MotionEvent.PointerCoords[] coords = new MotionEvent.PointerCoords[1];
    coords[0] = new MotionEvent.PointerCoords();
    coords[0].setAxisValue(MotionEvent.AXIS_VSCROLL, scroll);
    coords[0].x = dp.widthPx / 2;
    coords[0].y = dp.heightPx / 2;
    final long time = SystemClock.uptimeMillis();
    return MotionEvent.obtain(time, time, MotionEvent.ACTION_SCROLL, 1, pointerProperties, coords, 0, 0, 1.0f, 1.0f, 0, 0, InputDevice.SOURCE_CLASS_POINTER, 0);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) PointerProperties(android.view.MotionEvent.PointerProperties) MotionEvent(android.view.MotionEvent)

Example 23 with DeviceProfile

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

the class RecentsView method updateSizeAndPadding.

// Update task size and padding that are dependent on DeviceProfile and insets.
private void updateSizeAndPadding() {
    DeviceProfile dp = mActivity.getDeviceProfile();
    getTaskSize(mTempRect);
    mTaskWidth = mTempRect.width();
    mTaskHeight = mTempRect.height();
    mTempRect.top -= dp.overviewTaskThumbnailTopMarginPx;
    setPadding(mTempRect.left - mInsets.left, mTempRect.top - mInsets.top, dp.widthPx - mInsets.right - mTempRect.right, dp.heightPx - mInsets.bottom - mTempRect.bottom);
    mSizeStrategy.calculateGridSize(mActivity, mActivity.getDeviceProfile(), mLastComputedGridSize);
    mSizeStrategy.calculateGridTaskSize(mActivity, mActivity.getDeviceProfile(), mLastComputedGridTaskSize, mOrientationHandler);
    // Force TaskView to update size from thumbnail
    updateTaskSize();
    // Update ActionsView position
    if (mActionsView != null) {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mActionsView.getLayoutParams();
        if (dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
            layoutParams.gravity = Gravity.BOTTOM;
            layoutParams.bottomMargin = dp.heightPx - mInsets.bottom - mLastComputedGridSize.bottom;
            layoutParams.leftMargin = mLastComputedTaskSize.left;
            layoutParams.rightMargin = dp.widthPx - mLastComputedTaskSize.right;
            // When in modal state, remove bottom margin to avoid covering content.
            mActionsView.setModalTransformY(layoutParams.bottomMargin);
        } else {
            layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
            layoutParams.bottomMargin = 0;
            layoutParams.leftMargin = 0;
            layoutParams.rightMargin = 0;
            mActionsView.setModalTransformY(0);
        }
        mActionsView.setLayoutParams(layoutParams);
    }
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) FrameLayout(android.widget.FrameLayout)

Example 24 with DeviceProfile

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

the class RecentsView method setInsets.

@Override
public void setInsets(Rect insets) {
    mInsets.set(insets);
    // Update DeviceProfile dependant state.
    DeviceProfile dp = mActivity.getDeviceProfile();
    setOverviewGridEnabled(mActivity.getStateManager().getState().displayOverviewTasksAsGrid(dp));
    // Propagate DeviceProfile change event.
    mLiveTileTaskViewSimulator.setDp(dp);
    mActionsView.setDp(dp);
    mOrientationState.setDeviceProfile(dp);
    // Update RecentsView adn TaskView's DeviceProfile dependent layout.
    updateOrientationHandler();
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile)

Example 25 with DeviceProfile

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

the class RecentsView method updateOrientationHandler.

private void updateOrientationHandler(boolean forceRecreateDragLayerControllers) {
    // Handle orientation changes.
    PagedOrientationHandler oldOrientationHandler = mOrientationHandler;
    mOrientationHandler = mOrientationState.getOrientationHandler();
    mIsRtl = mOrientationHandler.getRecentsRtlSetting(getResources());
    setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
    if (forceRecreateDragLayerControllers || !mOrientationHandler.equals(oldOrientationHandler)) {
        // Changed orientations, update controllers so they intercept accordingly.
        mActivity.getDragLayer().recreateControllers();
    }
    boolean isInLandscape = mOrientationState.getTouchRotation() != ROTATION_0 || mOrientationState.getRecentsActivityRotation() != ROTATION_0;
    mActionsView.updateHiddenFlags(HIDDEN_NON_ZERO_ROTATION, !mOrientationState.canRecentsActivityRotate() && isInLandscape);
    // Update TaskView's DeviceProfile dependent layout.
    updateChildTaskOrientations();
    // Recalculate DeviceProfile dependent layout.
    updateSizeAndPadding();
    requestLayout();
    // Reapply the current page to update page scrolls.
    setCurrentPage(mCurrentPage);
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

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