From bbbb0de12ee3b2f4b28207aad2675407194a9c94 Mon Sep 17 00:00:00 2001 From: Eduarda Barbosa Date: Fri, 1 Nov 2024 13:23:42 -0300 Subject: [PATCH] move low storage check --- .../au/com/shiftyjelly/pocketcasts/ui/MainActivity.kt | 11 ----------- .../pocketcasts/settings/StorageSettingsFragment.kt | 5 ++++- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/au/com/shiftyjelly/pocketcasts/ui/MainActivity.kt b/app/src/main/java/au/com/shiftyjelly/pocketcasts/ui/MainActivity.kt index 4130f8ee20..1b0d509d15 100644 --- a/app/src/main/java/au/com/shiftyjelly/pocketcasts/ui/MainActivity.kt +++ b/app/src/main/java/au/com/shiftyjelly/pocketcasts/ui/MainActivity.kt @@ -17,12 +17,8 @@ import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.widget.Toolbar -import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.platform.ComposeView import androidx.core.content.ContextCompat import androidx.core.view.isVisible @@ -147,7 +143,6 @@ import au.com.shiftyjelly.pocketcasts.ui.theme.ThemeColor import au.com.shiftyjelly.pocketcasts.utils.Network import au.com.shiftyjelly.pocketcasts.utils.featureflag.Feature import au.com.shiftyjelly.pocketcasts.utils.featureflag.FeatureFlag -import au.com.shiftyjelly.pocketcasts.utils.isDeviceRunningOnLowStorage import au.com.shiftyjelly.pocketcasts.utils.log.LogBuffer import au.com.shiftyjelly.pocketcasts.utils.observeOnce import au.com.shiftyjelly.pocketcasts.view.BottomNavHideManager @@ -748,14 +743,8 @@ class MainActivity : ComposeView(viewGroup.context).apply { setContent { val downloadedEpisodesState by viewModel.downloadedEpisodeState.collectAsState() - var isLowStorage by remember { mutableStateOf(false) } - - LaunchedEffect(Unit) { - isLowStorage = isDeviceRunningOnLowStorage() - } val shouldShow = downloadedEpisodesState.downloadedEpisodes != 0L && - isLowStorage && FeatureFlag.isEnabled(Feature.MANAGE_DOWNLOADED_EPISODES) AppTheme(theme.activeTheme) { diff --git a/modules/features/settings/src/main/java/au/com/shiftyjelly/pocketcasts/settings/StorageSettingsFragment.kt b/modules/features/settings/src/main/java/au/com/shiftyjelly/pocketcasts/settings/StorageSettingsFragment.kt index eea261869b..498324fd6d 100644 --- a/modules/features/settings/src/main/java/au/com/shiftyjelly/pocketcasts/settings/StorageSettingsFragment.kt +++ b/modules/features/settings/src/main/java/au/com/shiftyjelly/pocketcasts/settings/StorageSettingsFragment.kt @@ -23,6 +23,7 @@ import au.com.shiftyjelly.pocketcasts.repositories.file.StorageOptions import au.com.shiftyjelly.pocketcasts.settings.viewmodel.StorageSettingsViewModel import au.com.shiftyjelly.pocketcasts.ui.helper.FragmentHostListener import au.com.shiftyjelly.pocketcasts.utils.extensions.pxToDp +import au.com.shiftyjelly.pocketcasts.utils.isDeviceRunningOnLowStorage import au.com.shiftyjelly.pocketcasts.views.fragments.BaseFragment import au.com.shiftyjelly.pocketcasts.views.lowstorage.LowStorageBottomSheetListener import dagger.hilt.android.AndroidEntryPoint @@ -77,7 +78,9 @@ class StorageSettingsFragment : BaseFragment() { super.onViewCreated(view, savedInstanceState) viewLifecycleOwner.lifecycleScope.launch { viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { - lowStorageListener?.showModal() + if (isDeviceRunningOnLowStorage()) { + lowStorageListener?.showModal() + } viewModel.permissionRequest.collect { permissionRequest -> if (permissionRequest == Manifest.permission.WRITE_EXTERNAL_STORAGE) { requestPermissionLauncher.launch(permissionRequest)