mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 22:45:22 +00:00
This reverts commit 0c7505b588.
This commit is contained in:
@@ -112,8 +112,6 @@ class MainActivity : OrientationAwareActivity() {
|
||||
// Ensure foreground service is running and get mesh instance from holder
|
||||
try { com.bitchat.android.service.MeshForegroundService.start(applicationContext) } catch (_: Exception) { }
|
||||
meshService = com.bitchat.android.service.MeshServiceHolder.getOrCreate(applicationContext)
|
||||
// Expose BLE mesh to Wi‑Fi Aware controller for cross-transport relays
|
||||
try { com.bitchat.android.wifiaware.WifiAwareController.setBleMeshService(meshService) } catch (_: Exception) { }
|
||||
bluetoothStatusManager = BluetoothStatusManager(
|
||||
activity = this,
|
||||
context = this,
|
||||
@@ -161,52 +159,6 @@ class MainActivity : OrientationAwareActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bridge Wi‑Fi Aware callbacks into ChatViewModel (reusing BLE delegate methods)
|
||||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
com.bitchat.android.wifiaware.WifiAwareController.running.collect { running ->
|
||||
val svc = com.bitchat.android.wifiaware.WifiAwareController.getService()
|
||||
if (running && svc != null) {
|
||||
svc.delegate = object : com.bitchat.android.wifiaware.WifiAwareMeshDelegate {
|
||||
override fun didReceiveMessage(message: com.bitchat.android.model.BitchatMessage) {
|
||||
if (message.isPrivate) {
|
||||
message.senderPeerID?.let { pid -> com.bitchat.android.services.AppStateStore.addPrivateMessage(pid, message) }
|
||||
} else if (message.channel != null) {
|
||||
com.bitchat.android.services.AppStateStore.addChannelMessage(message.channel, message)
|
||||
} else {
|
||||
com.bitchat.android.services.AppStateStore.addPublicMessage(message)
|
||||
}
|
||||
chatViewModel.didReceiveMessage(message)
|
||||
}
|
||||
override fun didUpdatePeerList(peers: List<String>) {
|
||||
chatViewModel.didUpdatePeerList(peers)
|
||||
}
|
||||
override fun didReceiveChannelLeave(channel: String, fromPeer: String) {
|
||||
chatViewModel.didReceiveChannelLeave(channel, fromPeer)
|
||||
}
|
||||
override fun didReceiveDeliveryAck(messageID: String, recipientPeerID: String) {
|
||||
chatViewModel.didReceiveDeliveryAck(messageID, recipientPeerID)
|
||||
}
|
||||
override fun didReceiveReadReceipt(messageID: String, recipientPeerID: String) {
|
||||
chatViewModel.didReceiveReadReceipt(messageID, recipientPeerID)
|
||||
}
|
||||
override fun decryptChannelMessage(encryptedContent: ByteArray, channel: String): String? {
|
||||
return chatViewModel.decryptChannelMessage(encryptedContent, channel)
|
||||
}
|
||||
override fun getNickname(): String? {
|
||||
return chatViewModel.getNickname()
|
||||
}
|
||||
override fun isFavorite(peerID: String): Boolean {
|
||||
return try {
|
||||
com.bitchat.android.favorites.FavoritesPersistenceService.shared.getFavoriteStatus(peerID)?.isMutual == true
|
||||
} catch (_: Exception) { false }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only start onboarding process if we're in the initial CHECKING state
|
||||
// This prevents restarting onboarding on configuration changes
|
||||
@@ -395,12 +347,6 @@ class MainActivity : OrientationAwareActivity() {
|
||||
bluetoothStatusManager.logBluetoothStatus()
|
||||
mainViewModel.updateBluetoothStatus(bluetoothStatusManager.checkBluetoothStatus())
|
||||
|
||||
val bleRequired = try { com.bitchat.android.ui.debug.DebugPreferenceManager.getBleEnabled(true) } catch (_: Exception) { true }
|
||||
if (!bleRequired) {
|
||||
// Skip BLE checks entirely when BLE is disabled in debug settings
|
||||
checkLocationAndProceed()
|
||||
return
|
||||
}
|
||||
when (mainViewModel.bluetoothStatus.value) {
|
||||
BluetoothStatus.ENABLED -> {
|
||||
// Bluetooth is enabled, check location services next
|
||||
@@ -567,9 +513,8 @@ class MainActivity : OrientationAwareActivity() {
|
||||
else -> BatteryOptimizationStatus.ENABLED
|
||||
}
|
||||
|
||||
val bleRequired2 = try { com.bitchat.android.ui.debug.DebugPreferenceManager.getBleEnabled(true) } catch (_: Exception) { true }
|
||||
when {
|
||||
bleRequired2 && currentBluetoothStatus != BluetoothStatus.ENABLED -> {
|
||||
currentBluetoothStatus != BluetoothStatus.ENABLED -> {
|
||||
// Bluetooth still disabled, but now we have permissions to enable it
|
||||
Log.d("MainActivity", "Permissions granted, but Bluetooth still disabled. Showing Bluetooth enable screen.")
|
||||
mainViewModel.updateBluetoothStatus(currentBluetoothStatus)
|
||||
|
||||
Reference in New Issue
Block a user