Loading app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,13 @@ public class OverlayQRCodeView extends View { private void init() { private void init() { qrcode = ContextCompat.getDrawable(this.getContext(), R.drawable.scan_area); 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(); DisplayMetrics displayMetrics = this.getContext().getResources().getDisplayMetrics(); final int screenWidth = displayMetrics.widthPixels; final int screenWidth = displayMetrics.widthPixels; final int screenHeight = displayMetrics.heightPixels; final int screenHeight = displayMetrics.heightPixels; Loading @@ -51,7 +58,10 @@ public class OverlayQRCodeView extends View { isValid = false; isValid = false; } else { } else { qrcode.setBounds(left, top, right, bottom); qrcode.setBounds(left, top, right, bottom); isValid = true; } } invalidate(); // Redraw the view } } @Override @Override Loading Loading
app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,13 @@ public class OverlayQRCodeView extends View { private void init() { private void init() { qrcode = ContextCompat.getDrawable(this.getContext(), R.drawable.scan_area); 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(); DisplayMetrics displayMetrics = this.getContext().getResources().getDisplayMetrics(); final int screenWidth = displayMetrics.widthPixels; final int screenWidth = displayMetrics.widthPixels; final int screenHeight = displayMetrics.heightPixels; final int screenHeight = displayMetrics.heightPixels; Loading @@ -51,7 +58,10 @@ public class OverlayQRCodeView extends View { isValid = false; isValid = false; } else { } else { qrcode.setBounds(left, top, right, bottom); qrcode.setBounds(left, top, right, bottom); isValid = true; } } invalidate(); // Redraw the view } } @Override @Override Loading