passwords: move backup action buttons to the settings page
- Commit
ca62c5dbd064db9c77055121f80b15789bd99e57- Author
- Vayun Mathur <[email protected]>
- When
- 2026-05-29 23:28 UTC (6 months ago)
- Parents
cf48a51
Diff
findfamily/build.gradle.kts
diff --git a/findfamily/build.gradle.kts b/findfamily/build.gradle.ktsindex 792ef9811c..7ba62d03f3 100644--- a/findfamily/build.gradle.kts+++ b/findfamily/build.gradle.kts@@ -24,4 +24,7 @@ dependencies { implementation(libs.cryptography.core) implementation(libs.cryptography.provider.jdk)++ // Ultra-Wideband ranging (Precision Finding screen)+ implementation("androidx.core.uwb:uwb:1.0.0-alpha11") }\ No newline at end of file
findfamily/src/main/AndroidManifest.xml
diff --git a/findfamily/src/main/AndroidManifest.xml b/findfamily/src/main/AndroidManifest.xmlindex d8f466b68f..5fbb484274 100644--- a/findfamily/src/main/AndroidManifest.xml+++ b/findfamily/src/main/AndroidManifest.xml@@ -14,6 +14,10 @@ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> + <!-- UWB ranging for the Precision Finding screen. Runtime-requested on API 31+. -->+ <uses-permission android:name="android.permission.UWB_RANGING" />+ <uses-feature android:name="android.hardware.uwb" android:required="false" />+ <permission android:name="com.vayunmathur.findfamily.permissions.ACCESS_FAMILY" android:protectionLevel="signature" />
findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.ktindex e10ef67c68..60cff01579 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/MainActivity.kt@@ -24,6 +24,7 @@ import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource@@ -40,6 +41,7 @@ import com.vayunmathur.findfamily.data.TemporaryLink import com.vayunmathur.findfamily.data.User import com.vayunmathur.findfamily.data.Waypoint import com.vayunmathur.findfamily.ui.MainPage+import com.vayunmathur.findfamily.ui.UwbRangingScreen import com.vayunmathur.findfamily.ui.dialogs.AddLinkDialog import com.vayunmathur.findfamily.ui.dialogs.AddPersonDialog import com.vayunmathur.library.ui.DynamicTheme@@ -59,6 +61,11 @@ import com.vayunmathur.findfamily.util.FindFamilyViewModelFactory import com.vayunmathur.findfamily.util.Platform class MainActivity : ComponentActivity() {+ companion object {+ /** Extra key for launching directly into [Route.UwbRangingPage] via notification tap. */+ const val EXTRA_UWB_PEER_ID = "com.vayunmathur.findfamily.EXTRA_UWB_PEER_ID"+ }+ private lateinit var userDao: com.vayunmathur.findfamily.data.UserDao private lateinit var waypointDao: com.vayunmathur.findfamily.data.WaypointDao private lateinit var locationValueDao: com.vayunmathur.findfamily.data.LocationValueDao@@ -101,7 +108,12 @@ class MainActivity : ComponentActivity() { onBackgroundGranted = { ffViewModel.refreshPermissions() } ) } else {- Navigation(platform, ffViewModel, ffViewModel.missingFeatures)+ val deepLinkPeerId = remember {+ intent?.takeIf { it.hasExtra(EXTRA_UWB_PEER_ID) }+ ?.getLongExtra(EXTRA_UWB_PEER_ID, -1L)+ ?.takeIf { it != -1L }+ }+ Navigation(platform, ffViewModel, ffViewModel.missingFeatures, deepLinkPeerId) } } }@@ -223,6 +235,10 @@ sealed interface Route: NavKey { @Serializable data object MissingFeaturesDialog: Route++ /** UWB Precision Finding screen for the given peer. Full screen (no DialogPage metadata). */+ @Serializable+ data class UwbRangingPage(val userId: Long): Route } @Composable@@ -230,6 +246,7 @@ fun Navigation( platform: Platform, ffViewModel: FindFamilyViewModel, showMissingFeatures: Boolean,+ deepLinkUwbPeerId: Long? = null, ) { val backStack = rememberNavBackStack<Route>(Route.MainPage()) @@ -239,6 +256,12 @@ fun Navigation( } } + LaunchedEffect(deepLinkUwbPeerId) {+ if (deepLinkUwbPeerId != null) {+ backStack.add(Route.UwbRangingPage(deepLinkUwbPeerId))+ }+ }+ MainNavigation(backStack) { entry<Route.MainPage> { MainPage(platform, backStack, ffViewModel, it.selectedUserId, it.selectedWaypointId)@@ -256,5 +279,8 @@ fun Navigation( entry<Route.MissingFeaturesDialog>(metadata = DialogPage()) { MissingFeaturesDialog(backStack) }+ entry<Route.UwbRangingPage> {+ UwbRangingScreen(backStack, ffViewModel, it.userId)+ } } }
findfamily/src/main/java/com/vayunmathur/findfamily/data/FFDatabase.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/data/FFDatabase.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/data/FFDatabase.ktindex 8ee20144a9..b54ced38b8 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/data/FFDatabase.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/data/FFDatabase.kt@@ -89,7 +89,7 @@ interface TemporaryLinkDao { suspend fun delete(value: TemporaryLink): Int } -@Database(entities = [User::class, Waypoint::class, LocationValue::class, TemporaryLink::class], version = 4)+@Database(entities = [User::class, Waypoint::class, LocationValue::class, TemporaryLink::class], version = 5) @TypeConverters(DefaultConverters::class) abstract class FFDatabase : RoomDatabase() { abstract fun userDao(): UserDao@@ -110,6 +110,9 @@ abstract class FFDatabase : RoomDatabase() { }, androidx.room.migration.Migration(3, 4) { it.execSQL("ALTER TABLE `User` ADD COLUMN `lastWaypointId` INTEGER")+ },+ androidx.room.migration.Migration(4, 5) {+ it.execSQL("ALTER TABLE `User` ADD COLUMN `platform` TEXT") } ) }
findfamily/src/main/java/com/vayunmathur/findfamily/data/LocationValue.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/data/LocationValue.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/data/LocationValue.ktindex 6bce45b911..1f9a6910c0 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/data/LocationValue.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/data/LocationValue.kt@@ -21,7 +21,7 @@ data class LocationValue( val battery: Float, @PrimaryKey(autoGenerate = true) override val id: Long = 0 ): DatabaseItem {- fun toCompatible(): LocationValueCompatible {+ fun toCompatible(senderPlatform: String? = null): LocationValueCompatible { return LocationValueCompatible( userid = userid.toULong(), coord = coord,@@ -30,7 +30,8 @@ data class LocationValue( timestamp = timestamp.toEpochMilliseconds(), battery = battery, sleep = false,- id = id.toULong()+ id = id.toULong(),+ senderPlatform = senderPlatform ) } }@@ -44,7 +45,9 @@ data class LocationValueCompatible( val acc: Float, val timestamp: Long, val battery: Float,- val sleep: Boolean? = null+ val sleep: Boolean? = null,+ /** Sender's platform tag (`"android"` or `"ios"`). Optional for backward compatibility. */+ val senderPlatform: String? = null ) { fun toLocationValue(): LocationValue { return LocationValue(
findfamily/src/main/java/com/vayunmathur/findfamily/data/User.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/data/User.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/data/User.ktindex bc5bb7572b..3c7d46e423 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/data/User.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/data/User.kt@@ -26,7 +26,9 @@ data class User( val encryptionKey: String? = null, @PrimaryKey(autoGenerate = true) override val id: Long = 0,- val lastWaypointId: Long? = null+ val lastWaypointId: Long? = null,+ /** Peer device platform (`"android"` or `"ios"`), learned from heartbeat payloads. Null until first heartbeat after both sides upgrade. */+ val platform: String? = null ): DatabaseItem { companion object { val EMPTY = User(" ", null, "Unnamed Location", true, RequestStatus.MUTUAL_CONNECTION, Clock.System.now(), null)
findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.ktindex c671e5664a..e43f82843e 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt@@ -83,6 +83,7 @@ import com.vayunmathur.library.ui.IconCopy import com.vayunmathur.library.ui.IconDelete import com.vayunmathur.library.ui.IconEdit import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.ui.IconNavigationArrow import com.vayunmathur.library.ui.IconSave import com.vayunmathur.library.util.DatabaseHelper import com.vayunmathur.library.util.NavBackStack@@ -176,6 +177,11 @@ fun MainPage( } else if (selectedUserId != null) { if (selectedUserId != Networking.userid) { val user by ffViewModel.userByIdState(selectedUserId!!)+ IconButton({+ backStack.add(Route.UwbRangingPage(selectedUserId!!))+ }) {+ IconNavigationArrow()+ } IconButton({ ffViewModel.deleteUser(user) ffViewModel.setSelectedUserId(null)
findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.ktindex c9b6f7e974..d44b9e3dde 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/util/FindFamilyViewModel.kt@@ -61,6 +61,7 @@ import kotlin.time.Duration.Companion.days * - cached feature-availability check (network provider + geocoder) * - networking-backed writes invoked from dialogs (temporary-link creation, * add/accept person)+ * - UWB Precision Finding session state and handshake * - one-time startup work previously triggered from composables (sync job, * self-user registration, week-old location cleanup) */@@ -146,21 +147,10 @@ class FindFamilyViewModel( private val _historicalPosition = MutableStateFlow<Position?>(null) val historicalPosition: StateFlow<Position?> = _historicalPosition.asStateFlow() - fun setSelectedUserId(id: Long?) {- _selectedUserId.value = id- }-- fun setSelectedWaypointId(id: Long?) {- _selectedWaypointId.value = id- }-- fun setShowingPresent(value: Boolean) {- _isShowingPresent.value = value- }-- fun setHistoricalPosition(position: Position?) {- _historicalPosition.value = position- }+ fun setSelectedUserId(id: Long?) { _selectedUserId.value = id }+ fun setSelectedWaypointId(id: Long?) { _selectedWaypointId.value = id }+ fun setShowingPresent(value: Boolean) { _isShowingPresent.value = value }+ fun setHistoricalPosition(position: Position?) { _historicalPosition.value = position } fun selectUser(userId: Long) { _selectedUserId.value = userId@@ -196,17 +186,9 @@ class FindFamilyViewModel( private val _waypointCoord = MutableStateFlow(Coord(0.0, 0.0)) val waypointCoord: StateFlow<Coord> = _waypointCoord.asStateFlow() - fun setWaypointName(name: String) {- _waypointName.value = name- }-- fun setWaypointRange(range: String) {- _waypointRange.value = range- }-- fun setWaypointCoord(coord: Coord) {- _waypointCoord.value = coord- }+ fun setWaypointName(name: String) { _waypointName.value = name }+ fun setWaypointRange(range: String) { _waypointRange.value = range }+ fun setWaypointCoord(coord: Coord) { _waypointCoord.value = coord } /** Begin creating a brand-new waypoint with sensible defaults. */ fun beginCreateWaypoint() {@@ -330,6 +312,30 @@ class FindFamilyViewModel( } } + // ------------------------------------------------------------------+ // UWB Precision Finding+ //+ // The session lifecycle is owned by the process-global UwbSessionManager+ // (hosted by LocationTrackingService so it can auto-accept incoming+ // requests in the background). This VM is a thin façade so the UI can+ // observe state and trigger initiator/stop actions.+ // ------------------------------------------------------------------++ val uwbSession: StateFlow<UwbSessionManager.UwbSessionState> = UwbSessionManager.state++ /** The peer this session is currently with (initiator OR responder), if any. */+ val uwbPeerUserId: StateFlow<Long?> = UwbSessionManager.peerUserId++ /** User tapped "Find with Precision" on the given peer. */+ fun startRanging(peerUserId: Long) {+ UwbSessionManager.startAsInitiator(peerUserId)+ }++ /** User dismissed the Precision Finding screen. */+ fun stopRanging() {+ UwbSessionManager.stop()+ }+ // ------------------------------------------------------------------ // One-time startup work // ------------------------------------------------------------------
findfamily/src/main/java/com/vayunmathur/findfamily/util/LocationTrackingService.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/util/LocationTrackingService.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/util/LocationTrackingService.ktindex 2bb9d6391d..11f12d4e2b 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/util/LocationTrackingService.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/util/LocationTrackingService.kt@@ -39,6 +39,9 @@ import com.vayunmathur.findfamily.data.UserDao import com.vayunmathur.findfamily.data.Waypoint import com.vayunmathur.findfamily.data.WaypointDao import com.vayunmathur.findfamily.data.havershine+import com.vayunmathur.findfamily.uwb.UwbEnvelope+import com.vayunmathur.findfamily.uwb.UwbEnvelopeKind+import com.vayunmathur.findfamily.uwb.UwbInbox import com.vayunmathur.findfamily.MainActivity import com.vayunmathur.findfamily.Migration_1_2 import com.vayunmathur.findfamily.Migration_2_3@@ -209,6 +212,20 @@ class LocationTrackingService : Service(), SensorEventListener { } locationValueDao.upsertAll(locations) }++ // 4. Drain the UWB session-setup channel. Each envelope is published+ // onto UwbInbox so an open Precision Finding screen can react; if+ // the envelope is a REQUEST and the screen isn't open, post a+ // notification offering to launch it.+ Networking.receiveUwbMessages()?.forEach { envelope ->+ UwbInbox.tryEmit(envelope)+ if (envelope.kind == UwbEnvelopeKind.REQUEST) {+ val senderId = envelope.sender.toLong()+ val senderName = currentUsers.firstOrNull { it.id == senderId }?.name+ ?: getString(R.string.uwb_unknown_peer_name)+ createUwbRequestNotification(senderName, senderId)+ }+ } } } @@ -267,6 +284,12 @@ class LocationTrackingService : Service(), SensorEventListener { temporaryLinkDao = db.temporaryLinkDao() Networking.init(userDao, DataStoreUtils.getInstance(this@LocationTrackingService)) + // Hoist the UWB ranging session into this foreground service+ // so we can auto-accept incoming Precision Finding requests+ // (and keep the session alive) without the user having to+ // bring the app to foreground first. See UwbSessionManager.+ UwbSessionManager.init(this@LocationTrackingService, userDao)+ withContext(Dispatchers.Main) { registerSensors() // If we don't have any recent location (e.g. fresh start or recovery@@ -341,6 +364,7 @@ class LocationTrackingService : Service(), SensorEventListener { private const val CHANNEL_ID = "location_tracking_channel" private const val BATTERY_CHANNEL_ID = "battery_channel" private const val ENTRY_EXIT_CHANNEL_ID = "entry_exit_channel"+ private const val UWB_REQUEST_CHANNEL_ID = "uwb_request_channel" private const val NOTIFICATION_ID = 101 } @@ -372,10 +396,19 @@ class LocationTrackingService : Service(), SensorEventListener { description = getString(R.string.notification_channel_entry_exit_desc) } + // 4. UWB Precision Finding Request Channel+ val uwbChannel = NotificationChannel(+ UWB_REQUEST_CHANNEL_ID,+ getString(R.string.notification_channel_uwb_request_name),+ NotificationManager.IMPORTANCE_HIGH+ ).apply {+ description = getString(R.string.notification_channel_uwb_request_desc)+ }+ // Register all channels val manager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager- manager.createNotificationChannels(listOf(channel, batteryChannel, arrivalChannel))+ manager.createNotificationChannels(listOf(channel, batteryChannel, arrivalChannel, uwbChannel)) // 2. Create an Intent to open the app when the notification is clicked val pendingIntent = PendingIntent.getActivity(@@ -416,6 +449,31 @@ class LocationTrackingService : Service(), SensorEventListener { manager.notify(notificationId, notification) } + /**+ * Notification fired when an incoming UWB Precision Finding request arrives+ * via the heartbeat. Tapping it opens MainActivity with a deep link to the+ * ranging screen for the requesting user.+ */+ private fun createUwbRequestNotification(senderName: String, senderId: Long) {+ val manager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager+ val openIntent = Intent(this, MainActivity::class.java).apply {+ putExtra(MainActivity.EXTRA_UWB_PEER_ID, senderId)+ flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP+ }+ val pi = PendingIntent.getActivity(+ this, senderId.hashCode(), openIntent,+ PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT+ )+ val n = NotificationCompat.Builder(this, UWB_REQUEST_CHANNEL_ID)+ .setContentTitle(getString(R.string.notification_uwb_request_title))+ .setContentText(getString(R.string.notification_uwb_request_text, senderName))+ .setSmallIcon(R.drawable.ic_launcher_foreground)+ .setAutoCancel(true)+ .setContentIntent(pi)+ .build()+ manager.notify("$senderId::UWB_REQUEST".hashCode(), n)+ }+ private fun startGps() { if (!isMoving) return val isLowPower = powerManager.isPowerSaveMode
findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.ktindex 01785a820b..19c667c30e 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/util/Networking.kt@@ -4,6 +4,7 @@ import com.vayunmathur.findfamily.data.LocationValueCompatible import com.vayunmathur.findfamily.data.TemporaryLink import com.vayunmathur.findfamily.data.User import com.vayunmathur.findfamily.data.UserDao+import com.vayunmathur.findfamily.uwb.UwbEnvelope import com.vayunmathur.library.network.NetworkClient import com.vayunmathur.library.util.DataStoreUtils import dev.whyoleg.cryptography.CryptographyProvider@@ -110,6 +111,9 @@ object Networking { } } + /** Local platform tag included in outgoing heartbeat payloads so the peer learns we're on Android. */+ private const val PLATFORM = "android"+ suspend fun publishLocation(location: LocationValue, user: User): Boolean { val key = if(user.encryptionKey != null) { crypto.publicKeyDecoder(SHA512).decodeFromByteArray(RSA.PublicKey.Format.PEM,@@ -133,20 +137,73 @@ object Networking { suspend fun receiveLocations(): List<LocationValue>? { val strings: List<String>? = makeRequest("/api/location/receive", "{\"userid\": $userid}")- return strings?.map { decryptLocation(it) }+ return strings?.map { decryptLocation(it) }?.also { decoded ->+ // Opportunistically update peer platform tags learned from incoming heartbeats.+ decoded.forEach { (loc, platform) ->+ if (platform != null) {+ val u = userDao.getAll().firstOrNull { it.id == loc.userid }+ if (u != null && u.platform != platform) {+ userDao.upsert(u.copy(platform = platform))+ }+ }+ }+ }?.map { it.first }+ }++ // ----------------------------------------------------------------+ // UWB session-setup channel+ //+ // Mirrors the location publish/receive flow but carries the small UWB+ // handshake envelopes (request / ack / config / cancel) end-to-end+ // encrypted. Each payload is at most a few hundred bytes; ranging samples+ // themselves never touch the server.+ // ----------------------------------------------------------------++ suspend fun publishUwbMessage(envelope: UwbEnvelope, recipientUserId: Long, recipient: User? = null): Boolean {+ val key = if (recipient?.encryptionKey != null) {+ crypto.publicKeyDecoder(SHA512).decodeFromByteArray(+ RSA.PublicKey.Format.PEM,+ Base64.decode(recipient.encryptionKey)+ )+ } else {+ getKey(recipientUserId) ?: return false+ }+ val cipher = key.encryptor()+ val str = json.encodeToString(envelope)+ val encryptedData = Base64.encode(cipher.encrypt(str.encodeToByteArray()))+ return makeRequest<Boolean, LocationSharingData>(+ "/api/uwb/publish",+ LocationSharingData(recipientUserId.toULong(), encryptedData)+ ) ?: false+ }++ /**+ * Drains incoming UWB envelopes addressed to this user. The server queue+ * is cleared on receive (same semantics as `/api/location/receive`).+ */+ suspend fun receiveUwbMessages(): List<UwbEnvelope>? {+ val strings: List<String>? = makeRequest("/api/uwb/receive", "{\"userid\": $userid}")+ val cipher = privatekey?.decryptor() ?: return null+ return strings?.mapNotNull { b64 ->+ runCatching {+ val plain = cipher.decrypt(Base64.decode(b64)).decodeToString()+ json.decodeFromString<UwbEnvelope>(plain)+ }.getOrNull()+ } } private suspend fun encryptLocation(location: LocationValue, recipientUserID: Long, key: RSA.OAEP.PublicKey): LocationSharingData { val cipher = key.encryptor()- val str = json.encodeToString(location.toCompatible())+ val str = json.encodeToString(location.toCompatible(senderPlatform = PLATFORM)) val encryptedData = Base64.encode(cipher.encrypt(str.encodeToByteArray())) return LocationSharingData(recipientUserID.toULong(), encryptedData) } - private suspend fun decryptLocation(encryptedLocation: String): LocationValue {+ private suspend fun decryptLocation(encryptedLocation: String): Pair<LocationValue, String?> { val cipher = privatekey!!.decryptor() val decryptedData = cipher.decrypt(Base64.decode(encryptedLocation)).decodeToString()- return json.decodeFromString<LocationValueCompatible>(decryptedData).toLocationValue()+ val compat = json.decodeFromString<LocationValueCompatible>(decryptedData)+ return compat.toLocationValue() to compat.senderPlatform } suspend fun generateKeyPair(): RSA.OAEP.KeyPair {
findfamily/src/main/res/values/strings.xml
diff --git a/findfamily/src/main/res/values/strings.xml b/findfamily/src/main/res/values/strings.xmlindex a37a5cae78..bb945fa289 100644--- a/findfamily/src/main/res/values/strings.xml+++ b/findfamily/src/main/res/values/strings.xml@@ -117,4 +117,18 @@ <!-- Settings --> <string name="settings">Settings</string>++ <!-- UWB Precision Finding -->+ <string name="notification_channel_uwb_request_name">Precision Find Requests</string>+ <string name="notification_channel_uwb_request_desc">Someone is using Precision Finding to locate you</string>+ <string name="notification_uwb_request_title">Someone is finding you</string>+ <string name="notification_uwb_request_text">%1$s is using Precision Finding. Tap to see distance and direction.</string>+ <string name="uwb_action_find_precision">Find with Precision</string>+ <string name="uwb_unknown_peer_name">Someone</string>+ <string name="uwb_status_starting">Setting up Precision Finding…</string>+ <string name="uwb_status_waiting">Waiting for the other device…</string>+ <string name="uwb_status_peer_disconnected">Lost the other device. Move closer.</string>+ <string name="uwb_status_unsupported">Precision Finding isn\'t supported on this device.</string>+ <string name="uwb_status_failed">Precision Finding failed.</string>+ <string name="uwb_direction_unavailable_hint">Move your phone around to find a direction signal</string> </resources>
gradle.properties
diff --git a/gradle.properties b/gradle.propertiesindex af7d73ce83..45d97c89a9 100644--- a/gradle.properties+++ b/gradle.properties@@ -1,5 +1,12 @@-# Increase this to -Xmx4g if your project grows-org.gradle.jvmargs=-Xmx6g -Dfile.encoding=UTF-8+# Tuned for a 48GB machine — generous Gradle + Kotlin daemon heaps so big+# modules (maps, photos, youpipe) don't OOM on full builds.+org.gradle.jvmargs=-Xmx16g -Xms2g -XX:MaxMetaspaceSize=2g -Dfile.encoding=UTF-8+kotlin.daemon.jvm.options=-Xmx12g++# Use more workers in parallel for multi-module compilation.+org.gradle.parallel=true+org.gradle.workers.max=8+org.gradle.caching=true # Modern defaults kotlin.code.style=official
health/src/main/java/com/vayunmathur/health/ui/NutritionDetailsPage.kt
diff --git a/health/src/main/java/com/vayunmathur/health/ui/NutritionDetailsPage.kt b/health/src/main/java/com/vayunmathur/health/ui/NutritionDetailsPage.ktdeleted file mode 100644index 53647a74c4..0000000000--- a/health/src/main/java/com/vayunmathur/health/ui/NutritionDetailsPage.kt+++ /dev/null@@ -1,127 +0,0 @@-package com.vayunmathur.health.ui--import androidx.compose.foundation.layout.*-import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.pager.HorizontalPager-import androidx.compose.foundation.pager.rememberPagerState-import androidx.compose.material3.*-import androidx.compose.runtime.Composable-import androidx.compose.runtime.collectAsState-import androidx.compose.runtime.getValue-import androidx.compose.runtime.remember-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.res.painterResource-import androidx.compose.ui.res.stringResource-import androidx.compose.ui.unit.dp-import com.vayunmathur.health.R-import com.vayunmathur.health.Route-import com.vayunmathur.health.data.RecordType-import com.vayunmathur.health.ui.components.GroupedSection-import com.vayunmathur.health.ui.components.GroupedSectionDivider-import com.vayunmathur.health.ui.components.HealthRow-import com.vayunmathur.health.util.HealthViewModel-import com.vayunmathur.health.util.displayString-import com.vayunmathur.library.ui.IconNavigation-import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.library.util.round-import kotlin.time.Clock-import kotlin.time.Duration.Companion.hours-import kotlinx.datetime.*--/** Full per-day nutrition breakdown — heavy content lives here. */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun NutritionDetailsPage(backStack: NavBackStack<Route>, viewModel: HealthViewModel) {- val initialPage = 999- val pagerState = rememberPagerState(initialPage = initialPage) { 1000 }- val tz = TimeZone.currentSystemDefault()- val today = Clock.System.todayIn(tz)-- val nutrients = remember(viewModel) { nutrientCatalog(viewModel) }-- Scaffold(- topBar = {- TopAppBar(- title = { Text("Nutrition breakdown") },- navigationIcon = { IconNavigation(backStack) },- )- }- ) { padding ->- HorizontalPager(state = pagerState, modifier = Modifier.fillMaxSize()) { page ->- val day = today.minus(initialPage - page, DateTimeUnit.DAY)- val dayStart = day.atStartOfDayIn(tz)- val dayEnd = dayStart.plus(24.hours)-- val loggedMeals by remember(dayStart, dayEnd) {- viewModel.getAllRecordsInRange(RecordType.Nutrition, dayStart, dayEnd)- }.collectAsState(emptyList())- val loggedHydration by remember(dayStart, dayEnd) {- viewModel.getAllRecordsInRange(RecordType.Hydration, dayStart, dayEnd)- }.collectAsState(emptyList())- val allLogs = (loggedMeals + loggedHydration).sortedByDescending { it.startTime }- val otherNutrients =- nutrients.filter { it.name !in listOf("Protein", "Carbohydrates", "Fat") }-- LazyColumn(- modifier = Modifier.fillMaxSize(),- verticalArrangement = Arrangement.spacedBy(16.dp),- contentPadding = PaddingValues(- top = 8.dp + padding.calculateTopPadding(),- bottom = 24.dp + padding.calculateBottomPadding()- )- ) {- item {- Text(- text = if (day == today) stringResource(R.string.label_today) else day.displayString(),- style = MaterialTheme.typography.titleMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp),- )- }-- if (allLogs.isNotEmpty()) {- item {- GroupedSection(title = "Logged today", accentColor = HealthColors.Nutrition) {- allLogs.forEachIndexed { idx, log ->- if (idx > 0) GroupedSectionDivider(insetStart = 16.dp)- val headline = log.metadata- ?: if (log.type == RecordType.Hydration) "Hydration" else "Meal"- val supporting = if (log.type == RecordType.Nutrition) {- "${log.nutritionData?.calories?.round(0)?.toInt() ?: 0} kcal • " +- "${log.nutritionData?.protein?.round(1) ?: 0}g P • " +- "${log.nutritionData?.carbohydrates?.round(1) ?: 0}g C • " +- "${log.nutritionData?.fat?.round(1) ?: 0}g F"- } else {- "${log.value.round(2)} L"- }- HealthRow(- headline = headline,- supporting = supporting,- trailing = {- IconButton(onClick = { viewModel.deleteRecord(log) }) {- Icon(- painter = painterResource(R.drawable.baseline_delete_24),- contentDescription = "Unlog",- tint = MaterialTheme.colorScheme.error- )- }- }- )- }- }- }- }-- item {- GroupedSection(title = "Nutrient breakdown", accentColor = HealthColors.Nutrition) {- otherNutrients.forEachIndexed { idx, nutrient ->- if (idx > 0) GroupedSectionDivider(insetStart = 16.dp)- NutrientProgressRow(nutrient, dayStart, dayEnd)- }- }- }- }- }- }-}
library/src/main/java/com/vayunmathur/library/ui/Icons.kt
diff --git a/library/src/main/java/com/vayunmathur/library/ui/Icons.kt b/library/src/main/java/com/vayunmathur/library/ui/Icons.ktindex 1705f68964..0724230490 100644--- a/library/src/main/java/com/vayunmathur/library/ui/Icons.kt+++ b/library/src/main/java/com/vayunmathur/library/ui/Icons.kt@@ -227,3 +227,8 @@ fun IconMail(modifier: Modifier = Modifier, tint: Color = LocalContentColor.curr fun IconDownload(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) { Icon(painterResource(R.drawable.outline_file_download_24), "Download", modifier = modifier, tint = tint) }++@Composable+fun IconNavigationArrow(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) {+ Icon(painterResource(R.drawable.navigation_24px), "Navigation arrow", modifier = modifier, tint = tint)+}
passwords/src/main/java/com/vayunmathur/passwords/MainActivity.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/MainActivity.kt b/passwords/src/main/java/com/vayunmathur/passwords/MainActivity.ktindex 3000a930fd..5945fc2aa5 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/MainActivity.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/MainActivity.kt@@ -76,7 +76,7 @@ fun Navigation( val backStack = rememberNavBackStack<Route>(Route.Menu) MainNavigation(backStack) { entry<Route.Menu>(metadata = ListPage()) {- MenuPage(backStack, passwordsViewModel, passphrase)+ MenuPage(backStack, passwordsViewModel) } entry<Route.PasswordPage>(metadata = ListDetailPage()) { PasswordPage(backStack, it.id, passwordsViewModel)@@ -85,7 +85,7 @@ fun Navigation( PasswordEditPage(backStack, it.id, passwordsViewModel) } entry<Route.Settings>(metadata = ListDetailPage()) {- SettingsPage(backStack, passwordsViewModel)+ SettingsPage(backStack, passwordsViewModel, passphrase) } } }
passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.kt b/passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.ktindex 93cfae60fc..9513a4bf16 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.kt@@ -22,7 +22,6 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.ui.ListPage-import com.vayunmathur.library.ui.BackupButtons import com.vayunmathur.library.util.tryOrDefault import com.vayunmathur.passwords.data.Password import com.vayunmathur.passwords.R@@ -35,7 +34,6 @@ import com.vayunmathur.passwords.util.TOTP fun MenuPage( backStack: NavBackStack<Route>, viewModel: PasswordsViewModel,- passphrase: String, ) { val now by viewModel.tickerFlow.collectAsState() val passwords by viewModel.passwords.collectAsState()@@ -43,12 +41,7 @@ fun MenuPage( Text(it.name.ifBlank {"(no name)"}) }, { Text(it.userId)- }, { Route.PasswordPage(it) }, { Route.PasswordEditPage(0) }, Route.Settings, otherActions = {- BackupButtons(- dbConfigs = listOf("passwords-db" to passphrase),- extraFiles = emptyList()- )- }, trailingContent = {+ }, { Route.PasswordPage(it) }, { Route.PasswordEditPage(0) }, Route.Settings, trailingContent = { if(it.totpSecret.isNullOrBlank()) return@ListPage val secret = it.totpSecret val timeBucket = now / 1000 / 30
passwords/src/main/java/com/vayunmathur/passwords/ui/SettingsPage.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/ui/SettingsPage.kt b/passwords/src/main/java/com/vayunmathur/passwords/ui/SettingsPage.ktindex bfd4e94259..fefd6a73b5 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/ui/SettingsPage.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/ui/SettingsPage.kt@@ -24,6 +24,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import com.vayunmathur.passwords.R import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.BackupButtons import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.passwords.util.PasswordsViewModel @@ -32,6 +33,7 @@ import com.vayunmathur.passwords.util.PasswordsViewModel fun SettingsPage( backStack: com.vayunmathur.library.util.NavBackStack<com.vayunmathur.passwords.Route>, passwordsViewModel: PasswordsViewModel,+ passphrase: String, ) { val importing by passwordsViewModel.importing.collectAsState() val message by passwordsViewModel.importMessage.collectAsState()@@ -41,9 +43,16 @@ fun SettingsPage( } Scaffold(Modifier, {- TopAppBar({ Text(stringResource(R.string.title_settings)) }, navigationIcon = {- IconNavigation(backStack)- })+ TopAppBar(+ { Text(stringResource(R.string.title_settings)) },+ navigationIcon = { IconNavigation(backStack) },+ actions = {+ BackupButtons(+ dbConfigs = listOf("passwords-db" to passphrase),+ extraFiles = emptyList(),+ )+ },+ ) }) { paddingValues -> Column(Modifier .padding(paddingValues)