Skip to content

Commit

Permalink
Merge pull request #67 from Semper-Viventem/master
Browse files Browse the repository at this point in the history
Release 0.20.1-beta
  • Loading branch information
Semper-Viventem authored Dec 20, 2023
2 parents 8159ec2 + fde35f3 commit ea211a1
Show file tree
Hide file tree
Showing 16 changed files with 199 additions and 81 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ This application does not share your personal data or geolocation, all work is o

<br>

<img src='https://github.com/Semper-Viventem/MetaRadar/assets/18288554/1ed51c54-5c99-43a5-af00-b8e758430245' width='300'/> <img src='https://github.com/Semper-Viventem/MetaRadar/assets/18288554/d5154621-a66a-4bb2-8099-d1d2c27503df' width='300'/>
<img src='https://github.com/Semper-Viventem/MetaRadar/assets/18288554/e307d2f3-63ed-4401-8828-194f6b67fa24' width='300'/> <img src='https://github.com/Semper-Viventem/MetaRadar/assets/18288554/6991f8ba-6375-4c3f-8784-059e0d04f9ac' width='300'/>

<img src='https://github.com/Semper-Viventem/MetaRadar/assets/18288554/8a59cc0d-ccc8-47c0-a1d3-3a08f8ff347a' width='300'/> <img src='https://github.com/Semper-Viventem/MetaRadar/assets/18288554/6e51793a-00ce-4e4b-9e59-c69973cde6a2' width='300'/>
<img src='https://github.com/Semper-Viventem/MetaRadar/assets/18288554/9383851d-0dc5-4244-91b3-f902cb777892' width='300'/> <img src='https://github.com/Semper-Viventem/MetaRadar/assets/18288554/9b9bedd2-c96f-4ff2-82bd-0d84424467d6' width='300'/>
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.20.0-beta"
versionName = "0.20.1-beta"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
android:name="f.cking.software.ui.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="fullSensor"
android:screenOrientation="user"
android:theme="@style/Theme.MetaRadar">

<intent-filter>
Expand Down
39 changes: 37 additions & 2 deletions app/src/main/java/f/cking/software/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@ package f.cking.software.ui

import android.content.Intent
import android.content.SharedPreferences
import android.graphics.Color
import android.os.Bundle
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.windowInsetsTopHeight
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Typography
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.colorResource
import androidx.lifecycle.ViewModel
Expand All @@ -17,6 +29,7 @@ import f.cking.software.R
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.navigation.BackCommand
import f.cking.software.utils.navigation.Navigator
import f.cking.software.utils.navigation.RouterImpl
Expand All @@ -38,6 +51,14 @@ class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val navigationBarStyle = if (isDarkModeOn()) {
SystemBarStyle.dark(Color.TRANSPARENT)
} else {
SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT)
}
enableEdgeToEdge(navigationBarStyle = navigationBarStyle)

Configuration.getInstance().load(this, sharedPreferences)

router.attachNavigator(viewModel.navigator)
Expand Down Expand Up @@ -67,8 +88,22 @@ class MainActivity : AppCompatActivity() {
finish()
} else {
focusManager.clearFocus(true)
stack.forEach { screen ->
screen()
Column {
Box(
modifier = Modifier
.windowInsetsTopHeight(WindowInsets.statusBars)
.fillMaxWidth()
.background(MaterialTheme.colors.primary)
)
Box(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
) {
stack.forEach { screen ->
screen()
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ 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.GlassSystemNavbar
import f.cking.software.utils.graphic.MapView
import f.cking.software.utils.graphic.RoundedBox
import f.cking.software.utils.graphic.SystemNavbarSpacer
import f.cking.software.utils.graphic.TagChip
import kotlinx.coroutines.isActive
import org.koin.androidx.compose.koinViewModel
Expand All @@ -86,10 +88,14 @@ object DeviceDetailsScreen {
AppBar(viewModel = viewModel)
},
content = {
Content(
modifier = Modifier.background(MaterialTheme.colors.surface).padding(it),
viewModel = viewModel,
)
GlassSystemNavbar {
Content(
modifier = Modifier
.background(MaterialTheme.colors.surface)
.padding(it),
viewModel = viewModel,
)
}
}
)
}
Expand Down Expand Up @@ -237,6 +243,7 @@ object DeviceDetailsScreen {
text = stringResource(R.string.time_ago, deviceData.lastDetectionPeriod(LocalContext.current))
)
Spacer(modifier = Modifier.height(8.dp))
SystemNavbarSpacer()
}
}

Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import f.cking.software.R
import f.cking.software.domain.model.RadarProfile
import f.cking.software.utils.graphic.SystemNavbarSpacer
import f.cking.software.utils.navigation.BackCommand
import f.cking.software.utils.navigation.Router

Expand All @@ -39,7 +40,9 @@ object SelectFilterScreen {
Scaffold(
topBar = { AppBar { router.navigate(BackCommand) } },
content = { paddings ->
Column(modifier = Modifier.background(MaterialTheme.colors.surface).padding(paddings)) {
Column(modifier = Modifier
.background(MaterialTheme.colors.surface)
.padding(paddings)) {
LazyColumn(
Modifier
.fillMaxWidth()
Expand All @@ -61,14 +64,16 @@ object SelectFilterScreen {
}

Surface(elevation = 12.dp) {
Box(
Column(
modifier = Modifier
.background(MaterialTheme.colors.primary)
.fillMaxWidth(),
) {
val context = LocalContext.current
Button(
modifier = Modifier.fillMaxWidth().padding(16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
colors = ButtonDefaults.buttonColors(backgroundColor = MaterialTheme.colors.primaryVariant),
onClick = {
val filter = initialFilterState
Expand All @@ -85,6 +90,8 @@ object SelectFilterScreen {
) {
Text(text = stringResource(R.string.confirm), color = MaterialTheme.colors.onPrimary)
}

SystemNavbarSpacer()
}
}
}
Expand Down
20 changes: 9 additions & 11 deletions app/src/main/java/f/cking/software/ui/main/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,30 @@ import com.vanpra.composematerialdialogs.rememberMaterialDialogState
import f.cking.software.R
import f.cking.software.ui.GlobalUiState
import f.cking.software.utils.graphic.GlassNavigationbar
import f.cking.software.utils.graphic.SystemNavbarSpacer
import f.cking.software.utils.graphic.pxToDp
import org.koin.androidx.compose.koinViewModel

object MainScreen {

private const val NAVBAR_HEIGHT_DP = 60f

@SuppressLint("NewApi")
@Composable
fun Screen() {
val viewModel: MainViewModel = koinViewModel()
Scaffold(
modifier = Modifier.fillMaxSize(),
topBar = {
TopBar(viewModel)
},
content = { paddings ->
content = { innerPaddings ->
GlassNavigationbar(
modifier = Modifier
.padding(paddings)
.padding(innerPaddings)
.fillMaxWidth()
.fillMaxHeight(),
overlayColor = MaterialTheme.colors.primaryVariant.copy(alpha = 0.3f),
navBarContent = {
BottomNavigationBar(
Modifier
.height(NAVBAR_HEIGHT_DP.dp),
viewModel
)
BottomNavigationBar(Modifier, viewModel)
},
content = {
viewModel.tabs.firstOrNull { it.selected }?.screen?.invoke()
Expand Down Expand Up @@ -114,12 +110,13 @@ object MainScreen {

@Composable
private fun BottomNavigationBar(modifier: Modifier, viewModel: MainViewModel) {
Box(
Column(
modifier = modifier
.onGloballyPositioned { GlobalUiState.setBottomOffset(navbarOffset = it.size.height.toFloat()) }
.fillMaxWidth(),
contentAlignment = Alignment.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Spacer(modifier = Modifier.height(8.dp))
Row(
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
Expand All @@ -130,6 +127,7 @@ object MainScreen {
TabButton(viewModel = viewModel, targetTab = tab, modifier = Modifier.weight(1f))
}
}
SystemNavbarSpacer()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ import f.cking.software.R
import f.cking.software.ui.filter.FilterScreen
import f.cking.software.ui.filter.FilterUiState
import f.cking.software.ui.filter.SelectFilterTypeScreen
import f.cking.software.utils.graphic.GlassSystemNavbar
import f.cking.software.utils.graphic.RoundedBox
import f.cking.software.utils.graphic.SystemNavbarSpacer
import org.koin.androidx.compose.koinViewModel
import org.koin.core.parameter.parametersOf

Expand All @@ -57,11 +59,13 @@ object ProfileDetailsScreen {
AppBar(viewModel)
},
content = {
Box(modifier = Modifier
.background(MaterialTheme.colors.surface)
.fillMaxSize()
.padding(it)) {
Content(viewModel)
GlassSystemNavbar {
Box(modifier = Modifier
.background(MaterialTheme.colors.surface)
.fillMaxSize()
.padding(it)) {
Content(viewModel)
}
}
}
)
Expand Down Expand Up @@ -157,6 +161,8 @@ object ProfileDetailsScreen {
} else {
item { CreateFilter(viewModel = viewModel) }
}

item { SystemNavbarSpacer() }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package f.cking.software.ui.selectdevice

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TextField
Expand All @@ -18,6 +21,8 @@ import androidx.compose.ui.res.stringResource
import f.cking.software.R
import f.cking.software.domain.model.DeviceData
import f.cking.software.utils.graphic.DeviceListItem
import f.cking.software.utils.graphic.GlassSystemNavbar
import f.cking.software.utils.graphic.SystemNavbarSpacer
import org.koin.androidx.compose.koinViewModel

object SelectDeviceScreen {
Expand All @@ -28,6 +33,7 @@ object SelectDeviceScreen {
first.name != second.name -> first.name?.compareTo(second.name ?: return@Comparator 1) ?: -1
first.manufacturerInfo?.name != second.manufacturerInfo?.name ->
first.manufacturerInfo?.name?.compareTo(second.manufacturerInfo?.name ?: return@Comparator 1) ?: -1

else -> first.address.compareTo(second.address)
}
}
Expand All @@ -40,34 +46,50 @@ object SelectDeviceScreen {
Scaffold(
topBar = { AppBar(viewModel) },
content = { paddings ->
LazyColumn(modifier = Modifier.padding(paddings)) {
val list = viewModel.devices.asSequence()
.filter { device ->
viewModel.searchStr.takeIf { it.isNotBlank() }?.let { searchStr ->
(device.name?.contains(searchStr, true) ?: false)
|| (device.customName?.contains(searchStr, true) ?: false)
|| (device.manufacturerInfo?.name?.contains(searchStr, true) ?: false)
|| device.address.contains(searchStr, true)
} ?: true
}
.sortedWith(generalComparator)
.toList()
GlassSystemNavbar {
Content(Modifier.padding(paddings), viewModel, onSelected)
}
}
)
}

list.forEachIndexed { index, device ->
item {
DeviceListItem(device = device) {
onSelected.invoke(device)
viewModel.back()
}
}
val showDivider = list.getOrNull(index + 1)?.lastDetectTimeMs != device.lastDetectTimeMs
if (showDivider) {
item { Divider() }
}
@Composable
private fun Content(
modifier: Modifier,
viewModel: SelectDeviceViewModel,
onSelected: (deviceData: DeviceData) -> Unit
) {
LazyColumn(
modifier = Modifier
.background(MaterialTheme.colors.surface)
.fillMaxSize()
) {
val list = viewModel.devices.asSequence()
.filter { device ->
viewModel.searchStr.takeIf { it.isNotBlank() }?.let { searchStr ->
(device.name?.contains(searchStr, true) ?: false)
|| (device.customName?.contains(searchStr, true) ?: false)
|| (device.manufacturerInfo?.name?.contains(searchStr, true) ?: false)
|| device.address.contains(searchStr, true)
} ?: true
}
.sortedWith(generalComparator)
.toList()

list.forEachIndexed { index, device ->
item {
DeviceListItem(device = device) {
onSelected.invoke(device)
viewModel.back()
}
}
val showDivider = list.getOrNull(index + 1)?.lastDetectTimeMs != device.lastDetectTimeMs
if (showDivider) {
item { Divider() }
}
item { SystemNavbarSpacer() }
}
)
}
}

@Composable
Expand Down
Loading

0 comments on commit ea211a1

Please sign in to comment.