Skip to content

Commit

Permalink
Merge branch 'develop' into feat/message-draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed Mar 15, 2024
2 parents 6b495bc + 2ff2e04 commit aa3fde9
Show file tree
Hide file tree
Showing 110 changed files with 3,322 additions and 1,060 deletions.
10 changes: 10 additions & 0 deletions AR-builder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ pipeline {
}
}
}

stage('Keep builds forever if important') {
steps {
script {
if (params.SOURCE_BRANCH.startsWith("release/") || params.SOURCE_BRANCH == "develop" || params.SOURCE_BRANCH == "main" || params.SOURCE_BRANCH == "prod") {
currentBuild.keepLog = true
}
}
}
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.wire.android"
android:sharedUserId="${sharedUserId}">
android:sharedUserId="${sharedUserId}"
android:installLocation="internalOnly"
>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand All @@ -39,6 +41,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 +323,7 @@
<service
android:name=".services.OngoingCallService"
android:exported="false"
android:foregroundServiceType="phoneCall" />

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

</manifest>
1 change: 1 addition & 0 deletions app/src/main/kotlin/com/wire/android/WireApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class WireApplication : Application(), Configuration.Provider {
override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder()
.setWorkerFactory(wireWorkerFactory.get())
.setMinimumLoggingLevel(android.util.Log.DEBUG)
.build()
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/wire/android/di/ViewModelScoped.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fun <R : ScopedArgs> scopedArgs(argsClass: KClass<R>, argsContainer: SavedStateH
@Suppress("BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER")
@Composable
inline fun <reified T, reified S, reified R : ScopedArgs> hiltViewModelScoped(arguments: R): S where T : ViewModel, T : S = when {
LocalInspectionMode.current -> ViewModelScopedPreviews.firstNotNullOf { it as S }
LocalInspectionMode.current -> ViewModelScopedPreviews.firstNotNullOf { it as? S }
else -> hiltViewModelScoped<T>(key = arguments.key, defaultArguments = Bundlizer.bundle(R::class.serializer(), arguments))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.wire.kalium.logic.feature.asset.GetAssetSizeLimitUseCase
import com.wire.kalium.logic.feature.asset.GetAvatarAssetUseCase
import com.wire.kalium.logic.feature.client.FinalizeMLSClientAfterE2EIEnrollment
import com.wire.kalium.logic.feature.conversation.GetAllContactsNotInConversationUseCase
import com.wire.kalium.logic.feature.e2ei.usecase.EnrollE2EIUseCase
import com.wire.kalium.logic.feature.e2ei.usecase.GetE2eiCertificateUseCase
import com.wire.kalium.logic.feature.e2ei.usecase.GetMembersE2EICertificateStatusesUseCase
import com.wire.kalium.logic.feature.e2ei.usecase.GetUserE2eiCertificateStatusUseCase
Expand Down Expand Up @@ -113,11 +112,6 @@ class UserModule {
fun providePersistReadReceiptsStatusConfig(userScope: UserScope): PersistReadReceiptsStatusConfigUseCase =
userScope.persistReadReceiptsStatusConfig

@ViewModelScoped
@Provides
fun provideEnrollE2EIUseCase(userScope: UserScope): EnrollE2EIUseCase =
userScope.enrollE2EI

@ViewModelScoped
@Provides
fun provideFinalizeMLSClientAfterE2EIEnrollmentUseCase(userScope: UserScope): FinalizeMLSClientAfterE2EIEnrollment =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
@file:Suppress("StringTemplate")

package com.wire.android.feature

import android.content.Context
import android.content.Intent
import android.os.Build
import com.wire.android.appLogger
import com.wire.android.services.PersistentWebSocketService
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class StartPersistentWebsocketIfNecessaryUseCase @Inject constructor(
@ApplicationContext private val appContext: Context,
private val shouldStartPersistentWebSocketService: ShouldStartPersistentWebSocketServiceUseCase
) {
suspend operator fun invoke() {
val persistentWebSocketServiceIntent = PersistentWebSocketService.newIntent(appContext)
shouldStartPersistentWebSocketService().let {
when (it) {
is ShouldStartPersistentWebSocketServiceUseCase.Result.Failure -> {
appLogger.e("${TAG}: Failure while fetching persistent web socket status flow")
}

is ShouldStartPersistentWebSocketServiceUseCase.Result.Success -> {
if (it.shouldStartPersistentWebSocketService) {
startForegroundService(persistentWebSocketServiceIntent)
} else {
appLogger.i("${TAG}: Stopping PersistentWebsocketService, no user with persistent web socket enabled found")
appContext.stopService(persistentWebSocketServiceIntent)
}
}
}
}
}

private fun startForegroundService(persistentWebSocketServiceIntent: Intent) {
when {
PersistentWebSocketService.isServiceStarted -> {
appLogger.i("${TAG}: PersistentWebsocketService already started, not starting again")
}

else -> {
appLogger.i("${TAG}: Starting PersistentWebsocketService")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
appContext.startForegroundService(persistentWebSocketServiceIntent)
} else {
appContext.startService(persistentWebSocketServiceIntent)
}
}
}
}

companion object {
const val TAG = "StartPersistentWebsocketIfNecessaryUseCase"
}
}
32 changes: 18 additions & 14 deletions app/src/main/kotlin/com/wire/android/feature/e2ei/OAuthUseCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,25 @@ class OAuthUseCase(

fun launch(
activityResultRegistry: ActivityResultRegistry,
resultHandler: (OAuthResult) -> Unit
forceLoginFlow: Boolean,
resultHandler: (OAuthResult) -> Unit,
) {
authState.performActionWithFreshTokens(authorizationService) { _, idToken, exception ->
if (exception != null) {
appLogger.e(
message = "OAuthTokenRefreshManager: Error refreshing tokens, continue with login!",
throwable = exception
)
launchLoginFlow(activityResultRegistry, resultHandler)
} else {
resultHandler(
OAuthResult.Success(
idToken.toString(),
authState.jsonSerializeString()
if (forceLoginFlow) {
launchLoginFlow(activityResultRegistry, resultHandler)
} else {
authState.performActionWithFreshTokens(authorizationService) { _, idToken, exception ->
if (exception != null) {
appLogger.e(
message = "OAuthTokenRefreshManager: Error refreshing tokens, continue with login!", throwable = exception
)
)
launchLoginFlow(activityResultRegistry, resultHandler)
} else {
resultHandler(
OAuthResult.Success(
idToken.toString(), authState.jsonSerializeString()
)
)
}
}
}
}
Expand Down Expand Up @@ -163,6 +166,7 @@ class OAuthUseCase(
AuthorizationRequest.Scope.PROFILE,
AuthorizationRequest.Scope.OFFLINE_ACCESS
).setClaims(JSONObject(claims.toString()))
.setPrompt(AuthorizationRequest.Prompt.LOGIN)
.build()

private fun AuthorizationRequest.Builder.setCodeVerifier(): AuthorizationRequest.Builder {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.wire.android.util.ui.WireSessionImageLoader
import com.wire.kalium.logic.data.message.DeliveryStatus
import com.wire.kalium.logic.data.message.Message
import com.wire.kalium.logic.data.message.MessageContent
import com.wire.android.ui.theme.Accent
import com.wire.kalium.logic.data.user.OtherUser
import com.wire.kalium.logic.data.user.SelfUser
import com.wire.kalium.logic.data.user.User
Expand Down Expand Up @@ -157,7 +158,8 @@ class MessageMapper @Inject constructor(
is OtherUser -> sender.isUnavailableUser
is SelfUser, null -> false
},
clientId = (message as? Message.Sendable)?.senderClientId
clientId = (message as? Message.Sendable)?.senderClientId,
accent = sender?.accentId?.let { Accent.fromAccentId(it) } ?: Accent.Unknown,
)

private fun getMessageStatus(message: Message.Standalone): MessageStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class RegularMessageMapper @Inject constructor(
text = it.text,
isSelected = it.isSelected
)
}
}.toPersistentList()
)
}

Expand Down
8 changes: 7 additions & 1 deletion app/src/main/kotlin/com/wire/android/model/ImageAsset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ package com.wire.android.model

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.painterResource
import com.wire.android.R
import com.wire.android.util.ui.WireSessionImageLoader
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.QualifiedIdMapper
Expand Down Expand Up @@ -75,7 +78,10 @@ sealed class ImageAsset(private val imageLoader: WireSessionImageLoader) {
fun paint(
fallbackData: Any? = null,
withCrossfadeAnimation: Boolean = false
) = imageLoader.paint(asset = this, fallbackData = fallbackData, withCrossfadeAnimation = withCrossfadeAnimation)
) = when {
LocalInspectionMode.current -> painterResource(id = R.drawable.ic_welcome_1)
else -> imageLoader.paint(asset = this, fallbackData = fallbackData, withCrossfadeAnimation = withCrossfadeAnimation)
}
}

fun String.parseIntoPrivateImageAsset(
Expand Down
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 @@ -43,7 +43,7 @@ import com.wire.android.ui.joinConversation.JoinConversationViaCodeState
import com.wire.android.ui.joinConversation.JoinConversationViaDeepLinkDialog
import com.wire.android.ui.joinConversation.JoinConversationViaInviteLinkError
import com.wire.android.ui.theme.WireTheme
import com.wire.android.util.formatMediumDateTime
import com.wire.android.util.deviceDateTimeFormat
import com.wire.android.util.ui.PreviewMultipleThemes
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.configuration.server.ServerConfig
Expand Down Expand Up @@ -319,7 +319,7 @@ fun NewClientDialog(
val devicesList = data.clientsInfo.map {
stringResource(
R.string.new_device_dialog_message_defice_info,
it.date.formatMediumDateTime() ?: "",
it.date.deviceDateTimeFormat() ?: "",
it.deviceInfo.asString()
)
}.joinToString("")
Expand Down
Loading

0 comments on commit aa3fde9

Please sign in to comment.