Skip to content

Commit

Permalink
display modal when running on low storage
Browse files Browse the repository at this point in the history
  • Loading branch information
mebarbosa committed Nov 1, 2024
1 parent 3a73919 commit e0714e2
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit e0714e2

Please sign in to comment.