Skip to content

Commit

Permalink
remove built in zoom controls
Browse files Browse the repository at this point in the history
  • Loading branch information
wuan committed Oct 5, 2024
1 parent ec99d07 commit 0823947
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 39 deletions.
36 changes: 13 additions & 23 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "org.blitzortung.android.app"
minSdkVersion 21
targetSdkVersion 34
versionCode 322
versionName '2.2.5'
versionCode 323
versionName '2.2.6'
multiDexEnabled false
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -93,41 +93,31 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
testLogging {
// Enables easier debugging of tests in Github Actions CI
events TestLogEvent.FAILED
exceptionFormat TestExceptionFormat.FULL
showExceptions true
showCauses true
showStackTraces true
}
maxHeapSize = "4g"
}

task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {

reports {
xml.required.set(true)
html.required.set(true)
}

getReports().getXml().setDestination(file("${project.buildDir}/reports/jacoco/jacocoRootReport/merged.xml"))
// Add files that should not be listed in the report (e.g. generated Files from dagger)
def fileFilter = ['**/*Dagger.*']

def kotlinDebugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/debug", excludes: fileFilter)

def mainSrc = "$projectDir/src/main/java"
sourceDirectories.from = files([mainSrc])
classDirectories.from = files([kotlinDebugTree])

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*', '**/*$ViewBinder*.*']
def debugTree = fileTree(dir: "$project.buildDir/intermediates/javac/debug/classes", excludes: fileFilter)
def kotlinDebugTree = fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/debug", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"
// Make sure the path is correct (if not run the unit tests and try find the .exec file that is generated after the unit tests are finished should be similar to that one)
executionData.from = fileTree(dir: "$buildDir", includes: ["outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec"])

sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([debugTree, kotlinDebugTree]))
executionData.setFrom(fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
]))
}

sonar {
properties {
property "sonar.junit.reportPaths", "build/test-results/testDebugUnitTest/"
property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/jacocoRootReport/merged.xml"
property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"
}
}
17 changes: 4 additions & 13 deletions app/src/main/java/org/blitzortung/android/map/MapFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,13 @@ class MapFragment : Fragment(), OnSharedPreferenceChangeListener {
centered.setBoolean(mScaleBarOverlay, true)
mapView.overlays.add(this.mScaleBarOverlay)

//built in zoom controls
mapView.zoomController.setVisibility(CustomZoomButtonsController.Visibility.SHOW_AND_FADEOUT)
// disable built in zoom controls
mapView.zoomController.setVisibility(CustomZoomButtonsController.Visibility.NEVER)

setZoomControllerBottomOffset(bottomOffset + 10)

//needed for pinch zooms
// enable pinch zoom
mapView.setMultiTouchControls(true)

//scales tiles to the current screen's DPI, helps with readability of labels
// scales tiles to the current screen's DPI, helps with readability of labels
mapView.isTilesScaledToDpi = true

//the rest of this is restoring the last map location the user looked at
Expand All @@ -103,13 +101,6 @@ class MapFragment : Fragment(), OnSharedPreferenceChangeListener {
onSharedPreferenceChanged(preferences, PreferenceKey.MAP_TYPE, PreferenceKey.MAP_SCALE)
}

private fun setZoomControllerBottomOffset(bottomOffset: Int) {
val f: Field = CustomZoomButtonsController::class.java.getDeclaredField("mDisplay")
f.isAccessible = true // Abracadabra
val zoomDisplay = f.get(mapView.zoomController) as CustomZoomButtonsDisplay
zoomDisplay.setAdditionalPixelMargins(0f, 0f, 0f, bottomOffset.toFloat())
}

fun updateForgroundColor(fgcolor: Int) {
mScaleBarOverlay.barPaint = mScaleBarOverlay.barPaint.apply { color = fgcolor }
mScaleBarOverlay.textPaint = mScaleBarOverlay.textPaint.apply { color = fgcolor }
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.6.1' apply false
id 'com.android.library' version '8.6.1' apply false
id 'com.android.application' version '8.7.0' apply false
id 'com.android.library' version '8.7.0' apply false
id 'org.jetbrains.kotlin.android' version '2.0.20' apply false
id "org.sonarqube" version "5.1.0.4882"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip

0 comments on commit 0823947

Please sign in to comment.