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

Commit ab1ebc21 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

camera: Fix qr scan view orientation

parent f6f032de
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -38,6 +38,13 @@ public class OverlayQRCodeView extends View {

    private void init() {
        qrcode = ContextCompat.getDrawable(this.getContext(), R.drawable.scan_area);

        // Ensure the view recalculates the position based on the current orientation
        addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft,
                                   oldTop, oldRight, oldBottom) -> updateQRCodeBounds());
    }

    private void updateQRCodeBounds() {
        DisplayMetrics displayMetrics = this.getContext().getResources().getDisplayMetrics();
        final int screenWidth = displayMetrics.widthPixels;
        final int screenHeight = displayMetrics.heightPixels;
@@ -51,7 +58,10 @@ public class OverlayQRCodeView extends View {
            isValid = false;
        } else {
            qrcode.setBounds(left, top, right, bottom);
            isValid = true;
        }

        invalidate(); // Redraw the view
    }

    @Override