Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Project] Manage Downloaded Episodes - Display Modal when running on low storage and turn on Auto Download #3151

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

mebarbosa
Copy link
Contributor

@mebarbosa mebarbosa commented Nov 1, 2024

Description

  • Displays the low storage modal when running on low storage and turn on Auto Download
  • This PR does not implement the snooze for 7 days feature when taping on Maybe Later button
  • See: VvERCFIopLjFL8Fnczsf8r-fi-123_1167
  • Context: p1730298732804909/1730291928.354409-slack-C07TL9YK9V1

Fixes #3150

Testing Instructions

Modify the code bellow to always return true to make the tests faster. This will mock the low storage check

suspend fun isDeviceRunningOnLowStorage(statFs: StatFs = StatFs(Environment.getExternalStorageDirectory().path)): Boolean = withContext(Dispatchers.IO) {

  1. Download an episode
  2. Go to Profile -> Auto Download
  3. Turn on New Episodes toggle
  4. ✅ Ensure the modal opens

Screenshots or Screencast

Screen_recording_20241101_133738.webm

Checklist

  • If this is a user-facing change, I have added an entry in CHANGELOG.md
  • Ensure the linter passes (./gradlew spotlessApply to automatically apply formatting/linting)
  • I have considered whether it makes sense to add tests for my changes
  • All strings that need to be localized are in modules/services/localization/src/main/res/values/strings.xml
  • Any jetpack compose components I added or changed are covered by compose previews
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

I have tested any UI changes...

  • with different themes
  • with a landscape orientation
  • with the device set to have a large display and font size
  • for accessibility with TalkBack

@mebarbosa mebarbosa added this to the 7.77 milestone Nov 1, 2024
@mebarbosa mebarbosa requested a review from a team as a code owner November 1, 2024 16:38
@mebarbosa mebarbosa requested review from geekygecko and removed request for a team November 1, 2024 16:38
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 1, 2024

📲 You can test the changes from this Pull Request in 📱 Mobile by scanning the QR code below to install the corresponding build.
App Name 📱 Mobile
Build TypedebugProd
Commit022d930
Direct Downloadpocketcasts-app-prototype-build-pr3151-022d930.apk
📲 You can test the changes from this Pull Request in 🚗 Automotive by scanning the QR code below to install the corresponding build.
App Name 🚗 Automotive
Build TypedebugProd
Commit022d930
Direct Downloadpocketcasts-automotive-prototype-build-pr3151-022d930.apk
📲 You can test the changes from this Pull Request in ⌚ Wear by scanning the QR code below to install the corresponding build.
App Name ⌚ Wear
Build TypedebugProd
Commit022d930
Direct Downloadpocketcasts-wear-prototype-build-pr3151-022d930.apk

Base automatically changed from task/add-low-storage-bottom-sheet to main November 4, 2024 05:25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a question for my knowledge, are we meant to update this file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes we need to regenerate it. Like in this case where onAttach() got reported incorrectly by Lint. However, due to GH Lint integration we need to un-comment this line first.

// Uncomment this when regenerating baseline files
// ignoreWarnings = true

mebarbosa and others added 3 commits November 4, 2024 08:11
…casts/views/lowstorage/LowStorageDialog.kt

Co-authored-by: Philip Simpson <[email protected]>
…casts/views/lowstorage/LowStorageDialog.kt

Co-authored-by: Philip Simpson <[email protected]>
@mebarbosa mebarbosa force-pushed the task/open-storage-modal-on-autodownload-change branch from 5cf6b4b to 088d085 Compare November 4, 2024 11:36
@MiSikora
Copy link
Contributor

MiSikora commented Nov 4, 2024

In 5497a6b isDeviceRunningOnLowStorage() got changed to use Dispatcher.IO but can you update it to something like this?

--- suspend fun isDeviceRunningOnLowStorage(statFs: StatFs = StatFs(Environment.getExternalStorageDirectory().path)): Boolean = withContext(Dispatchers.IO) {
+++ suspend fun isDeviceRunningOnLowStorage(file: File = Environment.getExternalStorageDirectory()): Boolean = withContext(Dispatchers.IO) {
+++    val statFs = StatFs(file.path)

The expensive part isn't reading all the properties of the StatFs object but creating it because this is what calls statvfs(2).

@mebarbosa mebarbosa force-pushed the task/open-storage-modal-on-autodownload-change branch from dff28c2 to 022d930 Compare November 4, 2024 16:50
@mebarbosa
Copy link
Contributor Author

suspend fun isDeviceRunningOnLowStorage(file: File = Environment.getExternalStorageDirectory()): Boolean = withContext(Dispatchers.IO) {
val statFs = StatFs(file.path)

@MiSikora I am struggling to make this change because it breaks the unit tests https://github.com/Automattic/pocket-casts-android/blob/main/modules/services/utils/src/test/java/au/com/shiftyjelly/pocketcasts/utils/StorageUtilTest.kt

I can not inject a mock after this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Project] Manage Downloaded Episodes - Display modal when running low storage and turn on Auto Download
4 participants