bluetooth optional

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