From 54ec9e5d10b4b5a346c1ae1bb7f536c2c1f2363d Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:39:44 +1100 Subject: [PATCH] Renamed --- .../thoughtcrime/securesms/configs/ConfigUploader.kt | 6 +++--- .../securesms/groups/GroupPollerManager.kt | 7 ++----- .../securesms/preferences/SettingsActivity.kt | 11 ----------- .../securesms/preferences/SettingsViewModel.kt | 4 ++-- .../securesms/service/WebRtcCallService.kt | 6 +++--- ...InternetConnectivity.kt => NetworkConnectivity.kt} | 6 ++++-- 6 files changed, 14 insertions(+), 26 deletions(-) rename app/src/main/java/org/thoughtcrime/securesms/util/{InternetConnectivity.kt => NetworkConnectivity.kt} (90%) diff --git a/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigUploader.kt b/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigUploader.kt index 59bd20825b..b3ac243416 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigUploader.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigUploader.kt @@ -44,7 +44,7 @@ import org.session.libsignal.utilities.Log import org.session.libsignal.utilities.Namespace import org.session.libsignal.utilities.Snode import org.session.libsignal.utilities.retryWithUniformInterval -import org.thoughtcrime.securesms.util.InternetConnectivity +import org.thoughtcrime.securesms.util.NetworkConnectivity import javax.inject.Inject private const val TAG = "ConfigUploader" @@ -64,7 +64,7 @@ class ConfigUploader @Inject constructor( private val configFactory: ConfigFactoryProtocol, private val storageProtocol: StorageProtocol, private val clock: SnodeClock, - private val internetConnectivity: InternetConnectivity, + private val networkConnectivity: NetworkConnectivity, private val textSecurePreferences: TextSecurePreferences, ) { private var job: Job? = null @@ -77,7 +77,7 @@ class ConfigUploader @Inject constructor( * The value pushed doesn't matter as nothing is emitted when the conditions are not met. */ @OptIn(ExperimentalCoroutinesApi::class) - private fun pathBecomesAvailable(): Flow<*> = internetConnectivity.networkAvailable + private fun pathBecomesAvailable(): Flow<*> = networkConnectivity.networkAvailable .flatMapLatest { hasNetwork -> if (hasNetwork) { OnionRequestAPI.hasPath.filter { it } diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupPollerManager.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupPollerManager.kt index a13f94401a..cd58bc11a2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupPollerManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupPollerManager.kt @@ -1,6 +1,5 @@ package org.thoughtcrime.securesms.groups -import dagger.Lazy import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -25,8 +24,6 @@ import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.supervisorScope -import org.session.libsession.database.StorageProtocol -import org.session.libsession.messaging.groups.GroupManagerV2 import org.session.libsession.snode.SnodeClock import org.session.libsession.utilities.ConfigUpdateNotification import org.session.libsession.utilities.TextSecurePreferences @@ -35,7 +32,7 @@ import org.session.libsignal.utilities.AccountId import org.session.libsignal.utilities.Log import org.thoughtcrime.securesms.dependencies.ConfigFactory import org.thoughtcrime.securesms.util.AppVisibilityManager -import org.thoughtcrime.securesms.util.InternetConnectivity +import org.thoughtcrime.securesms.util.NetworkConnectivity import javax.inject.Inject import javax.inject.Singleton @@ -59,7 +56,7 @@ class GroupPollerManager @Inject constructor( clock: SnodeClock, preferences: TextSecurePreferences, appVisibilityManager: AppVisibilityManager, - connectivity: InternetConnectivity, + connectivity: NetworkConnectivity, groupRevokedMessageHandler: GroupRevokedMessageHandler, ) { @Suppress("OPT_IN_USAGE") diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt index 03dd82141b..b3e1ee3fd2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt @@ -2,10 +2,8 @@ import android.Manifest import android.app.Activity -import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import android.content.IntentFilter import android.graphics.BitmapFactory import android.net.Uri import android.os.Bundle @@ -53,18 +51,10 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope -import androidx.localbroadcastmanager.content.LocalBroadcastManager import com.canhub.cropper.CropImageContract import com.squareup.phrase.Phrase import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.callbackFlow -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext import network.loki.messenger.BuildConfig import network.loki.messenger.R import network.loki.messenger.databinding.ActivitySettingsBinding @@ -103,7 +93,6 @@ import org.thoughtcrime.securesms.ui.theme.PreviewTheme import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider import org.thoughtcrime.securesms.ui.theme.ThemeColors import org.thoughtcrime.securesms.ui.theme.dangerButtonColors -import org.thoughtcrime.securesms.util.InternetConnectivity import org.thoughtcrime.securesms.util.push import java.io.File import javax.inject.Inject diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsViewModel.kt index 20e52b1eac..676905313e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsViewModel.kt @@ -36,7 +36,7 @@ import org.thoughtcrime.securesms.preferences.SettingsViewModel.AvatarDialogStat import org.thoughtcrime.securesms.profiles.ProfileMediaConstraints import org.thoughtcrime.securesms.util.BitmapDecodingException import org.thoughtcrime.securesms.util.BitmapUtil -import org.thoughtcrime.securesms.util.InternetConnectivity +import org.thoughtcrime.securesms.util.NetworkConnectivity import java.io.File import java.io.IOException import javax.inject.Inject @@ -46,7 +46,7 @@ class SettingsViewModel @Inject constructor( @ApplicationContext private val context: Context, private val prefs: TextSecurePreferences, private val configFactory: ConfigFactory, - private val connectivity: InternetConnectivity, + private val connectivity: NetworkConnectivity, ) : ViewModel() { private val TAG = "SettingsViewModel" diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt b/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt index 8ae08c9c47..6f55dde70e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt @@ -43,7 +43,7 @@ import org.thoughtcrime.securesms.util.CallNotificationBuilder.Companion.TYPE_IN import org.thoughtcrime.securesms.util.CallNotificationBuilder.Companion.TYPE_INCOMING_RINGING import org.thoughtcrime.securesms.util.CallNotificationBuilder.Companion.TYPE_OUTGOING_RINGING import org.thoughtcrime.securesms.util.CallNotificationBuilder.Companion.WEBRTC_NOTIFICATION -import org.thoughtcrime.securesms.util.InternetConnectivity +import org.thoughtcrime.securesms.util.NetworkConnectivity import org.thoughtcrime.securesms.webrtc.AudioManagerCommand import org.thoughtcrime.securesms.webrtc.CallManager import org.thoughtcrime.securesms.webrtc.CallViewModel @@ -219,7 +219,7 @@ class WebRtcCallService : LifecycleService(), CallManager.WebRtcListener { lateinit var callManager: CallManager @Inject - lateinit var internetConnectivity: InternetConnectivity + lateinit var networkConnectivity: NetworkConnectivity private var wantsToAnswer = false private var currentTimeouts = 0 @@ -335,7 +335,7 @@ class WebRtcCallService : LifecycleService(), CallManager.WebRtcListener { registerUncaughtExceptionHandler() GlobalScope.launch { - internetConnectivity.networkAvailable.collectLatest(::networkChange) + networkConnectivity.networkAvailable.collectLatest(::networkChange) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/InternetConnectivity.kt b/app/src/main/java/org/thoughtcrime/securesms/util/NetworkConnectivity.kt similarity index 90% rename from app/src/main/java/org/thoughtcrime/securesms/util/InternetConnectivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/util/NetworkConnectivity.kt index 516b1beb17..027f916325 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/InternetConnectivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/NetworkConnectivity.kt @@ -17,10 +17,12 @@ import javax.inject.Inject import javax.inject.Singleton /** - * Provides a flow that emits `true` when the device has internet connectivity and `false` otherwise. + * Provides a flow that emits `true` when the device has network connectivity. We won't be sure + * if there's internet or not, it's by designed so that we don't get false negatives in censorship + * countries. */ @Singleton -class InternetConnectivity @Inject constructor(application: Application) { +class NetworkConnectivity @Inject constructor(application: Application) { val networkAvailable = callbackFlow { val connectivityManager = application.getSystemService(ConnectivityManager::class.java)