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;
}
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);
}
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);
}
}
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();
}
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);
}
Aggregations