From e0714e2a008bec0c1a402e33a14eb6ea97354e87 Mon Sep 17 00:00:00 2001 From: Eduarda Barbosa Date: Fri, 1 Nov 2024 10:58:08 -0300 Subject: [PATCH] display modal when running on low storage --- .../shiftyjelly/pocketcasts/ui/MainActivity.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 575d0111ca..4130f8ee20 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,8 +17,12 @@ 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 @@ -143,6 +147,7 @@ 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 @@ -743,10 +748,20 @@ 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) { LowStorageLaunchBottomSheet( parent = viewGroup, - shouldShow = downloadedEpisodesState.downloadedEpisodes != 0L, + shouldShow = shouldShow, onManageDownloadsClick = { analyticsTracker.track(AnalyticsEvent.DOWNLOADS_OPTIONS_MODAL_OPTION_TAPPED, mapOf(OPTION_KEY to CLEAN_UP)) addFragment(ManualCleanupFragment.newInstance())