use of com.android.launcher3.DeviceProfile in project Neo-Launcher by NeoApplications.
the class WindowTransformSwipeHandler method doLogGesture.
private void doLogGesture(GestureEndTarget endTarget) {
DeviceProfile dp = mDp;
if (dp == null || mDownPos == null) {
// We probably never received an animation controller, skip logging.
return;
}
int pageIndex = endTarget == LAST_TASK ? LOG_NO_OP_PAGE_INDEX : mRecentsView.getNextPage();
UserEventDispatcher.newInstance(mContext).logStateChangeAction(mLogAction, mLogDirection, (int) mDownPos.x, (int) mDownPos.y, ContainerType.NAVBAR, ContainerType.APP, endTarget.containerType, pageIndex);
}
use of com.android.launcher3.DeviceProfile in project Neo-Launcher by NeoApplications.
the class PortraitStatesTouchController method getHotseatTop.
public static int getHotseatTop(Launcher launcher) {
DeviceProfile dp = launcher.getDeviceProfile();
int hotseatHeight = dp.hotseatBarSizePx + dp.getInsets().bottom;
return launcher.getDragLayer().getHeight() - hotseatHeight;
}
use of com.android.launcher3.DeviceProfile in project Neo-Launcher by NeoApplications.
the class CellLayout method visualizeDropLocation.
void visualizeDropLocation(View v, DragPreviewProvider outlineProvider, int cellX, int cellY, int spanX, int spanY, boolean resize, DropTarget.DragObject dragObject) {
final int oldDragCellX = mDragCell[0];
final int oldDragCellY = mDragCell[1];
if (outlineProvider == null || outlineProvider.generatedDragOutline == null) {
return;
}
Bitmap dragOutline = outlineProvider.generatedDragOutline;
if (cellX != oldDragCellX || cellY != oldDragCellY) {
Point dragOffset = dragObject.dragView.getDragVisualizeOffset();
Rect dragRegion = dragObject.dragView.getDragRegion();
mDragCell[0] = cellX;
mDragCell[1] = cellY;
final int oldIndex = mDragOutlineCurrent;
mDragOutlineAnims[oldIndex].animateOut();
mDragOutlineCurrent = (oldIndex + 1) % mDragOutlines.length;
Rect r = mDragOutlines[mDragOutlineCurrent];
if (resize) {
cellToRect(cellX, cellY, spanX, spanY, r);
if (v instanceof LauncherAppWidgetHostView) {
DeviceProfile profile = mActivity.getWallpaperDeviceProfile();
Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
}
} else {
// Find the top left corner of the rect the object will occupy
final int[] topLeft = mTmpPoint;
cellToPoint(cellX, cellY, topLeft);
int left = topLeft[0];
int top = topLeft[1];
if (v != null && dragOffset == null) {
// When drawing the drag outline, it did not account for margin offsets
// added by the view's parent.
MarginLayoutParams lp = (MarginLayoutParams) v.getLayoutParams();
left += lp.leftMargin;
top += lp.topMargin;
// Offsets due to the size difference between the View and the dragOutline.
// There is a size difference to account for the outer blur, which may lie
// outside the bounds of the view.
top += ((mCellHeight * spanY) - dragOutline.getHeight()) / 2;
// We center about the x axis
left += ((mCellWidth * spanX) - dragOutline.getWidth()) / 2;
} else {
if (dragOffset != null && dragRegion != null) {
// Center the drag region *horizontally* in the cell and apply a drag
// outline offset
left += dragOffset.x + ((mCellWidth * spanX) - dragRegion.width()) / 2;
int cHeight = getShortcutsAndWidgets().getCellContentHeight();
int cellPaddingY = (int) Math.max(0, ((mCellHeight - cHeight) / 2f));
top += dragOffset.y + cellPaddingY;
} else {
// Center the drag outline in the cell
left += ((mCellWidth * spanX) - dragOutline.getWidth()) / 2;
top += ((mCellHeight * spanY) - dragOutline.getHeight()) / 2;
}
}
r.set(left, top, left + dragOutline.getWidth(), top + dragOutline.getHeight());
}
Utilities.scaleRectAboutCenter(r, mChildScale);
mDragOutlineAnims[mDragOutlineCurrent].setTag(dragOutline);
mDragOutlineAnims[mDragOutlineCurrent].animateIn();
if (dragObject.stateAnnouncer != null) {
dragObject.stateAnnouncer.announce(getItemMoveDescription(cellX, cellY));
}
}
}
use of com.android.launcher3.DeviceProfile in project Neo-Launcher by NeoApplications.
the class LayoutUtils method calculateTaskSize.
@AnyThread
public static void calculateTaskSize(Context context, DeviceProfile dp, float extraVerticalSpace, @MultiWindowStrategy int multiWindowStrategy, Rect outRect) {
float taskWidth, taskHeight, paddingHorz;
Resources res = context.getResources();
Rect insets = dp.getInsets();
if (dp.isMultiWindowMode) {
if (multiWindowStrategy == MULTI_WINDOW_STRATEGY_HALF_SCREEN) {
DeviceProfile fullDp = dp.getFullScreenProfile();
// Use availableWidthPx and availableHeightPx instead of widthPx and heightPx to
// account for system insets
taskWidth = fullDp.availableWidthPx;
taskHeight = fullDp.availableHeightPx;
float halfDividerSize = res.getDimension(R.dimen.multi_window_task_divider_size) / 2;
if (fullDp.isLandscape) {
taskWidth = taskWidth / 2 - halfDividerSize;
} else {
taskHeight = taskHeight / 2 - halfDividerSize;
}
} else {
// multiWindowStrategy == MULTI_WINDOW_STRATEGY_DEVICE_PROFILE
taskWidth = dp.widthPx;
taskHeight = dp.heightPx;
}
paddingHorz = res.getDimension(R.dimen.multi_window_task_card_horz_space);
} else {
taskWidth = dp.availableWidthPx;
taskHeight = dp.availableHeightPx;
paddingHorz = res.getDimension(dp.isVerticalBarLayout() ? R.dimen.landscape_task_card_horz_space : R.dimen.portrait_task_card_horz_space);
}
float topIconMargin = res.getDimension(R.dimen.task_thumbnail_top_margin);
float paddingVert = res.getDimension(R.dimen.task_card_vert_space);
// Note this should be same as dp.availableWidthPx and dp.availableHeightPx unless
// we override the insets ourselves.
int launcherVisibleWidth = dp.widthPx - insets.left - insets.right;
int launcherVisibleHeight = dp.heightPx - insets.top - insets.bottom;
float availableHeight = launcherVisibleHeight - topIconMargin - extraVerticalSpace - paddingVert;
float availableWidth = launcherVisibleWidth - paddingHorz;
float scale = Math.min(availableWidth / taskWidth, availableHeight / taskHeight);
float outWidth = scale * taskWidth;
float outHeight = scale * taskHeight;
// Center in the visible space
float x = insets.left + (launcherVisibleWidth - outWidth) / 2;
float y = insets.top + Math.max(topIconMargin, (launcherVisibleHeight - extraVerticalSpace - outHeight) / 2);
outRect.set(Math.round(x), Math.round(y), Math.round(x) + Math.round(outWidth), Math.round(y) + Math.round(outHeight));
}
use of com.android.launcher3.DeviceProfile in project Neo-Launcher by NeoApplications.
the class InvariantDeviceProfile method initGrid.
private String initGrid(Context context, String gridName) {
DefaultDisplay.Info displayInfo = DefaultDisplay.INSTANCE.get(context).getInfo();
Point smallestSize = new Point(displayInfo.smallestSize);
Point largestSize = new Point(displayInfo.largestSize);
// This guarantees that width < height
float minWidthDps = Utilities.dpiFromPx(Math.min(smallestSize.x, smallestSize.y), displayInfo.metrics);
float minHeightDps = Utilities.dpiFromPx(Math.min(largestSize.x, largestSize.y), displayInfo.metrics);
Point realSize = new Point(displayInfo.realSize);
// The real size never changes. smallSide and largeSide will remain the
// same in any orientation.
int smallSide = Math.min(realSize.x, realSize.y);
int largeSide = max(realSize.x, realSize.y);
// We want a list of all options as well as the list of filtered options. This allows us
// to have a consistent UI for areas that the grid size change should not affect
// ie. All Apps should be consistent between grid sizes.
ArrayList<DisplayOption> allOptions = new ArrayList<>();
ArrayList<DisplayOption> filteredOptions = new ArrayList<>();
getPredefinedDeviceProfiles(context, gridName, filteredOptions, allOptions);
if (allOptions.isEmpty() && filteredOptions.isEmpty()) {
throw new RuntimeException("No display option with canBeDefault=true");
}
// Sort the profiles based on the closeness to the device size
Comparator<DisplayOption> comparator = (a, b) -> Float.compare(dist(minWidthDps, minHeightDps, a.minWidthDps, a.minHeightDps), dist(minWidthDps, minHeightDps, b.minWidthDps, b.minHeightDps));
// Calculate the device profiles as if there is no grid override.
Collections.sort(allOptions, comparator);
DisplayOption interpolatedDisplayOption = invDistWeightedInterpolate(minWidthDps, minHeightDps, allOptions);
initGridOption(context, allOptions, interpolatedDisplayOption, displayInfo.metrics);
// Create IDP with no grid override values.
InvariantDeviceProfile originalIDP = new InvariantDeviceProfile(this);
originalIDP.landscapeProfile = new DeviceProfile(context, this, null, smallestSize, largestSize, largeSide, smallSide, true, /* isLandscape */
false);
originalIDP.portraitProfile = new DeviceProfile(context, this, null, smallestSize, largestSize, smallSide, largeSide, false, /* isLandscape */
false);
if (filteredOptions.isEmpty()) {
filteredOptions = allOptions;
landscapeProfile = originalIDP.landscapeProfile;
portraitProfile = originalIDP.portraitProfile;
} else {
Collections.sort(filteredOptions, comparator);
interpolatedDisplayOption = invDistWeightedInterpolate(minWidthDps, minHeightDps, filteredOptions);
initGridOption(context, filteredOptions, interpolatedDisplayOption, displayInfo.metrics);
numAllAppsColumns = originalIDP.numAllAppsColumns;
landscapeProfile = new DeviceProfile(context, this, originalIDP, smallestSize, largestSize, largeSide, smallSide, true, /* isLandscape */
false);
portraitProfile = new DeviceProfile(context, this, originalIDP, smallestSize, largestSize, smallSide, largeSide, false, /* isLandscape */
false);
}
GridOption closestProfile = filteredOptions.get(0).grid;
if (!closestProfile.name.equals(gridName)) {
Utilities.getPrefs(context).edit().putString(KEY_IDP_GRID_NAME, closestProfile.name).apply();
}
// for the intended parallax effects
if (context.getResources().getConfiguration().smallestScreenWidthDp >= 720) {
defaultWallpaperSize = new Point((int) (largeSide * wallpaperTravelToScreenWidthRatio(largeSide, smallSide)), largeSide);
} else {
defaultWallpaperSize = new Point(max(smallSide * 2, largeSide), largeSide);
}
ComponentName cn = new ComponentName(context.getPackageName(), getClass().getName());
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
return closestProfile.name;
}
Aggregations