Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Fixes the CardView customization mentioned in #1582 #1595

Merged
merged 41 commits into from
Aug 4, 2023

Conversation

kunzef
Copy link
Contributor

@kunzef kunzef commented Jul 6, 2023

Issue

This fixes the following issue(s):

What it does

This PR rewrites the way Cards handle its discard and alyways hide functionality. It moves all information stored for the card in regards to the discard functionality into one SharedPreference per Card. This shared preference can then be completly wiped when restoring the card. The alyways hide functionality is set in the default SharedPreferences by a key defined in the new CardType enum. This key is stored in the String resource file making it easy to use across the Application and preventing accidental differnces in these keys. The usage of String resource also allows for seamless integration into the Settings.xml ensuring synchronity between the state of the Card. Also settings option for every Card were added because previously there was no way to restore these once alyawys hide was pressed. The CardTypes enum and the combination with the string resource also makes the addition of new Cards less error prone as it is more centralized. The PR also fixes a bug when refreshing the CardView leading to an error when using doAsync from Anko and a crash when using coroutines as mentioned here.

Why this is useful for all students

This PR fixes the issues mentioned in #1582. Thus enhancing the user experience by restoring the excepted functionality.

Copy link
Contributor

@tobiasjungmann tobiasjungmann left a comment

Choose a reason for hiding this comment

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

Please try to not format the whole file in the future - either use a different PR for reformatting / adapt the formatting rules in your IDE to the previously used version. That also happens to me every time :D
Some of your commit messages can be more intuitive ;)
Add some sort of comment (e.g. "Value is only written in the editor, changes are not yet copied back in the shared preferences.") to line 118 in card.kt to make obvious that the changes are not yet applied. I cannot annotate the function with a comment myself since there are no changes. Afterwards it should be ready to merge!

@kunzef
Copy link
Contributor Author

kunzef commented Jul 7, 2023

Please try to not format the whole file in the future - either use a different PR for reformatting / adapt the formatting rules in your IDE to the previously used version.

Are you refering to the first Fixed formatting #ce29bab commit? I think my error there was to accept the option Remove custom line breaks.
Otherwise I adopte the suggested changes.
Thanks for the feedback.

@kunzef kunzef closed this Jul 7, 2023
@kunzef kunzef reopened this Jul 7, 2023
@kunzef kunzef requested a review from tobiasjungmann July 7, 2023 13:45
@tobiasjungmann
Copy link
Contributor

The code is great!
After trying it out I just found one small bug: after restoring the cards, the image for the News-Spread is only shown every second time. Every other time, only the title is shown.
Also if a card is removed by swiping and the cards are reloaded by pulling down before the revert bar has disappeared, the card is visible again. However, I don't think this is an issue since the card is correctly hidden after the necessary time has passed.
Do you see an easy fix for these issues? otherwise we can leave them like this since they are quite minor and do not affect the everyday usage :D

TCA_weird_reload_beahvior.webm

@kunzef
Copy link
Contributor Author

kunzef commented Aug 1, 2023

I was able to fix both issues. However, the fix for the visibility of the news card does not fix the root cause described here #1597. But it will work perfectly for the startpage without further issues.

Copy link
Contributor

@tobiasjungmann tobiasjungmann left a comment

Choose a reason for hiding this comment

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

Amazing, thank you for looking into it! I could not spot any bug anymore.

@tobiasjungmann tobiasjungmann merged commit 377cc3b into TUM-Dev:master Aug 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MainScreen / CardView customization not working [BUG]
2 participants