Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
minSdk = 29
targetSdk = 36

versionCode = 1708536379
versionName = "0.31.2-beta"
versionCode = 1708536380
versionName = "0.32.0-beta"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/f/cking/software/domain/model/LocationModel.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package f.cking.software.domain.model

import android.location.Location
import org.osmdroid.util.GeoPoint
import java.io.Serializable

@kotlinx.serialization.Serializable
Expand All @@ -15,4 +16,20 @@ data class LocationModel(
Location.distanceBetween(lat, lng, other.lat, other.lng, result)
return result[0]
}
}

fun LocationModel.toLocation(): Location {
val location = Location("")
location.latitude = lat
location.longitude = lng
location.time = time
return location
}

fun LocationModel.toGeoPoint(): GeoPoint {
return GeoPoint(lat, lng)
}

fun Location.toGeoPoint(): GeoPoint {
return GeoPoint(latitude, longitude)
}
3 changes: 1 addition & 2 deletions app/src/main/java/f/cking/software/ui/AsyncBatchProcessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package f.cking.software.ui
import android.os.Handler
import android.os.Looper
import android.os.SystemClock
import java.util.*

/**
* The helper class splits large rendering operations into small subtasks to don't stuck the main thread for a long time.
* The helper class splits large rendering operations into small subtasks in order not to freeze the main thread.
*
* @param frameRate frames per second
* @param renderLoad percentage of one frame rendering time that may be busy bu batch processor's task
Expand Down
37 changes: 30 additions & 7 deletions app/src/main/java/f/cking/software/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Typography
Expand All @@ -21,11 +23,18 @@ import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.IntSize
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
Expand All @@ -35,6 +44,7 @@ import f.cking.software.data.helpers.ActivityProvider
import f.cking.software.data.helpers.IntentHelper
import f.cking.software.data.helpers.PermissionHelper
import f.cking.software.isDarkModeOn
import f.cking.software.utils.ScreenSizeLocal
import f.cking.software.utils.graphic.rememberProgressDialog
import f.cking.software.utils.navigation.BackCommand
import f.cking.software.utils.navigation.Navigator
Expand Down Expand Up @@ -86,13 +96,24 @@ class MainActivity : AppCompatActivity() {
bodySmall = MaterialTheme.typography.bodySmall.copy(color = colors.onSurface),
)
) {
val stack = viewModel.navigator.stack
if (stack.isEmpty()) {
finish()
} else {
focusManager.clearFocus(true)
stack.forEach { screen ->
screen()
var screenSize by remember { mutableStateOf(IntSize(0, 0)) }
Box(
modifier = Modifier
.fillMaxSize()
.onGloballyPositioned { layoutCoordinates ->
screenSize = layoutCoordinates.size
}
) {
val stack = viewModel.navigator.stack
if (stack.isEmpty()) {
finish()
} else {
focusManager.clearFocus(true)
CompositionLocalProvider(ScreenSizeLocal provides screenSize) {
stack.forEach { screen ->
screen()
}
}
}
}

Expand Down Expand Up @@ -183,6 +204,7 @@ class MainActivity : AppCompatActivity() {
outlineVariant = colorResource(id = R.color.md_theme_dark_outlineVariant),
scrim = colorResource(id = R.color.md_theme_dark_scrim),
)

!darkMode -> lightColorScheme(
primary = colorResource(id = R.color.md_theme_light_primary),
onPrimary = colorResource(id = R.color.md_theme_light_onPrimary),
Expand Down Expand Up @@ -217,6 +239,7 @@ class MainActivity : AppCompatActivity() {
outlineVariant = colorResource(id = R.color.md_theme_light_outlineVariant),
scrim = colorResource(id = R.color.md_theme_light_scrim),
)

else -> throw IllegalStateException("This state is unreachable")
}
return colors
Expand Down
Loading