From 492d79d42e52b9f6ffd5af327736125d1232c472 Mon Sep 17 00:00:00 2001 From: Arndt Brenschede Date: Mon, 20 Dec 2021 09:52:53 +0100 Subject: [PATCH 01/65] inreased download speed limit from 4 to 16 mbit/s --- .../src/main/java/btools/routingapp/BRouterActivity.java | 2 +- .../src/main/java/btools/routingapp/DownloadService.java | 4 ++-- 2 files changed, 3 insertions(+), 3 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 40bcb5f..5fb8e04 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java @@ -129,7 +129,7 @@ public class BRouterActivity extends Activity implements ActivityCompat.OnReques .setMessage( "*** Attention: ***\n\n" + "The Download Manager is used to download routing-data " + "files which can be up to 170MB each. Do not start the Download Manager " + "on a cellular data connection without a data plan! " - + "Download speed is restricted to 4 MBit/s.").setPositiveButton("I know", new DialogInterface.OnClickListener() { + + "Download speed is restricted to 16 MBit/s.").setPositiveButton("I know", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(BRouterActivity.this, BInstallerActivity.class); startActivity(intent); diff --git a/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java b/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java index c1a0c0a..2726327 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java @@ -433,8 +433,8 @@ public class DownloadService extends Service implements ProgressListener { output.write(data, 0, count); - // enforce < 2 Mbit/s - long dt = t0 + total / 524 - System.currentTimeMillis(); + // enforce < 16 Mbit/s + long dt = t0 + total / 2096 - System.currentTimeMillis(); if (dt > 0) { try { Thread.sleep(dt); From a5b8ba459bfb6f2656c0df15c6581b3d275cc219 Mon Sep 17 00:00:00 2001 From: Arndt Brenschede Date: Mon, 20 Dec 2021 10:10:12 +0100 Subject: [PATCH 02/65] removed brouter-suspects/traffic-analyisis profiles --- misc/profiles2/car-eco-de.brf | 182 -------------------- misc/profiles2/car-eco-suspect_scan.brf | 214 ------------------------ misc/profiles2/car-traffic_analysis.brf | 128 -------------- 3 files changed, 524 deletions(-) delete mode 100644 misc/profiles2/car-eco-de.brf delete mode 100644 misc/profiles2/car-eco-suspect_scan.brf delete mode 100644 misc/profiles2/car-traffic_analysis.brf diff --git a/misc/profiles2/car-eco-de.brf b/misc/profiles2/car-eco-de.brf deleted file mode 100644 index 136bce2..0000000 --- a/misc/profiles2/car-eco-de.brf +++ /dev/null @@ -1,182 +0,0 @@ -# -# Car-Routing based on a kinematic model -# -# Depending on the vmax-parameter (target-speed) -# this can be anything from least-time routing to eco-routing -# -# ----model:btools.router.KinematicModel - ----context:global - -# kinematic parameters - -assign vmax = 90 # kmh -assign recup_efficiency = 0.7 # (ratio) -assign totalweight = 1640 # kg -assign f_roll = 232 # Newton -assign f_air = 0.4 # 0.5*cw*A*rho -assign f_recup = 400 # Newton -assign p_standby = 250 # Watt - -# technical parameters - -assign forceSecondaryData = true -assign validForCars = true -assign pass1coefficient = 1.3 -assign turnInstructionMode = 1 # 0=none, 1=auto-choose, 2=locus-style, 3=osmand-style - ----context:way # following code refers to way-tags - -assign initialcost switch route=ferry 20000 0 - -# -# calculate logical car access -# -assign caraccess - switch motorcar= - switch motor_vehicle= - switch vehicle= - switch access= - switch highway=motorway|motorway_link 1 - switch highway=trunk|trunk_link 1 - switch highway=primary|primary_link 1 - switch highway=secondary|secondary_link 1 - switch highway=tertiary|tertiary_link 1 - switch highway=unclassified 1 - switch route=ferry 1 - switch highway=residential|living_street 1 - switch highway=service 1 - 0 - access=yes|permissive|designated|destination - vehicle=yes|designated|destination - motor_vehicle=yes|permissive|designated|destination - motorcar=yes|permissive|designated|destination - -assign accessspeedlimit = if caraccess then 999 else 0 - -assign isbadoneway = if reversedirection=yes then ( if oneway= then junction=roundabout else oneway=yes|true|1 ) else oneway=-1 -assign onewayspeedlimit = if isbadoneway then 0 else 999 - -assign islinktype = highway=motorway_link|trunk_link|primary_link|secondary_link|tertiary_link - -assign maxspeed_surface = - switch or surface= surface=paved|asphalt|concrete 999 - switch surface=paving_stones|cobblestone 30 - 2 - -assign maxspeed_tracktype = - switch tracktype= 999 - switch tracktype=grade1 40 - switch tracktype=grade2 5 - 1 - -assign maxspeed_implicit = - switch highway=motorway 999 - switch highway=motorway_link 130 - switch highway=trunk 250 - switch highway=trunk_link 100 - switch highway=primary|primary_link 100 - switch highway=secondary|secondary_link 90 - switch highway=tertiary|tertiary_link 80 - switch highway=unclassified 50 - switch route=ferry 10 - switch highway=bridleway 10 - switch highway=residential|living_street 30 - switch highway=service 30 - switch highway=track|road|path switch tracktype=grade1 30 5 - 0 - -assign maxspeed = - min onewayspeedlimit - min accessspeedlimit - switch maxspeed=50 50 - switch maxspeed=30 30 - switch maxspeed=10 10 - switch maxspeed=20 20 - switch maxspeed=40 40 - switch maxspeed=60 60 - switch maxspeed=70 70 - switch maxspeed=80 80 - switch maxspeed=90 90 - switch maxspeed=100 100 - switch maxspeed=110 110 - switch maxspeed=120 120 - switch maxspeed=130 130 - switch maxspeed=urban 50 - switch maxspeed=rural 100 - min maxspeed_implicit - min maxspeed_surface maxspeed_tracktype - -assign costfactor = if equal maxspeed 0 then 10000 else 0 - -assign minspeed = - switch highway=motorway|trunk 75 0 - -# way priorities used for voice hint generation - -assign priorityclassifier = - - if ( highway=motorway ) then 30 - else if ( highway=motorway_link ) then 29 - else if ( highway=trunk ) then 28 - else if ( highway=trunk_link ) then 27 - else if ( highway=primary ) then 26 - else if ( highway=primary_link ) then 25 - else if ( highway=secondary ) then 24 - else if ( highway=secondary_link ) then 23 - else if ( highway=tertiary ) then 22 - else if ( highway=tertiary_link ) then 21 - else if ( highway=unclassified ) then 20 - else if ( highway=residential|living_street ) then 6 - else if ( highway=service ) then 6 - else if ( highway=track ) then if tracktype=grade1 then 4 else 2 - else if ( highway=bridleway|road ) then 2 - else 0 - -# some more classifying bits used for voice hint generation... - -assign isgoodoneway = if reversedirection=yes then oneway=-1 - else if oneway= then junction=roundabout else oneway=yes|true|1 -assign isroundabout = junction=roundabout -assign isgoodforcars = if greater priorityclassifier 6 then true - else if highway=residential|living_street|service then true - else if ( and highway=track tracktype=grade1 ) then true - else false - -# ... encoded into a bitmask - -assign classifiermask add isbadoneway - add multiply isgoodoneway 2 - add multiply isroundabout 4 - add multiply islinktype 8 - add multiply isgoodforcars 16 - multiply highway=residential|living_street 32 - - ----context:node # following code refers to node tags - -# -# calculate logical car access to nodes -# -assign caraccess - switch motorcar= - switch motor_vehicle= - switch vehicle= - switch access= - not barrier=gate|bollard|lift_gate|cycle_barrier - access=yes|permissive|designated|destination - vehicle=yes|permissive|designated|destination - motor_vehicle=yes|permissive|designated|destination - motorcar=yes|permissive|designated|destination - -assign initialcost = - - switch caraccess - 0 - 1000000 - -assign maxspeed = - - if or crossing=traffic_signals highway=traffic_signals then 0 - else 999 diff --git a/misc/profiles2/car-eco-suspect_scan.brf b/misc/profiles2/car-eco-suspect_scan.brf deleted file mode 100644 index 802f394..0000000 --- a/misc/profiles2/car-eco-suspect_scan.brf +++ /dev/null @@ -1,214 +0,0 @@ -# -# Car-Routing based on a kinematic model -# -# Depending on the vmax-parameter (target-speed) -# this can be anything from least-time routing to eco-routing -# -# ----model:btools.router.KinematicModel - ----context:global - -# kinematic parameters - -assign vmax = 90 # kmh -assign recup_efficiency = 0.7 # (ratio) -assign totalweight = 1640 # kg -assign f_roll = 232 # Newton -assign f_air = 0.4 # 0.5*cw*A*rho -assign f_recup = 400 # Newton -assign p_standby = 250 # Watt - -# technical parameters - -assign validForCars = true -assign pass1coefficient = 1.3 -assign turnInstructionMode = 1 # 0=none, 1=auto-choose, 2=locus-style, 3=osmand-style - ----context:way # following code refers to way-tags - -assign initialcost switch route=ferry 20000 0 - -# -# calculate logical car access -# -assign isresidentialorliving = or highway=residential|living_street living_street=yes - -assign caraccess - switch motorcar= - switch motor_vehicle= - switch vehicle= - switch access= - switch highway=motorway|motorway_link 1 - switch highway=trunk|trunk_link 1 - switch highway=primary|primary_link 1 - switch highway=secondary|secondary_link 1 - switch highway=tertiary|tertiary_link 1 - switch highway=unclassified 1 - switch route=ferry 1 - switch isresidentialorliving 1 - switch highway=service 1 - 0 - access=yes|permissive|designated|destination - vehicle=yes|designated|destination - motor_vehicle=yes|permissive|designated|destination - motorcar=yes|permissive|designated|destination - -assign unknowncaraccess - switch motorcar= - switch motor_vehicle= - switch vehicle= - access=unknown - vehicle=unknown - motor_vehicle=unknown - motorcar=unknown - -assign psvaccess - or bus=yes|designated|urban - or psv=yes|designated - or hov=yes|designated - switch motorcar= - switch motor_vehicle= - switch vehicle= - access=psv|hov - vehicle=psv|hov - motor_vehicle=psv|hov - motorcar=psv|hov - -assign accessspeedlimit = if caraccess then 999 else 0 - -assign isroundabout = junction=roundabout|circular -assign implicitoneway = or isroundabout highway=motorway -assign isbadoneway = if reversedirection=yes then ( if oneway= then implicitoneway else oneway=yes|true|1 ) else oneway=-1 -assign onewayspeedlimit = if isbadoneway then 0 else 999 - -assign islinktype = highway=motorway_link|trunk_link|primary_link|secondary_link|tertiary_link - -assign maxspeed_surface = - switch or surface= surface=paved|asphalt|concrete 999 - switch surface=paving_stones|cobblestone 30 - 2 - -assign maxspeed_tracktype = - switch tracktype= 999 - switch tracktype=grade1 40 - switch tracktype=grade2 5 - 1 - -assign maxspeed_implicit = - switch highway=motorway 999 - switch highway=motorway_link 130 - switch highway=trunk 250 - switch highway=trunk_link 100 - switch highway=primary|primary_link 100 - switch highway=secondary|secondary_link 90 - switch highway=tertiary|tertiary_link 80 - switch highway=unclassified 50 - switch route=ferry 10 - switch highway=bridleway 10 - switch isresidentialorliving 30 - switch highway=service 30 - switch highway=track|road|path switch tracktype=grade1 30 5 - 0 - -assign maxspeed = - min onewayspeedlimit - min accessspeedlimit - switch maxspeed=50 50 - switch maxspeed=30 30 - switch maxspeed=10 10 - switch maxspeed=20 20 - switch maxspeed=40 40 - switch maxspeed=60 60 - switch maxspeed=70 70 - switch maxspeed=80 80 - switch maxspeed=90 90 - switch maxspeed=100 100 - switch maxspeed=110 110 - switch maxspeed=120 120 - switch maxspeed=130 130 - switch maxspeed=urban 50 - switch maxspeed=rural 100 - min maxspeed_implicit - min maxspeed_surface maxspeed_tracktype - -assign minspeed = - switch highway=motorway|trunk 75 0 - -# way priorities used for voice hint generation - -assign priorityclassifier = - - if ( highway=motorway ) then 30 - else if ( highway=motorway_link ) then 29 - else if ( highway=trunk ) then 28 - else if ( highway=trunk_link ) then 27 - else if ( highway=primary ) then 26 - else if ( highway=primary_link ) then 25 - else if ( highway=secondary ) then 24 - else if ( highway=secondary_link ) then 23 - else if ( highway=tertiary ) then 22 - else if ( highway=tertiary_link ) then 21 - else if ( highway=unclassified ) then 20 - else if ( isresidentialorliving ) then 6 - else if ( highway=service ) then 6 - else if ( highway=track ) then if tracktype=grade1 then 4 else 2 - else if ( highway=bridleway|road ) then 2 - else 0 - -assign costfactor = if equal maxspeed 0 - then ( if ( and equal accessspeedlimit 0 and greater onewayspeedlimit 0 and greater priorityclassifier 20 not psvaccess ) - then switch unknowncaraccess 9997 9998 - else 10000 ) - else 0 - -# some more classifying bits used for voice hint generation... - -assign isgoodoneway = if reversedirection=yes then oneway=-1 - else if oneway= then implicitoneway else oneway=yes|true|1 -assign isgoodforcars = if greater priorityclassifier 6 then true - else if or isresidentialorliving highway=service then true - else if ( and highway=track tracktype=grade1 ) then true - else false - -# ... encoded into a bitmask - -assign classifiermask add isbadoneway - add multiply isgoodoneway 2 - add multiply isroundabout 4 - add multiply islinktype 8 - add multiply isgoodforcars 16 - multiply isresidentialorliving 32 - - ----context:node # following code refers to node tags - -# -# calculate logical car access to nodes -# -assign caraccess - switch motorcar= - switch motor_vehicle= - switch vehicle= - switch access= - not barrier=gate|bollard|lift_gate|cycle_barrier - access=yes|permissive|designated|destination - vehicle=yes|permissive|designated|destination - motor_vehicle=yes|permissive|designated|destination - motorcar=yes|permissive|designated|destination - -assign initialcost = - - switch caraccess - 0 - 1000000 - -assign maxspeed = - - if or crossing=traffic_signals highway=traffic_signals - then - switch greater way:priorityclassifier 24 5 - switch greater way:priorityclassifier 22 3 - switch greater way:priorityclassifier 20 1 - 0 - else 999 diff --git a/misc/profiles2/car-traffic_analysis.brf b/misc/profiles2/car-traffic_analysis.brf deleted file mode 100644 index ba12476..0000000 --- a/misc/profiles2/car-traffic_analysis.brf +++ /dev/null @@ -1,128 +0,0 @@ -# -# Car-Routing is experimantal !!! -# -# DO NOT USE FOR ACTUAL NAVIGATION -# -# Turn restrictions are missing, leading to wrong routes -# - ----context:global - -assign downhillcost 0 -assign downhillcutoff 0 -assign uphillcost 0 -assign uphillcutoff 0 - -assign validForCars 1 -assign considerTurnRestrictions = false - -assign pass1coefficient 0. -assign pass2coefficient -1 - ----context:way # following code refers to way-tags - - -assign turncost = 0 - -assign initialcost switch route=ferry 20000 0 - - -# -# calculate logical car access -# -assign isresidentialorliving = or highway=residential|living_street living_street=yes - -assign caraccess - switch motorcar= - switch motor_vehicle= - switch vehicle= - switch access= - switch or highway=motorway highway=motorway_link 1 - switch or highway=trunk highway=trunk_link 1 - switch or highway=primary highway=primary_link 1 - switch or highway=secondary highway=secondary_link 1 - switch or highway=tertiary highway=tertiary_link 1 - switch highway=unclassified 1 - switch route=ferry 1 - switch isresidentialorliving 1 - switch highway=service 1 - 0 - or access=yes or access=permissive or access=designated access=destination - or vehicle=yes or vehicle=designated vehicle=destination - or motor_vehicle=yes or motor_vehicle=permissive or motor_vehicle=designated motor_vehicle=destination - or motorcar=yes or motorcar=permissive or motorcar=designated motorcar=destination - -assign accesspenalty - switch caraccess - 0 - 10000 - -assign onewaypenalty - switch switch reversedirection=yes - switch oneway= - junction=roundabout - or oneway=yes or oneway=true oneway=1 - oneway=-1 - 10000 - 0.0 - - -assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones - - -assign costfactor - - add max onewaypenalty accesspenalty - - switch and highway= not route=ferry 10000 - - switch or highway=motorway highway=motorway_link 1 - switch or highway=trunk highway=trunk_link 1 - switch or highway=primary highway=primary_link 1.2 - switch or highway=secondary highway=secondary_link 1.6 - switch or highway=tertiary highway=tertiary_link 2.0 - switch highway=unclassified 2.5 - switch route=ferry 5.67 - switch highway=bridleway 5 - switch isresidentialorliving 3.5 - switch highway=service 3.5 - switch or highway=track or highway=road highway=path - switch tracktype=grade1 5 - switch ispaved 5 - 30 - 10000 - -assign trafficsourcedensity = - if isresidentialorliving then 1 - else if and maxspeed=30|50 highway=tertiary|secondary|primary then 1 - else 0 - -assign istrafficbackbone - if greater costfactor 9999 then false - else if highway=motorway|motorway_link then true - else false - ----context:node # following code refers to node tags - -# -# calculate logical car access to nodes -# -assign caraccess - switch motorcar= - switch motor_vehicle= - switch vehicle= - switch access= - switch barrier=gate 0 - switch barrier=bollard 0 - switch barrier=lift_gate 0 - switch barrier=cycle_barrier 0 - 1 - or access=yes or access=permissive or access=designated access=destination - or vehicle=yes or vehicle=permissive or vehicle=designated vehicle=destination - or motor_vehicle=yes or motor_vehicle=permissive or motor_vehicle=designated motor_vehicle=destination - or motorcar=yes or motorcar=permissive or motorcar=designated motorcar=destination - -assign initialcost - switch caraccess - 0 - 1000000 From 905fe6df1963c6b2b40e5c15806be107b602fc77 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Tue, 21 Dec 2021 17:00:20 +0100 Subject: [PATCH 03/65] add osmand folder to distribution --- brouter-server/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/brouter-server/build.gradle b/brouter-server/build.gradle index cb0c78e..69d5959 100644 --- a/brouter-server/build.gradle +++ b/brouter-server/build.gradle @@ -56,6 +56,7 @@ distributions { exclude('**/softaccess.brf') from ('../misc') { include 'readmes/*' + include 'readmes/osmand/*' include 'profiles2/*' } from ('../brouter-routing-app/build/outputs/apk/api19/release') { From 623f3c0279aad3d1144fca3eb4a2e95e9194cdba Mon Sep 17 00:00:00 2001 From: afischerdev Date: Tue, 21 Dec 2021 17:02:35 +0100 Subject: [PATCH 04/65] set new version 1.6.3 --- brouter-core/src/main/java/btools/router/OsmTrack.java | 4 ++-- brouter-routing-app/build.gradle | 2 +- build.gradle | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/OsmTrack.java b/brouter-core/src/main/java/btools/router/OsmTrack.java index fde92a6..4c9b356 100644 --- a/brouter-core/src/main/java/btools/router/OsmTrack.java +++ b/brouter-core/src/main/java/btools/router/OsmTrack.java @@ -33,8 +33,8 @@ import btools.util.StringUtils; public final class OsmTrack { - final public static String version = "1.6.2"; - final public static String versionDate = "10102021"; + final public static String version = "1.6.3"; + final public static String versionDate = "21122021"; // csv-header-line private static final String MESSAGES_HEADER = "Longitude\tLatitude\tElevation\tDistance\tCostPerKm\tElevCost\tTurnCost\tNodeCost\tInitialCost\tWayTags\tNodeTags\tTime\tEnergy"; diff --git a/brouter-routing-app/build.gradle b/brouter-routing-app/build.gradle index cbec74f..f91133a 100644 --- a/brouter-routing-app/build.gradle +++ b/brouter-routing-app/build.gradle @@ -10,7 +10,7 @@ android { defaultConfig { applicationId "btools.routingapp" - versionCode 42 + versionCode 43 versionName project.version resValue('string', 'app_version', defaultConfig.versionName) diff --git a/build.gradle b/build.gradle index 7e9984f..3e0f897 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ allprojects { // this file // app: build.gradle (versionCode only) // OsmTrack (version and versionDate) - project.version "1.6.2" + project.version "1.6.3" group 'org.btools' repositories { From 50c5581e03bbd3c47e175c6d8ef40e03d037b7fa Mon Sep 17 00:00:00 2001 From: abrensch Date: Thu, 23 Dec 2021 16:38:41 +0100 Subject: [PATCH 05/65] Update build.gradle android version code 43->45 (due to problems uploading to google-play) --- brouter-routing-app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brouter-routing-app/build.gradle b/brouter-routing-app/build.gradle index f91133a..58dde91 100644 --- a/brouter-routing-app/build.gradle +++ b/brouter-routing-app/build.gradle @@ -10,7 +10,7 @@ android { defaultConfig { applicationId "btools.routingapp" - versionCode 43 + versionCode 45 versionName project.version resValue('string', 'app_version', defaultConfig.versionName) From c128a45cc2bf2c0d6a8159fe9c244f19c5b1e4d4 Mon Sep 17 00:00:00 2001 From: abrensch Date: Thu, 23 Dec 2021 17:45:54 +0100 Subject: [PATCH 06/65] Copy gradle-publish-test from afisherdev repo --- .github/workflows/gradle-publish-test.yml | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/gradle-publish-test.yml diff --git a/.github/workflows/gradle-publish-test.yml b/.github/workflows/gradle-publish-test.yml new file mode 100644 index 0000000..e3a2550 --- /dev/null +++ b/.github/workflows/gradle-publish-test.yml @@ -0,0 +1,47 @@ +# This workflow will build a package using Gradle, no releasee + +name: Gradle Package Test + +on: + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-latest + environment: BRouter + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'zulu' + cache: gradle + - name: Create local.properties + run: touch local.properties + - name: Setup keystore + env: + BROUTER_KEYSTORE_BASE64: ${{ secrets.BROUTER_KEYSTORE_BASE64 }} + run: | + echo $BROUTER_KEYSTORE_BASE64 | base64 -di > ${{ github.workspace }}/brouter.jks + - name: Build with Gradle + env: + BROUTER_KEYSTORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} + BROUTER_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} + BROUTER_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} + BROUTER_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} + run: ./gradlew build + - name: Upload BRouter zip + uses: actions/upload-artifact@v2 + with: + name: BRouter_current + path: brouter-server/build/distributions/brouter-*.zip + # The USERNAME and TOKEN need to correspond to the credentials environment variables used in + # the publishing section of your build.gradle + #- name: Publish to GitHub Packages + # run: gradle publish + # env: + # USERNAME: ${{ github.actor }} + # TOKEN: ${{ secrets.GITHUB_TOKEN }} + # REPO: ${{ github.repository }} From 06550dcbc85a5c5519ef3fdbb4cad83448233e10 Mon Sep 17 00:00:00 2001 From: abrensch Date: Fri, 24 Dec 2021 10:26:49 +0100 Subject: [PATCH 07/65] Update gradle-publish-test.yml --- .github/workflows/gradle-publish-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle-publish-test.yml b/.github/workflows/gradle-publish-test.yml index e3a2550..c4f74fe 100644 --- a/.github/workflows/gradle-publish-test.yml +++ b/.github/workflows/gradle-publish-test.yml @@ -31,7 +31,7 @@ jobs: BROUTER_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} BROUTER_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} BROUTER_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} - run: ./gradlew build + run: ./gradlew clean build - name: Upload BRouter zip uses: actions/upload-artifact@v2 with: From 7394ff151aba0b8417c9b8325183c8b1d0968ed3 Mon Sep 17 00:00:00 2001 From: abrensch Date: Fri, 24 Dec 2021 14:12:55 +0100 Subject: [PATCH 08/65] Update gradle-publish-test.yml --- .github/workflows/gradle-publish-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle-publish-test.yml b/.github/workflows/gradle-publish-test.yml index c4f74fe..045243d 100644 --- a/.github/workflows/gradle-publish-test.yml +++ b/.github/workflows/gradle-publish-test.yml @@ -27,10 +27,10 @@ jobs: echo $BROUTER_KEYSTORE_BASE64 | base64 -di > ${{ github.workspace }}/brouter.jks - name: Build with Gradle env: - BROUTER_KEYSTORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} - BROUTER_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} - BROUTER_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} - BROUTER_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} + ORG_GRADLE_PROJECT_BROUTER_KEYSTORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} + ORG_GRADLE_PROJECT_BROUTER_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} + ORG_GRADLE_PROJECT_BROUTER_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_BROUTER_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} run: ./gradlew clean build - name: Upload BRouter zip uses: actions/upload-artifact@v2 From d74b82944e2173ec11b3c1bfbc5896416a418d7b Mon Sep 17 00:00:00 2001 From: abrensch Date: Fri, 24 Dec 2021 14:24:37 +0100 Subject: [PATCH 09/65] Update gradle-publish-test.yml --- .github/workflows/gradle-publish-test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gradle-publish-test.yml b/.github/workflows/gradle-publish-test.yml index 045243d..7d22810 100644 --- a/.github/workflows/gradle-publish-test.yml +++ b/.github/workflows/gradle-publish-test.yml @@ -27,11 +27,11 @@ jobs: echo $BROUTER_KEYSTORE_BASE64 | base64 -di > ${{ github.workspace }}/brouter.jks - name: Build with Gradle env: - ORG_GRADLE_PROJECT_BROUTER_KEYSTORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} - ORG_GRADLE_PROJECT_BROUTER_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} - ORG_GRADLE_PROJECT_BROUTER_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} - ORG_GRADLE_PROJECT_BROUTER_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} - run: ./gradlew clean build + BROUTER_KEYSTORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} + BROUTER_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} + BROUTER_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} + BROUTER_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} + run: ./gradlew clean build -PBROUTER_KEYSTORE_FILE=$BROUTER_KEYSTORE_FILE -PBROUTER_KEY_ALIAS=$BROUTER_KEY_ALIAS -PBROUTER_KEY_ALIAS=$BROUTER_KEY_ALIAS -PBROUTER_STORE_PASSWORD=$BROUTER_STORE_PASSWORD - name: Upload BRouter zip uses: actions/upload-artifact@v2 with: From a7276c9be80262d0d8014866e6f70244e49689ae Mon Sep 17 00:00:00 2001 From: abrensch Date: Fri, 24 Dec 2021 14:40:47 +0100 Subject: [PATCH 10/65] Update gradle-publish-test.yml --- .github/workflows/gradle-publish-test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gradle-publish-test.yml b/.github/workflows/gradle-publish-test.yml index 7d22810..eea1f0c 100644 --- a/.github/workflows/gradle-publish-test.yml +++ b/.github/workflows/gradle-publish-test.yml @@ -27,11 +27,11 @@ jobs: echo $BROUTER_KEYSTORE_BASE64 | base64 -di > ${{ github.workspace }}/brouter.jks - name: Build with Gradle env: - BROUTER_KEYSTORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} - BROUTER_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} - BROUTER_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} - BROUTER_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} - run: ./gradlew clean build -PBROUTER_KEYSTORE_FILE=$BROUTER_KEYSTORE_FILE -PBROUTER_KEY_ALIAS=$BROUTER_KEY_ALIAS -PBROUTER_KEY_ALIAS=$BROUTER_KEY_ALIAS -PBROUTER_STORE_PASSWORD=$BROUTER_STORE_PASSWORD + RELEASE_STORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} + RELEASE_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} + RELEASE_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} + RELEASE_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} + run: ./gradlew clean build - name: Upload BRouter zip uses: actions/upload-artifact@v2 with: From f1b21fc270c02b61405998acafdf7e7340ddbb9c Mon Sep 17 00:00:00 2001 From: abrensch Date: Fri, 24 Dec 2021 14:45:18 +0100 Subject: [PATCH 11/65] Update gradle-publish-test.yml --- .github/workflows/gradle-publish-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle-publish-test.yml b/.github/workflows/gradle-publish-test.yml index eea1f0c..fd0b626 100644 --- a/.github/workflows/gradle-publish-test.yml +++ b/.github/workflows/gradle-publish-test.yml @@ -27,10 +27,10 @@ jobs: echo $BROUTER_KEYSTORE_BASE64 | base64 -di > ${{ github.workspace }}/brouter.jks - name: Build with Gradle env: - RELEASE_STORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} - RELEASE_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} - RELEASE_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} - RELEASE_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} + ORG_GRADLE_PROJECT_RELEASE_STORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} + ORG_GRADLE_PROJECT_RELEASE_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} + ORG_GRADLE_PROJECT_RELEASE_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_RELEASE_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} run: ./gradlew clean build - name: Upload BRouter zip uses: actions/upload-artifact@v2 From f5c3103dcf16e3c1bff45f53dea5f6a83c22212e Mon Sep 17 00:00:00 2001 From: afischerdev Date: Mon, 27 Dec 2021 20:02:13 +0100 Subject: [PATCH 12/65] update workflow, add check #379 --- .github/workflows/gradle-publish.yml | 12 ++++++++++++ .github/workflows/gradle.yml | 12 +++++++++++- .../main/java/btools/routingapp/BRouterActivity.java | 3 ++- .../src/main/java/btools/routingapp/BRouterView.java | 4 +++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 88ce852..960762b 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -12,6 +12,7 @@ jobs: build: runs-on: ubuntu-latest + environment: BRouter permissions: contents: read packages: write @@ -27,6 +28,17 @@ jobs: server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file + - name: Setup keystore + env: + BROUTER_KEYSTORE_BASE64: ${{ secrets.BROUTER_KEYSTORE_BASE64 }} + run: | + echo $BROUTER_KEYSTORE_BASE64 | base64 -di > ${{ github.workspace }}/brouter.jks + - name: Build with Gradle + env: + ORG_GRADLE_PROJECT_RELEASE_STORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} + ORG_GRADLE_PROJECT_RELEASE_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} + ORG_GRADLE_PROJECT_RELEASE_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_RELEASE_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} - name: Build with Gradle run: gradle build diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f27ddf3..354677c 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -13,7 +13,7 @@ jobs: build: runs-on: ubuntu-latest - + environment: BRouter steps: - uses: actions/checkout@v2 - name: Set up JDK 11 @@ -24,7 +24,17 @@ jobs: cache: gradle - name: Create local.properties run: touch local.properties + - name: Setup keystore + env: + BROUTER_KEYSTORE_BASE64: ${{ secrets.BROUTER_KEYSTORE_BASE64 }} + run: | + echo $BROUTER_KEYSTORE_BASE64 | base64 -di > ${{ github.workspace }}/brouter.jks - name: Build with Gradle + env: + ORG_GRADLE_PROJECT_RELEASE_STORE_FILE: ${{ secrets.BROUTER_KEYSTORE_FILE }} + ORG_GRADLE_PROJECT_RELEASE_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} + ORG_GRADLE_PROJECT_RELEASE_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_RELEASE_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} run: ./gradlew build - name: Upload ZIP uses: actions/upload-artifact@v2 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 5fb8e04..4b2e89a 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java @@ -596,7 +596,8 @@ public class BRouterActivity extends Activity implements ActivityCompat.OnReques } } - if (checkExternalStorageWritable()) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q + && checkExternalStorageWritable()) { res.add(Environment.getExternalStorageDirectory()); } 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 9b04dba..640c92f 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java @@ -204,7 +204,9 @@ public class BRouterView extends View { // new init is done move old files if (waitingForMigration) { - moveFolders(oldMigrationPath, basedir + "/brouter"); + Log.d("BR", "path " + oldMigrationPath + " " + basedir); + if (!oldMigrationPath.equals(basedir + "/brouter")) + moveFolders(oldMigrationPath, basedir + "/brouter"); waitingForMigration = false; } From 7b460d25d36338aaae9774bd3757cba42900601c Mon Sep 17 00:00:00 2001 From: afischerdev Date: Tue, 28 Dec 2021 10:49:56 +0100 Subject: [PATCH 13/65] add file check for A10 #379 --- .../btools/routingapp/BRouterActivity.java | 2 +- .../java/btools/routingapp/BRouterView.java | 27 +++++++++++++------ 2 files changed, 20 insertions(+), 9 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 4b2e89a..9f933be 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java @@ -596,7 +596,7 @@ public class BRouterActivity extends Activity implements ActivityCompat.OnReques } } - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R && checkExternalStorageWritable()) { res.add(Environment.getExternalStorageDirectory()); } 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 640c92f..3141278 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java @@ -123,6 +123,15 @@ public class BRouterView extends View { if (brd.isDirectory()) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q && !brd.getAbsolutePath().contains("/Android/media/btools.routingapp")) { + + // don't ask twice + String version = "v" + getContext().getString(R.string.app_version); + File vFile = new File(brd, "profiles2/"+version ); + if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.Q + && vFile.exists()) { + startSetup(baseDir, false); + return; + } String message = "(previous basedir " + baseDir + " has to migrate )"; ((BRouterActivity) getContext()).selectBasedir(((BRouterActivity) getContext()).getStorageDirectories(), guessBaseDir(), message); @@ -608,16 +617,18 @@ public class BRouterView extends View { break; String name = ze.getName(); File outfile = new File(path, name); - outfile.getParentFile().mkdirs(); - FileOutputStream fos = new FileOutputStream(outfile); + if (!outfile.exists()) { + outfile.getParentFile().mkdirs(); + FileOutputStream fos = new FileOutputStream(outfile); - for (; ; ) { - int len = zis.read(data, 0, 1024); - if (len < 0) - break; - fos.write(data, 0, len); + for (; ; ) { + int len = zis.read(data, 0, 1024); + if (len < 0) + break; + fos.write(data, 0, len); + } + fos.close(); } - fos.close(); } is.close(); return true; From 236c65d8edbcb5aff7537bcb8f58f7c678310a23 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Thu, 30 Dec 2021 14:24:03 +0100 Subject: [PATCH 14/65] Fix external storage access - Allow writing on all versions - Skip migration if BRouter version has already setup basedir --- .../src/main/java/btools/routingapp/BRouterActivity.java | 3 +-- .../src/main/java/btools/routingapp/BRouterView.java | 2 +- 2 files changed, 2 insertions(+), 3 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 9f933be..5fb8e04 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java @@ -596,8 +596,7 @@ public class BRouterActivity extends Activity implements ActivityCompat.OnReques } } - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R - && checkExternalStorageWritable()) { + if (checkExternalStorageWritable()) { res.add(Environment.getExternalStorageDirectory()); } 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 3141278..8b5f69c 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java @@ -127,7 +127,7 @@ 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 ); - if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.Q + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q && vFile.exists()) { startSetup(baseDir, false); return; From 82d28ed08ac7d8d39e1499c2d61abfaf2580e4b0 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Fri, 31 Dec 2021 08:30:37 +0100 Subject: [PATCH 15/65] Fix build with empty signing environment variables GitHub action secrets default to empty values if they aren't defined in a repository. Any fork of the repo doesn't have access to the secrets and the jobs therefore fail. --- brouter-routing-app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brouter-routing-app/build.gradle b/brouter-routing-app/build.gradle index 58dde91..9ddfdb3 100644 --- a/brouter-routing-app/build.gradle +++ b/brouter-routing-app/build.gradle @@ -21,7 +21,7 @@ android { sourceSets.main.assets.srcDirs += new File(project.buildDir, 'assets') - if(project.hasProperty("RELEASE_STORE_FILE")) { + if(project.hasProperty("RELEASE_STORE_FILE") && RELEASE_STORE_FILE.length() > 0) { signingConfigs { // this uses a file ~/.gradle/gradle.properties // with content: @@ -49,7 +49,7 @@ android { release { minifyEnabled false debuggable false - if(project.hasProperty("RELEASE_STORE_FILE")) { + if(project.hasProperty("RELEASE_STORE_FILE") && RELEASE_STORE_FILE.length() > 0) { signingConfig signingConfigs.release } proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' From b5f6acf63afefcbf038534b2e5b4bfeffbc94cc4 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Fri, 31 Dec 2021 08:33:43 +0100 Subject: [PATCH 16/65] Fix gradle-publish --- .github/workflows/gradle-publish.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 960762b..0dab983 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -39,10 +39,8 @@ jobs: ORG_GRADLE_PROJECT_RELEASE_KEY_ALIAS: ${{ secrets.BROUTER_KEY_ALIAS }} ORG_GRADLE_PROJECT_RELEASE_KEY_PASSWORD: ${{ secrets.BROUTER_KEY_PASSWORD }} ORG_GRADLE_PROJECT_RELEASE_STORE_PASSWORD: ${{ secrets.BROUTER_STORE_PASSWORD }} - - name: Build with Gradle run: gradle build - # The USERNAME and TOKEN need to correspond to the credentials environment variables used in # the publishing section of your build.gradle - name: Publish to GitHub Packages From d9b8f69f59b1f246da9c7cc4003132a9e32b2b76 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Tue, 26 Oct 2021 10:13:43 +0200 Subject: [PATCH 17/65] Add test to ensure legacy storage access --- brouter-routing-app/build.gradle | 6 +++ .../routingapp/BRouterActivityTest.java | 47 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 brouter-routing-app/src/androidTest/java/btools/routingapp/BRouterActivityTest.java diff --git a/brouter-routing-app/build.gradle b/brouter-routing-app/build.gradle index 58dde91..bd69984 100644 --- a/brouter-routing-app/build.gradle +++ b/brouter-routing-app/build.gradle @@ -17,6 +17,8 @@ android { setProperty("archivesBaseName","BRouterApp." + defaultConfig.versionName) minSdkVersion 14 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } sourceSets.main.assets.srcDirs += new File(project.buildDir, 'assets') @@ -99,6 +101,10 @@ dependencies { implementation project(':brouter-expressions') implementation project(':brouter-util') + testImplementation 'junit:junit:4.13.2' + + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } task generateProfiles(type: Exec) { diff --git a/brouter-routing-app/src/androidTest/java/btools/routingapp/BRouterActivityTest.java b/brouter-routing-app/src/androidTest/java/btools/routingapp/BRouterActivityTest.java new file mode 100644 index 0000000..6a6a9cd --- /dev/null +++ b/brouter-routing-app/src/androidTest/java/btools/routingapp/BRouterActivityTest.java @@ -0,0 +1,47 @@ +package btools.routingapp; + +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; + +import android.os.Build; +import android.os.Environment; + +import androidx.test.core.app.ActivityScenario; +import androidx.test.ext.junit.rules.ActivityScenarioRule; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.List; + +@RunWith(AndroidJUnit4.class) +public class BRouterActivityTest { + @Rule + public ActivityScenarioRule rule = new ActivityScenarioRule<>(BRouterActivity.class); + + @Test + public void storageDirectories() { + ActivityScenario scenario = rule.getScenario(); + scenario.onActivity(activity -> { + List storageDirectories = activity.getStorageDirectories(); + + // Before Android Q (10) legacy storage access is possible + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + assertThat(storageDirectories, hasItem(Environment.getExternalStorageDirectory())); + } + + // When targeting older SDK we can access legacy storage on any android version + if (activity.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.Q) { + assertThat(storageDirectories, hasItem(Environment.getExternalStorageDirectory())); + } + + assertThat(storageDirectories, not(empty())); + }); + } + +} From 553f064ce0435da1a8c5a26888a853548fcbfac4 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Sat, 20 Nov 2021 14:42:05 +0100 Subject: [PATCH 18/65] Optimize Imports --- .../btools/routingapp/BInstallerActivity.java | 8 +++--- .../btools/routingapp/BInstallerView.java | 25 +++++-------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index 9fdbc76..9b58547 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -1,8 +1,5 @@ package btools.routingapp; -import java.util.HashSet; -import java.util.Set; - import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -16,9 +13,10 @@ import android.os.Build; import android.os.Bundle; import android.os.PowerManager; import android.os.PowerManager.WakeLock; -import android.speech.tts.TextToSpeech.OnInitListener; import android.os.StatFs; -import android.util.Log; + +import java.util.HashSet; +import java.util.Set; public class BInstallerActivity extends Activity { 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 f262cfc..2752b8e 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -1,15 +1,5 @@ package btools.routingapp; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.Locale; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -20,21 +10,18 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; -import android.os.AsyncTask; -import android.os.PowerManager; -import android.os.StatFs; -import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.widget.Toast; -import btools.mapaccess.PhysicalFile; -import btools.mapaccess.Rd5DiffManager; -import btools.mapaccess.Rd5DiffTool; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Locale; + import btools.router.RoutingHelper; -import btools.util.ProgressListener; public class BInstallerView extends View { private static final int MASK_SELECTED_RD5 = 1; From 89ef74f95b6c67549309588f1a721b4d52c0e33d Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Tue, 19 Oct 2021 06:00:04 +0200 Subject: [PATCH 19/65] Android Studio automatic cleanup --- .../btools/routingapp/BInstallerActivity.java | 29 ++-- .../btools/routingapp/BInstallerView.java | 125 ++++++++---------- 2 files changed, 65 insertions(+), 89 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index 9b58547..e42b3d0 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -28,20 +28,7 @@ public class BInstallerActivity extends Activity { private PowerManager mPowerManager; private WakeLock mWakeLock; private DownloadReceiver myReceiver; - - - public class DownloadReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - if (intent.hasExtra("txt")) { - String txt = intent.getStringExtra("txt"); - boolean ready = intent.getBooleanExtra("ready", false); - mBInstallerView.setState(txt, ready); - } - } - } - + private final Set dialogIds = new HashSet(); /** * Called when the activity is first created. @@ -132,8 +119,6 @@ public class BInstallerActivity extends Activity { showDialog(DIALOG_CONFIRM_DELETE_ID); } - private Set dialogIds = new HashSet(); - private void showNewDialog(int id) { if (dialogIds.contains(Integer.valueOf(id))) { removeDialog(id); @@ -142,6 +127,18 @@ public class BInstallerActivity extends Activity { showDialog(id); } + public class DownloadReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + if (intent.hasExtra("txt")) { + String txt = intent.getStringExtra("txt"); + boolean ready = intent.getBooleanExtra("ready", false); + mBInstallerView.setState(txt, ready); + } + } + } + static public long getAvailableSpace(String baseDir) { StatFs stat = new StatFs(baseDir); 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 2752b8e..0ba2448 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -28,50 +28,63 @@ public class BInstallerView extends View { private static final int MASK_DELETED_RD5 = 2; private static final int MASK_INSTALLED_RD5 = 4; private static final int MASK_CURRENT_RD5 = 8; - - private int imgwOrig; - private int imghOrig; - private float scaleOrig; - - private int imgw; - private int imgh; - - private float lastDownX; - private float lastDownY; - - private Bitmap bmp; - - private float viewscale; - - private float[] testVector = new float[2]; - - private int[] tileStatus; - - private boolean tilesVisible = false; - - private long availableSize; - private File baseDir; - private File segmentDir; - - private boolean isDownloading = false; public static boolean downloadCanceled = false; - - private long currentDownloadSize; - private String currentDownloadFile = ""; - private volatile String currentDownloadOperation = ""; - private String downloadAction = ""; - private volatile String newDownloadAction = ""; - - private long totalSize = 0; - private long rd5Tiles = 0; - private long delTiles = 0; - Paint pnt_1 = new Paint(); Paint pnt_2 = new Paint(); Paint paint = new Paint(); - Activity mActivity; + int btnh = 40; + int btnw = 160; + float tx, ty; + private final int imgwOrig; + private final int imghOrig; + private final float scaleOrig; + private final int imgw; + private final int imgh; + private float lastDownX; + private float lastDownY; + private Bitmap bmp; + private float viewscale; + private final float[] testVector = new float[2]; + private int[] tileStatus; + private boolean tilesVisible = false; + private long availableSize; + private File baseDir; + private File segmentDir; + private boolean isDownloading = false; + private long currentDownloadSize; + private final String currentDownloadFile = ""; + private volatile String currentDownloadOperation = ""; + private String downloadAction = ""; + private final String newDownloadAction = ""; + private long totalSize = 0; + private long rd5Tiles = 0; + private long delTiles = 0; + private Matrix mat; + private final Matrix matText; + public BInstallerView(Context context) { + super(context); + mActivity = (Activity) context; + + DisplayMetrics metrics = new DisplayMetrics(); + ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); + imgwOrig = metrics.widthPixels; + imghOrig = metrics.heightPixels; + int im = imgwOrig > imghOrig ? imgwOrig : imghOrig; + + scaleOrig = im / 480.f; + + matText = new Matrix(); + matText.preScale(scaleOrig, scaleOrig); + + imgw = (int) (imgwOrig / scaleOrig); + imgh = (int) (imghOrig / scaleOrig); + + totalSize = 0; + rd5Tiles = 0; + delTiles = 0; + } protected String baseNameForTile(int tileIndex) { int lon = (tileIndex % 72) * 5 - 180; @@ -100,7 +113,6 @@ public class BInstallerView extends View { return (ilon + 180) / 5 + 72 * ((ilat + 90) / 5); } - public boolean isDownloadCanceled() { return downloadCanceled; } @@ -167,7 +179,6 @@ public class BInstallerView extends View { deleteRawTracks(); // invalidate raw-tracks after data update } - public void downloadDone(boolean success) { isDownloading = false; if (success) { @@ -234,7 +245,7 @@ public class BInstallerView extends View { availableSize = -1; try { - availableSize = (long) ((BInstallerActivity) getContext()).getAvailableSpace(baseDir.getAbsolutePath()); + availableSize = ((BInstallerActivity) getContext()).getAvailableSpace(baseDir.getAbsolutePath()); //StatFs stat = new StatFs(baseDir.getAbsolutePath ()); //availableSize = (long)stat.getAvailableBlocksLong()*stat.getBlockSizeLong(); } catch (Exception e) { /* ignore */ } @@ -256,9 +267,6 @@ public class BInstallerView extends View { } } - private Matrix mat; - private Matrix matText; - public void startInstaller() { baseDir = ConfigHelper.getBaseDir(getContext()); @@ -285,29 +293,6 @@ public class BInstallerView extends View { tilesVisible = false; } - public BInstallerView(Context context) { - super(context); - mActivity = (Activity) context; - - DisplayMetrics metrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); - imgwOrig = metrics.widthPixels; - imghOrig = metrics.heightPixels; - int im = imgwOrig > imghOrig ? imgwOrig : imghOrig; - - scaleOrig = im / 480.f; - - matText = new Matrix(); - matText.preScale(scaleOrig, scaleOrig); - - imgw = (int) (imgwOrig / scaleOrig); - imgh = (int) (imghOrig / scaleOrig); - - totalSize = 0; - rd5Tiles = 0; - delTiles = 0; - } - @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); @@ -411,12 +396,6 @@ public class BInstallerView extends View { } } - int btnh = 40; - int btnw = 160; - - - float tx, ty; - private void drawSelectedTiles(Canvas canvas, Paint pnt, float fw, float fh, int status, int mask, boolean doCount, boolean cntDel, boolean doDraw) { for (int ix = 0; ix < 72; ix++) for (int iy = 0; iy < 36; iy++) { From de7dd71a944e7120a3111b52bc288069c61bcf28 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Tue, 19 Oct 2021 06:06:34 +0200 Subject: [PATCH 20/65] Apply Quick Fixes suggested by Android Studio --- .../btools/routingapp/BInstallerActivity.java | 6 +-- .../btools/routingapp/BInstallerView.java | 48 ++----------------- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index e42b3d0..1b80c6b 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -28,7 +28,7 @@ public class BInstallerActivity extends Activity { private PowerManager mPowerManager; private WakeLock mWakeLock; private DownloadReceiver myReceiver; - private final Set dialogIds = new HashSet(); + private final Set dialogIds = new HashSet<>(); /** * Called when the activity is first created. @@ -120,10 +120,10 @@ public class BInstallerActivity extends Activity { } private void showNewDialog(int id) { - if (dialogIds.contains(Integer.valueOf(id))) { + if (dialogIds.contains(id)) { removeDialog(id); } - dialogIds.add(Integer.valueOf(id)); + dialogIds.add(id); showDialog(id); } 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 0ba2448..a209bf7 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -13,7 +13,6 @@ import android.graphics.Paint; import android.util.DisplayMetrics; import android.view.MotionEvent; import android.view.View; -import android.widget.Toast; import java.io.File; import java.io.IOException; @@ -52,11 +51,8 @@ public class BInstallerView extends View { private File baseDir; private File segmentDir; private boolean isDownloading = false; - private long currentDownloadSize; - private final String currentDownloadFile = ""; private volatile String currentDownloadOperation = ""; private String downloadAction = ""; - private final String newDownloadAction = ""; private long totalSize = 0; private long rd5Tiles = 0; private long delTiles = 0; @@ -71,7 +67,7 @@ public class BInstallerView extends View { ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); imgwOrig = metrics.widthPixels; imghOrig = metrics.heightPixels; - int im = imgwOrig > imghOrig ? imgwOrig : imghOrig; + int im = Math.max(imgwOrig, imghOrig); scaleOrig = im / 480.f; @@ -80,10 +76,6 @@ public class BInstallerView extends View { imgw = (int) (imgwOrig / scaleOrig); imgh = (int) (imghOrig / scaleOrig); - - totalSize = 0; - rd5Tiles = 0; - delTiles = 0; } protected String baseNameForTile(int tileIndex) { @@ -113,10 +105,6 @@ public class BInstallerView extends View { return (ilon + 180) / 5 + 72 * ((ilat + 90) / 5); } - public boolean isDownloadCanceled() { - return downloadCanceled; - } - private void toggleDownload() { if (isDownloading) { downloadCanceled = true; @@ -129,7 +117,6 @@ public class BInstallerView extends View { return; } - int tidx_min = -1; int min_size = Integer.MAX_VALUE; ArrayList downloadList = new ArrayList<>(); @@ -141,7 +128,6 @@ public class BInstallerView extends View { int tilesize = BInstallerSizes.getRd5Size(tidx); downloadList.add(tidx); if (tilesize > 0 && tilesize < min_size) { - tidx_min = tidx; min_size = tilesize; } } @@ -152,7 +138,7 @@ public class BInstallerView extends View { isDownloading = true; downloadAll(downloadList); for (Integer i : downloadList) { - tileStatus[i.intValue()] ^= tileStatus[i.intValue()] & MASK_SELECTED_RD5; + tileStatus[i] ^= tileStatus[i] & MASK_SELECTED_RD5; } downloadList.clear(); } @@ -161,7 +147,7 @@ public class BInstallerView extends View { private void downloadAll(ArrayList downloadList) { ArrayList urlparts = new ArrayList<>(); for (Integer i : downloadList) { - urlparts.add(baseNameForTile(i.intValue())); + urlparts.add(baseNameForTile(i)); } currentDownloadOperation = "Start download ..."; @@ -169,8 +155,6 @@ public class BInstallerView extends View { downloadCanceled = false; isDownloading = true; - //final DownloadBackground downloadTask = new DownloadBackground(getContext(), urlparts, baseDir); - //downloadTask.execute( ); Intent intent = new Intent(mActivity, DownloadService.class); intent.putExtra("dir", baseDir.getAbsolutePath() + "/brouter/"); intent.putExtra("urlparts", urlparts); @@ -179,15 +163,6 @@ public class BInstallerView extends View { deleteRawTracks(); // invalidate raw-tracks after data update } - public void downloadDone(boolean success) { - isDownloading = false; - if (success) { - scanExistingFiles(); - toggleDownload(); // keep on if no error - } - invalidate(); - } - public void setState(String txt, boolean b) { currentDownloadOperation = txt; downloadAction = ""; @@ -245,9 +220,7 @@ public class BInstallerView extends View { availableSize = -1; try { - availableSize = ((BInstallerActivity) getContext()).getAvailableSpace(baseDir.getAbsolutePath()); - //StatFs stat = new StatFs(baseDir.getAbsolutePath ()); - //availableSize = (long)stat.getAvailableBlocksLong()*stat.getBlockSizeLong(); + availableSize = BInstallerActivity.getAvailableSpace(baseDir.getAbsolutePath()); } catch (Exception e) { /* ignore */ } } @@ -286,7 +259,7 @@ public class BInstallerView extends View { float scaleX = imgwOrig / ((float) bmp.getWidth()); float scaley = imghOrig / ((float) bmp.getHeight()); - viewscale = scaleX < scaley ? scaleX : scaley; + viewscale = Math.min(scaleX, scaley); mat = new Matrix(); mat.postScale(viewscale, viewscale); @@ -298,10 +271,6 @@ public class BInstallerView extends View { super.onSizeChanged(w, h, oldw, oldh); } - private void toast(String msg) { - Toast.makeText(getContext(), msg, Toast.LENGTH_LONG).show(); - } - @Override protected void onDraw(Canvas canvas) { if (!isDownloading) { @@ -359,7 +328,6 @@ public class BInstallerView extends View { long mb = 1024 * 1024; if (isDownloading) { - String sizeHint = currentDownloadSize > 0 ? " (" + ((currentDownloadSize + mb - 1) / mb) + " MB)" : ""; paint.setTextSize(30); canvas.drawText(currentDownloadOperation, 30, (imgh / 3) * 2 - 30, paint); // canvas.drawText( currentDownloadOperation + " " + currentDownloadFile + sizeHint, 30, (imgh/3)*2-30, paint); @@ -443,12 +411,6 @@ public class BInstallerView extends View { @Override public boolean onTouchEvent(MotionEvent event) { - // get pointer index from the event object - int pointerIndex = event.getActionIndex(); - - // get pointer ID - int pointerId = event.getPointerId(pointerIndex); - // get masked (not specific to a pointer) action int maskedAction = event.getActionMasked(); From dd7a2fcd98969bf34fe3f84ecfa9e1985cf70b82 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Tue, 4 Jan 2022 12:01:57 +0100 Subject: [PATCH 21/65] More Fixes --- .../btools/routingapp/BInstallerActivity.java | 38 ++++++------------- .../btools/routingapp/BInstallerView.java | 14 +++---- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index 1b80c6b..2c27b50 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -15,26 +15,31 @@ import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.StatFs; -import java.util.HashSet; -import java.util.Set; - public class BInstallerActivity extends Activity { public static final String DOWNLOAD_ACTION = "btools.routingapp.download"; private static final int DIALOG_CONFIRM_DELETE_ID = 1; - private BInstallerView mBInstallerView; private PowerManager mPowerManager; private WakeLock mWakeLock; private DownloadReceiver myReceiver; - private final Set dialogIds = new HashSet<>(); + + static public long getAvailableSpace(String baseDir) { + StatFs stat = new StatFs(baseDir); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + return stat.getAvailableBlocksLong() * stat.getBlockSizeLong(); + } else { + //noinspection deprecation + return (long) stat.getAvailableBlocks() * stat.getBlockSize(); + } + } /** * Called when the activity is first created. */ @Override - @SuppressWarnings("deprecation") public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -91,7 +96,6 @@ public class BInstallerActivity extends Activity { } @Override - @SuppressWarnings("deprecation") protected Dialog onCreateDialog(int id) { AlertDialog.Builder builder; switch (id) { @@ -114,19 +118,10 @@ public class BInstallerActivity extends Activity { } } - @SuppressWarnings("deprecation") public void showConfirmDelete() { showDialog(DIALOG_CONFIRM_DELETE_ID); } - private void showNewDialog(int id) { - if (dialogIds.contains(id)) { - removeDialog(id); - } - dialogIds.add(id); - showDialog(id); - } - public class DownloadReceiver extends BroadcastReceiver { @Override @@ -138,15 +133,4 @@ public class BInstallerActivity extends Activity { } } } - - - static public long getAvailableSpace(String baseDir) { - StatFs stat = new StatFs(baseDir); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - return stat.getAvailableBlocksLong() * stat.getBlockSizeLong(); - } else { - return stat.getAvailableBlocks() * stat.getBlockSize(); - } - } } 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 a209bf7..d3c3199 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -28,6 +28,13 @@ public class BInstallerView extends View { private static final int MASK_INSTALLED_RD5 = 4; private static final int MASK_CURRENT_RD5 = 8; public static boolean downloadCanceled = false; + private final int imgwOrig; + private final int imghOrig; + private final float scaleOrig; + private final int imgw; + private final int imgh; + private final float[] testVector = new float[2]; + private final Matrix matText; Paint pnt_1 = new Paint(); Paint pnt_2 = new Paint(); Paint paint = new Paint(); @@ -35,16 +42,10 @@ public class BInstallerView extends View { int btnh = 40; int btnw = 160; float tx, ty; - private final int imgwOrig; - private final int imghOrig; - private final float scaleOrig; - private final int imgw; - private final int imgh; private float lastDownX; private float lastDownY; private Bitmap bmp; private float viewscale; - private final float[] testVector = new float[2]; private int[] tileStatus; private boolean tilesVisible = false; private long availableSize; @@ -57,7 +58,6 @@ public class BInstallerView extends View { private long rd5Tiles = 0; private long delTiles = 0; private Matrix mat; - private final Matrix matText; public BInstallerView(Context context) { super(context); From 64a80e763ba8d8b48bd2cadda045946f1a7f6254 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Tue, 19 Oct 2021 06:13:37 +0200 Subject: [PATCH 22/65] Merge startInstaller into constructor --- .../btools/routingapp/BInstallerActivity.java | 7 --- .../btools/routingapp/BInstallerView.java | 61 +++++++++---------- 2 files changed, 29 insertions(+), 39 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index 2c27b50..4a3ef2e 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -36,9 +36,6 @@ public class BInstallerActivity extends Activity { } } - /** - * Called when the activity is first created. - */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -52,7 +49,6 @@ public class BInstallerActivity extends Activity { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); - // instantiate our simulation view and set it as the activity's content mBInstallerView = new BInstallerView(this); setContentView(mBInstallerView); } @@ -72,9 +68,6 @@ public class BInstallerActivity extends Activity { myReceiver = new DownloadReceiver(); registerReceiver(myReceiver, filter); - - // Start the download manager - mBInstallerView.startInstaller(); } @Override 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 d3c3199..f86188b 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -35,6 +35,12 @@ public class BInstallerView extends View { private final int imgh; private final float[] testVector = new float[2]; private final Matrix matText; + private final File baseDir; + private final File segmentDir; + private final Matrix mat; + private final Bitmap bmp; + private final float viewscale; + private final int[] tileStatus; Paint pnt_1 = new Paint(); Paint pnt_2 = new Paint(); Paint paint = new Paint(); @@ -44,20 +50,14 @@ public class BInstallerView extends View { float tx, ty; private float lastDownX; private float lastDownY; - private Bitmap bmp; - private float viewscale; - private int[] tileStatus; private boolean tilesVisible = false; private long availableSize; - private File baseDir; - private File segmentDir; private boolean isDownloading = false; private volatile String currentDownloadOperation = ""; private String downloadAction = ""; private long totalSize = 0; private long rd5Tiles = 0; private long delTiles = 0; - private Matrix mat; public BInstallerView(Context context) { super(context); @@ -76,6 +76,29 @@ public class BInstallerView extends View { imgw = (int) (imgwOrig / scaleOrig); imgh = (int) (imghOrig / scaleOrig); + + baseDir = ConfigHelper.getBaseDir(getContext()); + segmentDir = new File(baseDir, "brouter/segments4"); + + try { + AssetManager assetManager = getContext().getAssets(); + InputStream istr = assetManager.open("world.png"); + bmp = BitmapFactory.decodeStream(istr); + istr.close(); + } catch (IOException io) { + throw new RuntimeException("cannot read world.png from assets"); + } + + tileStatus = new int[72 * 36]; + scanExistingFiles(); + + float scaleX = imgwOrig / ((float) bmp.getWidth()); + float scaley = imghOrig / ((float) bmp.getHeight()); + + viewscale = Math.min(scaleX, scaley); + + mat = new Matrix(); + mat.postScale(viewscale, viewscale); } protected String baseNameForTile(int tileIndex) { @@ -240,32 +263,6 @@ public class BInstallerView extends View { } } - public void startInstaller() { - - baseDir = ConfigHelper.getBaseDir(getContext()); - segmentDir = new File(baseDir, "brouter/segments4"); - try { - AssetManager assetManager = getContext().getAssets(); - InputStream istr = assetManager.open("world.png"); - bmp = BitmapFactory.decodeStream(istr); - istr.close(); - } catch (IOException io) { - throw new RuntimeException("cannot read world.png from assets"); - } - - tileStatus = new int[72 * 36]; - scanExistingFiles(); - - float scaleX = imgwOrig / ((float) bmp.getWidth()); - float scaley = imghOrig / ((float) bmp.getHeight()); - - viewscale = Math.min(scaleX, scaley); - - mat = new Matrix(); - mat.postScale(viewscale, viewscale); - tilesVisible = false; - } - @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); From 32747a1f6f99249de4b4736dafaaaf72a4d24cd8 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Fri, 15 Oct 2021 16:30:05 +0200 Subject: [PATCH 23/65] Remove wakelock from BInstallerActivity --- .../btools/routingapp/BInstallerActivity.java | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index 4a3ef2e..1cae08b 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -11,8 +11,6 @@ import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.os.Build; import android.os.Bundle; -import android.os.PowerManager; -import android.os.PowerManager.WakeLock; import android.os.StatFs; public class BInstallerActivity extends Activity { @@ -21,8 +19,6 @@ public class BInstallerActivity extends Activity { private static final int DIALOG_CONFIRM_DELETE_ID = 1; private BInstallerView mBInstallerView; - private PowerManager mPowerManager; - private WakeLock mWakeLock; private DownloadReceiver myReceiver; static public long getAvailableSpace(String baseDir) { @@ -40,13 +36,6 @@ public class BInstallerActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Get an instance of the PowerManager - mPowerManager = (PowerManager) getSystemService(POWER_SERVICE); - - // Create a bright wake lock - mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass() - .getName()); - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mBInstallerView = new BInstallerView(this); @@ -56,12 +45,6 @@ public class BInstallerActivity extends Activity { @Override protected void onResume() { super.onResume(); - /* - * when the activity is resumed, we acquire a wake-lock so that the - * screen stays on, since the user will likely not be fiddling with the - * screen or buttons. - */ - mWakeLock.acquire(); IntentFilter filter = new IntentFilter(); filter.addAction(DOWNLOAD_ACTION); @@ -73,12 +56,6 @@ public class BInstallerActivity extends Activity { @Override protected void onPause() { super.onPause(); - - - super.onPause(); - - mWakeLock.release(); - } @Override From e045a732fb601725069817c7a507bdc4b12a76ab Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Fri, 15 Oct 2021 16:31:13 +0200 Subject: [PATCH 24/65] Rename DownloadReceiver --- .../main/java/btools/routingapp/BInstallerActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index 1cae08b..5a787f8 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -19,7 +19,7 @@ public class BInstallerActivity extends Activity { private static final int DIALOG_CONFIRM_DELETE_ID = 1; private BInstallerView mBInstallerView; - private DownloadReceiver myReceiver; + private DownloadReceiver downloadReceiver; static public long getAvailableSpace(String baseDir) { StatFs stat = new StatFs(baseDir); @@ -49,8 +49,8 @@ public class BInstallerActivity extends Activity { IntentFilter filter = new IntentFilter(); filter.addAction(DOWNLOAD_ACTION); - myReceiver = new DownloadReceiver(); - registerReceiver(myReceiver, filter); + downloadReceiver = new DownloadReceiver(); + registerReceiver(downloadReceiver, filter); } @Override @@ -61,7 +61,7 @@ public class BInstallerActivity extends Activity { @Override public void onDestroy() { super.onDestroy(); - if (myReceiver != null) unregisterReceiver(myReceiver); + if (downloadReceiver != null) unregisterReceiver(downloadReceiver); System.exit(0); } From 806ae6250e14defabd306eb3ec9019ae283149ab Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Sat, 16 Oct 2021 06:54:02 +0200 Subject: [PATCH 25/65] Draw rect using canvas --- .../src/main/java/btools/routingapp/BInstallerView.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 f86188b..0b9376b 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -352,11 +352,9 @@ public class BInstallerView extends View { RoutingHelper.hasDirectoryAnyDatafiles(segmentDir)) btnText = "Update all"; if (btnText != null) { - canvas.drawLine(imgw - btnw, imgh - btnh, imgw - btnw, imgh - 2, paint); - canvas.drawLine(imgw - btnw, imgh - btnh, imgw - 2, imgh - btnh, paint); - canvas.drawLine(imgw - btnw, imgh - btnh, imgw - btnw, imgh - 2, paint); - canvas.drawLine(imgw - 2, imgh - btnh, imgw - 2, imgh - 2, paint); - canvas.drawLine(imgw - btnw, imgh - 2, imgw - 2, imgh - 2, paint); + paint.setStyle(Paint.Style.STROKE); + canvas.drawRect(imgw - btnw, imgh - btnh, imgw - 2, imgh - 2, paint); + paint.setStyle(Paint.Style.FILL); canvas.drawText(btnText, imgw - btnw + 5, imgh - 10, paint); } } From 89f075fa6162d370bc30629c12ec3ec1ea95c88e Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Sun, 17 Oct 2021 07:37:00 +0200 Subject: [PATCH 26/65] Draw only available segments --- .../btools/routingapp/BInstallerView.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) 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 0b9376b..c7e2395 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -284,24 +284,26 @@ public class BInstallerView extends View { boolean drawGrid = tilesVisible && !isDownloading; if (drawGrid) { - pnt_1.setColor(Color.GREEN); - - for (int ix = 1; ix < 72; ix++) { - float fx = fw * ix; - canvas.drawLine(fx, 0, fx, ih, pnt_1); - } - for (int iy = 1; iy < 36; iy++) { - float fy = fh * iy; - canvas.drawLine(0, fy, iw, fy, pnt_1); + pnt_1.setStyle(Paint.Style.STROKE); + for (int ix = 0; ix < 72; ix++) { + for (int iy = 0; iy < 36; iy++) { + int tidx = gridPos2Tileindex(ix, iy); + int tilesize = BInstallerSizes.getRd5Size(tidx); + if (tilesize > 0) { + canvas.drawRect(fw * ix, fh * (iy + 1), fw * (ix + 1), fh * iy, pnt_1); + } + } } } + rd5Tiles = 0; delTiles = 0; totalSize = 0; int mask2 = MASK_SELECTED_RD5 | MASK_DELETED_RD5 | MASK_INSTALLED_RD5; int mask3 = mask2 | MASK_CURRENT_RD5; + pnt_2.setStyle(Paint.Style.STROKE); pnt_2.setColor(Color.GRAY); pnt_2.setStrokeWidth(1); drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_INSTALLED_RD5, mask3, false, false, drawGrid); @@ -381,10 +383,7 @@ public class BInstallerView extends View { canvas.drawLine(fw * ix, fh * (iy + 1), fw * (ix + 1), fh * iy, pnt); // draw frame - canvas.drawLine(fw * ix, fh * iy, fw * (ix + 1), fh * iy, pnt); - canvas.drawLine(fw * ix, fh * (iy + 1), fw * (ix + 1), fh * (iy + 1), pnt); - canvas.drawLine(fw * ix, fh * iy, fw * ix, fh * (iy + 1), pnt); - canvas.drawLine(fw * (ix + 1), fh * iy, fw * (ix + 1), fh * (iy + 1), pnt); + canvas.drawRect(fw * ix, fh * (iy + 1), fw * (ix + 1), fh * iy, pnt); } } } From 6045a18a610b47a5890dc10b0da126d46684901f Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Sat, 30 Oct 2021 08:05:51 +0200 Subject: [PATCH 27/65] Inflate BInstallerView from layout --- .../java/btools/routingapp/BInstallerActivity.java | 4 ++-- .../main/java/btools/routingapp/BInstallerView.java | 5 +++-- .../src/main/res/layout/activity_binstaller.xml | 11 +++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 brouter-routing-app/src/main/res/layout/activity_binstaller.xml diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index 5a787f8..e5565e5 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -38,8 +38,8 @@ public class BInstallerActivity extends Activity { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); - mBInstallerView = new BInstallerView(this); - setContentView(mBInstallerView); + setContentView(R.layout.activity_binstaller); + mBInstallerView = findViewById(R.id.BInstallerView); } @Override 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 c7e2395..7643050 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -10,6 +10,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; +import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.MotionEvent; import android.view.View; @@ -59,8 +60,8 @@ public class BInstallerView extends View { private long rd5Tiles = 0; private long delTiles = 0; - public BInstallerView(Context context) { - super(context); + public BInstallerView(Context context, AttributeSet attrs) { + super(context, attrs); mActivity = (Activity) context; DisplayMetrics metrics = new DisplayMetrics(); diff --git a/brouter-routing-app/src/main/res/layout/activity_binstaller.xml b/brouter-routing-app/src/main/res/layout/activity_binstaller.xml new file mode 100644 index 0000000..1fd64f7 --- /dev/null +++ b/brouter-routing-app/src/main/res/layout/activity_binstaller.xml @@ -0,0 +1,11 @@ + + + + + From 51ef5c6aad2f21479cc77ea874a170c14343699f Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Sat, 30 Oct 2021 09:25:51 +0200 Subject: [PATCH 28/65] Show download progress in different view --- .../btools/routingapp/BInstallerActivity.java | 71 +++++++++++- .../btools/routingapp/BInstallerView.java | 106 ++++-------------- .../btools/routingapp/DownloadService.java | 2 +- .../main/res/layout/activity_binstaller.xml | 33 +++++- .../src/main/res/values/strings.xml | 3 + 5 files changed, 124 insertions(+), 91 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index e5565e5..f2ec66b 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -12,14 +12,24 @@ import android.content.pm.ActivityInfo; import android.os.Build; import android.os.Bundle; import android.os.StatFs; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +import java.io.File; +import java.util.ArrayList; public class BInstallerActivity extends Activity { public static final String DOWNLOAD_ACTION = "btools.routingapp.download"; - private static final int DIALOG_CONFIRM_DELETE_ID = 1; + public static boolean downloadCanceled = false; + private File baseDir; private BInstallerView mBInstallerView; private DownloadReceiver downloadReceiver; + private View mDownloadInfo; + private TextView mDownloadInfoText; + private Button mButtonDownloadCancel; static public long getAvailableSpace(String baseDir) { StatFs stat = new StatFs(baseDir); @@ -40,6 +50,58 @@ public class BInstallerActivity extends Activity { setContentView(R.layout.activity_binstaller); mBInstallerView = findViewById(R.id.BInstallerView); + mDownloadInfo = findViewById(R.id.view_download_progress); + mDownloadInfoText = findViewById(R.id.textViewDownloadProgress); + mButtonDownloadCancel = findViewById(R.id.buttonDownloadCancel); + mButtonDownloadCancel.setOnClickListener(view -> { + cancelDownload(); + }); + + baseDir = ConfigHelper.getBaseDir(this); + } + + private String baseNameForTile(int tileIndex) { + int lon = (tileIndex % 72) * 5 - 180; + int lat = (tileIndex / 72) * 5 - 90; + String slon = lon < 0 ? "W" + (-lon) : "E" + lon; + String slat = lat < 0 ? "S" + (-lat) : "N" + lat; + return slon + "_" + slat; + } + + private void deleteRawTracks() { + File modeDir = new File(baseDir, "brouter/modes"); + String[] fileNames = modeDir.list(); + if (fileNames == null) return; + for (String fileName : fileNames) { + if (fileName.endsWith("_rawtrack.dat")) { + File f = new File(modeDir, fileName); + f.delete(); + } + } + } + + private void cancelDownload() { + downloadCanceled = true; + mDownloadInfoText.setText(getString(R.string.download_info_cancel)); + } + + public void downloadAll(ArrayList downloadList) { + ArrayList urlparts = new ArrayList<>(); + for (Integer i : downloadList) { + urlparts.add(baseNameForTile(i)); + } + + mBInstallerView.setVisibility(View.GONE); + mDownloadInfo.setVisibility(View.VISIBLE); + downloadCanceled = false; + mDownloadInfoText.setText(R.string.download_info_start); + + Intent intent = new Intent(this, DownloadService.class); + intent.putExtra("dir", baseDir.getAbsolutePath() + "/brouter/"); + intent.putExtra("urlparts", urlparts); + startService(intent); + + deleteRawTracks(); // invalidate raw-tracks after data update } @Override @@ -99,7 +161,12 @@ public class BInstallerActivity extends Activity { if (intent.hasExtra("txt")) { String txt = intent.getStringExtra("txt"); boolean ready = intent.getBooleanExtra("ready", false); - mBInstallerView.setState(txt, ready); + if (!ready) { + mBInstallerView.setVisibility(View.VISIBLE); + mDownloadInfo.setVisibility(View.GONE); + scanExistingFiles(); + } + mDownloadInfoText.setText(txt); } } } 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 7643050..8d3a101 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -2,7 +2,6 @@ package btools.routingapp; import android.app.Activity; import android.content.Context; -import android.content.Intent; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -28,7 +27,12 @@ public class BInstallerView extends View { private static final int MASK_DELETED_RD5 = 2; private static final int MASK_INSTALLED_RD5 = 4; private static final int MASK_CURRENT_RD5 = 8; - public static boolean downloadCanceled = false; + private final File baseDir; + private final File segmentDir; + private final Matrix mat; + private final Bitmap bmp; + private final float viewscale; + private final int[] tileStatus; private final int imgwOrig; private final int imghOrig; private final float scaleOrig; @@ -36,12 +40,6 @@ public class BInstallerView extends View { private final int imgh; private final float[] testVector = new float[2]; private final Matrix matText; - private final File baseDir; - private final File segmentDir; - private final Matrix mat; - private final Bitmap bmp; - private final float viewscale; - private final int[] tileStatus; Paint pnt_1 = new Paint(); Paint pnt_2 = new Paint(); Paint paint = new Paint(); @@ -53,9 +51,6 @@ public class BInstallerView extends View { private float lastDownY; private boolean tilesVisible = false; private long availableSize; - private boolean isDownloading = false; - private volatile String currentDownloadOperation = ""; - private String downloadAction = ""; private long totalSize = 0; private long rd5Tiles = 0; private long delTiles = 0; @@ -130,12 +125,6 @@ public class BInstallerView extends View { } private void toggleDownload() { - if (isDownloading) { - downloadCanceled = true; - downloadAction = "Canceling..."; - return; - } - if (delTiles > 0) { ((BInstallerActivity) getContext()).showConfirmDelete(); return; @@ -159,8 +148,8 @@ public class BInstallerView extends View { } if (downloadList.size() > 0) { - isDownloading = true; - downloadAll(downloadList); + // isDownloading = true; + ((BInstallerActivity) getContext()).downloadAll(downloadList); for (Integer i : downloadList) { tileStatus[i] ^= tileStatus[i] & MASK_SELECTED_RD5; } @@ -168,35 +157,6 @@ public class BInstallerView extends View { } } - private void downloadAll(ArrayList downloadList) { - ArrayList urlparts = new ArrayList<>(); - for (Integer i : downloadList) { - urlparts.add(baseNameForTile(i)); - } - - currentDownloadOperation = "Start download ..."; - downloadAction = ""; - downloadCanceled = false; - isDownloading = true; - - Intent intent = new Intent(mActivity, DownloadService.class); - intent.putExtra("dir", baseDir.getAbsolutePath() + "/brouter/"); - intent.putExtra("urlparts", urlparts); - mActivity.startService(intent); - - deleteRawTracks(); // invalidate raw-tracks after data update - } - - public void setState(String txt, boolean b) { - currentDownloadOperation = txt; - downloadAction = ""; - isDownloading = b; - if (!b) { - scanExistingFiles(); - } - invalidate(); - } - private int tileIndex(float x, float y) { int ix = (int) (72.f * x / bmp.getWidth()); int iy = (int) (36.f * y / bmp.getHeight()); @@ -220,18 +180,6 @@ public class BInstallerView extends View { return testVector[1] / viewscale; } - private void deleteRawTracks() { - File modeDir = new File(baseDir, "brouter/modes"); - String[] fileNames = modeDir.list(); - if (fileNames == null) return; - for (String fileName : fileNames) { - if (fileName.endsWith("_rawtrack.dat")) { - File f = new File(modeDir, fileName); - f.delete(); - } - } - } - private void scanExistingFiles() { clearTileSelection(MASK_INSTALLED_RD5 | MASK_CURRENT_RD5); @@ -271,10 +219,8 @@ public class BInstallerView extends View { @Override protected void onDraw(Canvas canvas) { - if (!isDownloading) { - canvas.setMatrix(mat); - canvas.drawBitmap(bmp, 0, 0, null); - } + canvas.setMatrix(mat); + canvas.drawBitmap(bmp, 0, 0, null); // draw 5*5 lattice starting at scale=3 int iw = bmp.getWidth(); @@ -282,9 +228,7 @@ public class BInstallerView extends View { float fw = iw / 72.f; float fh = ih / 36.f; - boolean drawGrid = tilesVisible && !isDownloading; - - if (drawGrid) { + if (tilesVisible) { pnt_1.setColor(Color.GREEN); pnt_1.setStyle(Paint.Style.STROKE); for (int ix = 0; ix < 72; ix++) { @@ -307,19 +251,19 @@ public class BInstallerView extends View { pnt_2.setStyle(Paint.Style.STROKE); pnt_2.setColor(Color.GRAY); pnt_2.setStrokeWidth(1); - drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_INSTALLED_RD5, mask3, false, false, drawGrid); + drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_INSTALLED_RD5, mask3, false, false, tilesVisible); pnt_2.setColor(Color.BLUE); pnt_2.setStrokeWidth(1); - drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_INSTALLED_RD5 | MASK_CURRENT_RD5, mask3, false, false, drawGrid); + drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_INSTALLED_RD5 | MASK_CURRENT_RD5, mask3, false, false, tilesVisible); pnt_2.setColor(Color.GREEN); pnt_2.setStrokeWidth(2); - drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_SELECTED_RD5, mask2, true, false, drawGrid); + drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_SELECTED_RD5, mask2, true, false, tilesVisible); pnt_2.setColor(Color.YELLOW); pnt_2.setStrokeWidth(2); - drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_SELECTED_RD5 | MASK_INSTALLED_RD5, mask2, true, false, drawGrid); + drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_SELECTED_RD5 | MASK_INSTALLED_RD5, mask2, true, false, tilesVisible); pnt_2.setColor(Color.RED); pnt_2.setStrokeWidth(2); - drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_DELETED_RD5 | MASK_INSTALLED_RD5, mask2, false, true, drawGrid); + drawSelectedTiles(canvas, pnt_2, fw, fh, MASK_DELETED_RD5 | MASK_INSTALLED_RD5, mask2, false, true, tilesVisible); canvas.setMatrix(matText); @@ -327,13 +271,7 @@ public class BInstallerView extends View { long mb = 1024 * 1024; - if (isDownloading) { - paint.setTextSize(30); - canvas.drawText(currentDownloadOperation, 30, (imgh / 3) * 2 - 30, paint); - // canvas.drawText( currentDownloadOperation + " " + currentDownloadFile + sizeHint, 30, (imgh/3)*2-30, paint); - canvas.drawText(downloadAction, 30, (imgh / 3) * 2, paint); - } - if (!tilesVisible && !isDownloading) { + if (!this.tilesVisible) { paint.setTextSize(35); canvas.drawText("Touch region to zoom in!", 30, (imgh / 3) * 2, paint); } @@ -347,10 +285,9 @@ public class BInstallerView extends View { String btnText = null; - if (isDownloading) btnText = "Cancel Download"; - else if (delTiles > 0) btnText = "Delete " + delTiles + " tiles"; + if (delTiles > 0) btnText = "Delete " + delTiles + " tiles"; else if (rd5Tiles > 0) btnText = "Start Download"; - else if (tilesVisible && + else if (this.tilesVisible && rd5Tiles == 0 && RoutingHelper.hasDirectoryAnyDatafiles(segmentDir)) btnText = "Update all"; @@ -420,7 +357,6 @@ public class BInstallerView extends View { } case MotionEvent.ACTION_MOVE: { // a pointer was moved - if (isDownloading) break; int np = event.getPointerCount(); int nh = event.getHistorySize(); if (nh == 0) break; @@ -482,7 +418,7 @@ public class BInstallerView extends View { } // download button? - if ((delTiles > 0 || rd5Tiles >= 0 || isDownloading) && event.getX() > imgwOrig - btnw * scaleOrig && event.getY() > imghOrig - btnh * scaleOrig) { + if ((delTiles > 0 || rd5Tiles >= 0) && event.getX() > imgwOrig - btnw * scaleOrig && event.getY() > imghOrig - btnh * scaleOrig) { if (rd5Tiles == 0) { for (int ix = 0; ix < 72; ix++) { for (int iy = 0; iy < 36; iy++) { @@ -511,8 +447,6 @@ public class BInstallerView extends View { break; } - if (isDownloading) break; - Matrix imat = new Matrix(); if (mat.invert(imat)) { float[] touchpoint = new float[2]; diff --git a/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java b/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java index 2726327..7457a84 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java @@ -481,7 +481,7 @@ public class DownloadService extends Service implements ProgressListener { public boolean isCanceled() { - return BInstallerView.downloadCanceled; + return BInstallerActivity.downloadCanceled; } } diff --git a/brouter-routing-app/src/main/res/layout/activity_binstaller.xml b/brouter-routing-app/src/main/res/layout/activity_binstaller.xml index 1fd64f7..ccaa634 100644 --- a/brouter-routing-app/src/main/res/layout/activity_binstaller.xml +++ b/brouter-routing-app/src/main/res/layout/activity_binstaller.xml @@ -1,11 +1,40 @@ + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + +