mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 02:39:55 +01:00
Prepare the websocket keepalive for API 31.
This commit is contained in:
@@ -45,6 +45,7 @@ import org.thoughtcrime.securesms.util.navigation.safeNavigate
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.max
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__internal_preferences) {
|
||||
|
||||
@@ -201,6 +202,25 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
|
||||
sectionHeaderPref(R.string.preferences__internal_network)
|
||||
|
||||
switchPref(
|
||||
title = DSLSettingsText.from("Force websocket mode"),
|
||||
summary = DSLSettingsText.from("Pretend you have no Play Services. Ignores websocket messages and keeps the websocket open in a foreground service. You have to manually force-stop the app for changes to take effect."),
|
||||
isChecked = state.forceWebsocketMode,
|
||||
onClick = {
|
||||
viewModel.setForceWebsocketMode(!state.forceWebsocketMode)
|
||||
SimpleTask.run({
|
||||
val jobState = ApplicationDependencies.getJobManager().runSynchronously(RefreshAttributesJob(), 10.seconds.inWholeMilliseconds)
|
||||
return@run jobState.isPresent && jobState.get().isComplete
|
||||
}, { success ->
|
||||
if (success) {
|
||||
Toast.makeText(context, "Successfully refreshed attributes. Force-stop the app for changes to take effect.", Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Toast.makeText(context, "Failed to refresh attributes.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
switchPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__internal_allow_censorship_toggle),
|
||||
summary = DSLSettingsText.from(R.string.preferences__internal_allow_censorship_toggle_description),
|
||||
|
||||
@@ -10,6 +10,7 @@ data class InternalSettingsState(
|
||||
val gv2ignoreServerChanges: Boolean,
|
||||
val gv2ignoreP2PChanges: Boolean,
|
||||
val allowCensorshipSetting: Boolean,
|
||||
val forceWebsocketMode: Boolean,
|
||||
val callingServer: String,
|
||||
val callingAudioProcessingMethod: CallManager.AudioProcessingMethod,
|
||||
val callingBandwidthMode: CallManager.BandwidthMode,
|
||||
|
||||
@@ -59,6 +59,11 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setForceWebsocketMode(enabled: Boolean) {
|
||||
preferenceDataStore.putBoolean(InternalValues.FORCE_WEBSOCKET_MODE, enabled)
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setUseBuiltInEmoji(enabled: Boolean) {
|
||||
preferenceDataStore.putBoolean(InternalValues.FORCE_BUILT_IN_EMOJI, enabled)
|
||||
refresh()
|
||||
@@ -109,6 +114,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
||||
gv2ignoreServerChanges = SignalStore.internalValues().gv2IgnoreServerChanges(),
|
||||
gv2ignoreP2PChanges = SignalStore.internalValues().gv2IgnoreP2PChanges(),
|
||||
allowCensorshipSetting = SignalStore.internalValues().allowChangingCensorshipSetting(),
|
||||
forceWebsocketMode = SignalStore.internalValues().isWebsocketModeForced,
|
||||
callingServer = SignalStore.internalValues().groupCallingServer(),
|
||||
callingAudioProcessingMethod = SignalStore.internalValues().callingAudioProcessingMethod(),
|
||||
callingBandwidthMode = SignalStore.internalValues().callingBandwidthMode(),
|
||||
|
||||
Reference in New Issue
Block a user