Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6205603 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Creating landscape and portrait device profiles at app initialization

Change-Id: Ide9d007adc36b348e19b05cdf49e87f8b02db60e
parent 2805e639
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ public class AlphabeticalAppsList {
    public void setNumAppsPerRow(int numAppsPerRow, int numPredictedAppsPerRow) {
        // Update the merge algorithm
        DeviceProfile grid = mLauncher.getDeviceProfile();
        if (grid.isPhone()) {
        if (grid.isPhone) {
            mMergeAlgorithm = new PhoneMergeAlgorithm((int) Math.ceil(numAppsPerRow / 2f),
                    MIN_ROWS_IN_MERGED_SECTION_PHONE, MAX_NUM_MERGES_PHONE);
        } else {
+1 −1
Original line number Diff line number Diff line
@@ -453,7 +453,7 @@ public class AppsContainerView extends BaseContainerView implements DragSource,

        // Update the apps recycler view, inset it by the container inset as well
        DeviceProfile grid = mLauncher.getDeviceProfile();
        int startMargin = grid.isPhone() ? mContentMarginStart : 0;
        int startMargin = grid.isPhone ? mContentMarginStart : 0;
        int inset = mFixedBounds.isEmpty() ? mContainerInset : mFixedBoundsContainerInset;
        if (isRtl) {
            mAppsRecyclerView.setPadding(inset + mAppsRecyclerView.getScrollbarWidth(), inset,
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> {
                            mPredictedAppsDividerPaint);
                    hasDrawnPredictedAppsDivider = true;

                } else if (grid.isPhone() && shouldDrawItemSection(holder, i, items)) {
                } else if (grid.isPhone && shouldDrawItemSection(holder, i, items)) {
                    // At this point, we only draw sections for each section break;
                    int viewTopOffset = (2 * child.getPaddingTop());
                    int pos = holder.getPosition();
+5 −9
Original line number Diff line number Diff line
@@ -821,8 +821,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        DeviceProfile grid = mLauncher.getDeviceProfile();

        int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
        int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
        int widthSize = MeasureSpec.getSize(widthMeasureSpec);
@@ -830,8 +828,8 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
        int childWidthSize = widthSize - (getPaddingLeft() + getPaddingRight());
        int childHeightSize = heightSize - (getPaddingTop() + getPaddingBottom());
        if (mFixedCellWidth < 0 || mFixedCellHeight < 0) {
            int cw = grid.calculateCellWidth(childWidthSize, mCountX);
            int ch = grid.calculateCellHeight(childHeightSize, mCountY);
            int cw = DeviceProfile.calculateCellWidth(childWidthSize, mCountX);
            int ch = DeviceProfile.calculateCellHeight(childHeightSize, mCountY);
            if (cw != mCellWidth || ch != mCellHeight) {
                mCellWidth = cw;
                mCellHeight = ch;
@@ -2714,16 +2712,14 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
     * @param result An array of length 2 in which to store the result (may be null).
     */
    public static int[] rectToCell(Launcher launcher, int width, int height, int[] result) {
        LauncherAppState app = LauncherAppState.getInstance();
        DeviceProfile grid = launcher.getDeviceProfile();
        Rect padding = grid.getWorkspacePadding(grid.isLandscape ?
                CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
        Rect padding = grid.getWorkspacePadding(Utilities.isRtl(launcher.getResources()));

        // Always assume we're working with the smallest span to make sure we
        // reserve enough space in both orientations.
        int parentWidth = grid.calculateCellWidth(grid.widthPx
        int parentWidth = DeviceProfile.calculateCellWidth(grid.widthPx
                - padding.left - padding.right, (int) grid.inv.numColumns);
        int parentHeight = grid.calculateCellHeight(grid.heightPx
        int parentHeight = DeviceProfile.calculateCellHeight(grid.heightPx
                - padding.top - padding.bottom, (int) grid.inv.numRows);
        int smallerSize = Math.min(parentWidth, parentHeight);

+111 −275

File changed.

Preview size limit exceeded, changes collapsed.

Loading