Skip to content

Commit

Permalink
Merge pull request #64 from Semper-Viventem/master
Browse files Browse the repository at this point in the history
Release 0.20.0-beta
  • Loading branch information
Semper-Viventem authored Dec 19, 2023
2 parents c1ec646 + 7eb4de4 commit 8159ec2
Show file tree
Hide file tree
Showing 39 changed files with 794 additions and 230 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
minSdk = 29
targetSdk = 34
versionCode = (System.currentTimeMillis() / 1000).toInt()
versionName = "0.19.0-beta"
versionName = "0.20.0-beta"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

<uses-feature android:name="android.hardware.location.gps" />
<uses-feature android:name="android.hardware.location.network" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE"/>

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Expand Down
25 changes: 25 additions & 0 deletions app/src/main/java/f/cking/software/ui/GlobalUiState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package f.cking.software.ui

import androidx.compose.runtime.mutableStateOf

object GlobalUiState {

val navbarOffsetPx = mutableStateOf(0f)
val fabOffsetPx = mutableStateOf(0f)
val totalOffset = mutableStateOf(navbarOffsetPx.value + fabOffsetPx.value)

fun setBottomOffset(navbarOffset: Float = navbarOffsetPx.value, fabOffset: Float = fabOffsetPx.value) {
var updateTotal = false
if (navbarOffset != navbarOffsetPx.value) {
navbarOffsetPx.value = navbarOffset
updateTotal = true
}
if (fabOffset != fabOffsetPx.value) {
fabOffsetPx.value = fabOffset
updateTotal = true
}
if (updateTotal) {
totalOffset.value = navbarOffset + fabOffset
}
}
}
26 changes: 16 additions & 10 deletions app/src/main/java/f/cking/software/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.MaterialTheme
import androidx.compose.ui.graphics.Color
import androidx.compose.material.Typography
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.colorResource
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import f.cking.software.R
import f.cking.software.common.navigation.BackCommand
import f.cking.software.common.navigation.Navigator
import f.cking.software.common.navigation.RouterImpl
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.utils.navigation.BackCommand
import f.cking.software.utils.navigation.Navigator
import f.cking.software.utils.navigation.RouterImpl
import org.koin.android.ext.android.inject
import org.osmdroid.config.Configuration

Expand Down Expand Up @@ -48,12 +48,18 @@ class MainActivity : AppCompatActivity() {
val focusManager = LocalFocusManager.current
MaterialTheme(
colors = MaterialTheme.colors.copy(
primary = colorResource(id = R.color.orange_500),
primaryVariant = colorResource(id = R.color.orange_700),
onPrimary = Color.White,
secondary = Color.Black,
secondaryVariant = Color.Black,
onSecondary = Color.White,
primary = colorResource(id = R.color.primary),
primaryVariant = colorResource(id = R.color.primary_variant),
onPrimary = colorResource(id = R.color.on_primary),
secondary = colorResource(id = R.color.secondary),
secondaryVariant = colorResource(id = R.color.secondary_variant),
onSecondary = colorResource(id = R.color.on_secondary),
surface = colorResource(id = R.color.surface_color),
onSurface = colorResource(id = R.color.on_surface),
),
typography = Typography(
body1 = MaterialTheme.typography.body1.copy(color = colorResource(id = R.color.on_surface)),
body2 = MaterialTheme.typography.body2.copy(color = colorResource(id = R.color.on_surface)),
)
) {
val stack = viewModel.navigator.stack
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package f.cking.software.ui

import f.cking.software.common.navigation.AddToStackCommand
import f.cking.software.common.navigation.BackCommand
import f.cking.software.domain.model.DeviceData
import f.cking.software.domain.model.LocationModel
import f.cking.software.domain.model.ManufacturerInfo
Expand All @@ -14,6 +12,8 @@ import f.cking.software.ui.profiledetails.ProfileDetailsScreen
import f.cking.software.ui.selectdevice.SelectDeviceScreen
import f.cking.software.ui.selectlocation.SelectLocationScreen
import f.cking.software.ui.selectmanufacturer.SelectManufacturerScreen
import f.cking.software.utils.navigation.AddToStackCommand
import f.cking.software.utils.navigation.BackCommand

object ScreenNavigationCommands {

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/f/cking/software/ui/UiModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package f.cking.software.ui

import f.cking.software.common.navigation.Router
import f.cking.software.common.navigation.RouterImpl
import f.cking.software.ui.devicedetails.DeviceDetailsViewModel
import f.cking.software.ui.devicelist.DeviceListViewModel
import f.cking.software.ui.journal.JournalViewModel
Expand All @@ -11,6 +9,8 @@ import f.cking.software.ui.profileslist.ProfilesListViewModel
import f.cking.software.ui.selectdevice.SelectDeviceViewModel
import f.cking.software.ui.selectmanufacturer.SelectManufacturerViewModel
import f.cking.software.ui.settings.SettingsViewModel
import f.cking.software.utils.navigation.Router
import f.cking.software.utils.navigation.RouterImpl
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,30 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.google.accompanist.flowlayout.FlowRow
import com.vanpra.composematerialdialogs.MaterialDialog
import com.vanpra.composematerialdialogs.rememberMaterialDialogState
import f.cking.software.R
import f.cking.software.common.MapView
import f.cking.software.common.RoundedBox
import f.cking.software.common.TagChip
import f.cking.software.dateTimeStringFormat
import f.cking.software.domain.model.DeviceData
import f.cking.software.domain.model.LocationModel
import f.cking.software.dpToPx
import f.cking.software.frameRate
import f.cking.software.ui.AsyncBatchProcessor
import f.cking.software.ui.tagdialog.TagDialog
import f.cking.software.utils.graphic.MapView
import f.cking.software.utils.graphic.RoundedBox
import f.cking.software.utils.graphic.TagChip
import kotlinx.coroutines.isActive
import org.koin.androidx.compose.koinViewModel
import org.koin.core.parameter.parametersOf
Expand All @@ -77,14 +79,15 @@ object DeviceDetailsScreen {

Scaffold(
modifier = Modifier
.background(MaterialTheme.colors.surface)
.fillMaxWidth()
.fillMaxHeight(),
topBar = {
AppBar(viewModel = viewModel)
},
content = {
Content(
modifier = Modifier.padding(it),
modifier = Modifier.background(MaterialTheme.colors.surface).padding(it),
viewModel = viewModel,
)
}
Expand All @@ -107,7 +110,7 @@ object DeviceDetailsScreen {
Icon(
imageVector = ImageVector.vectorResource(id = iconId),
contentDescription = text,
tint = Color.White
tint = MaterialTheme.colors.onPrimary,
)
}
}
Expand All @@ -117,7 +120,7 @@ object DeviceDetailsScreen {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = stringResource(R.string.back),
tint = Color.White
tint = MaterialTheme.colors.onPrimary
)
}
}
Expand All @@ -131,7 +134,7 @@ object DeviceDetailsScreen {
) {
val deviceData = viewModel.deviceState
if (deviceData == null) {
Progress()
Progress(modifier)
} else {
DeviceDetails(modifier = modifier, viewModel = viewModel, deviceData = deviceData)
}
Expand Down Expand Up @@ -197,7 +200,7 @@ object DeviceDetailsScreen {
Text(
text = deviceData.buildDisplayName(),
fontSize = 20.sp,
fontWeight = FontWeight.Bold
fontWeight = FontWeight.Bold,
)
Spacer(modifier = Modifier.height(8.dp))

Expand All @@ -214,18 +217,25 @@ object DeviceDetailsScreen {
Spacer(modifier = Modifier.height(8.dp))

Row {
Text(text = stringResource(R.string.device_details_detect_count), fontWeight = FontWeight.Bold)
Text(
text = stringResource(R.string.device_details_detect_count),
fontWeight = FontWeight.Bold,
)
Spacer(Modifier.width(4.dp))
Text(text = deviceData.detectCount.toString())
}
Spacer(modifier = Modifier.height(8.dp))

Text(text = stringResource(R.string.device_details_first_detection), fontWeight = FontWeight.Bold)
Text(text = stringResource(R.string.time_ago, deviceData.firstDetectionPeriod(LocalContext.current)))
Text(
text = stringResource(R.string.time_ago, deviceData.firstDetectionPeriod(LocalContext.current))
)
Spacer(modifier = Modifier.height(8.dp))

Text(text = stringResource(R.string.device_details_last_detection), fontWeight = FontWeight.Bold)
Text(text = stringResource(R.string.time_ago, deviceData.lastDetectionPeriod(LocalContext.current)))
Text(
text = stringResource(R.string.time_ago, deviceData.lastDetectionPeriod(LocalContext.current))
)
Spacer(modifier = Modifier.height(8.dp))
}
}
Expand Down Expand Up @@ -263,8 +273,11 @@ object DeviceDetailsScreen {
MaterialDialog(
dialogState = dialogState,
buttons = {
negativeButton(text = stringResource(R.string.cancel)) { dialogState.hide() }
positiveButton(text = stringResource(R.string.confirm)) {
negativeButton(
text = stringResource(R.string.cancel),
textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)
) { dialogState.hide() }
positiveButton(text = stringResource(R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) {
dialogState.hide()
viewModel.onRemoveTagClick(deviceData, name)
}
Expand All @@ -290,12 +303,12 @@ object DeviceDetailsScreen {
}
Chip(
colors = ChipDefaults.chipColors(
backgroundColor = MaterialTheme.colors.primary,
contentColor = Color.White,
backgroundColor = MaterialTheme.colors.secondary,
contentColor = MaterialTheme.colors.onSecondary,
),
onClick = { addTagDialog.show() },
leadingIcon = {
Icon(imageVector = Icons.Default.Add, contentDescription = null)
Icon(imageVector = Icons.Default.Add, contentDescription = null, tint = MaterialTheme.colors.onSurface)
}
) { Text(text = stringResource(R.string.add_tag)) }
}
Expand All @@ -309,7 +322,10 @@ object DeviceDetailsScreen {
MaterialDialog(
dialogState = dialog,
buttons = {
negativeButton(stringResource(R.string.cancel)) { dialog.hide() }
negativeButton(
stringResource(R.string.cancel),
textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)
) { dialog.hide() }
},
) {
Column(
Expand Down Expand Up @@ -362,13 +378,14 @@ object DeviceDetailsScreen {
Spacer(modifier = Modifier.height(4.dp))
Text(
text = stringResource(R.string.device_details_history_period_subtitle),
fontWeight = FontWeight.Light
fontWeight = FontWeight.Light,
)
}
Spacer(modifier = Modifier.width(8.dp))
Image(
modifier = Modifier.size(24.dp),
imageVector = Icons.Default.Edit,
colorFilter = ColorFilter.tint(MaterialTheme.colors.onSurface),
contentDescription = stringResource(R.string.change)
)
}
Expand Down Expand Up @@ -403,7 +420,7 @@ object DeviceDetailsScreen {
.fillMaxHeight(),
contentAlignment = Alignment.Center,
) {
Box(modifier = Modifier.background(color = colorResource(id = R.color.black_300), shape = RoundedCornerShape(8.dp))) {
Box(modifier = Modifier.background(color = colorResource(id = R.color.black_30), shape = RoundedCornerShape(8.dp))) {
Text(
modifier = Modifier.padding(16.dp),
text = stringResource(R.string.device_details_no_location_history_for_such_period),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import f.cking.software.R
import f.cking.software.common.navigation.BackCommand
import f.cking.software.common.navigation.Router
import f.cking.software.data.helpers.LocationProvider
import f.cking.software.data.helpers.PermissionHelper
import f.cking.software.data.repo.DevicesRepository
Expand All @@ -19,6 +17,8 @@ import f.cking.software.domain.interactor.RemoveTagFromDeviceInteractor
import f.cking.software.domain.model.DeviceData
import f.cking.software.domain.model.LocationModel
import f.cking.software.domain.toDomain
import f.cking.software.utils.navigation.BackCommand
import f.cking.software.utils.navigation.Router
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.launch

Expand Down
Loading

0 comments on commit 8159ec2

Please sign in to comment.