Skip to content

Commit

Permalink
Merge branch 'develop' into Temporarily-stopping-sending-ui.clicked-p…
Browse files Browse the repository at this point in the history
…rofile-event
  • Loading branch information
ohassine authored Jan 28, 2025
2 parents 114df03 + 3b4eaad commit 14b4fce
Show file tree
Hide file tree
Showing 19 changed files with 120 additions and 147 deletions.
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/wire/android/WireApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class WireApplication : BaseApp() {

private suspend fun initializeApplicationLoggingFrameworks() {
// 1. Datadog should be initialized first
ExternalLoggerManager.initDatadogLogger(applicationContext, globalDataStore.get())
ExternalLoggerManager.initDatadogLogger(applicationContext)
// 2. Initialize our internal logging framework
val isLoggingEnabled = globalDataStore.get().isLoggingEnabled().first()
val config = if (isLoggingEnabled) {
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/kotlin/com/wire/android/datastore/GlobalDataStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class GlobalDataStore @Inject constructor(@ApplicationContext private val contex
private val MIGRATION_COMPLETED = booleanPreferencesKey("migration_completed")
private val WELCOME_SCREEN_PRESENTED = booleanPreferencesKey("welcome_screen_presented")
private val IS_LOGGING_ENABLED = booleanPreferencesKey("is_logging_enabled")
private val IS_ENCRYPTED_PROTEUS_STORAGE_ENABLED =
booleanPreferencesKey("is_encrypted_proteus_storage_enabled")
private val APP_LOCK_PASSCODE = stringPreferencesKey("app_lock_passcode")
private val APP_LOCK_SOURCE = intPreferencesKey("app_lock_source")

Expand Down Expand Up @@ -104,16 +102,6 @@ class GlobalDataStore @Inject constructor(@ApplicationContext private val contex
context.dataStore.edit { it[RECORD_AUDIO_EFFECTS_CHECKBOX] = enabled }
}

fun isEncryptedProteusStorageEnabled(): Flow<Boolean> =
getBooleanPreference(
IS_ENCRYPTED_PROTEUS_STORAGE_ENABLED,
BuildConfig.ENCRYPT_PROTEUS_STORAGE
)

suspend fun setEncryptedProteusStorageEnabled(enabled: Boolean) {
context.dataStore.edit { it[IS_ENCRYPTED_PROTEUS_STORAGE_ENABLED] = enabled }
}

suspend fun setMigrationCompleted() {
context.dataStore.edit { it[MIGRATION_COMPLETED] = true }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,20 @@ package com.wire.android.di
import android.content.Context
import android.os.Build
import com.wire.android.BuildConfig
import com.wire.android.datastore.GlobalDataStore
import com.wire.android.util.isWebsocketEnabledByDefault
import com.wire.kalium.logic.featureFlags.BuildFileRestrictionState
import com.wire.kalium.logic.featureFlags.KaliumConfigs
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking

@Module
@InstallIn(SingletonComponent::class)
class KaliumConfigsModule {

@Provides
fun provideKaliumConfigs(globalDataStore: GlobalDataStore, context: Context): KaliumConfigs {
fun provideKaliumConfigs(context: Context): KaliumConfigs {
val fileRestriction: BuildFileRestrictionState = if (BuildConfig.FILE_RESTRICTION_ENABLED) {
BuildConfig.FILE_RESTRICTION_LIST.split(",").map { it.trim() }.let {
BuildFileRestrictionState.AllowSome(it)
Expand All @@ -55,7 +52,7 @@ class KaliumConfigsModule {
lowerKeyingMaterialsUpdateThreshold = BuildConfig.PRIVATE_BUILD,
developmentApiEnabled = BuildConfig.DEVELOPMENT_API_ENABLED,
ignoreSSLCertificatesForUnboundCalls = BuildConfig.IGNORE_SSL_CERTIFICATES,
encryptProteusStorage = runBlocking { globalDataStore.isEncryptedProteusStorageEnabled().first() },
encryptProteusStorage = true,
guestRoomLink = BuildConfig.ENABLE_GUEST_ROOM_LINK,
selfDeletingMessages = BuildConfig.SELF_DELETING_MESSAGES,
wipeOnCookieInvalid = BuildConfig.WIPE_ON_COOKIE_INVALID,
Expand Down
22 changes: 2 additions & 20 deletions app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ fun DebugDataOptions(
) {
LocalSnackbarHostState.current.collectAndShowSnackbar(snackbarFlow = viewModel.infoMessage)
DebugDataOptionsContent(
state = viewModel.state(),
state = viewModel.state,
appVersion = appVersion,
buildVariant = buildVariant,
onCopyText = onCopyText,
onEnableEncryptedProteusStorageChange = viewModel::enableEncryptedProteusStorage,
onRestartSlowSyncForRecovery = viewModel::restartSlowSyncForRecovery,
onForceUpdateApiVersions = viewModel::forceUpdateApiVersions,
onManualMigrationPressed = { onManualMigrationPressed(viewModel.currentAccount()) },
Expand All @@ -89,7 +88,6 @@ fun DebugDataOptionsContent(
appVersion: String,
buildVariant: String,
onCopyText: (String) -> Unit,
onEnableEncryptedProteusStorageChange: (Boolean) -> Unit,
onDisableEventProcessingChange: (Boolean) -> Unit,
onRestartSlowSyncForRecovery: () -> Unit,
onForceUpdateApiVersions: () -> Unit,
Expand Down Expand Up @@ -198,10 +196,7 @@ fun DebugDataOptionsContent(
)
}
}
ProteusOptions(
isEncryptedStorageEnabled = state.isEncryptedProteusStorageEnabled,
onEncryptedStorageEnabledChange = onEnableEncryptedProteusStorageChange
)

if (BuildConfig.DEBUG) {
MLSOptions(
keyPackagesCount = state.keyPackagesCount,
Expand Down Expand Up @@ -337,17 +332,6 @@ private fun MLSOptions(
//endregion

//region Proteus Options
@Composable
private fun ProteusOptions(
isEncryptedStorageEnabled: Boolean,
onEncryptedStorageEnabledChange: (Boolean) -> Unit,
) {
FolderHeader(stringResource(R.string.label_proteus_option_title))
EnableEncryptedProteusStorageSwitch(
isEnabled = isEncryptedStorageEnabled,
onCheckedChange = onEncryptedStorageEnabledChange
)
}

@Composable
private fun EnableEncryptedProteusStorageSwitch(
Expand Down Expand Up @@ -539,15 +523,13 @@ fun PreviewOtherDebugOptions() = WireTheme {
buildVariant = "debug",
onCopyText = {},
state = DebugDataOptionsState(
isEncryptedProteusStorageEnabled = true,
keyPackagesCount = 10,
mslClientId = "clientId",
mlsErrorMessage = "error",
isManualMigrationAllowed = true,
debugId = "debugId",
commitish = "commitish"
),
onEnableEncryptedProteusStorageChange = {},
onForceUpdateApiVersions = {},
onDisableEventProcessingChange = {},
onRestartSlowSyncForRecovery = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package com.wire.android.ui.debug

data class DebugDataOptionsState(
val isEncryptedProteusStorageEnabled: Boolean = false,
val isEventProcessingDisabled: Boolean = false,
val keyPackagesCount: Int = 0,
val mslClientId: String = "null",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ import javax.inject.Inject
@ViewModelScopedPreview
interface DebugDataOptionsViewModel {
val infoMessage: SharedFlow<UIText> get() = MutableSharedFlow()
fun state(): DebugDataOptionsState = DebugDataOptionsState()
val state: DebugDataOptionsState get() = DebugDataOptionsState()
fun currentAccount(): UserId = UserId("value", "domain")
fun checkCrlRevocationList() {}
fun enableEncryptedProteusStorage(enabled: Boolean) {}
fun restartSlowSyncForRecovery() {}
fun enrollE2EICertificate() {}
fun handleE2EIEnrollmentResult(result: Either<CoreFailure, E2EIEnrollmentResult>) {}
Expand Down Expand Up @@ -95,15 +94,14 @@ class DebugDataOptionsViewModelImpl
private val getDefaultProtocolUseCase: GetDefaultProtocolUseCase,
) : ViewModel(), DebugDataOptionsViewModel {

var state by mutableStateOf(
override var state by mutableStateOf(
DebugDataOptionsState()
)

private val _infoMessage = MutableSharedFlow<UIText>()
override val infoMessage = _infoMessage.asSharedFlow()

init {
observeEncryptedProteusStorageState()
observeMlsMetadata()
checkIfCanTriggerManualMigration()
setGitHashAndDeviceId()
Expand Down Expand Up @@ -159,7 +157,6 @@ class DebugDataOptionsViewModelImpl
}
}

override fun state() = state
override fun currentAccount(): UserId = currentAccount

override fun checkCrlRevocationList() {
Expand All @@ -170,14 +167,6 @@ class DebugDataOptionsViewModelImpl
}
}

override fun enableEncryptedProteusStorage(enabled: Boolean) {
if (enabled) {
viewModelScope.launch {
globalDataStore.setEncryptedProteusStorageEnabled(true)
}
}
}

override fun restartSlowSyncForRecovery() {
viewModelScope.launch {
restartSlowSyncProcessForRecovery()
Expand Down Expand Up @@ -257,15 +246,6 @@ class DebugDataOptionsViewModelImpl
}
}

//region Private
private fun observeEncryptedProteusStorageState() {
viewModelScope.launch {
globalDataStore.isEncryptedProteusStorageEnabled().collect {
state = state.copy(isEncryptedProteusStorageEnabled = it)
}
}
}

// If status is NoNeed, it means that the user has already been migrated in and older app version,
// or it is a new install
// this is why we check the existence of the database file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fun ReactionOption(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceEvenly
) {
listOf("❤️", "👍", "😁", "🙂", "☹️", "👎").forEach { emoji ->
listOf("👍", "🙂", "❤️", "☹️", "👎").forEach { emoji ->
CompositionLocalProvider(
LocalMinimumInteractiveComponentSize provides Dp.Unspecified,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.input.TextFieldLineLimits
import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
Expand Down Expand Up @@ -312,7 +313,8 @@ private fun MessageComposerTextInput(
},
interactionSource = interactionSource,
onSelectedLineIndexChanged = onSelectedLineIndexChanged,
onLineBottomYCoordinateChanged = onLineBottomYCoordinateChanged
onLineBottomYCoordinateChanged = onLineBottomYCoordinateChanged,
lineLimits = TextFieldLineLimits.Default,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ private fun SelfQRCodeContent(
val context = LocalContext.current

BackHandler {
trackAnalyticsEvent(AnalyticsEvent.QrCode.Modal.Back)
trackAnalyticsEvent(
AnalyticsEvent.QrCode.Modal.Back(
isTeam = state.isTeamMember
)
)
onBackClick()
}

Expand All @@ -118,7 +122,11 @@ private fun SelfQRCodeContent(
WireCenterAlignedTopAppBar(
title = stringResource(id = R.string.user_profile_qr_code_title),
onNavigationPressed = {
trackAnalyticsEvent(AnalyticsEvent.QrCode.Modal.Back)
trackAnalyticsEvent(
AnalyticsEvent.QrCode.Modal.Back(
isTeam = state.isTeamMember
)
)
onBackClick()
},
elevation = 0.dp
Expand All @@ -127,26 +135,26 @@ private fun SelfQRCodeContent(
) { internalPadding ->
Column(
modifier =
Modifier
.fillMaxSize()
.background(colorsScheme().background)
.padding(internalPadding),
Modifier
.fillMaxSize()
.background(colorsScheme().background)
.padding(internalPadding),
horizontalAlignment = Alignment.CenterHorizontally
) {
VerticalSpace.x24()
Column(
modifier =
Modifier
.padding(horizontal = dimensions().spacing16x)
.clip(RoundedCornerShape(dimensions().spacing8x))
.fillMaxWidth()
.drawWithContent {
graphicsLayer.record {
this@drawWithContent.drawContent()
Modifier
.padding(horizontal = dimensions().spacing16x)
.clip(RoundedCornerShape(dimensions().spacing8x))
.fillMaxWidth()
.drawWithContent {
graphicsLayer.record {
this@drawWithContent.drawContent()
}
drawLayer(graphicsLayer)
}
drawLayer(graphicsLayer)
}
.background(Color.White),
.background(Color.White),
horizontalAlignment = Alignment.CenterHorizontally
) {
VerticalSpace.x16()
Expand All @@ -159,14 +167,14 @@ private fun SelfQRCodeContent(
Box(
contentAlignment = Alignment.Center,
modifier =
Modifier
.clip(CircleShape)
.border(
width = dimensions().spacing2x,
shape = CircleShape,
color = Color.White
)
.background(colorsScheme().primary)
Modifier
.clip(CircleShape)
.border(
width = dimensions().spacing2x,
shape = CircleShape,
color = Color.White
)
.background(colorsScheme().primary)
) {
Icon(
painter = painterResource(id = R.drawable.ic_launcher_foreground),
Expand Down Expand Up @@ -203,10 +211,14 @@ private fun SelfQRCodeContent(
color = colorsScheme().secondaryText
)
Spacer(modifier = Modifier.weight(1f))
ShareLinkButton(state.userAccountProfileLink, trackAnalyticsEvent)
ShareLinkButton(state.isTeamMember, state.userAccountProfileLink, trackAnalyticsEvent)
VerticalSpace.x8()
ShareQRCodeButton {
trackAnalyticsEvent(AnalyticsEvent.QrCode.Modal.ShareQrCode)
trackAnalyticsEvent(
AnalyticsEvent.QrCode.Modal.ShareQrCode(
isTeam = state.isTeamMember
)
)
coroutineScope.launch {
val bitmap = graphicsLayer.toImageBitmap()
val qrUri = shareQRAssetClick(bitmap.asAndroidBitmap())
Expand All @@ -222,32 +234,37 @@ private fun SelfQRCodeContent(
fun ShareQRCodeButton(shareQRAssetClick: () -> Unit) {
WirePrimaryButton(
modifier =
Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.background)
.padding(horizontal = dimensions().spacing16x)
.testTag("Share QR link"),
Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.background)
.padding(horizontal = dimensions().spacing16x)
.testTag("Share QR link"),
text = stringResource(R.string.user_profile_qr_code_share_image_link),
onClick = shareQRAssetClick
)
}

@Composable
private fun ShareLinkButton(
isTeamMember: Boolean,
selfProfileUrl: String,
trackAnalyticsEvent: (AnalyticsEvent.QrCode.Modal) -> Unit
) {
val context = LocalContext.current
WirePrimaryButton(
modifier =
Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.background)
.padding(horizontal = dimensions().spacing16x)
.testTag("Share link"),
Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.background)
.padding(horizontal = dimensions().spacing16x)
.testTag("Share link"),
text = stringResource(R.string.user_profile_qr_code_share_link),
onClick = {
trackAnalyticsEvent(AnalyticsEvent.QrCode.Modal.ShareProfileLink)
trackAnalyticsEvent(
AnalyticsEvent.QrCode.Modal.ShareProfileLink(
isTeam = isTeamMember
)
)
context.shareLinkToProfile(selfProfileUrl)
}
)
Expand Down
Loading

0 comments on commit 14b4fce

Please sign in to comment.