Skip to content

Handle special characters in notification title #1766

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

Closed

Conversation

maskaravivek
Copy link
Member

Title (required)

Fixes #1600

Description (required)

Fixes #1600 where notification activity was crashing as soon as it was opened. It was happening for a subset of users who had special characters(read characters in other scripts). Have simply added a try catch handling for such cases as I wasn't able to find an elegant solution.

Tests performed (required)

Not reproducible for me. @neslihanturan Can you help in testing this. :)

@codecov-io
Copy link

Codecov Report

Merging #1766 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1766   +/-   ##
======================================
  Coverage    3.63%   3.63%           
======================================
  Files         182     182           
  Lines        9154    9154           
  Branches      795     794    -1     
======================================
  Hits          333     333           
  Misses       8799    8799           
  Partials       22      22
Impacted Files Coverage Δ
...ee/nrw/commons/notification/NotificationUtils.java 0% <0%> (ø) ⬆️
...nrw/commons/notification/NotificationRenderer.java 0% <0%> (ø) ⬆️

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 3e5a663...b053f46. Read the comment docs.

@neslihanturan
Copy link
Collaborator

neslihanturan commented Jul 30, 2018

Now it gives this error after notifications are displayed:

 FATAL EXCEPTION: main
                                                                         Process: fr.free.nrw.commons.debug, PID: 3839
                                                                         java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable()' on a null object reference
                                                                             at android.graphics.drawable.LayerDrawable$ChildDrawable.<init>(LayerDrawable.java:1723)
                                                                             at android.graphics.drawable.LayerDrawable$LayerState.<init>(LayerDrawable.java:1792)
                                                                             at android.graphics.drawable.TransitionDrawable$TransitionState.<init>(TransitionDrawable.java:248)
                                                                             at android.graphics.drawable.TransitionDrawable.createConstantState(TransitionDrawable.java:101)
                                                                             at android.graphics.drawable.LayerDrawable.mutate(LayerDrawable.java:1652)
                                                                             at android.widget.ImageView.applyImageTint(ImageView.java:560)
                                                                             at android.widget.ImageView.updateDrawable(ImageView.java:895)
                                                                             at android.widget.ImageView.setImageDrawable(ImageView.java:472)
                                                                             at android.support.v7.widget.AppCompatImageView.setImageDrawable(AppCompatImageView.java:99)
                                                                             at com.bumptech.glide.request.target.ImageViewTarget.setDrawable(ImageViewTarget.java:56)
                                                                             at com.bumptech.glide.request.transition.DrawableCrossFadeTransition.transition(DrawableCrossFadeTransition.java:57)
                                                                             at com.bumptech.glide.request.transition.DrawableCrossFadeTransition.transition(DrawableCrossFadeTransition.java:15)
                                                                             at com.bumptech.glide.request.target.ImageViewTarget.onResourceReady(ImageViewTarget.java:103)
                                                                             at com.bumptech.glide.request.SingleRequest.onResourceReady(SingleRequest.java:579)
                                                                             at com.bumptech.glide.request.SingleRequest.onResourceReady(SingleRequest.java:549)
                                                                             at com.bumptech.glide.load.engine.EngineJob.handleResultOnMainThread(EngineJob.java:218)
                                                                             at com.bumptech.glide.load.engine.EngineJob$MainThreadCallback.handleMessage(EngineJob.java:324)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                             at android.os.Looper.loop(Looper.java:148)```

@maskaravivek
Copy link
Member Author

@neslihanturan Can you share the response object for your notification? This seems to be a different error.

@maskaravivek maskaravivek changed the base branch from master to 2.8-release August 4, 2018 16:14
@maskaravivek maskaravivek force-pushed the notificationCrashFix branch from b053f46 to ecf70eb Compare August 4, 2018 16:15
@neslihanturan
Copy link
Collaborator

Sure, here:
08-20 00:24:27.193 5147-5147/fr.free.nrw.commons.debug D/deneme notification is: ‪Wikimedia Commons We...‬ left a message on your talk page. , type is:EDIT_USER_TALK You just made your first edit; thank you, and welcome! , type is:THANK_YOU_EDIT You just made your tenth edit; thank you, and please keep going! , type is:THANK_YOU_EDIT ‪Jæ‬ left a message on your talk page. , type is:EDIT_USER_TALK ‪Jæ‬ left a message on your talk page. , type is:EDIT_USER_TALK You just made your hundredth edit; thank you very much! , type is:THANK_YOU_EDIT
And it actually displays notifications first as in picture, then crashes:
image

Lastly given error is:
Process: fr.free.nrw.commons.debug, PID: 5282 java.lang.NullPointerException at android.graphics.drawable.LayerDrawable$LayerState.<init>(LayerDrawable.java:671) at android.graphics.drawable.TransitionDrawable$TransitionState.<init>(TransitionDrawable.java:249) at android.graphics.drawable.TransitionDrawable.createConstantState(TransitionDrawable.java:101) at android.graphics.drawable.LayerDrawable.mutate(LayerDrawable.java:608) at android.widget.ImageView.applyColorMod(ImageView.java:1216) at android.widget.ImageView.updateDrawable(ImageView.java:716) at android.widget.ImageView.setImageDrawable(ImageView.java:421) at android.support.v7.widget.AppCompatImageView.setImageDrawable(AppCompatImageView.java:99) at com.bumptech.glide.request.target.ImageViewTarget.setDrawable(ImageViewTarget.java:56) at com.bumptech.glide.request.transition.DrawableCrossFadeTransition.transition(DrawableCrossFadeTransition.java:57) at com.bumptech.glide.request.transition.DrawableCrossFadeTransition.transition(DrawableCrossFadeTransition.java:15) at com.bumptech.glide.request.target.ImageViewTarget.onResourceReady(ImageViewTarget.java:103) at com.bumptech.glide.request.SingleRequest.onResourceReady(SingleRequest.java:579) at com.bumptech.glide.request.SingleRequest.onResourceReady(SingleRequest.java:549) at com.bumptech.glide.load.engine.EngineJob.handleResultOnMainThread(EngineJob.java:218) at com.bumptech.glide.load.engine.EngineJob$MainThreadCallback.handleMessage(EngineJob.java:324) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:136)

@neslihanturan
Copy link
Collaborator

Can it be related with loading icon drawables?

@neslihanturan
Copy link
Collaborator

Update: It also crashes with same error on API level 23, as in 19. So it seems like independent from API level, probably my notifications trigger this crash. I feel like there is an uncovered case about drawables and notification types.

@maskaravivek maskaravivek deleted the notificationCrashFix branch September 12, 2018 20:25
@maskaravivek maskaravivek restored the notificationCrashFix branch September 12, 2018 20:25
@maskaravivek maskaravivek deleted the notificationCrashFix branch September 12, 2018 20:26
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.

5 participants