Skip to content

Commit

Permalink
move low storage check
Browse files Browse the repository at this point in the history
  • Loading branch information
mebarbosa committed Nov 1, 2024
1 parent 8eebc12 commit 8d6ed0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +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
Expand Down Expand Up @@ -147,7 +144,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
Expand Down Expand Up @@ -748,14 +744,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8d6ed0f

Please sign in to comment.