-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
LoyaltCardEditActivity: Migrate to materialdatepicker dialog #1588
LoyaltCardEditActivity: Migrate to materialdatepicker dialog #1588
Conversation
Are the tests failing due to migration? I think not but not sure. |
Had to run the CI on GitHub a few times to get the same error as locally, but there does seem to be a test failure:
|
app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
Outdated
Show resolved
Hide resolved
app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
Outdated
Show resolved
Hide resolved
Hard to tell if this is a bug in the code or in robolectric. I can try to debug more later if someone else doesn't figure it out first :) |
app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
Outdated
Show resolved
Hide resolved
Sorry for asking some general questions about the need to keep (or possibility to improve) certain existing bits of code without being explicit about that. I did want to know if those were still relevant after the migration to the new date picker, but if they aren't affected by the change, changes to that code should probably be considered out of scope for this PR and left to a later follow-up. |
27326c5
to
a1c281d
Compare
app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
Outdated
Show resolved
Hide resolved
app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
Outdated
Show resolved
Hide resolved
d38f46c
to
fac0d9b
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.
Finally got some time to do basic testing. It definitely looks a lot prettier, but I am noticing several bugs:
User can set expiry before valid from date
To reproduce:
- Create a new card
- Set "Valid from" to tomorrow
- Click "Choose expiry date" in "Expiry date"
- Note that the calendar picker uses today's date as default
- Press OK
- Notice "Valid from" is tomorrow but "Expiry date" is today
On rotation change, dialog stops affecting value
To reproduce:
- Pick "Choose valid from date" or "Choose expiry date"
- Wait for the dialog to show
- Rotate the screen
- Pick a date
- Press OK
- Notice the "Valid from" or "Expiry date" field stays on the old value
(It vaguely reminds me of #1431, although that was a crash, this is just state loss.)
30f8a0f
to
5f0396d
Compare
Signed-off-by: Aayush Gupta <[email protected]>
… migration Signed-off-by: Aayush Gupta <[email protected]>
5f0396d
to
5cab0e3
Compare
…ePicker MaterialDatePicker is final and thus cannot be extended to handle loss of callback on configuration changes. We aren't using ViewModel as well that would help us to persist changes till lifecycle. Fallback to how DatePicker was handling this situation with a couple of more hacks. Signed-off-by: Aayush Gupta <[email protected]>
I'm not too fond of the last commit but cannot think of something better. When we will have ViewModel, half of this won't be required. |
Seems to work great now, thanks! A nice ViewModel structure would probably be a good improvement, but well, there's only so much time in each day so it is pretty low down my own priority list I'm afraid 😅 |
Summary
This PR migrates Catima to use the new MaterialDatePicker. MaterialDatePicker is already based on DialogFragment, thus drop the current fragment and use the picker directly.
Related Issue