From 559a4bc5532dcb368681b6ec7ae9620d44250748 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Fri, 19 Apr 2024 14:07:39 +0200 Subject: [PATCH 1/6] Issue 2131 update icon content. --- .../main/res/drawable/ic_switch_qrcode.xml | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/drawable/ic_switch_qrcode.xml b/app/src/main/res/drawable/ic_switch_qrcode.xml index 8b31106f9..6fa827cf0 100644 --- a/app/src/main/res/drawable/ic_switch_qrcode.xml +++ b/app/src/main/res/drawable/ic_switch_qrcode.xml @@ -1,17 +1,47 @@ + android:width="36dp" + android:height="36dp" + android:viewportWidth="36" + android:viewportHeight="36"> + android:pathData="M0,0h36v36h-36z"/> + + + + + + + + + + -- GitLab From a13e4b4aa632503792d636cf2f45d981bb8e3974 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Fri, 19 Apr 2024 15:52:15 +0200 Subject: [PATCH 2/6] Issue 2130 Move the buttons to the line below so the URL is entirely readable --- .../main/res/layout/qr_bottom_sheet_dialog.xml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/layout/qr_bottom_sheet_dialog.xml b/app/src/main/res/layout/qr_bottom_sheet_dialog.xml index c0b491489..318616b31 100644 --- a/app/src/main/res/layout/qr_bottom_sheet_dialog.xml +++ b/app/src/main/res/layout/qr_bottom_sheet_dialog.xml @@ -27,7 +27,7 @@ + tools:text="URL" + android:breakStrategy="high_quality" /> Date: Fri, 19 Apr 2024 16:39:22 +0200 Subject: [PATCH 3/6] Add scan_area.xml and dedicated view. --- .../opencamera/preview/OverlayQRCodeView.java | 62 +++++++++++++++++++ app/src/main/res/drawable/scan_area.xml | 14 +++++ 2 files changed, 76 insertions(+) create mode 100644 app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java create mode 100644 app/src/main/res/drawable/scan_area.xml diff --git a/app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java b/app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java new file mode 100644 index 000000000..f4b038be4 --- /dev/null +++ b/app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java @@ -0,0 +1,62 @@ +/* + * Copyright MURENA SAS 2024 + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.sourceforge.opencamera.preview; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.util.DisplayMetrics; +import android.view.View; + +import androidx.core.content.ContextCompat; + +import foundation.e.camera.R; + +public class OverlayQRCodeView extends View { + private Drawable qrcode; + // Do not draw the additional resource if something goes wrong + private boolean isValid = true; + + public OverlayQRCodeView(Context context) { + super(context); + init(); + } + + private void init() { + qrcode = ContextCompat.getDrawable(this.getContext(), R.drawable.scan_area); + DisplayMetrics displayMetrics =this.getContext().getResources().getDisplayMetrics(); + final int screenWidth = displayMetrics.widthPixels; + final int screenHeight = displayMetrics.heightPixels; + + final int left = (screenWidth - qrcode.getIntrinsicWidth()) / 2; + final int top = (screenHeight - qrcode.getIntrinsicHeight()) / 2; + final int right = left + qrcode.getIntrinsicWidth(); + final int bottom = top + qrcode.getIntrinsicHeight(); + + if (left<=0 || top<=0 || right<=0 || bottom<=0) + isValid = false; + else + qrcode.setBounds(left, top, right, bottom); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + if (isValid) + qrcode.draw(canvas); + } +} diff --git a/app/src/main/res/drawable/scan_area.xml b/app/src/main/res/drawable/scan_area.xml new file mode 100644 index 000000000..2486da080 --- /dev/null +++ b/app/src/main/res/drawable/scan_area.xml @@ -0,0 +1,14 @@ + + + + + + -- GitLab From 86c795493c2f32fabee5d01983ce7da31fb91c5a Mon Sep 17 00:00:00 2001 From: frankpreel Date: Fri, 19 Apr 2024 16:45:22 +0200 Subject: [PATCH 4/6] Issue 2129 --- .../sourceforge/opencamera/preview/Preview.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java b/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java index 8ce360f26..d9cb9e254 100644 --- a/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java +++ b/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java @@ -14,6 +14,7 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; +import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; @@ -226,6 +227,8 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu * Important to call close() when the video recording is finished, to free up any resources * (e.g., supplied ParcelFileDescriptor). */ + + private OverlayQRCodeView overlayQRCodeView; private static class VideoFileInfo { private final ApplicationInterface.VideoMethod video_method; private final Uri video_uri; // for VideoMethod.SAF, VideoMethod.URI or VideoMethod.MEDIASTORE @@ -502,6 +505,8 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu if (canvasView != null) { parent.addView(canvasView); } + + overlayQRCodeView = new OverlayQRCodeView(getContext()); } /*private void previewToCamera(float [] coords) { @@ -4771,6 +4776,9 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu stopVideo(false); } this.functionalMode = FunctionalMode.QRCODE; + final Activity activity = (Activity) Preview.this.getContext(); + final FrameLayout rootLayout = activity.findViewById(android.R.id.content); + rootLayout.addView(overlayQRCodeView); int qrcodeCamId = ((MainActivity)getContext()).getBetterQRCodeCameraID(); if (qrcodeCamId >= 0) { applicationInterface.setCameraIdPref(qrcodeCamId); @@ -4778,6 +4786,11 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu } } else if (this.is_qrcode()) { this.functionalMode = FunctionalMode.PHOTO; + final Activity activity = (Activity) Preview.this.getContext(); + final FrameLayout rootLayout = activity.findViewById(android.R.id.content); + if(overlayQRCodeView.getParent() != null) { + rootLayout.removeView(overlayQRCodeView); + } } else if (this.is_photo()) { if (this.isOnTimer()) { cancelTimer(); @@ -4791,6 +4804,7 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu ((MainActivity)getContext()).setDecorFitsSystemWindows(true); this.functionalMode = FunctionalMode.VIDEO; } + // nothing to do for overlayQRCodeView in this mode } if (is_qrcode() != old_is_qrcode) { -- GitLab From d2b4dac42019464b807ed696253bc359e8ad8cf1 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 23 Apr 2024 12:38:05 +0000 Subject: [PATCH 5/6] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Jonathan Klee --- .../main/java/net/sourceforge/opencamera/preview/Preview.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java b/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java index d9cb9e254..3ffe7fee8 100644 --- a/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java +++ b/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java @@ -4788,7 +4788,7 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu this.functionalMode = FunctionalMode.PHOTO; final Activity activity = (Activity) Preview.this.getContext(); final FrameLayout rootLayout = activity.findViewById(android.R.id.content); - if(overlayQRCodeView.getParent() != null) { + if (overlayQRCodeView.getParent() != null) { rootLayout.removeView(overlayQRCodeView); } } else if (this.is_photo()) { -- GitLab From f97ce089706ab519cf100b0652e83b8a0c015e4d Mon Sep 17 00:00:00 2001 From: Mohammed Althaf Thayyil Date: Wed, 24 Apr 2024 03:57:17 +0000 Subject: [PATCH 6/6] Apply 2 suggestion(s) to 1 file(s) --- .../sourceforge/opencamera/preview/OverlayQRCodeView.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java b/app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java index f4b038be4..92d5f397f 100644 --- a/app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java +++ b/app/src/main/java/net/sourceforge/opencamera/preview/OverlayQRCodeView.java @@ -47,16 +47,18 @@ public class OverlayQRCodeView extends View { final int right = left + qrcode.getIntrinsicWidth(); final int bottom = top + qrcode.getIntrinsicHeight(); - if (left<=0 || top<=0 || right<=0 || bottom<=0) + if (left <= 0 || top <= 0 || right <= 0 || bottom <= 0) { isValid = false; - else + } else { qrcode.setBounds(left, top, right, bottom); + } } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); - if (isValid) + if (isValid) { qrcode.draw(canvas); + } } } -- GitLab