From 11f104afe9d9cbde714ea09eedb3882d61047fe6 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Sun, 24 Apr 2022 14:23:58 +0200 Subject: [PATCH] Rearange BRouterActivity/BRouterView --- .../btools/routingapp/BRouterActivity.java | 47 +++++++------------ .../java/btools/routingapp/BRouterView.java | 31 +++++------- 2 files changed, 29 insertions(+), 49 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java index c3253ce..a03f65d 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java @@ -48,10 +48,27 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat private static final int DIALOG_SHOW_REPEAT_TIMEOUT_HELP_ID = 16; private static final int DIALOG_SHOW_API23_HELP_ID = 17; - private BRouterView mBRouterView; private PowerManager mPowerManager; private WakeLock mWakeLock; + private String[] availableProfiles; + private String selectedProfile = null; + private List availableBasedirs; + private String[] basedirOptions; + private int selectedBasedir; + private String[] availableWaypoints; + private String[] routingModes; + private boolean[] routingModesChecked; + private String defaultbasedir = null; + private String message = null; + private String[] availableVias; + private Set selectedVias; + private List nogoList; + private String maptoolDirCandidate; + private Set dialogIds = new HashSet(); + private String errorMessage; + private String title; + private int wpCount; /** * Called when the activity is first created. @@ -359,28 +376,6 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat return checked; } - private String[] availableProfiles; - private String selectedProfile = null; - - private List availableBasedirs; - private String[] basedirOptions; - private int selectedBasedir; - - private String[] availableWaypoints; - - private String[] routingModes; - private boolean[] routingModesChecked; - - private String defaultbasedir = null; - private String message = null; - - private String[] availableVias; - private Set selectedVias; - - private List nogoList; - - private String maptoolDirCandidate; - @SuppressWarnings("deprecation") public void selectProfile(String[] items) { availableProfiles = items; @@ -486,8 +481,6 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat showDialog(DIALOG_NOGOSELECT_ID); } - private Set dialogIds = new HashSet(); - private void showNewDialog(int id) { if (dialogIds.contains(Integer.valueOf(id))) { removeDialog(id); @@ -496,10 +489,6 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat showDialog(id); } - private String errorMessage; - private String title; - private int wpCount; - @SuppressWarnings("deprecation") public void showErrorMessage(String msg) { errorMessage = msg; diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java b/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java index 2551d25..4fcdc10 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java @@ -47,10 +47,11 @@ import btools.router.RoutingHelper; import btools.util.CheapRuler; public class BRouterView extends View { + + public boolean canAccessSdCard; RoutingEngine cr; private int imgw; private int imgh; - private int centerLon; private int centerLat; private double scaleLon; // ilon -> pixel @@ -60,7 +61,6 @@ public class BRouterView extends View { private List nogoList; private List nogoVetoList; private OsmTrack rawTrack; - private File retryBaseDir; private File modesDir; private File tracksDir; @@ -73,32 +73,26 @@ public class BRouterView extends View { private boolean waitingForMigration = false; private String rawTrackPath; private String oldMigrationPath; - private boolean needsViaSelection; private boolean needsNogoSelection; private boolean needsWaypointSelection; - private WpDatabaseScanner dataBaseScanner; - private long lastDataTime = System.currentTimeMillis(); - private CoordinateReader cor; - private int[] imgPixels; - private int memoryClass; - - public boolean canAccessSdCard; - - public void stopRouting() { - if (cr != null) cr.terminate(); - } + private long lastTs = System.currentTimeMillis(); + private long startTime = 0L; public BRouterView(Context context, int memoryClass) { super(context); this.memoryClass = memoryClass; } + public void stopRouting() { + if (cr != null) cr.terminate(); + } + public void init() { try { // get base dir from private file @@ -114,9 +108,9 @@ public class BRouterView extends View { // don't ask twice String version = "v" + getContext().getString(R.string.app_version); - File vFile = new File(brd, "profiles2/"+version ); + File vFile = new File(brd, "profiles2/" + version); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q - && vFile.exists()) { + && vFile.exists()) { startSetup(baseDir, false); return; } @@ -568,7 +562,7 @@ public class BRouterView extends View { // for profile remote, use ref-track logic same as service interface rc.rawTrackPath = rawTrackPath; - cr = new RoutingEngine(tracksDir.getAbsolutePath()+"/brouter", null, segmentDir, wpList, rc); + cr = new RoutingEngine(tracksDir.getAbsolutePath() + "/brouter", null, segmentDir, wpList, rc); cr.start(); invalidate(); @@ -703,9 +697,6 @@ public class BRouterView extends View { lastDataTime += 4000; // give time for the toast before exiting } - private long lastTs = System.currentTimeMillis(); - private long startTime = 0L; - @Override protected void onDraw(Canvas canvas) { try {