From d1d55b80a4c1b49d6ed4a2e55b5fd34caa6ce444 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Tue, 5 Apr 2022 14:12:02 +0600 Subject: [PATCH] 167-Toast_message_not_horizontally_centered_issue issue: https://gitlab.e.foundation/e/os/backlog/-/issues/167 Preview.RotatedTextView is calculating the view programetic Adding 30 margin in the sideway, make the view centered. --- .../java/net/sourceforge/opencamera/preview/Preview.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 9ce999663..cb7369a69 100644 --- a/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java +++ b/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java @@ -7236,10 +7236,11 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu final int padding = (int) (14 * scale + 0.5f); // padding for the shaded rectangle; convert dps to pixels canvas.save(); canvas.rotate(ui_rotation, canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f); + float margin = 32.0f; - rect.left = canvas.getWidth() / 2.0f - bounds.width() / 2.0f + bounds.left - padding; + rect.left = canvas.getWidth() / 2.0f - bounds.width() / 2.0f + bounds.left - padding + margin; rect.top = canvas.getHeight() / 2.0f + bounds.top - padding + offset_y; - rect.right = canvas.getWidth() / 2.0f - bounds.width() / 2.0f + bounds.right + padding; + rect.right = canvas.getWidth() / 2.0f - bounds.width() / 2.0f + bounds.right + padding + margin; rect.bottom = canvas.getHeight() / 2.0f + bounds.bottom + padding + offset_y; paint.setStyle(Paint.Style.FILL); @@ -7252,7 +7253,7 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu paint.setColor(Color.WHITE); int ypos = canvas.getHeight() / 2 + offset_y - ((lines.length - 1) * height) / 2; for (String line : lines) { - canvas.drawText(line, canvas.getWidth() / 2.0f - bounds.width() / 2.0f, ypos, paint); + canvas.drawText(line, canvas.getWidth() / 2.0f - bounds.width() / 2.0f + margin, ypos, paint); if (style_outline) { // draw outline @@ -7260,7 +7261,7 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu paint.setColor(Color.BLACK); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(1); - canvas.drawText(line, canvas.getWidth() / 2.0f - bounds.width() / 2.0f, ypos, paint); + canvas.drawText(line, canvas.getWidth() / 2.0f - bounds.width() / 2.0f + margin, ypos, paint); paint.setStyle(Paint.Style.FILL); paint.setColor(current_color); } -- GitLab