Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/accent-colore…
Browse files Browse the repository at this point in the history
…d-user-names
  • Loading branch information
saleniuk committed Mar 12, 2024
2 parents 687847e + eba05a8 commit 79b6423
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 21 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Expand Down Expand Up @@ -320,8 +321,7 @@
<service
android:name=".services.OngoingCallService"
android:exported="false"
android:foregroundServiceType="phoneCall" />

android:foregroundServiceType="phoneCall|microphone" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.wire.android.notification

import android.os.Build
import androidx.annotation.VisibleForTesting
import com.wire.android.R
import com.wire.android.appLogger
Expand Down Expand Up @@ -399,7 +400,7 @@ class WireNotificationManager @Inject constructor(
private suspend fun observeOngoingCalls(currentScreenState: StateFlow<CurrentScreen>) {
currentScreenState
.flatMapLatest { currentScreen ->
if (currentScreen !is CurrentScreen.InBackground) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE && currentScreen !is CurrentScreen.InBackground) {
flowOf(null)
} else {
coreLogic.getGlobalScope().session.currentSessionFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.app.Notification
import android.app.Service
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo
import android.os.IBinder
import com.wire.android.appLogger
import com.wire.android.di.KaliumCoreLogic
Expand All @@ -47,6 +48,7 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import java.util.concurrent.atomic.AtomicReference
import javax.inject.Inject
import androidx.core.app.ServiceCompat

@AndroidEntryPoint
class OngoingCallService : Service() {
Expand Down Expand Up @@ -131,17 +133,38 @@ class OngoingCallService : Service() {
scope.cancel()
}

private fun generateForegroundNotification(callName: String, conversationId: String, userId: UserId) {
private fun generateForegroundNotification(
callName: String,
conversationId: String,
userId: UserId
) {
appLogger.i("$TAG: generating foregroundNotification...")
val notification: Notification = callNotificationManager.builder.getOngoingCallNotification(callName, conversationId, userId)
startForeground(CALL_ONGOING_NOTIFICATION_ID, notification)
val notification: Notification = callNotificationManager.builder.getOngoingCallNotification(
callName,
conversationId,
userId
)
ServiceCompat.startForeground(
this,
CALL_ONGOING_NOTIFICATION_ID,
notification,
ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
)

appLogger.i("$TAG: started foreground with proper notification")
}

private fun generatePlaceholderForegroundNotification() {
appLogger.i("$TAG: generating foregroundNotification placeholder...")
val notification: Notification = callNotificationManager.builder.getOngoingCallPlaceholderNotification()
startForeground(CALL_ONGOING_NOTIFICATION_ID, notification)
val notification: Notification =
callNotificationManager.builder.getOngoingCallPlaceholderNotification()
ServiceCompat.startForeground(
this,
CALL_ONGOING_NOTIFICATION_ID,
notification,
ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
)

appLogger.i("$TAG: started foreground with placeholder notification")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package com.wire.android.ui.home.settings.appsettings.networkSettings
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import com.wire.android.ui.common.scaffold.WireScaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
Expand All @@ -33,6 +32,7 @@ import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootNavGraph
import com.wire.android.R
import com.wire.android.navigation.Navigator
import com.wire.android.ui.common.scaffold.WireScaffold
import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar
import com.wire.android.ui.home.conversations.details.options.ArrowType
import com.wire.android.ui.home.conversations.details.options.GroupConversationOptionsItem
Expand Down Expand Up @@ -74,20 +74,27 @@ fun NetworkSettingsScreenContent(
.fillMaxSize()
.padding(internalPadding)
) {
if (!isWebsocketEnabledByDefault(LocalContext.current)) {
GroupConversationOptionsItem(
title = stringResource(R.string.settings_keep_connection_to_websocket),
subtitle = stringResource(
R.string.settings_keep_connection_to_websocket_description,
backendName
),
switchState = SwitchState.Enabled(
value = isWebSocketEnabled,
onCheckedChange = setWebSocketState
),
arrowType = ArrowType.NONE
val appContext = LocalContext.current
val isWebSocketEnforcedByDefault = isWebsocketEnabledByDefault(appContext)

val switchState = if (isWebSocketEnforcedByDefault) {
SwitchState.TextOnly(true)
} else {
SwitchState.Enabled(
value = isWebSocketEnabled,
onCheckedChange = setWebSocketState
)
}

GroupConversationOptionsItem(
title = stringResource(R.string.settings_keep_connection_to_websocket),
subtitle = stringResource(
R.string.settings_keep_connection_to_websocket_description,
backendName
),
switchState = switchState,
arrowType = ArrowType.NONE
)
}
}
}
Expand Down

0 comments on commit 79b6423

Please sign in to comment.