mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: Replace Nordic, use Kable backend for Desktop and Android with BLE support (#4818)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
0e5f94579f
commit
0b2e89c46f
79 changed files with 1980 additions and 2965 deletions
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.meshtastic.feature.settings.radio.component
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import androidx.compose.foundation.clickable
|
||||
|
|
@ -38,6 +40,7 @@ import androidx.compose.material3.IconButton
|
|||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
|
|
@ -47,6 +50,7 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.RectangleShape
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
|
|
@ -56,7 +60,6 @@ import androidx.compose.ui.text.input.ImeAction
|
|||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import no.nordicsemi.android.common.core.registerReceiver
|
||||
import org.jetbrains.compose.resources.StringResource
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import org.meshtastic.core.model.util.toPosixString
|
||||
|
|
@ -252,10 +255,23 @@ fun DeviceConfigScreen(viewModel: RadioConfigViewModel, onBack: () -> Unit) {
|
|||
}
|
||||
item {
|
||||
TitledCard(title = stringResource(Res.string.time_zone)) {
|
||||
val context = LocalContext.current
|
||||
var appTzPosixString by remember { mutableStateOf(ZoneId.systemDefault().toPosixString()) }
|
||||
|
||||
registerReceiver(IntentFilter(Intent.ACTION_TIMEZONE_CHANGED)) {
|
||||
appTzPosixString = ZoneId.systemDefault().toPosixString()
|
||||
DisposableEffect(context) {
|
||||
val receiver =
|
||||
object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
appTzPosixString = ZoneId.systemDefault().toPosixString()
|
||||
}
|
||||
}
|
||||
androidx.core.content.ContextCompat.registerReceiver(
|
||||
context,
|
||||
receiver,
|
||||
IntentFilter(Intent.ACTION_TIMEZONE_CHANGED),
|
||||
androidx.core.content.ContextCompat.RECEIVER_NOT_EXPORTED,
|
||||
)
|
||||
onDispose { context.unregisterReceiver(receiver) }
|
||||
}
|
||||
|
||||
EditTextPreference(
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import androidx.compose.ui.platform.LocalFocusManager
|
|||
import androidx.core.location.LocationCompat
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import kotlinx.coroutines.launch
|
||||
import no.nordicsemi.android.common.permissions.ble.RequireLocation
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import org.meshtastic.core.model.Position
|
||||
import org.meshtastic.core.resources.Res
|
||||
|
|
@ -251,16 +250,16 @@ fun PositionConfigScreen(viewModel: RadioConfigViewModel, onBack: () -> Unit) {
|
|||
onValueChanged = { alt: Int -> locationInput = locationInput.copy(altitude = alt) },
|
||||
)
|
||||
HorizontalDivider()
|
||||
RequireLocation { isLocationRequiredAndDisabled: Boolean ->
|
||||
TextButton(
|
||||
enabled = state.connected && !isLocationRequiredAndDisabled,
|
||||
onClick = {
|
||||
@SuppressLint("MissingPermission")
|
||||
coroutineScope.launch { phoneLocation = viewModel.getCurrentLocation() }
|
||||
},
|
||||
) {
|
||||
Text(text = stringResource(Res.string.position_config_set_fixed_from_phone))
|
||||
}
|
||||
// RequireLocation wrapper removed to complete Nordic removal.
|
||||
// Should be replaced with a generic solution later.
|
||||
TextButton(
|
||||
enabled = state.connected,
|
||||
onClick = {
|
||||
@SuppressLint("MissingPermission")
|
||||
coroutineScope.launch { phoneLocation = viewModel.getCurrentLocation() as? Location }
|
||||
},
|
||||
) {
|
||||
Text(text = stringResource(Res.string.position_config_set_fixed_from_phone))
|
||||
}
|
||||
} else {
|
||||
HorizontalDivider()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue