Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/gradle/androidx.benchmark-benc…
Browse files Browse the repository at this point in the history
…hmark-macro-junit4-1.2.4
  • Loading branch information
ohassine authored Apr 18, 2024
2 parents 0953f2d + 3b3a972 commit 0103d6f
Show file tree
Hide file tree
Showing 51 changed files with 803 additions and 695 deletions.
31 changes: 23 additions & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import scripts.Variants_gradle

/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
Expand Down Expand Up @@ -43,6 +45,11 @@ repositories {
google()
}

fun isFossSourceSet(): Boolean {
return (Variants_gradle.Default.explicitBuildFlavor() ?: gradle.startParameter.taskRequests.toString())
.lowercase()
.contains("fdroid")
}
android {
// Most of the configuration is done in the build-logic
// through the Wire Application convention plugin
Expand All @@ -58,16 +65,18 @@ android {
}
android.buildFeatures.buildConfig = true

var fdroidBuild = gradle.startParameter.taskRequests.toString().lowercase().contains("fdroid")
val fdroidBuild = isFossSourceSet()

sourceSets {
// Add the "foss" sourceSets for the fdroid flavor
if(fdroidBuild) {
getByName("main") {

if (fdroidBuild) {
getByName("fdroid") {
java.srcDirs("src/foss/kotlin", "src/prod/kotlin")
resources.srcDirs("src/prod/res")
println("Building with FOSS sourceSets")
}
// For all other flavors use the "nonfree" sourceSets
// For all other flavors use the "nonfree" sourceSets
} else {
getByName("main") {
java.srcDirs("src/main/kotlin", "src/nonfree/kotlin")
Expand Down Expand Up @@ -170,11 +179,17 @@ dependencies {
implementation(libs.resaca.hilt)
implementation(libs.bundlizer.core)

// firebase
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.fcm)
var fdroidBuild = isFossSourceSet()

if (!fdroidBuild) {
// firebase
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.fcm)
implementation(libs.googleGms.location)
} else {
println("Excluding FireBase for FDroid build")
}
implementation(libs.androidx.work)
implementation(libs.googleGms.location)

// commonMark
implementation(libs.commonmark.core)
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,26 @@
android:name=".ui.AppLockActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />

<activity
android:name=".ui.calling.CallActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />

<activity
android:name=".ui.WireActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.SplashScreen"
android:windowSoftInputMode="adjustResize|stateHidden">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
57 changes: 28 additions & 29 deletions app/src/main/kotlin/com/wire/android/model/ImageAsset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,43 @@ import com.wire.kalium.logic.data.user.UserAssetId
import okio.Path

@Stable
sealed class ImageAsset(private val imageLoader: WireSessionImageLoader) {
/**
* Value that uniquely identifies this Asset,
* can be used for caching purposes, for example.
*/
abstract val uniqueKey: String

@Stable
data class UserAvatarAsset(
private val imageLoader: WireSessionImageLoader,
val userAssetId: UserAssetId
) : ImageAsset(imageLoader) {
override val uniqueKey: String
get() = userAssetId.toString()
}
sealed class ImageAsset {

/**
* Represents an image asset that is stored locally on the device, and it isn't necessarily bounded to any specific conversation or
* message, i.e. some preview images that the user selected from local device gallery.
*/
@Stable
data class LocalImageAsset(
private val imageLoader: WireSessionImageLoader,
data class Local(
val dataPath: Path,
val idKey: String
) : ImageAsset(imageLoader) {
) : ImageAsset()

sealed class Remote(private val imageLoader: WireSessionImageLoader) : ImageAsset() {

/**
* Value that uniquely identifies this Asset,
* can be used for caching purposes, for example.
*/
abstract val uniqueKey: String

@Composable
fun paint(
fallbackData: Any? = null,
withCrossfadeAnimation: Boolean = false
) = when {
LocalInspectionMode.current -> painterResource(id = R.drawable.ic_welcome_1)
else -> imageLoader.paint(asset = this, fallbackData = fallbackData, withCrossfadeAnimation = withCrossfadeAnimation)
}
}

@Stable
data class UserAvatarAsset(
private val imageLoader: WireSessionImageLoader,
val userAssetId: UserAssetId
) : Remote(imageLoader) {
override val uniqueKey: String
get() = idKey
get() = userAssetId.toString()
}

@Stable
Expand All @@ -68,20 +76,11 @@ sealed class ImageAsset(private val imageLoader: WireSessionImageLoader) {
val messageId: String,
val isSelfAsset: Boolean,
val isEphemeral: Boolean = false
) : ImageAsset(imageLoader) {
) : Remote(imageLoader) {
override fun toString(): String = "$conversationId:$messageId:$isSelfAsset:$isEphemeral"
override val uniqueKey: String
get() = toString()
}

@Composable
fun paint(
fallbackData: Any? = null,
withCrossfadeAnimation: Boolean = false
) = 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 @@ -27,13 +27,3 @@ object SlideNavigationAnimation : WireDestinationStyleAnimated {
object PopUpNavigationAnimation : WireDestinationStyleAnimated {
override fun animationType(): TransitionAnimationType = TransitionAnimationType.POP_UP
}

object WakeUpScreenPopUpNavigationAnimation : WireDestinationStyleAnimated, ScreenModeStyle {
override fun animationType(): TransitionAnimationType = TransitionAnimationType.POP_UP
override fun screenMode(): ScreenMode = ScreenMode.WAKE_UP
}

object KeepOnScreenPopUpNavigationAnimation : WireDestinationStyleAnimated, ScreenModeStyle {
override fun animationType(): TransitionAnimationType = TransitionAnimationType.POP_UP
override fun screenMode(): ScreenMode = ScreenMode.KEEP_ON
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun getActionReply(

fun getOpenIncomingCallAction(context: Context, conversationId: String, userId: String) = getAction(
context.getString(R.string.notification_action_open_call),
openIncomingCallPendingIntent(context, conversationId, userId)
fullScreenIncomingCallPendingIntent(context, conversationId, userId)
)

fun getDeclineCallAction(context: Context, conversationId: String, userId: String) = getAction(
Expand Down
37 changes: 10 additions & 27 deletions app/src/main/kotlin/com/wire/android/notification/PendingIntents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import com.wire.android.notification.broadcastreceivers.CallNotificationDismissR
import com.wire.android.notification.broadcastreceivers.EndOngoingCallReceiver
import com.wire.android.notification.broadcastreceivers.NotificationReplyReceiver
import com.wire.android.ui.WireActivity
import com.wire.android.ui.calling.CallActivity
import com.wire.android.ui.calling.CallScreenType
import com.wire.android.util.deeplink.DeepLinkProcessor

fun messagePendingIntent(context: Context, conversationId: String, userId: String?): PendingIntent {
Expand Down Expand Up @@ -81,17 +83,6 @@ fun replyMessagePendingIntent(context: Context, conversationId: String, userId:
PendingIntent.FLAG_MUTABLE
)

fun openIncomingCallPendingIntent(context: Context, conversationId: String, userId: String): PendingIntent {
val intent = openIncomingCallIntent(context, conversationId, userId)

return PendingIntent.getActivity(
context.applicationContext,
OPEN_INCOMING_CALL_REQUEST_CODE,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
}

fun openOngoingCallPendingIntent(context: Context, conversationId: String): PendingIntent {
val intent = openOngoingCallIntent(context, conversationId)

Expand Down Expand Up @@ -132,27 +123,21 @@ fun fullScreenIncomingCallPendingIntent(context: Context, conversationId: String
context,
FULL_SCREEN_REQUEST_CODE,
intent,
PendingIntent.FLAG_IMMUTABLE
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
}

private fun openIncomingCallIntent(context: Context, conversationId: String, userId: String) =
Intent(context.applicationContext, WireActivity::class.java).apply {
data = Uri.Builder()
.scheme(DeepLinkProcessor.DEEP_LINK_SCHEME)
.authority(DeepLinkProcessor.INCOMING_CALL_DEEPLINK_HOST)
.appendPath(conversationId)
.appendQueryParameter(DeepLinkProcessor.USER_TO_USE_QUERY_PARAM, userId)
.build()
Intent(context.applicationContext, CallActivity::class.java).apply {
putExtra(CallActivity.EXTRA_CONVERSATION_ID, conversationId)
putExtra(CallActivity.EXTRA_USER_ID, userId)
putExtra(CallActivity.EXTRA_SCREEN_TYPE, CallScreenType.Incoming.name)
}

private fun openOngoingCallIntent(context: Context, conversationId: String) =
Intent(context.applicationContext, WireActivity::class.java).apply {
data = Uri.Builder()
.scheme(DeepLinkProcessor.DEEP_LINK_SCHEME)
.authority(DeepLinkProcessor.ONGOING_CALL_DEEPLINK_HOST)
.appendPath(conversationId)
.build()
Intent(context.applicationContext, CallActivity::class.java).apply {
putExtra(CallActivity.EXTRA_CONVERSATION_ID, conversationId)
putExtra(CallActivity.EXTRA_SCREEN_TYPE, CallScreenType.Ongoing.name)
}

private fun openMigrationLoginIntent(context: Context, userHandle: String) =
Expand Down Expand Up @@ -188,14 +173,12 @@ fun openAppPendingIntent(context: Context): PendingIntent {

private const val MESSAGE_NOTIFICATIONS_SUMMARY_REQUEST_CODE = 0
private const val DECLINE_CALL_REQUEST_CODE = "decline_call_"
private const val OPEN_INCOMING_CALL_REQUEST_CODE = 2
private const val FULL_SCREEN_REQUEST_CODE = 3
private const val OPEN_ONGOING_CALL_REQUEST_CODE = 4
private const val OPEN_MIGRATION_LOGIN_REQUEST_CODE = 5
private const val END_ONGOING_CALL_REQUEST_CODE = "hang_up_call_"
private const val OPEN_MESSAGE_REQUEST_CODE_PREFIX = "open_message_"
private const val OPEN_OTHER_USER_PROFILE_CODE_PREFIX = "open_other_user_profile_"
private const val CALL_REQUEST_CODE_PREFIX = "call_"
private const val REPLY_MESSAGE_REQUEST_CODE_PREFIX = "reply_"

private fun getRequestCode(conversationId: String, prefix: String): Int = (prefix + conversationId).hashCode()
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ class WireNotificationManager @Inject constructor(
when (screens) {
is CurrentScreen.Conversation -> messagesNotificationManager.hideNotification(screens.id, userId)
is CurrentScreen.OtherUserProfile -> messagesNotificationManager.hideNotification(screens.id, userId)
is CurrentScreen.IncomingCallScreen -> callNotificationManager.hideIncomingCallNotification()
else -> {}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/kotlin/com/wire/android/ui/AppLockActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class AppLockActivity : AppCompatActivity() {
}
}
}

companion object {
const val SET_TEAM_APP_LOCK = "set_team_app_lock"
}
Expand Down
Loading

0 comments on commit 0103d6f

Please sign in to comment.