Skip to content

Commit 9d5a186

Browse files
committed
cleanup
1 parent 16b0a81 commit 9d5a186

31 files changed

+68
-95
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
1313

1414
<application
15-
android:allowBackup="true"
1615
android:usesCleartextTraffic="true"
1716
android:hardwareAccelerated="true"
1817
android:icon="@drawable/icon"

app/src/main/java/org/blitzortung/android/alert/handler/AlertDataHandler.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ open class AlertDataHandler @Inject internal constructor(
6666
}
6767

6868
private fun calculateDistanceTo(location: Location, strike: Strike, measurementSystem: MeasurementSystem): Float {
69-
strikeLocation.longitude = strike.longitude.toDouble()
70-
strikeLocation.latitude = strike.latitude.toDouble()
69+
strikeLocation.longitude = strike.longitude
70+
strikeLocation.latitude = strike.latitude
7171
val distanceInMeters = location.distanceTo(strikeLocation)
7272
return measurementSystem.calculateDistance(distanceInMeters)
7373
}
@@ -121,8 +121,8 @@ open class AlertDataHandler @Inject internal constructor(
121121
}
122122

123123
private fun calculateBearingToStrike(location: Location, strikeLocation: Location, strike: Strike): Float {
124-
strikeLocation.longitude = strike.longitude.toDouble()
125-
strikeLocation.latitude = strike.latitude.toDouble()
124+
strikeLocation.longitude = strike.longitude
125+
strikeLocation.latitude = strike.latitude
126126
return location.bearingTo(strikeLocation)
127127
}
128128

app/src/main/java/org/blitzortung/android/alert/handler/AlertSignal.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class AlertSignal @Inject constructor(
3232
onSharedPreferenceChanged(preferences, ALERT_VIBRATION_SIGNAL, ALERT_SOUND_SIGNAL)
3333
}
3434

35-
private var soundSignal: Uri? = null;
35+
private var soundSignal: Uri? = null
3636

37-
private var vibrationDuration = 0L;
37+
private var vibrationDuration = 0L
3838

3939
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: PreferenceKey) {
4040

app/src/main/java/org/blitzortung/android/app/AppService.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ import org.blitzortung.android.app.view.OnSharedPreferenceChangeListener
3636
import org.blitzortung.android.app.view.PreferenceKey
3737
import org.blitzortung.android.app.view.get
3838
import org.blitzortung.android.data.ServiceDataHandler
39-
import org.blitzortung.android.data.Parameters
4039
import org.blitzortung.android.data.provider.result.DataEvent
41-
import org.blitzortung.android.data.provider.result.ResultEvent
4240
import org.blitzortung.android.location.LocationHandler
4341
import org.blitzortung.android.util.LogUtil
4442
import org.blitzortung.android.util.isAtLeast
@@ -77,7 +75,7 @@ class AppService : Service(), OnSharedPreferenceChangeListener {
7775
@set:Inject
7876
internal lateinit var wakeLock: PowerManager.WakeLock
7977

80-
private val dataEventConsumer = { event: DataEvent ->
78+
private val dataEventConsumer = { _: DataEvent ->
8179
releaseWakeLock()
8280
}
8381

@@ -225,7 +223,8 @@ class AppService : Service(), OnSharedPreferenceChangeListener {
225223

226224
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager?
227225
if (alarmManager != null) {
228-
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 0, (backgroundPeriod * 1000).toLong(), pendingIntent)
226+
val period = (backgroundPeriod * 1000).toLong()
227+
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, period, period, pendingIntent)
229228
} else {
230229
Log.e(Main.LOG_TAG, "AppService.createAlarm() failed")
231230
}

app/src/main/java/org/blitzortung/android/app/BootReceiver.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package org.blitzortung.android.app
2121
import android.content.BroadcastReceiver
2222
import android.content.Context
2323
import android.content.Intent
24-
import android.os.Build
2524
import android.util.Log
2625
import org.blitzortung.android.app.Main.Companion.LOG_TAG
2726

@@ -33,7 +32,7 @@ class BootReceiver : BroadcastReceiver() {
3332
val bootIntent = Intent(context, AppService::class.java)
3433
bootIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
3534
try {
36-
context.startService(bootIntent);
35+
context.startService(bootIntent)
3736
} catch (e: Exception) {
3837
Log.e(LOG_TAG, "BootReceiver.onReceive() start service failed after boot completed", e)
3938
}

app/src/main/java/org/blitzortung/android/app/Main.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ import android.os.Bundle
3333
import android.os.PowerManager
3434
import android.preference.PreferenceManager
3535
import android.provider.Settings
36-
import androidx.fragment.app.FragmentActivity
37-
import androidx.appcompat.app.AlertDialog
3836
import android.text.format.DateFormat
3937
import android.util.AndroidRuntimeException
4038
import android.util.Log
@@ -44,6 +42,8 @@ import android.view.ViewConfiguration
4442
import android.view.WindowManager
4543
import android.widget.ImageButton
4644
import android.widget.Toast
45+
import androidx.appcompat.app.AlertDialog
46+
import androidx.fragment.app.FragmentActivity
4747
import dagger.android.AndroidInjection
4848
import kotlinx.android.synthetic.main.main.*
4949
import org.blitzortung.android.alert.event.AlertResultEvent
@@ -277,7 +277,7 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
277277

278278
with(histogram_view) {
279279
setStrikesOverlay(strikeListOverlay)
280-
setOnClickListener { _ ->
280+
setOnClickListener {
281281
val currentResult = currentResult
282282
if (currentResult != null) {
283283
val rasterParameters = currentResult.rasterParameters
@@ -305,10 +305,8 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
305305
}
306306

307307
private fun openQuickSettingsDialog() {
308-
if (isAtLeast(Build.VERSION_CODES.HONEYCOMB)) {
309-
val dialog = QuickSettingsDialog()
310-
dialog.show(fragmentManager, "QuickSettingsDialog")
311-
}
308+
val dialog = QuickSettingsDialog()
309+
dialog.show(supportFragmentManager, "QuickSettingsDialog")
312310
}
313311

314312
private fun animateToLocationAndVisibleSize(longitude: Double, latitude: Double, diameter: Float?) {
@@ -588,8 +586,8 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
588586
GPS(LocationManager.GPS_PROVIDER), PASSIVE(LocationManager.PASSIVE_PROVIDER), NETWORK(LocationManager.NETWORK_PROVIDER);
589587

590588
companion object {
591-
val byProviderName: Map<String, LocationProviderRelation> = LocationProviderRelation.values().groupBy { it.providerName }.mapValues { it.value.first() }
592-
val byOrdinal: Map<Int, LocationProviderRelation> = LocationProviderRelation.values().groupBy { it.ordinal }.mapValues { it.value.first() }
589+
val byProviderName: Map<String, LocationProviderRelation> = values().groupBy { it.providerName }.mapValues { it.value.first() }
590+
val byOrdinal: Map<Int, LocationProviderRelation> = values().groupBy { it.ordinal }.mapValues { it.value.first() }
593591
}
594592
}
595593

app/src/main/java/org/blitzortung/android/app/helper/ViewHelper.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.blitzortung.android.app.helper
2020

2121
import android.content.Context
22-
import android.view.View
2322

2423
object ViewHelper {
2524

app/src/main/java/org/blitzortung/android/app/view/AlertView.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class AlertView @JvmOverloads constructor(
7676
val locationEventConsumer: (LocationEvent) -> Unit = { locationEvent ->
7777
Log.v(Main.LOG_TAG, "AlertView received location ${locationEvent.location}")
7878
location = locationEvent.location
79-
val visibility = if (location != null) View.VISIBLE else View.INVISIBLE
79+
val visibility = if (location != null) VISIBLE else INVISIBLE
8080
setVisibility(visibility)
8181
invalidate()
8282
}
@@ -89,7 +89,7 @@ class AlertView @JvmOverloads constructor(
8989

9090
with(textStyle) {
9191
color = 0xff404040.toInt()
92-
textSize = 0.8f * this@AlertView.textSize * TabletAwareView.textSizeFactor(context)
92+
textSize = 0.8f * this@AlertView.textSize * textSizeFactor(context)
9393
}
9494

9595
background.color = 0xffb0b0b0.toInt()
@@ -111,14 +111,14 @@ class AlertView @JvmOverloads constructor(
111111
}
112112

113113
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
114-
val getSize = fun(spec: Int) = View.MeasureSpec.getSize(spec)
114+
val getSize = fun(spec: Int) = MeasureSpec.getSize(spec)
115115

116116
val parentWidth = getSize(widthMeasureSpec) * sizeFactor
117117
val parentHeight = getSize(heightMeasureSpec) * sizeFactor
118118

119119
val size = Math.min(parentWidth.toInt(), parentHeight.toInt())
120120

121-
super.onMeasure(View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY))
121+
super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY))
122122
}
123123

124124
override fun onDraw(canvas: Canvas) {

app/src/main/java/org/blitzortung/android/app/view/HistogramView.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ class HistogramView @JvmOverloads constructor(
6969
}
7070

7171
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
72-
val getSize = fun(spec: Int) = View.MeasureSpec.getSize(spec)
72+
val getSize = fun(spec: Int) = MeasureSpec.getSize(spec)
7373

7474
val parentWidth = getSize(widthMeasureSpec) * sizeFactor
7575
val parentHeight = getSize(heightMeasureSpec) * sizeFactor
7676

77-
super.onMeasure(View.MeasureSpec.makeMeasureSpec(parentWidth.toInt(), View.MeasureSpec.EXACTLY),
78-
View.MeasureSpec.makeMeasureSpec(parentHeight.toInt(), View.MeasureSpec.EXACTLY))
77+
super.onMeasure(MeasureSpec.makeMeasureSpec(parentWidth.toInt(), MeasureSpec.EXACTLY),
78+
MeasureSpec.makeMeasureSpec(parentHeight.toInt(), MeasureSpec.EXACTLY))
7979
}
8080

8181
override fun onDraw(canvas: Canvas) {
@@ -126,7 +126,7 @@ class HistogramView @JvmOverloads constructor(
126126

127127
private fun updateHistogram(dataEvent: ResultEvent) {
128128
if (dataEvent.failed) {
129-
visibility = View.INVISIBLE
129+
visibility = INVISIBLE
130130
histogram = null
131131
} else {
132132
val histogram = dataEvent.histogram
@@ -139,7 +139,7 @@ class HistogramView @JvmOverloads constructor(
139139
viewShouldBeVisible = createHistogram(dataEvent)
140140
}
141141

142-
visibility = if (viewShouldBeVisible) View.VISIBLE else View.INVISIBLE
142+
visibility = if (viewShouldBeVisible) VISIBLE else INVISIBLE
143143

144144
if (viewShouldBeVisible) {
145145
invalidate()

app/src/main/java/org/blitzortung/android/app/view/LegendView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class LegendView @JvmOverloads constructor(
8989
}
9090

9191
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
92-
val getSize = fun(spec: Int) = View.MeasureSpec.getSize(spec)
92+
val getSize = fun(spec: Int) = MeasureSpec.getSize(spec)
9393

9494
val parentWidth = getSize(widthMeasureSpec)
9595
val parentHeight = getSize(heightMeasureSpec)
@@ -116,7 +116,7 @@ class LegendView @JvmOverloads constructor(
116116
}
117117
}
118118

119-
super.onMeasure(View.MeasureSpec.makeMeasureSpec(width.toInt(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(height.toInt(), View.MeasureSpec.EXACTLY))
119+
super.onMeasure(MeasureSpec.makeMeasureSpec(width.toInt(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height.toInt(), MeasureSpec.EXACTLY))
120120
}
121121

122122
override fun onDraw(canvas: Canvas) {

0 commit comments

Comments
 (0)