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

Notification enhancement #31

Merged
merged 6 commits into from
Sep 8, 2016

Conversation

auricgoldfinger
Copy link
Contributor

@auricgoldfinger auricgoldfinger commented Sep 7, 2016

Description

Enhanced the notifications for birthdays:

  • In case of only one birthday, show the name and the age
  • In case of multiple birthdays:
    • If the notification is collapsed, keep the original behaviour except for the number of events (right bottom of notification) which now displays the number of birthdays
    • If the notification is expanded, show the name of each person and their age
Test(s) added

no. Frankly I don't know how I could test this 😄

Screenshots

In case of only one birthday
_20160907_204043

In case of multiple birthdays:
Collapsed
screenshot_2016-09-08-10-06-25

Expanded
screenshot_2016-09-08-09-48-41

@auricgoldfinger
Copy link
Contributor Author

Oh btw. Today is not my birthday.

.setContentIntent(intent)
.setNumber(events.getContactCount())
Copy link
Owner

Choose a reason for hiding this comment

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

This is done right before displaying the notification (https://github.com/alexstyl/Memento-Namedays/pull/31/files#diff-a57d0b3fb13451a13012ab3380f979cfR155) so it is going to be overridden eventually.

Can you remove the later one and keep yours as part of this PR please?

@alexstyl
Copy link
Owner

alexstyl commented Sep 7, 2016

This looks great! I have added some comments in the PR that needs fixing.

Don't worry about the testing. The class was written a couple of years ago when I didn't really know how to structure my code properly for testing, so it definitely needs work on my end 💃

@@ -19,6 +19,7 @@
<string name="today_celebrates_one">%1$s</string>
<string name="today_celebrates_two">%1$s and %2$s</string>
<string name="today_celebrates_many">%1$s and %2$d others</string>
<string name="age_today">%1$s %2$d today</string>
Copy link
Owner

@alexstyl alexstyl Sep 7, 2016

Choose a reason for hiding this comment

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

The app uses a "Turns X" (see string "turns_age") when communicating birthdays with age to the user.
Instead of using a new string, I would prefer if you use the existing one instead and add the name of the contact programmatically.

 - remove second .setNumber() on builder
 - remove final keyword
 - use turn_age in stead of new age_today
@auricgoldfinger
Copy link
Contributor Author

auricgoldfinger commented Sep 8, 2016

So I applied your remarks and now the notification looks like this

screenshot_2016-09-08-10-06-25

screenshot_2016-09-08-09-48-41


String lineFormatted = name;

if (EventType.BIRTHDAY.equals(event.getType())) {
Copy link
Owner

@alexstyl alexstyl Sep 8, 2016

Choose a reason for hiding this comment

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

❌ This is hard to extend. What happens when more events are added in the future? We would have to check all bits of code that do checks with specific events.

Also, a Birthday might not include a year of birth, which means that the following bit will throw an exception if the contact does not have a specified year of birth.

You could just copy-paste the getLabelFor() method. It checks only for that special case, and fallbacks to using the label of the eventType if there is no special case.

Don't worry about the code duplication from the other class. I'll solve it nicely in a later PR :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy Paste! Oh no!
...
Well, ok then. I'm not yet familiar enough with your code so I'm going to leave such a refactoring up to you. Let me add a big TODO and deprecated so that it can be found later.

I'm going to create an issue as well so that it is not forgotten

@alexstyl
Copy link
Owner

alexstyl commented Sep 8, 2016

Just one more comment and we are good to go 💯

Also, please update the PR description with the updated screenshot

@@ -114,8 +167,6 @@ public void forDailyReminder(ContactEvents events) {
builder.setPublicVersion(publicNotification.build());
}

builder.setNumber(contactCount);
Copy link
Owner

Choose a reason for hiding this comment

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

👍

@alexstyl
Copy link
Owner

alexstyl commented Sep 8, 2016

screen shot 2016-09-08 at 10 22 03

😱 Don't create commit messages like that! They are not informative of what is going on at all

The first commits messages you did were great 😄

@auricgoldfinger
Copy link
Contributor Author

auricgoldfinger commented Sep 8, 2016

I know. But the information is there when you click the ...
Git commit guidelines say the short descriptions must be only 50 characters long and I couldn't find a short description that contained all the changes 😃

Event labels are centralized this way. Fallback will make sure new
events will be handled automatically
+ check whether birthday includes a year to avoid NPE's

This method is copy-pased from ContactEventView and must be refactored.
@alexstyl
Copy link
Owner

alexstyl commented Sep 8, 2016

Good point, but not everyone is going through the history through Github ;)
Then again, I don't mention anything in the How to contribute section so jokes on me 😛

An alternative is to have one commit per change so that you can actually checkout the specific change at any time.

@@ -188,6 +179,27 @@ public void forDailyReminder(ContactEvents events) {

}

/**
* TODO duplicated from {@link com.alexstyl.specialdates.upcoming.ui.ContactEventView#getLabelFor(ContactEvent)}
Copy link
Owner

Choose a reason for hiding this comment

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

👍

@auricgoldfinger
Copy link
Contributor Author

Yeah indeed. In this case, that would have been a better idea. I have to get used to checking in very small changes though. I'm used to SVN and try to avoid too many small commits. But Git works better that way I guess...

@alexstyl alexstyl added this to the Exposed Search milestone Sep 8, 2016
@alexstyl
Copy link
Owner

alexstyl commented Sep 8, 2016

Thanks for the contribution. It is going to be included in the next update of the app 💯

@alexstyl alexstyl merged commit dc80bd5 into alexstyl:develop Sep 8, 2016
@auricgoldfinger auricgoldfinger deleted the notification-enhancement branch September 8, 2016 10:04
@alexstyl alexstyl mentioned this pull request Sep 18, 2016
alexstyl added a commit that referenced this pull request Jul 4, 2020
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.

None yet

2 participants