Skip to content

Colota - Android GPS Location tracker

fix(android): measure text at the external display's density so DeX shows it in full (#998)

Max Dietrich519ebef7d5ab
diff --git a/apps/docs/docs/development/architecture.md b/apps/docs/docs/development/architecture.md
index 03e2a683..7beb7f3f 100644
--- a/apps/docs/docs/development/architecture.md
+++ b/apps/docs/docs/development/architecture.md
@@ -288,6 +288,7 @@ For backups, two `internal` methods support the export/import flow without expos
| Module | Purpose |
| --- | --- |
+| `MainActivity` | The React Native activity. Refills `DisplayMetricsHolder` from itself after create and every configuration change, because React Native reads the phone's display metrics and would measure text on an external display (DeX) at the wrong density |
| `LocationBootReceiver` | Auto-restarts tracking after device reboot |
| `AlarmScheduler` | Shared one-shot wake-up alarm used by the geofence heartbeat, the stationary heartbeat and the tracking watchdog. `setAndAllowWhileIdle` fires through Doze without `SCHEDULE_EXACT_ALARM`, at the cost of being inexact, so every interval built on it is a minimum and not a schedule. Floors the delay at 60s, and each alarm needs its own request code. Whoever handles a tick re-arms the next one |
| `GeofenceHeartbeatScheduler` / `GeofenceHeartbeatReceiver` | Wakes the service for the zone heartbeat while paused in a geofence. Replaced a coroutine delay, which stopped counting while the phone slept |
diff --git a/apps/mobile/android/app/src/main/java/com/colota/MainActivity.kt b/apps/mobile/android/app/src/main/java/com/colota/MainActivity.kt
index 7168619a..2e8c7956 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/MainActivity.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/MainActivity.kt
@@ -5,6 +5,7 @@
package com.Colota
+import android.content.res.Configuration
import android.os.Bundle
import android.util.Log
import android.view.MotionEvent
@@ -12,11 +13,19 @@ import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
+import com.facebook.react.uimanager.DisplayMetricsHolder
class MainActivity : ReactActivity() {
+ // RN reads display metrics from the app context (the phone's screen); refill them from this activity's display.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(null)
+ DisplayMetricsHolder.initDisplayMetrics(this)
+ }
+
+ override fun onConfigurationChanged(newConfig: Configuration) {
+ super.onConfigurationChanged(newConfig)
+ DisplayMetricsHolder.initDisplayMetrics(this)
}
// RN ScrollView pointerIndex race: getY() on an invalidated pointer mid-gesture.
diff --git a/fastlane/metadata/android/en-US/changelogs/54.txt b/fastlane/metadata/android/en-US/changelogs/54.txt
new file mode 100644
index 00000000..52502a2e
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/54.txt
@@ -0,0 +1 @@
+- Fixed text showing only its top edge on Samsung DeX and other external displays