Loading app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java +11 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading Loading
app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java +11 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading