-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Refactor(MediaCheckDialog): Media check to use ViewModel #17943
base: main
Are you sure you want to change the base?
Conversation
Important Maintainers: This PR contains Strings changes
|
bc072d9
to
7a503ca
Compare
18ef3d5
to
6b62901
Compare
AnkiDroid/src/main/java/com/ichi2/anki/dialogs/mediacheck/ConfirmMediaCheckDialog.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/dialogs/mediacheck/MediaCheckResultDialog.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/dialogs/viewmodel/MediaCheckViewModel.kt
Outdated
Show resolved
Hide resolved
6b62901
to
337a7d4
Compare
93508d4
to
124a991
Compare
To resolve the issue in I am migrating the result from dialog to fragment. Why? Because the string builder is taking a lot of time to render strings i.e. 10k or 30k file names etc so its a heavy task for it, I have replicated the Anki behaviour in the fragment i.e. how it closes and how the user can interact with it |
9090d16
to
37301c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why you introduced the current granularity with the number of commits. Reverting any of the first three commits will render the other two commits useless as the content is tightly tied together. It also makes reviewing harder.
So please squash the first three commits into a single commit.
Requested some changes, the implementation seems fine.
AnkiDroid/src/main/java/com/ichi2/anki/mediacheck/ConfirmMediaCheckDialog.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/mediacheck/MediaCheckAdapter.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/mediacheck/MediaCheckAdapter.kt
Outdated
Show resolved
Hide resolved
android:id="@+id/file_name_textview" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textSize="11dp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this needs to be sp or look into one of the textApperance styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't fixed.
AnkiDroid/src/main/java/com/ichi2/anki/mediacheck/MediaCheckFragment.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/mediacheck/MediaCheckFragment.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/mediacheck/MediaCheckViewModel.kt
Outdated
Show resolved
Hide resolved
R.string.check_media_delete_unused, | ||
) | ||
|
||
setOnClickListener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This button shows a confirmation dialog before starting to delete and we should do this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't implemented, show an AlertDialog here and ask for confirmation and then initiate the delete process.
37301c4
to
6ef3989
Compare
feat: add media check fragment file - feat: adapter for media check result - refactor: confirm media check dialog
6ef3989
to
425ac64
Compare
- refactor: replace media check result dialog with fragment - refactor: remove unused parameter in Media.kt
425ac64
to
961d458
Compare
@@ -1226,6 +1221,17 @@ open class DeckPicker : | |||
} | |||
} | |||
|
|||
private fun showMediaCheckDialog() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name proposal: showMediaCheckConfirmationDialog()
android:id="@+id/file_name_textview" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textSize="11dp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't fixed.
R.string.check_media_delete_unused, | ||
) | ||
|
||
setOnClickListener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't implemented, show an AlertDialog here and ask for confirmation and then initiate the delete process.
text = | ||
TR.mediaCheckDeleteUnused().toSentenceCase( | ||
requireContext(), | ||
R.string.check_media_delete_unused, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string is used only here. It should be removed from 03-dialogs.xml and added to sentence case xml.
Purpose / Description
Migrates the logic of MediaCheck to ViewModel
Split the dialog logic, use different dialog for result and conformation
Fixes
Approach
Use ViewModel to handle the media check dialog and its result
How Has This Been Tested?
Tested on Google emulator API31
Screen_recording_20250220_045658.webm
Checklist
Please, go through these checks before submitting the PR.