Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wuan committed Oct 13, 2024
1 parent 4a845fe commit 3dd5022
Show file tree
Hide file tree
Showing 43 changed files with 108 additions and 88 deletions.
7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ android {
}
kotlin {
jvmToolchain(17)
compilerOptions {
apiVersion = KotlinVersion.KOTLIN_1_9
}
}
testOptions {
unitTests {
Expand Down Expand Up @@ -88,8 +91,8 @@ dependencies {

kapt.includeCompileClasspath = false

import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".AppService"
android:foregroundServiceType="dataSync"/>
<service
android:name=".AppService"
android:foregroundServiceType="dataSync" />
<activity
android:name=".Preferences"
android:label="@string/preferences" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AlertSignal @Inject constructor(
soundSignal = if (signalUri.isNotEmpty()) Uri.parse(signalUri) else null
Log.v(Main.LOG_TAG, "AlertHandler.onSharedPreferenceChanged() soundSignal = $soundSignal")
}

else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class AppService : Service(), OnSharedPreferenceChangeListener {

configureServiceMode(true)
}

else -> {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/blitzortung/android/app/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
Log.v(LOG_TAG, "requestWakeupPermissions() background alerts: $backgroundAlertEnabled")

if (backgroundAlertEnabled) {
val pm = context.getSystemService(Context.POWER_SERVICE)
val pm = context.getSystemService(POWER_SERVICE)
if (pm is PowerManager) {
val packageName = context.packageName
Log.v(LOG_TAG, "requestWakeupPermissions() package name $packageName")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Preferences : PreferenceActivity(), OnSharedPreferenceChangeListener {
val provider = configureLocationProviderPreferences(sharedPreferences)
getSystemService(Context.LOCATION_SERVICE) as LocationManager
if (provider != LocationHandler.MANUAL_PROVIDER &&
!(getSystemService(Context.LOCATION_SERVICE) as LocationManager).isProviderEnabled(provider)
!(getSystemService(LOCATION_SERVICE) as LocationManager).isProviderEnabled(provider)
) {
startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class WidgetProvider : AppWidgetProvider() {

override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
for (element in appWidgetIds) {
val appWidgetId = element
element
updateAppWidget(context)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class VersionComponent @Inject constructor(
configuredVersionCode == -1 -> State.FIRST_RUN
configuredMajorVersion != buildVersion.majorVersion ||
configuredMinorVersion != buildVersion.minorVersion -> State.FIRST_RUN_AFTER_UPDATE

else -> State.NO_UPDATE
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ open class NotificationHandler @Inject constructor(
isAtLeast(Build.VERSION_CODES.O) -> {
createNotification(contentIntent, notificationText)
}

else -> {
createJellyBeanNotification(contentIntent, notificationText)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class LegendView @JvmOverloads constructor(
}

private fun usesGrid(): Boolean {
return strikesOverlay?.usesGrid() ?: false
return strikesOverlay?.usesGrid() == true
}

private fun hasRegion(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import android.location.Location
import android.os.Handler
import android.util.Log
import android.widget.Toast
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.blitzortung.android.app.Main.Companion.LOG_TAG
import org.blitzortung.android.app.R
import org.blitzortung.android.app.view.OnSharedPreferenceChangeListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package org.blitzortung.android.data.beans

import java.io.Serializable

data class DefaultStrike (
data class DefaultStrike(
override val timestamp: Long = 0,
override val longitude: Double = 0.0,
override val latitude: Double = 0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ class Station(
minutesAgo > 24 * 60 -> {
State.OFF
}

minutesAgo > 15 -> {
State.DELAYED
}

else -> {
State.ON
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class BlitzortungHttpDataProvider @Inject constructor(
Log.w(Main.LOG_TAG, "BlitzortungHttpDataProvider.readFromUrl() $urlString not found")
return BufferedReader(InputStreamReader(ByteArrayInputStream("".toByteArray())))
}

else -> {
Log.w(Main.LOG_TAG, "BlitzortungHttpDataProvider.readFromUrl() $urlString failed")
throw RuntimeException(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class JsonRpcData(
private val serviceUrl: URL,
) {

fun requestData(parameters: Parameters) : JsonRpcResponse {
fun requestData(parameters: Parameters): JsonRpcResponse {
val intervalDuration = parameters.intervalDuration
val intervalOffset = parameters.intervalOffset
val gridSize = parameters.gridSize
Expand All @@ -38,6 +38,7 @@ class JsonRpcData(
}
jsonRpcResponse
}

LOCAL_REGION -> {
client.call(
serviceUrl,
Expand All @@ -50,6 +51,7 @@ class JsonRpcData(
countThreshold
)
}

else -> {
client.call(
serviceUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class JsonRpcDataProvider @Inject constructor(
this.serviceUrl =
toCheckedUrl(if (serviceUrl.isNotBlank()) serviceUrl.trim() else DEFAULT_SERVICE_URL.toString())
}

else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ class QuickSettingsDialog : DialogFragment() {
val selectedIntervalDuration = getSelectedIndex(intervalDurationValues, currentIntervalDurationValue)

val animationIntervalDurationValues = resources.getStringArray(R.array.animation_interval_duration_values)
val currentAnimationIntervalDurationValue = preferences.get(PreferenceKey.ANIMATION_INTERVAL_DURATION, animationIntervalDurationValues[1])
val selectedAnimationInterval = getSelectedIndex(animationIntervalDurationValues, currentAnimationIntervalDurationValue)
val currentAnimationIntervalDurationValue =
preferences.get(PreferenceKey.ANIMATION_INTERVAL_DURATION, animationIntervalDurationValues[1])
val selectedAnimationInterval =
getSelectedIndex(animationIntervalDurationValues, currentAnimationIntervalDurationValue)

@SuppressLint("InflateParams") val view = layoutInflater.inflate(R.layout.quick_settings_dialog, null, false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ChangelogParser {
parser.setInput(inputStream, null)
parser
}

"xml" -> context.resources.getXml(changeLogFileId)
else -> throw IllegalArgumentException("bad changelog resource type $resourceTypeName")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class JsonRpcClient @Inject constructor(client: HttpServiceClientDefault) : Http

return if (response.body.startsWith("[")) {
JsonRpcResponse(
data= JSONArray(response.body).getJSONObject(0),
data = JSONArray(response.body).getJSONObject(0),
)
} else {
val responseObject = JSONObject(response.body)
Expand All @@ -78,7 +78,7 @@ class JsonRpcClient @Inject constructor(client: HttpServiceClientDefault) : Http
)
}
JsonRpcResponse(
data= responseObject,
data = responseObject,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class LocationHandler @Inject constructor(
provider = newProvider
}
}

else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal fun createLocationProvider(
updateConsumer,
PreferenceManager.getDefaultSharedPreferences(context)
)

else -> null
} ?: throw IllegalArgumentException("Cannot find provider for name $providerName")
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ManualLocationProvider(locationUpdate: (Location?) -> Unit, private val sh

sendLocationUpdate(location)
}

else -> {}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/blitzortung/android/map/MapFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import org.blitzortung.android.app.view.get
import org.osmdroid.tileprovider.tilesource.TileSourceFactory
import org.osmdroid.util.GeoPoint
import org.osmdroid.views.CustomZoomButtonsController
import org.osmdroid.views.CustomZoomButtonsDisplay
import org.osmdroid.views.overlay.CopyrightOverlay
import org.osmdroid.views.overlay.ScaleBarOverlay
import java.lang.reflect.Field
import kotlin.math.min


Expand Down Expand Up @@ -151,11 +149,13 @@ class MapFragment : Fragment(), OnSharedPreferenceChangeListener {
val mapTypeString = sharedPreferences.get(key, "SATELLITE")
mapView.setTileSource(if (mapTypeString == "SATELLITE") TileSourceFactory.DEFAULT_TILE_SOURCE else TileSourceFactory.MAPNIK)
}

PreferenceKey.MAP_SCALE -> {
val scaleFactor = sharedPreferences.get(key, 100) / 100f
Log.v(Main.LOG_TAG, "MapFragment scale $scaleFactor")
mapView.tilesScaleFactor = scaleFactor
}

else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class StrikeOverlay(strike: Strike) {
}

fun pointIsInside(point: IGeoPoint, projection: Projection): Boolean {
return shape?.isPointInside(point, projection)
?: false
return shape?.isPointInside(point, projection) == true
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class TimeSlider : AppCompatSeekBar {
}

private fun drawSecondaryProgress(c: Canvas) {
val base: Float = (height - paddingBottom) /2f
val base: Float = (height - paddingBottom) / 2f

val distance = ViewHelper.pxFromDp(context, 8f)
val triangleSize = ViewHelper.pxFromDp(context, 5f)
Expand All @@ -123,7 +123,7 @@ class TimeSlider : AppCompatSeekBar {
}

private fun drawAxis(c: Canvas) {
val base: Float = (height - paddingBottom) /2f
val base: Float = (height - paddingBottom) / 2f

val axisWidth = ViewHelper.pxFromDp(context, 2f)
c.drawRect(
Expand All @@ -140,7 +140,7 @@ class TimeSlider : AppCompatSeekBar {
}

private fun drawAxisTics(c: Canvas) {
val base: Float = (height - paddingBottom) /2f
val base: Float = (height - paddingBottom) / 2f

val textPosition = base + ViewHelper.pxFromDp(context, 18f)
val shortTick = ViewHelper.pxFromDp(context, 3f)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/changelog_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Headline"
android:text="@string/changelog"/>
android:text="@string/changelog" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/changelog"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/log_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Headline"
android:text="@string/app_log"/>
android:text="@string/app_log" />

<View
android:layout_width="match_parent"
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,11 @@ Ivan Karev (karev.ivan@gmail.com)\nTschechisch: Jakub Mareček (jakubmarecek715@
<string name="share_log">E-Mail senden …</string>
<string name="share_unavailable">E-Mail kann nicht versendet werden.</string>
<string name="provider_warning">Bitte nutzen sie die Blitzortung.org Datenquelle nicht bei hoher Blitzaktivität. Die Dastellung der Karte wird möglicherweise verzögert.</string>
<string name="own_location_summary" >Einstellungen der Anzeige des Standorts</string>
<string name="own_location" >Eigener Standort</string>
<string name="own_location_size" >Größe des Standort-Symbols</string>
<string name="own_location_size_summary" >Einstellung der Größe des Standort-Symbols</string>
<string name="keep_zoom_goto_own_location_title" >Zoom beibehalten</string>
<string name="own_location_summary">Einstellungen der Anzeige des Standorts</string>
<string name="own_location">Eigener Standort</string>
<string name="own_location_size">Größe des Standort-Symbols</string>
<string name="own_location_size_summary">Einstellung der Größe des Standort-Symbols</string>
<string name="keep_zoom_goto_own_location_title">Zoom beibehalten</string>
<string name="keep_zoom_goto_own_location_summary">Einstellung zur Beibehaltung des aktuellen Zooms beim Zentrieren des eigenen Standorts</string>
<string name="background_query_toast">Bitte deaktivieren Sie die Akku-Optimierung für diese App damit die Warnung im Hintergrund zuverlässig funktioniert.</string>
<string name="open_battery_optimiziation">Bitte deaktivieren Sie die Akku-Optimierung für diese App wenn die Hintergrundabfrage aktiv ist. Drücken Sie auf Abbrechen um die Hintergrundabfrage zu deaktiveren oder auf OK um zur Einstellung der Batterieoptimierung zu gelangen.</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ Ruski: Ivan Karev (karev.ivan@gmail.com)\n
<string name="share_log">Pošalji email …</string>
<string name="share_unavailable">Dijeljenje emaila nije dostupno.</string>
<string name="provider_warning">Molimo nemojte koristiti Blitzortung.org kao izvor podataka tijekom učestalih aktivnosti munja jer će doći do degradacije pri prikazu karte.</string>
<string name="own_location_summary">Postavke prikaza vlastite lokacije</string>
<string name="own_location">Vlastita lokacija</string>
<string name="own_location_summary">Postavke prikaza vlastite lokacije</string>
<string name="own_location">Vlastita lokacija</string>
<string name="own_location_size">Veličina simbola vlastite lokacije</string>
<string name="own_location_size_summary">Određivanje veličine simbola vlastite lokacije</string>
<string name="keep_zoom_goto_own_location_summary">Zadrži trenutno zumiranje pri centriranju vlastite lokacije</string>
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,12 @@ Russisch: Ivan Karev (karev.ivan@gmail.com)\n
<string name="share_log">Stuur email …</string>
<string name="share_unavailable">E-mail delen is niet beschikbaar.</string>
<string name="provider_warning">Gebruik Blitzortung.org niet als informatiebron bij hoge activiteit, dit beinvloed prestaties van kaartweergave negatief.</string>
<string name="own_location_summary" >Eigen locatie weergave instellingen</string>
<string name="own_location" >Eigen locatie</string>
<string name="own_location_size" >Locatie symbool grootte</string>
<string name="own_location_size_summary" >Stel de grootte van het locatiesymbool in</string>
<string name="keep_zoom_goto_own_location_summary" >Instelling huidige zoom niveau behouden wanneer je centreerd naar je eigen locatie</string>
<string name="keep_zoom_goto_own_location_title" >Zoom behouden</string>
<string name="own_location_summary">Eigen locatie weergave instellingen</string>
<string name="own_location">Eigen locatie</string>
<string name="own_location_size">Locatie symbool grootte</string>
<string name="own_location_size_summary">Stel de grootte van het locatiesymbool in</string>
<string name="keep_zoom_goto_own_location_summary">Instelling huidige zoom niveau behouden wanneer je centreerd naar je eigen locatie</string>
<string name="keep_zoom_goto_own_location_title">Zoom behouden</string>
<string name="not_available">n/b</string>
<string name="unit_miles">mi.</string>
<string name="map_scale">Schaal kaart</string>
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Трекер молний</string>
<string name="app_name">Трекер молний</string>

<plurals name="strike">
<item quantity="zero">Нет молний</item>
Expand Down Expand Up @@ -359,12 +359,12 @@ Russian by Ivan Karev (karev.ivan@gmail.com)\n
<string name="share_log">Отправить по email …</string>
<string name="share_unavailable">Обмен по E-mail не доступен.</string>
<string name="provider_warning">Пожалуйста, не используйте Blitzortung.org во время высокой активности молний, так как производительность отображения карты будет снижаться.</string>
<string name="own_location_summary" >Настройки отображения Вашего месторасположения</string>
<string name="own_location" >Ваше месторасположение</string>
<string name="own_location_size" >Символ Вашего месторасположения</string>
<string name="own_location_size_summary" >Установите размер символа Вашего месторасположения</string>
<string name="keep_zoom_goto_own_location_summary" >Установка сохранения Вашего текущего масштаба при центрировании собственного местоположения</string>
<string name="keep_zoom_goto_own_location_title" >Сохранить масштаб</string>
<string name="own_location_summary">Настройки отображения Вашего месторасположения</string>
<string name="own_location">Ваше месторасположение</string>
<string name="own_location_size">Символ Вашего месторасположения</string>
<string name="own_location_size_summary">Установите размер символа Вашего месторасположения</string>
<string name="keep_zoom_goto_own_location_summary">Установка сохранения Вашего текущего масштаба при центрировании собственного местоположения</string>
<string name="keep_zoom_goto_own_location_title">Сохранить масштаб</string>
<string name="notification_channel_name">Предупреждение об урагане</string>
<string name="not_available">н/д</string>
<string name="unit_miles">миль</string>
Expand Down
Loading

0 comments on commit 3dd5022

Please sign in to comment.