Skip to content

Commit b3cc775

Browse files
authored
feat(v4.1): handling configuration for websocket enabled by default (WPB-967) (#1899)
* feat: enable websocket by default * feat: enable websocket by default * feat: fix detekt * feat: fix detekt * chore: kalium ref to tag
1 parent 82aefb9 commit b3cc775

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020

2121
package com.wire.android.di
2222

23+
import android.content.Context
2324
import android.os.Build
2425
import com.wire.android.BuildConfig
2526
import com.wire.android.datastore.GlobalDataStore
27+
import com.wire.android.util.extension.isGoogleServicesAvailable
2628
import com.wire.kalium.logic.featureFlags.KaliumConfigs
2729
import dagger.Module
2830
import dagger.Provides
@@ -36,7 +38,7 @@ import kotlinx.coroutines.runBlocking
3638
class KaliumConfigsModule {
3739

3840
@Provides
39-
fun provideKaliumConfigs(globalDataStore: GlobalDataStore): KaliumConfigs {
41+
fun provideKaliumConfigs(globalDataStore: GlobalDataStore, context: Context): KaliumConfigs {
4042
return KaliumConfigs(
4143
isChangeEmailEnabled = BuildConfig.ALLOW_CHANGE_OF_EMAIL,
4244
isLoggingEnabled = BuildConfig.LOGGING_ENABLED,
@@ -56,7 +58,8 @@ class KaliumConfigsModule {
5658
guestRoomLink = BuildConfig.ENABLE_GUEST_ROOM_LINK,
5759
wipeOnCookieInvalid = BuildConfig.WIPE_ON_COOKIE_INVALID,
5860
wipeOnDeviceRemoval = BuildConfig.WIPE_ON_DEVICE_REMOVAL,
59-
wipeOnRootedDevice = BuildConfig.WIPE_ON_ROOTED_DEVICE
61+
wipeOnRootedDevice = BuildConfig.WIPE_ON_ROOTED_DEVICE,
62+
isWebSocketEnabledByDefault = runBlocking { !context.isGoogleServicesAvailable() }
6063
)
6164
}
6265
}

app/src/main/kotlin/com/wire/android/ui/home/settings/appsettings/networkSettings/NetworkSettingsScreen.kt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
2727
import androidx.compose.material3.Scaffold
2828
import androidx.compose.runtime.Composable
2929
import androidx.compose.ui.Modifier
30+
import androidx.compose.ui.platform.LocalContext
3031
import androidx.compose.ui.res.stringResource
3132
import androidx.compose.ui.tooling.preview.Preview
3233
import androidx.compose.ui.unit.dp
@@ -36,6 +37,7 @@ import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar
3637
import com.wire.android.ui.home.conversations.details.options.ArrowType
3738
import com.wire.android.ui.home.conversations.details.options.GroupConversationOptionsItem
3839
import com.wire.android.ui.home.conversations.details.options.SwitchState
40+
import com.wire.android.util.extension.isGoogleServicesAvailable
3941

4042
@Composable
4143
fun NetworkSettingsScreen(networkSettingsViewModel: NetworkSettingsViewModel = hiltViewModel()) {
@@ -56,7 +58,6 @@ fun NetworkSettingsScreenContent(
5658
isWebSocketEnabled: Boolean,
5759
setWebSocketState: (Boolean) -> Unit,
5860
backendName: String
59-
6061
) {
6162
Scaffold(topBar = {
6263
WireCenterAlignedTopAppBar(
@@ -76,16 +77,28 @@ fun NetworkSettingsScreenContent(
7677
R.string.settings_keep_connection_to_websocket_description,
7778
backendName
7879
),
79-
switchState = SwitchState.Enabled(
80-
value = isWebSocketEnabled,
81-
onCheckedChange = setWebSocketState
82-
),
80+
switchState = getSwitchState(isWebSocketEnabled, setWebSocketState),
8381
arrowType = ArrowType.NONE
8482
)
8583
}
8684
}
8785
}
8886

87+
@Composable
88+
private fun getSwitchState(isWebSocketEnabled: Boolean, setWebSocketState: (Boolean) -> Unit): SwitchState {
89+
val context = LocalContext.current
90+
return if (context.isGoogleServicesAvailable()) {
91+
SwitchState.Enabled(
92+
value = isWebSocketEnabled,
93+
onCheckedChange = setWebSocketState
94+
)
95+
} else {
96+
SwitchState.Disabled(
97+
value = isWebSocketEnabled,
98+
)
99+
}
100+
}
101+
89102
@Composable
90103
@Preview
91104
fun PreviewNetworkSettingsScreen() {

0 commit comments

Comments
 (0)