Skip to content

Commit b8e3948

Browse files
Merge pull request #232 from Semper-Viventem/heatmap-locations-overlay
Improve map experience, add heatmap
2 parents ebc81e9 + 6009c8e commit b8e3948

File tree

10 files changed

+1037
-50
lines changed

10 files changed

+1037
-50
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
minSdk = 29
2727
targetSdk = 36
2828

29-
versionCode = 1708536379
30-
versionName = "0.31.2-beta"
29+
versionCode = 1708536380
30+
versionName = "0.32.0-beta"
3131

3232
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3333

app/src/main/java/f/cking/software/domain/model/LocationModel.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package f.cking.software.domain.model
22

33
import android.location.Location
4+
import org.osmdroid.util.GeoPoint
45
import java.io.Serializable
56

67
@kotlinx.serialization.Serializable
@@ -15,4 +16,20 @@ data class LocationModel(
1516
Location.distanceBetween(lat, lng, other.lat, other.lng, result)
1617
return result[0]
1718
}
19+
}
20+
21+
fun LocationModel.toLocation(): Location {
22+
val location = Location("")
23+
location.latitude = lat
24+
location.longitude = lng
25+
location.time = time
26+
return location
27+
}
28+
29+
fun LocationModel.toGeoPoint(): GeoPoint {
30+
return GeoPoint(lat, lng)
31+
}
32+
33+
fun Location.toGeoPoint(): GeoPoint {
34+
return GeoPoint(latitude, longitude)
1835
}

app/src/main/java/f/cking/software/ui/AsyncBatchProcessor.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ package f.cking.software.ui
33
import android.os.Handler
44
import android.os.Looper
55
import android.os.SystemClock
6-
import java.util.*
76

87
/**
9-
* The helper class splits large rendering operations into small subtasks to don't stuck the main thread for a long time.
8+
* The helper class splits large rendering operations into small subtasks in order not to freeze the main thread.
109
*
1110
* @param frameRate frames per second
1211
* @param renderLoad percentage of one frame rendering time that may be busy bu batch processor's task

app/src/main/java/f/cking/software/ui/MainActivity.kt

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import androidx.activity.enableEdgeToEdge
1313
import androidx.activity.viewModels
1414
import androidx.appcompat.app.AppCompatActivity
1515
import androidx.compose.foundation.isSystemInDarkTheme
16+
import androidx.compose.foundation.layout.Box
17+
import androidx.compose.foundation.layout.fillMaxSize
1618
import androidx.compose.material3.ColorScheme
1719
import androidx.compose.material3.MaterialTheme
1820
import androidx.compose.material3.Typography
@@ -21,11 +23,18 @@ import androidx.compose.material3.dynamicDarkColorScheme
2123
import androidx.compose.material3.dynamicLightColorScheme
2224
import androidx.compose.material3.lightColorScheme
2325
import androidx.compose.runtime.Composable
26+
import androidx.compose.runtime.CompositionLocalProvider
2427
import androidx.compose.runtime.collectAsState
2528
import androidx.compose.runtime.getValue
29+
import androidx.compose.runtime.mutableStateOf
30+
import androidx.compose.runtime.remember
31+
import androidx.compose.runtime.setValue
32+
import androidx.compose.ui.Modifier
33+
import androidx.compose.ui.layout.onGloballyPositioned
2634
import androidx.compose.ui.platform.LocalFocusManager
2735
import androidx.compose.ui.res.colorResource
2836
import androidx.compose.ui.res.stringResource
37+
import androidx.compose.ui.unit.IntSize
2938
import androidx.lifecycle.ViewModel
3039
import androidx.lifecycle.viewmodel.initializer
3140
import androidx.lifecycle.viewmodel.viewModelFactory
@@ -35,6 +44,7 @@ import f.cking.software.data.helpers.ActivityProvider
3544
import f.cking.software.data.helpers.IntentHelper
3645
import f.cking.software.data.helpers.PermissionHelper
3746
import f.cking.software.isDarkModeOn
47+
import f.cking.software.utils.ScreenSizeLocal
3848
import f.cking.software.utils.graphic.rememberProgressDialog
3949
import f.cking.software.utils.navigation.BackCommand
4050
import f.cking.software.utils.navigation.Navigator
@@ -86,13 +96,24 @@ class MainActivity : AppCompatActivity() {
8696
bodySmall = MaterialTheme.typography.bodySmall.copy(color = colors.onSurface),
8797
)
8898
) {
89-
val stack = viewModel.navigator.stack
90-
if (stack.isEmpty()) {
91-
finish()
92-
} else {
93-
focusManager.clearFocus(true)
94-
stack.forEach { screen ->
95-
screen()
99+
var screenSize by remember { mutableStateOf(IntSize(0, 0)) }
100+
Box(
101+
modifier = Modifier
102+
.fillMaxSize()
103+
.onGloballyPositioned { layoutCoordinates ->
104+
screenSize = layoutCoordinates.size
105+
}
106+
) {
107+
val stack = viewModel.navigator.stack
108+
if (stack.isEmpty()) {
109+
finish()
110+
} else {
111+
focusManager.clearFocus(true)
112+
CompositionLocalProvider(ScreenSizeLocal provides screenSize) {
113+
stack.forEach { screen ->
114+
screen()
115+
}
116+
}
96117
}
97118
}
98119

@@ -183,6 +204,7 @@ class MainActivity : AppCompatActivity() {
183204
outlineVariant = colorResource(id = R.color.md_theme_dark_outlineVariant),
184205
scrim = colorResource(id = R.color.md_theme_dark_scrim),
185206
)
207+
186208
!darkMode -> lightColorScheme(
187209
primary = colorResource(id = R.color.md_theme_light_primary),
188210
onPrimary = colorResource(id = R.color.md_theme_light_onPrimary),
@@ -217,6 +239,7 @@ class MainActivity : AppCompatActivity() {
217239
outlineVariant = colorResource(id = R.color.md_theme_light_outlineVariant),
218240
scrim = colorResource(id = R.color.md_theme_light_scrim),
219241
)
242+
220243
else -> throw IllegalStateException("This state is unreachable")
221244
}
222245
return colors

0 commit comments

Comments
 (0)