diff --git a/app/src/main/java/org/thoughtcrime/securesms/MainActivity.java b/app/src/main/java/org/thoughtcrime/securesms/MainActivity.java index 4739b579a2..9a08f7edbb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/MainActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/MainActivity.java @@ -20,7 +20,6 @@ import org.signal.donations.StripeApi; import org.thoughtcrime.securesms.components.DeviceSpecificNotificationBottomSheet; import org.thoughtcrime.securesms.components.PromptBatterySaverDialogFragment; -import org.thoughtcrime.securesms.components.ConnectivityWarningBottomSheet; import org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity; import org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController; import org.thoughtcrime.securesms.components.voice.VoiceNoteMediaControllerOwner; @@ -122,9 +121,6 @@ private void presentVitalsState(VitalsViewModel.State state) { case PROMPT_GENERAL_BATTERY_SAVER_DIALOG: PromptBatterySaverDialogFragment.show(getSupportFragmentManager()); break; - case PROMPT_CONNECTIVITY_WARNING: - ConnectivityWarningBottomSheet.show(getSupportFragmentManager()); - break; } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/ConnectivityWarningBottomSheet.kt b/app/src/main/java/org/thoughtcrime/securesms/components/ConnectivityWarningBottomSheet.kt deleted file mode 100644 index a70226b58c..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/components/ConnectivityWarningBottomSheet.kt +++ /dev/null @@ -1,101 +0,0 @@ -package org.thoughtcrime.securesms.components - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.wrapContentSize -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.unit.dp -import androidx.fragment.app.FragmentManager -import org.signal.core.ui.BottomSheets -import org.signal.core.ui.Buttons -import org.signal.core.ui.Previews -import org.signal.core.ui.SignalPreview -import org.thoughtcrime.securesms.R -import org.thoughtcrime.securesms.compose.ComposeBottomSheetDialogFragment -import org.thoughtcrime.securesms.keyvalue.SignalStore -import org.thoughtcrime.securesms.util.BottomSheetUtil - -/** - * A bottom sheet that warns the user when they haven't been able to connect to the websocket for some time. - */ -class ConnectivityWarningBottomSheet : ComposeBottomSheetDialogFragment() { - - override val peekHeightPercentage: Float = 0.66f - - companion object { - - @JvmStatic - fun show(fragmentManager: FragmentManager) { - if (fragmentManager.findFragmentByTag(BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG) == null) { - ConnectivityWarningBottomSheet().show(fragmentManager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG) - SignalStore.misc.lastConnectivityWarningTime = System.currentTimeMillis() - } - } - } - - @Composable - override fun SheetContent() { - Sheet( - onDismiss = { dismissAllowingStateLoss() } - ) - } -} - -@Composable -private fun Sheet(onDismiss: () -> Unit = {}) { - return Column( - horizontalAlignment = Alignment.CenterHorizontally, - modifier = Modifier.fillMaxWidth().wrapContentSize(Alignment.Center) - ) { - BottomSheets.Handle() - Icon( - painterResource(id = R.drawable.ic_connectivity_warning), - contentDescription = null, - tint = Color.Unspecified, - modifier = Modifier.padding(top = 32.dp, bottom = 8.dp) - ) - Text( - text = stringResource(id = R.string.ConnectivityWarningBottomSheet_title), - style = MaterialTheme.typography.headlineSmall, - textAlign = TextAlign.Center, - color = MaterialTheme.colorScheme.onSurface, - modifier = Modifier.padding(horizontal = 24.dp, vertical = 8.dp) - ) - Text( - text = stringResource(id = R.string.ConnectivityWarningBottomSheet_body), - style = MaterialTheme.typography.bodyLarge, - textAlign = TextAlign.Center, - color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(horizontal = 24.dp) - ) - Row( - modifier = Modifier.padding(top = 60.dp, bottom = 24.dp, start = 24.dp, end = 24.dp) - ) { - Buttons.MediumTonal( - onClick = onDismiss, - modifier = Modifier.padding(end = 12.dp) - ) { - Text(stringResource(id = R.string.ConnectivityWarningBottomSheet_dismiss_button)) - } - } - } -} - -@SignalPreview -@Composable -private fun ConnectivityWarningSheetPreview() { - Previews.BottomSheetPreview { - Sheet() - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/keyvalue/MiscellaneousValues.kt b/app/src/main/java/org/thoughtcrime/securesms/keyvalue/MiscellaneousValues.kt index e5212ff3fa..d16c81180e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/keyvalue/MiscellaneousValues.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/keyvalue/MiscellaneousValues.kt @@ -37,8 +37,6 @@ class MiscellaneousValues internal constructor(store: KeyValueStore) : SignalSto private const val LEAST_ACTIVE_LINKED_DEVICE = "misc.linked_device.least_active" private const val NEXT_DATABASE_ANALYSIS_TIME = "misc.next_database_analysis_time" private const val LAST_NETWORK_RESET_TIME = "misc.last_network_reset_time" - private const val LAST_WEBSOCKET_CONNECT_TIME = "misc.last_websocket_connect_time" - private const val LAST_CONNECTIVITY_WARNING_TIME = "misc.last_connectivity_warning_time" } public override fun onFirstEverAppLaunch() { @@ -248,14 +246,4 @@ class MiscellaneousValues internal constructor(store: KeyValueStore) : SignalSto var nextDatabaseAnalysisTime: Long by longValue(NEXT_DATABASE_ANALYSIS_TIME, 0) var lastNetworkResetDueToStreamResets: Long by longValue(LAST_NETWORK_RESET_TIME, 0L) - - /** - * The last time you successfully connected to the websocket. - */ - var lastWebSocketConnectTime: Long by longValue(LAST_WEBSOCKET_CONNECT_TIME, System.currentTimeMillis()) - - /** - * The last time we prompted the user regarding a [org.thoughtcrime.securesms.util.ConnectivityWarning]. - */ - var lastConnectivityWarningTime: Long by longValue(LAST_CONNECTIVITY_WARNING_TIME, 0) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/messages/IncomingMessageObserver.kt b/app/src/main/java/org/thoughtcrime/securesms/messages/IncomingMessageObserver.kt index 710f2c19e7..3d59b5efc4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/messages/IncomingMessageObserver.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/messages/IncomingMessageObserver.kt @@ -401,10 +401,6 @@ class IncomingMessageObserver(private val context: Application) { if (state != WebSocketConnectionState.CONNECTED) { decryptionDrained = false } - - if (state == WebSocketConnectionState.CONNECTED) { - SignalStore.misc.lastWebSocketConnectTime = System.currentTimeMillis() - } } signalWebSocket.connect(shouldKeepAliveUnidentified()) diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/VitalsViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/notifications/VitalsViewModel.kt index e2086c8fd2..7e4ab23aaa 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/VitalsViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/VitalsViewModel.kt @@ -12,12 +12,8 @@ import io.reactivex.rxjava3.core.Observable import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.schedulers.Schedulers import io.reactivex.rxjava3.subjects.BehaviorSubject -import org.thoughtcrime.securesms.keyvalue.SignalStore import org.thoughtcrime.securesms.notifications.DeviceSpecificNotificationConfig.ShowCondition -import org.thoughtcrime.securesms.util.ConnectivityWarning -import org.thoughtcrime.securesms.util.NetworkUtil import java.util.concurrent.TimeUnit -import kotlin.time.Duration.Companion.days /** * View model for checking for various app vitals, like slow notifications and crashes. @@ -32,7 +28,7 @@ class VitalsViewModel(private val context: Application) : AndroidViewModel(conte vitalsState = checkSubject .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) - .throttleFirst(1, TimeUnit.MINUTES) + .throttleLast(15, TimeUnit.MINUTES) .switchMapSingle { checkHeuristics() } @@ -64,13 +60,6 @@ class VitalsViewModel(private val context: Application) : AndroidViewModel(conte return@fromCallable State.PROMPT_GENERAL_BATTERY_SAVER_DIALOG } - val timeSinceLastConnection = System.currentTimeMillis() - SignalStore.misc.lastWebSocketConnectTime - val timeSinceLastConnectionWarning = System.currentTimeMillis() - SignalStore.misc.lastConnectivityWarningTime - - if (ConnectivityWarning.isEnabled && timeSinceLastConnection > ConnectivityWarning.threshold && timeSinceLastConnectionWarning > 14.days.inWholeMilliseconds && NetworkUtil.isConnected(context)) { - return@fromCallable State.PROMPT_CONNECTIVITY_WARNING - } - return@fromCallable State.NONE }.subscribeOn(Schedulers.io()) } @@ -79,6 +68,5 @@ class VitalsViewModel(private val context: Application) : AndroidViewModel(conte NONE, PROMPT_SPECIFIC_BATTERY_SAVER_DIALOG, PROMPT_GENERAL_BATTERY_SAVER_DIALOG, - PROMPT_CONNECTIVITY_WARNING, } }