From 9b2a2b2b0a213fbce48468eb48831751f7ab6689 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Fri, 7 Jul 2023 18:32:11 +0200 Subject: [PATCH] add portrait mode to app --- brouter-routing-app/src/main/AndroidManifest.xml | 2 +- .../main/java/btools/routingapp/BInstallerActivity.java | 2 -- .../src/main/java/btools/routingapp/BInstallerView.java | 9 ++++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/brouter-routing-app/src/main/AndroidManifest.xml b/brouter-routing-app/src/main/AndroidManifest.xml index bf68f8c..a2f9dfa 100644 --- a/brouter-routing-app/src/main/AndroidManifest.xml +++ b/brouter-routing-app/src/main/AndroidManifest.xml @@ -35,7 +35,7 @@ android:name=".BInstallerActivity" android:exported="true" android:launchMode="singleTask" - android:screenOrientation="landscape" /> + android:screenOrientation="locked" /> = Build.VERSION_CODES.TIRAMISU) { diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java index ef8dcca..4eaddac 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -63,7 +63,8 @@ public class BInstallerView extends View { if (currentScale() * ratio >= 1) { mat.postScale(ratio, ratio, focusX, focusY); fitBounds(); - tilesVisible = currentScale() >= SCALE_GRID_VISIBLE; + boolean landscape = getWidth() > getHeight(); + tilesVisible = currentScale() >= (landscape ? SCALE_GRID_VISIBLE: SCALE_GRID_VISIBLE-1); invalidate(); } @@ -149,7 +150,9 @@ public class BInstallerView extends View { viewscale = Math.max(scaleX, scaleY); - mat.postScale(viewscale, viewscale); + mat.preScale(viewscale, viewscale, bmp.getWidth() /2f, 0); + setRatio(1f, bmp.getWidth() /2f, bmp.getHeight() /2f); + tilesVisible = false; } @@ -285,7 +288,7 @@ public class BInstallerView extends View { @Override public boolean onDoubleTap(MotionEvent e) { if (!tilesVisible) { - setScale(5, e.getX(), e.getY()); + setScale(4, e.getX(), e.getY()); } else { setScale(1, e.getX(), e.getY()); }