Wifi aware skip bluetooth (#538)

* unify connection tracker for ble and wifi

* bluetooth optional
This commit is contained in:
callebtc
2026-01-04 02:02:24 +07:00
committed by GitHub
parent 12eb3e5a91
commit 35030a05d8
37 changed files with 89 additions and 18 deletions
@@ -266,6 +266,10 @@ class MainActivity : OrientationAwareActivity() {
onRetry = { onRetry = {
checkBluetoothAndProceed() checkBluetoothAndProceed()
}, },
onSkip = {
mainViewModel.skipBluetoothCheck()
checkLocationAndProceed()
},
isLoading = isBluetoothLoading isLoading = isBluetoothLoading
) )
} }
@@ -384,6 +388,13 @@ class MainActivity : OrientationAwareActivity() {
private fun checkBluetoothAndProceed() { private fun checkBluetoothAndProceed() {
// Log.d("MainActivity", "Checking Bluetooth status") // Log.d("MainActivity", "Checking Bluetooth status")
// Check if user has skipped Bluetooth check for this session
if (mainViewModel.isBluetoothCheckSkipped.value) {
Log.d("MainActivity", "Bluetooth check skipped by user, proceeding to location check")
checkLocationAndProceed()
return
}
// For first-time users, skip Bluetooth check and go straight to permissions // For first-time users, skip Bluetooth check and go straight to permissions
// We'll check Bluetooth after permissions are granted // We'll check Bluetooth after permissions are granted
if (permissionManager.isFirstTimeLaunch()) { if (permissionManager.isFirstTimeLaunch()) {
@@ -754,7 +765,7 @@ class MainActivity : OrientationAwareActivity() {
// Check if Bluetooth was disabled while app was backgrounded // Check if Bluetooth was disabled while app was backgrounded
val currentBluetoothStatus = bluetoothStatusManager.checkBluetoothStatus() val currentBluetoothStatus = bluetoothStatusManager.checkBluetoothStatus()
if (currentBluetoothStatus != BluetoothStatus.ENABLED) { if (currentBluetoothStatus != BluetoothStatus.ENABLED && !mainViewModel.isBluetoothCheckSkipped.value) {
Log.w("MainActivity", "Bluetooth disabled while app was backgrounded") Log.w("MainActivity", "Bluetooth disabled while app was backgrounded")
mainViewModel.updateBluetoothStatus(currentBluetoothStatus) mainViewModel.updateBluetoothStatus(currentBluetoothStatus)
mainViewModel.updateOnboardingState(OnboardingState.BLUETOOTH_CHECK) mainViewModel.updateOnboardingState(OnboardingState.BLUETOOTH_CHECK)
@@ -35,6 +35,9 @@ class MainViewModel : ViewModel() {
private val _isBatteryOptimizationLoading = MutableStateFlow(false) private val _isBatteryOptimizationLoading = MutableStateFlow(false)
val isBatteryOptimizationLoading: StateFlow<Boolean> = _isBatteryOptimizationLoading.asStateFlow() val isBatteryOptimizationLoading: StateFlow<Boolean> = _isBatteryOptimizationLoading.asStateFlow()
private val _isBluetoothCheckSkipped = MutableStateFlow(false)
val isBluetoothCheckSkipped: StateFlow<Boolean> = _isBluetoothCheckSkipped.asStateFlow()
// Public update functions for MainActivity // Public update functions for MainActivity
fun updateOnboardingState(state: OnboardingState) { fun updateOnboardingState(state: OnboardingState) {
_onboardingState.value = state _onboardingState.value = state
@@ -67,4 +70,8 @@ class MainViewModel : ViewModel() {
fun updateBatteryOptimizationLoading(loading: Boolean) { fun updateBatteryOptimizationLoading(loading: Boolean) {
_isBatteryOptimizationLoading.value = loading _isBatteryOptimizationLoading.value = loading
} }
fun skipBluetoothCheck() {
_isBluetoothCheckSkipped.value = true
}
} }
@@ -26,6 +26,7 @@ fun BluetoothCheckScreen(
status: BluetoothStatus, status: BluetoothStatus,
onEnableBluetooth: () -> Unit, onEnableBluetooth: () -> Unit,
onRetry: () -> Unit, onRetry: () -> Unit,
onSkip: () -> Unit,
isLoading: Boolean = false isLoading: Boolean = false
) { ) {
val colorScheme = MaterialTheme.colorScheme val colorScheme = MaterialTheme.colorScheme
@@ -39,13 +40,15 @@ fun BluetoothCheckScreen(
BluetoothDisabledContent( BluetoothDisabledContent(
onEnableBluetooth = onEnableBluetooth, onEnableBluetooth = onEnableBluetooth,
onRetry = onRetry, onRetry = onRetry,
onSkip = onSkip,
colorScheme = colorScheme, colorScheme = colorScheme,
isLoading = isLoading isLoading = isLoading
) )
} }
BluetoothStatus.NOT_SUPPORTED -> { BluetoothStatus.NOT_SUPPORTED -> {
BluetoothNotSupportedContent( BluetoothNotSupportedContent(
colorScheme = colorScheme colorScheme = colorScheme,
onSkip = onSkip
) )
} }
BluetoothStatus.ENABLED -> { BluetoothStatus.ENABLED -> {
@@ -61,6 +64,7 @@ fun BluetoothCheckScreen(
private fun BluetoothDisabledContent( private fun BluetoothDisabledContent(
onEnableBluetooth: () -> Unit, onEnableBluetooth: () -> Unit,
onRetry: () -> Unit, onRetry: () -> Unit,
onSkip: () -> Unit,
colorScheme: ColorScheme, colorScheme: ColorScheme,
isLoading: Boolean isLoading: Boolean
) { ) {
@@ -77,7 +81,7 @@ private fun BluetoothDisabledContent(
) )
Text( Text(
text = stringResource(R.string.bluetooth_required), text = stringResource(R.string.bluetooth_recommended),
style = MaterialTheme.typography.headlineSmall.copy( style = MaterialTheme.typography.headlineSmall.copy(
fontFamily = FontFamily.Monospace, fontFamily = FontFamily.Monospace,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
@@ -141,20 +145,17 @@ private fun BluetoothDisabledContent(
) )
} }
//Since we are automatically checking bluetooth state -- commented TextButton(
onClick = onSkip,
// OutlinedButton( modifier = Modifier.fillMaxWidth()
// onClick = onRetry, ) {
// modifier = Modifier.fillMaxWidth() Text(
// ) { text = stringResource(R.string.skip),
// Text( style = MaterialTheme.typography.labelLarge.copy(
// text = "Check Again", color = colorScheme.onSurface.copy(alpha = 0.7f)
// style = MaterialTheme.typography.bodyMedium.copy( )
// fontFamily = FontFamily.Monospace )
// ), }
// modifier = Modifier.padding(vertical = 4.dp)
// )
// }
} }
} }
} }
@@ -162,7 +163,8 @@ private fun BluetoothDisabledContent(
@Composable @Composable
private fun BluetoothNotSupportedContent( private fun BluetoothNotSupportedContent(
colorScheme: ColorScheme colorScheme: ColorScheme,
onSkip: () -> Unit
) { ) {
Column( Column(
verticalArrangement = Arrangement.spacedBy(24.dp), verticalArrangement = Arrangement.spacedBy(24.dp),
@@ -209,6 +211,16 @@ private fun BluetoothNotSupportedContent(
textAlign = TextAlign.Center textAlign = TextAlign.Center
) )
} }
Button(
onClick = onSkip,
modifier = Modifier.fillMaxWidth(),
colors = ButtonDefaults.buttonColors(
containerColor = colorScheme.secondary
)
) {
Text(text = stringResource(R.string.continue_btn))
}
} }
} }
+1
View File
@@ -362,4 +362,5 @@
<string name="location_notes_empty_desc">كن أول من يضيف ملاحظة لهذا المكان.</string> <string name="location_notes_empty_desc">كن أول من يضيف ملاحظة لهذا المكان.</string>
<string name="dismiss">إغلاق</string> <string name="dismiss">إغلاق</string>
<string name="location_notes_input_placeholder">أضف ملاحظة لهذا المكان</string> <string name="location_notes_input_placeholder">أضف ملاحظة لهذا المكان</string>
<string name="bluetooth_recommended">بلوتوث موصى به</string>
</resources> </resources>
+1
View File
@@ -349,4 +349,5 @@
<item quantity="other">%d জন</item> <item quantity="other">%d জন</item>
</plurals> </plurals>
<string name="bluetooth_recommended">ব্লুটুথ প্রস্তাবিত</string>
</resources> </resources>
+1
View File
@@ -363,4 +363,5 @@
<string name="location_notes_empty_desc">sei der Erste, der hier eine Notiz hinterlässt.</string> <string name="location_notes_empty_desc">sei der Erste, der hier eine Notiz hinterlässt.</string>
<string name="dismiss">schließen</string> <string name="dismiss">schließen</string>
<string name="location_notes_input_placeholder">füge eine Notiz zu diesem Ort hinzu</string> <string name="location_notes_input_placeholder">füge eine Notiz zu diesem Ort hinzu</string>
<string name="bluetooth_recommended">Bluetooth empfohlen</string>
</resources> </resources>
+1
View File
@@ -362,4 +362,5 @@
<string name="location_notes_empty_desc">sé el primero en añadir una para este sitio.</string> <string name="location_notes_empty_desc">sé el primero en añadir una para este sitio.</string>
<string name="dismiss">cerrar</string> <string name="dismiss">cerrar</string>
<string name="location_notes_input_placeholder">agrega una nota para este lugar</string> <string name="location_notes_input_placeholder">agrega una nota para este lugar</string>
<string name="bluetooth_recommended">Bluetooth recomendado</string>
</resources> </resources>
+1
View File
@@ -349,4 +349,5 @@
<item quantity="other">%d نفر</item> <item quantity="other">%d نفر</item>
</plurals> </plurals>
<string name="bluetooth_recommended">بلوتوث توصیه می شود</string>
</resources> </resources>
+1
View File
@@ -362,4 +362,5 @@
<item quantity="other">%d tao</item> <item quantity="other">%d tao</item>
</plurals> </plurals>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+1
View File
@@ -376,4 +376,5 @@
<string name="location_notes_empty_desc">soyez le premier à en ajouter pour cet endroit.</string> <string name="location_notes_empty_desc">soyez le premier à en ajouter pour cet endroit.</string>
<string name="dismiss">fermer</string> <string name="dismiss">fermer</string>
<string name="location_notes_input_placeholder">ajoutez une note pour cet endroit</string> <string name="location_notes_input_placeholder">ajoutez une note pour cet endroit</string>
<string name="bluetooth_recommended">Bluetooth recommandé</string>
</resources> </resources>
+2
View File
@@ -14,5 +14,7 @@
<string name="location_notes_empty_desc">היה הראשון להוסיף הערה למקום זה.</string> <string name="location_notes_empty_desc">היה הראשון להוסיף הערה למקום זה.</string>
<string name="dismiss">סגור</string> <string name="dismiss">סגור</string>
<string name="location_notes_input_placeholder">הוסף הערה למקום זה</string> <string name="location_notes_input_placeholder">הוסף הערה למקום זה</string>
<string name="skip">Skip</string>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+1
View File
@@ -362,4 +362,5 @@
<string name="location_notes_empty_desc">इस स्थान के लिए पहला नोट जोड़ें।</string> <string name="location_notes_empty_desc">इस स्थान के लिए पहला नोट जोड़ें।</string>
<string name="dismiss">बंद करें</string> <string name="dismiss">बंद करें</string>
<string name="location_notes_input_placeholder">इस स्थान के लिए एक नोट जोड़ें</string> <string name="location_notes_input_placeholder">इस स्थान के लिए एक नोट जोड़ें</string>
<string name="bluetooth_recommended">ब्लूटूथ अनुशंसित</string>
</resources> </resources>
+1
View File
@@ -362,4 +362,5 @@
<string name="location_notes_empty_desc">jadilah yang pertama menambahkan catatan untuk tempat ini.</string> <string name="location_notes_empty_desc">jadilah yang pertama menambahkan catatan untuk tempat ini.</string>
<string name="dismiss">tutup</string> <string name="dismiss">tutup</string>
<string name="location_notes_input_placeholder">tambahkan catatan untuk tempat ini</string> <string name="location_notes_input_placeholder">tambahkan catatan untuk tempat ini</string>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+1
View File
@@ -396,4 +396,5 @@
<string name="location_notes_empty_desc">sii il primo ad aggiungerne una per questo posto.</string> <string name="location_notes_empty_desc">sii il primo ad aggiungerne una per questo posto.</string>
<string name="dismiss">chiudi</string> <string name="dismiss">chiudi</string>
<string name="location_notes_input_placeholder">aggiungi una nota per questo luogo</string> <string name="location_notes_input_placeholder">aggiungi una nota per questo luogo</string>
<string name="bluetooth_recommended">Bluetooth consigliato</string>
</resources> </resources>
+1
View File
@@ -362,4 +362,5 @@
<string name="location_notes_empty_desc">この場所の最初のメモを追加しましょう。</string> <string name="location_notes_empty_desc">この場所の最初のメモを追加しましょう。</string>
<string name="dismiss">閉じる</string> <string name="dismiss">閉じる</string>
<string name="location_notes_input_placeholder">この場所へのメモを追加</string> <string name="location_notes_input_placeholder">この場所へのメモを追加</string>
<string name="bluetooth_recommended">Bluetooth推奨</string>
</resources> </resources>
+1
View File
@@ -349,4 +349,5 @@
<item quantity="other">%d ადამიანი</item> <item quantity="other">%d ადამიანი</item>
</plurals> </plurals>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+1
View File
@@ -362,4 +362,5 @@
<string name="location_notes_empty_desc">이 장소에 첫 번째 노트를 추가해 보세요.</string> <string name="location_notes_empty_desc">이 장소에 첫 번째 노트를 추가해 보세요.</string>
<string name="dismiss">닫기</string> <string name="dismiss">닫기</string>
<string name="location_notes_input_placeholder">이 장소에 노트 추가</string> <string name="location_notes_input_placeholder">이 장소에 노트 추가</string>
<string name="bluetooth_recommended">블루투스 권장</string>
</resources> </resources>
+1
View File
@@ -376,4 +376,5 @@
<item quantity="other">Olona %d</item> <item quantity="other">Olona %d</item>
</plurals> </plurals>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+2
View File
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<!-- TODO: Malay translations --> <!-- TODO: Malay translations -->
<string name="skip">Skip</string>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+1
View File
@@ -362,4 +362,5 @@
<item quantity="other">%d जना</item> <item quantity="other">%d जना</item>
</plurals> </plurals>
<string name="bluetooth_recommended">ब्लुटुथ सिफारिस गरिएको</string>
</resources> </resources>
+1
View File
@@ -394,4 +394,5 @@
<string name="location_notes_empty_desc">wees de eerste die een notitie voor deze plek toevoegt.</string> <string name="location_notes_empty_desc">wees de eerste die een notitie voor deze plek toevoegt.</string>
<string name="dismiss">sluiten</string> <string name="dismiss">sluiten</string>
<string name="location_notes_input_placeholder">voeg een notitie toe voor deze plek</string> <string name="location_notes_input_placeholder">voeg een notitie toe voor deze plek</string>
<string name="bluetooth_recommended">Bluetooth aanbevolen</string>
</resources> </resources>
@@ -349,4 +349,5 @@
<item quantity="other">%d بندے</item> <item quantity="other">%d بندے</item>
</plurals> </plurals>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+2
View File
@@ -14,5 +14,7 @@
<string name="location_notes_empty_desc">bądź pierwszy, który doda notatkę dla tego miejsca.</string> <string name="location_notes_empty_desc">bądź pierwszy, który doda notatkę dla tego miejsca.</string>
<string name="dismiss">zamknij</string> <string name="dismiss">zamknij</string>
<string name="location_notes_input_placeholder">dodaj notatkę dla tego miejsca</string> <string name="location_notes_input_placeholder">dodaj notatkę dla tego miejsca</string>
<string name="skip">Pomiń</string>
<string name="bluetooth_recommended">Bluetooth zalecany</string>
</resources> </resources>
@@ -362,4 +362,5 @@
<string name="location_notes_empty_desc">seja o primeiro a adicionar uma para este local.</string> <string name="location_notes_empty_desc">seja o primeiro a adicionar uma para este local.</string>
<string name="dismiss">fechar</string> <string name="dismiss">fechar</string>
<string name="location_notes_input_placeholder">adicione uma nota para este local</string> <string name="location_notes_input_placeholder">adicione uma nota para este local</string>
<string name="bluetooth_recommended">Bluetooth recomendado</string>
</resources> </resources>
+1
View File
@@ -362,4 +362,5 @@
<string name="location_notes_empty_desc">seja o primeiro a adicionar uma para este local.</string> <string name="location_notes_empty_desc">seja o primeiro a adicionar uma para este local.</string>
<string name="dismiss">fechar</string> <string name="dismiss">fechar</string>
<string name="location_notes_input_placeholder">adicione uma nota para este local</string> <string name="location_notes_input_placeholder">adicione uma nota para este local</string>
<string name="bluetooth_recommended">Bluetooth recomendado</string>
</resources> </resources>
+1
View File
@@ -352,4 +352,5 @@
<string name="location_notes_empty_desc">станьте первым, кто добавит заметку для этого места.</string> <string name="location_notes_empty_desc">станьте первым, кто добавит заметку для этого места.</string>
<string name="dismiss">закрыть</string> <string name="dismiss">закрыть</string>
<string name="location_notes_input_placeholder">добавьте заметку для этого места</string> <string name="location_notes_input_placeholder">добавьте заметку для этого места</string>
<string name="bluetooth_recommended">Рекомендуется Bluetooth</string>
</resources> </resources>
+1
View File
@@ -350,4 +350,5 @@
<string name="location_notes_empty_desc">var först med att lägga till en anteckning för den här platsen.</string> <string name="location_notes_empty_desc">var först med att lägga till en anteckning för den här platsen.</string>
<string name="dismiss">stäng</string> <string name="dismiss">stäng</string>
<string name="location_notes_input_placeholder">lägg till en anteckning för den här platsen</string> <string name="location_notes_input_placeholder">lägg till en anteckning för den här platsen</string>
<string name="bluetooth_recommended">Bluetooth rekommenderas</string>
</resources> </resources>
+2
View File
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<!-- TODO: Tamil translations --> <!-- TODO: Tamil translations -->
<string name="skip">Skip</string>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+1
View File
@@ -349,4 +349,5 @@
<item quantity="other">%d คน</item> <item quantity="other">%d คน</item>
</plurals> </plurals>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+1
View File
@@ -350,4 +350,5 @@
<string name="location_notes_empty_desc">bu yer için ilk notu ekleyen siz olun.</string> <string name="location_notes_empty_desc">bu yer için ilk notu ekleyen siz olun.</string>
<string name="dismiss">kapat</string> <string name="dismiss">kapat</string>
<string name="location_notes_input_placeholder">bu yer için bir not ekleyin</string> <string name="location_notes_input_placeholder">bu yer için bir not ekleyin</string>
<string name="bluetooth_recommended">Bluetooth Önerilir</string>
</resources> </resources>
+2
View File
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<!-- TODO: Ukrainian translations --> <!-- TODO: Ukrainian translations -->
<string name="skip">Пропустити</string>
<string name="bluetooth_recommended">Рекомендується Bluetooth</string>
</resources> </resources>
+1
View File
@@ -362,4 +362,5 @@
<string name="location_notes_empty_desc">اس جگہ کے لیے پہلا نوٹ شامل کریں۔</string> <string name="location_notes_empty_desc">اس جگہ کے لیے پہلا نوٹ شامل کریں۔</string>
<string name="dismiss">بند کریں</string> <string name="dismiss">بند کریں</string>
<string name="location_notes_input_placeholder">اس جگہ کے لیے ایک نوٹ شامل کریں</string> <string name="location_notes_input_placeholder">اس جگہ کے لیے ایک نوٹ شامل کریں</string>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>
+1
View File
@@ -349,4 +349,5 @@
<item quantity="other">%d người</item> <item quantity="other">%d người</item>
</plurals> </plurals>
<string name="bluetooth_recommended">Khuyên dùng Bluetooth</string>
</resources> </resources>
@@ -14,5 +14,7 @@
<string name="location_notes_empty_desc">成为第一个为此地点添加笔记的人。</string> <string name="location_notes_empty_desc">成为第一个为此地点添加笔记的人。</string>
<string name="dismiss">关闭</string> <string name="dismiss">关闭</string>
<string name="location_notes_input_placeholder">为此地点添加一条笔记</string> <string name="location_notes_input_placeholder">为此地点添加一条笔记</string>
<string name="skip">跳过</string>
<string name="bluetooth_recommended">建议开启蓝牙</string>
</resources> </resources>
@@ -14,5 +14,7 @@
<string name="location_notes_empty_desc">成為第一個為此地點新增筆記的人。</string> <string name="location_notes_empty_desc">成為第一個為此地點新增筆記的人。</string>
<string name="dismiss">關閉</string> <string name="dismiss">關閉</string>
<string name="location_notes_input_placeholder">為此地點新增一則筆記</string> <string name="location_notes_input_placeholder">為此地點新增一則筆記</string>
<string name="skip">跳過</string>
<string name="bluetooth_recommended">建議開啟藍牙</string>
</resources> </resources>
+1
View File
@@ -375,4 +375,5 @@
<string name="location_notes_empty_desc">成为第一个为此地点添加笔记的人。</string> <string name="location_notes_empty_desc">成为第一个为此地点添加笔记的人。</string>
<string name="dismiss">关闭</string> <string name="dismiss">关闭</string>
<string name="location_notes_input_placeholder">为此地点添加一条笔记</string> <string name="location_notes_input_placeholder">为此地点添加一条笔记</string>
<string name="bluetooth_recommended">建议开启蓝牙</string>
</resources> </resources>
+1
View File
@@ -399,4 +399,5 @@
<item quantity="other">%d people</item> <item quantity="other">%d people</item>
</plurals> </plurals>
<string name="bluetooth_recommended">Bluetooth Recommended</string>
</resources> </resources>