Skip to content

Added an onclick to the middle text of a Notification #1872

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

Merged
merged 2 commits into from
Nov 4, 2018

Conversation

befrou
Copy link
Contributor

@befrou befrou commented Sep 1, 2018

Enhancement issue #1862

Used a SpannableString to setup a ClickableSpan in the middle text of a Notification item so it works the same as when you click at the date in the right side or in the icon at the left.

Added on click to the "middle text" of a Notification item.
}
};

ss.setSpan(clickableSpan, 0, notificationText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment explaining the magic number "0" or make it a constant with an informative name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will add a comment.

@codecov-io
Copy link

codecov-io commented Sep 1, 2018

Codecov Report

Merging #1872 into master will increase coverage by 0.04%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1872      +/-   ##
=========================================
+ Coverage    3.61%   3.66%   +0.04%     
=========================================
  Files         188     189       +1     
  Lines        9839   10041     +202     
  Branches      873     916      +43     
=========================================
+ Hits          356     368      +12     
- Misses       9457    9646     +189     
- Partials       26      27       +1
Impacted Files Coverage Δ
...nrw/commons/notification/NotificationRenderer.java 0% <0%> (ø) ⬆️
...ain/java/fr/free/nrw/commons/utils/DialogUtil.java 0% <0%> (ø) ⬆️
...free/nrw/commons/upload/MultipleShareActivity.java 0% <0%> (ø) ⬆️
...ava/fr/free/nrw/commons/utils/PermissionUtils.java 0% <0%> (ø)
...n/java/fr/free/nrw/commons/CommonsApplication.java 31.81% <0%> (+3.74%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f52211...bda89a0. Read the comment docs.

Added comment to better explain method usage.
@albendz
Copy link
Contributor

albendz commented Sep 5, 2018

Testing the changes... sorry about the delay.

@albendz
Copy link
Contributor

albendz commented Sep 6, 2018

The build looks fine but how do I manually test this? I'm not sure how to trigger a notification. How did you test this?

@misaochan
Copy link
Member

Do you not already have any notifications in your Notifications activity (accessed via nav bar)? Usually you would have one just as a welcome, even if the acc is new.

@befrou
Copy link
Contributor Author

befrou commented Sep 6, 2018

I tested adding a Log function to the onclick then looked at the output in the logcat. If I am not mistaken I also tested modifying the onclick to open the notification.

@albendz
Copy link
Contributor

albendz commented Sep 6, 2018

@misaochan Unfortunately no, I don't have the welcome notification :(
@befrou Can you point me to what you modified to generate a notification?

@misaochan
Copy link
Member

@albendz What's your Commons username? One of us can send you a user talk message. :)

@albendz
Copy link
Contributor

albendz commented Sep 6, 2018

My user name is abendz. I will eagerly await the notification!

@albendz albendz closed this Sep 6, 2018
@albendz albendz reopened this Sep 6, 2018
@misaochan
Copy link
Member

Sent :)

@albendz
Copy link
Contributor

albendz commented Sep 6, 2018

Unfortunately it's not coming through the app. At this point we may want to ask someone else to test :(

@misaochan
Copy link
Member

misaochan commented Sep 7, 2018

No worries. However, could you please create a separate issue for your notifications problem, with a screenshot of what you see in the Notifications activity? As this might indicate an issue with notifications in general. Thanks!

(Edit: Just to clarify, we don't mean notifications in the Android sense. "Notifications" is an activity that is accessed via nav drawer, although we will soon be adding an icon to the main screen. Not sure if that was made clear. :))

@neslihanturan
Copy link
Collaborator

@albendz can you see your notifications from web interface of commons? If so we need to find out why your notifictions are not fetched.

I will be testing it, though

@albendz
Copy link
Contributor

albendz commented Sep 7, 2018

@neslihanturan I got the email about the talk message and it is showing in my notification history on the web. Thank you for picking up the testing.

@maskaravivek
Copy link
Member

@albendz It would be great if you could share logs. Notifications activity is known to crash if any notification contains a special character(PR #1766). There could be other issues related to the parsing of notifications that might be causing issues.

@albendz
Copy link
Contributor

albendz commented Sep 7, 2018

Alright, I'll create a second account and start talking to myself to generate notifications and get those logs :P

@albendz
Copy link
Contributor

albendz commented Sep 7, 2018

My problem: "You must be logged in."
I'm pretty sure I'm logged in though.

D/CustomApiResult: API response is <?xml version="1.0" encoding="UTF-8"?><api servedby="deployment-mediawiki-09"><error code="login-required" info="You must be logged in." xml:space="preserve">See https://commons.wikimedia.beta.wmflabs.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &amp;lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&amp;gt; for notice of API deprecations and breaking changes.</error></api> D/NotificationActivity: Number of notifications is 0

@misaochan
Copy link
Member

Oh! You need to be on a prod build variant, not beta. :)

@albendz
Copy link
Contributor

albendz commented Sep 7, 2018

I had tried on prod and wasn't getting any logs so I tried again using the beta website and the master branch of code to see if I could get notification and still wasn't but I was seeing this log. So, I retried this in master+beta and confirmed the web notifications are coming through but I'm still not able to get notifications on the phone. I couldn't see logs in the prod version.

@maskaravivek
Copy link
Member

@albendz Can you confirm what is the last commit in your master. We made a few fixes around authentication which was merged to master yesterday. Notifications should work both on beta and prod variants.

For prod you can use the following gradle task to make it debuggable:

:app:installProdDebug

@albendz
Copy link
Contributor

albendz commented Sep 8, 2018

This is the last master commit I have:
commit a63b9f8 (HEAD -> master, upstream/master, origin/master, origin/HEAD)
Author: Vivek Maskara maskaravivek@gmail.com
Date: Fri Sep 7 05:50:41 2018 +0530

I'm a little confused about why the PR uses prod and why master uses beta.

@maskaravivek
Copy link
Member

maskaravivek commented Sep 8, 2018

It's not that the PR uses prod. Some of the features in the app (eg. wiki data edits, upload count) work only on prod variant as the corresponding API for the beta environment isn't available. As far as notifications are concerned it should work both on beta and prod variant.

Beta:

Commons Web Url: https://commons.wikimedia.beta.wmflabs.org
Build:

:app:installBetaDebug

Commons Web URL: http://commons.wikimedia.org
Build:

:app:installProdDebug

If you check out our app's build.gradle you will find buildTypes where these URLs have been defined. Depending on the variant you are using, the app picks up which URL to use.

@misaochan
Copy link
Member

Additionally, the reason why we have the beta build variant to begin with, is to assist with testing. Testing certain features requires uploading a lot of pictures, and people don't always have pictures that are "Commons-worthy". The beta build variant lets you upload photos to the beta Commons server, which isn't the same as the REAL Commons server. So you can upload nonsense without worrying about spamming Commons. :)

Basically, use the beta build variant only when you really need to upload test pictures and don't want to pollute Commons.

@maskaravivek While notifications should work on both technically, I don't think cross-notifications is possible. So if I sent @albendz a message on the real Commons server, she wouldn't see anything in beta AFAIK?

@misaochan
Copy link
Member

I had tried on prod and wasn't getting any logs

@albendz Could we get a screencast of what happens when you try it, please? You can create a separate issue if you like. The problem now is not so much the testing of this PR, but rather that if notifications aren't working for someone, we need to figure out why.

@albendz
Copy link
Contributor

albendz commented Sep 10, 2018

Sure, I'll get a recording. Beta or prod?

@albendz
Copy link
Contributor

albendz commented Sep 16, 2018

@neslihanturan My issue aside, are you still working on testing this? Just want to make sure it doesn't get lost in the other issue.

@domdomegg domdomegg self-requested a review November 4, 2018 13:45
Copy link
Member

@domdomegg domdomegg left a comment

Choose a reason for hiding this comment

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

Tested tutorial, login, home, notifications, about page.

2.8.1-debug-pr-1872~bda89a0b on Samsung Galaxy S6 with API level 25
2.8.1-debug-pr-1872~bda89a0b on Galaxy Nexus (emulator) with API level 28

Results

  • Pages all okay
  • All my notifications show up, in the correct order
  • Notifications which don't have a url:
    • Icon gives tap animation
    • Middle text does nothing
    • Date gives tap animation
    • Show less/more works
  • Notifications which do have a url:
    • Icon gives tap animation and opens relevant page
    • Middle text opens relevant page
    • Date opens relevant page
    • Show less/more works

I'm happy to merge as everything is working. However, I'd suggest changes for the future as:

  • Have clicking on the middle text also show animation for consistency (also pressing and holding should make row darker shade like others)
  • Do something better with show more/show less:
    • As the target is small and the middle text link surrounds it, it's annoying to accidentally open the browser. Not sure how to fix this one, however I think having the functionality of clicking the text opening the browser is worth it.
    • All the times it's turned up for me it's not been helpful - with the 'show more' taking up more space than if it wasn't there. Maybe need to be less aggressive with it? item_notification.xml

A solution that might solve all of these issues is doing away with the "show more", and having the entire notification row be a link. Having a longer trimLength (I'm thinking like 280 chars) with an ellipsis if it's somehow over that should be okay. The user can view the commons website for the entire notification text if it's really long, if they're clicking through to the website anyways.

I've put these into two new issues, #1980 and #1981 to continue discussion.

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

Successfully merging this pull request may close these issues.

7 participants