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

Commit 414d992a authored by Kshitij's avatar Kshitij
Browse files

chore: Address CR

- Add braces to if'd assignments
- Commonise isGestural checks
- Simplify some conditions
parent 3a3fad7d
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -118,12 +118,13 @@ class WidgetContainer(context: Context, attrs: AttributeSet?) :
        super.onConfigurationChanged(newConfig)
        updatePadding()
        val spanCount =
            if (
                mLauncher != null &&
            if (mLauncher != null &&
                (mLauncher.deviceProfile.isTablet || mLauncher.deviceProfile.isLandscape)
            )
            ) {
                2
            else 1
            } else {
                1
            }
        mRecyclerView.layoutManager =
            NoScrollStaggeredLayoutManager(spanCount, StaggeredGridLayoutManager.VERTICAL)
    }
@@ -330,12 +331,13 @@ class WidgetContainer(context: Context, attrs: AttributeSet?) :
            widgetsDbHelper = WidgetsDbHelper.getInstance(context)
            widgetsAdapter = StaggeredAdapter()
            val spanCount =
                if (
                    launcher != null &&
                if (launcher != null &&
                    (launcher.deviceProfile.isTablet || launcher.deviceProfile.isLandscape)
                )
                ) {
                    2
                else 1
                } else {
                    1
                }
            recyclerView =
                RecyclerView(context, null).apply {
                    tag = "wrapper_children"
+13 −8
Original line number Diff line number Diff line
@@ -1365,7 +1365,7 @@ public class DeviceProfile {
        // Make sure to update all relevant sizes for cutout and orientation
        updateHotseatSizes(pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
        Rect hotseatBarPadding = new Rect();
        boolean isFullyGesture = mInfo.navigationMode == NavigationMode.NO_BUTTON;
        boolean isFullyGesture = isGestural();
        if (isVerticalBarLayout()) {
            // The hotseat icons will be placed in the middle of the hotseat cells.
            // Changing the hotseatCellHeightPx is not affecting hotseat icon positions
@@ -1482,9 +1482,8 @@ public class DeviceProfile {
     */
    private int getHotseatBarBottomPadding() {
        int heightDifference = Math.abs(hotseatCellHeightPx - iconSizePx);
        boolean isFullyGesture = mInfo.navigationMode == NavigationMode.NO_BUTTON;
        if (isTaskbarPresent) { // QSB on top or inline
            if (isFullyGesture) {
            if (isGestural()) {
                if (isLandscape) {
                    return 0;
                } else {
@@ -1499,7 +1498,7 @@ public class DeviceProfile {
            }

        } else {
            return hotseatBarBottomSpacePx + ((isFullyGesture ? 1 : 2) * heightDifference);
            return hotseatBarBottomSpacePx + ((isGestural() ? 1 : 2) * heightDifference);
        }
    }

@@ -1625,22 +1624,28 @@ public class DeviceProfile {

    private int getDeductibleGestureHeight() {
        if (isVerticalBarLayout() || context == null) return 0;
        boolean isFullyGesture = mInfo.navigationMode == NavigationMode.NO_BUTTON;
        boolean noHint = isFullyGesture && LineageSettings.System.getInt(
        boolean noHint = isGestural() && LineageSettings.System.getInt(
                context.getContentResolver(), LineageSettings.System.NAVIGATION_BAR_HINT, 0) != 1;
        if (!noHint) return 0;
        return ResourceUtils.getDimenByName(NAVBAR_BOTTOM_GESTURE_SIZE, context.getResources(), 0);
    }

    public int getExtraStatusBarPadding() {
        boolean isFullyGesture = mInfo.navigationMode == NavigationMode.NO_BUTTON;
        if (!isFullyGesture) {
        if (!isGestural()) {
            return ResourceUtils.getDimenByName(NAVBAR_HEIGHT, context.getResources(), 0);
        }
        // Fully gesture is always at the bottom
        return 0;
    }

    public boolean isGestural() {
        return mInfo.navigationMode == NavigationMode.NO_BUTTON;
    }

    public static boolean isGestural(Context context) {
        return DisplayController.getNavigationMode(context).equals(NavigationMode.NO_BUTTON);
    }

    private String pxToDpStr(String name, float value) {
        return "\t" + name + ": " + value + "px (" + dpiFromPx(value, mMetrics.densityDpi) + "dp)";
    }
+3 −5
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.
            }
        }
        int translation;
        boolean isGestural = DisplayController.getNavigationMode(getContext()).equals(NavigationMode.NO_BUTTON);
        boolean isGestural = DeviceProfile.isGestural(getContext());
        if (numOccupied != 0 && isGestural && !mActivity.getDeviceProfile().isVerticalBarLayout()) {
            final CellLayoutLayoutParams lp = (CellLayoutLayoutParams) getChildAt(0).getLayoutParams();
            int width = lp.width + mBorderSpace.x;
@@ -218,14 +218,12 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.
            }
            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);
                if (child.getVisibility() != GONE) {
                    if (child instanceof BubbleTextView) {
                if (child.getVisibility() != GONE && child instanceof BubbleTextView) {
                    ((BubbleTextView) child).translationX = mContainerType == HOTSEAT ? translation : 0;
                }
            }
        }
    }
    }

    public void setAnimatedTranslationX(float targetX) {
        this.animate()