Skip to content
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

Updated context for Nougat and newer devices #197

Closed
wants to merge 1 commit into from

Conversation

DebdeepG
Copy link

Changed the argument of asActivity inside the EmojiPopup constructor to pass the root view.
Changed the parameter of asActivity() in the Utils class to accept view instead of context.
Added code for Nougat and later for getting context.
For Nougat and later, rootView.getContext() returns an instance of DecorContext and not an Activity , so now the execution will not stop inside the while loop causing an anr.

@DebdeepG DebdeepG changed the title Updated `context for Nougat and newer devices Updated context for Nougat and newer devices Aug 31, 2017
@DebdeepG DebdeepG changed the title Updated context for Nougat and newer devices Updated context for Nougat and newer devices - MultiWindowMode Aug 31, 2017
@DebdeepG DebdeepG changed the title Updated context for Nougat and newer devices - MultiWindowMode Updated context for Nougat and newer devices Aug 31, 2017
@vanniktech
Copy link
Owner

I'll look at this PR shortly. I'm rather busy at the moment.

Copy link
Owner

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

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

I'm not quite sure why this is needed. I'm running this library on multiple N devices and I'm having no errors / issues.

@DebdeepG
Copy link
Author

DebdeepG commented Sep 6, 2017

I ran it on Samsung galaxy S7 and it was returning DecorContext. I think I still need to figure out why did that happen.

@vanniktech
Copy link
Owner

@rubengees did this in #97 and AFAIR he took that method from the support library. Would be interesting to see whether they changed their implementation too or whether it's still the same.

@vanniktech
Copy link
Owner

Any news?

@DebdeepG
Copy link
Author

I tested on a couple of Nougat devices and most of them are returning DecorContext. While still some of them aren't. Due to the multi-window feature, the DecorView has no longer access to the activity but the application as a whole. Take a look at the setWindow() in DecorView class, so whenever getContext() returns DecorContext, the DecorContext has the phone window set. Also the extra api-check inside asActivity() isn't necessary.

@DebdeepG
Copy link
Author

Their code is still the same.

@vanniktech
Copy link
Owner

So I guess we should leave it too?

@DebdeepG
Copy link
Author

Can you test it on any device - say google nexus 6p - v7.1.2 in genymotion and see as it returns DecorContext

@DebdeepG
Copy link
Author

DebdeepG commented Sep 12, 2017

I guess it is not safe to assume an context(esp. from rootView) would always return an Activity. We can simply keep this rootView.findViewById(android.R.id.content).getContext() as it works on all devices.

@vanniktech
Copy link
Owner

I'll test it out tomorrow-ish, do I need to use the multi screen feature?

@DebdeepG
Copy link
Author

okay, no prob! No just make sure to debug the context while testing on genymotion on Nougat devices.

@vanniktech
Copy link
Owner

Will this also occur on normal devices or just when used together with Genymotion?

@DebdeepG
Copy link
Author

It occurs on Nougat and above - be it genymotion or hardware devices and I have seen that. My app was causing anr's on multiple devices due to the while check. Shall I send you a screenshot of the DecorContext while debugging ?

@DebdeepG
Copy link
Author

screenshot from 2017-09-13 01-24-19
Here have a look at the context.

@vanniktech
Copy link
Owner

I ran Emoji on the normal AVD simulator image with API 25 and had no problems :/

Could it be that the layout is somehow different?

@DebdeepG
Copy link
Author

DebdeepG commented Sep 15, 2017

Which device image did you test on ? Was it a generic or ones from the genymotion ? I guess so and I mentioned earlier that some of the devices didn't show that behaviour

@vanniktech
Copy link
Owner

Device: 2.7 QVGA Api 25

Which one are you using?

I'm still not that convinced that we need this change especially if the support lib still has the same code as we do plus.

@DebdeepG
Copy link
Author

Can you download and test on this image in genymotion - google nexus 6p - v7.1.2 for once. If it doesn't occur then this merge shouldn't be necessary.

@vanniktech
Copy link
Owner

I don't have genymotion installed anymore. Also it's not the official simulator. The google ones have become pretty good these days and if on those devices you can find the same behavior feel free to reopen this one. Otherwise I'll close this. Also I've always had a few problems with the keyboard on Genymotion and decided to not use it for developing this, instead you can just use a normal android smartphone.

@vanniktech vanniktech closed this Sep 25, 2017
@DebdeepG
Copy link
Author

Okay will reopen this in case I face it on any other device:)

@ghost
Copy link

ghost commented Oct 22, 2017

Hi, I'm new to github as a developer, so maybe I'll need some assistance to fix things..
I'm getting the exception thrown always on One Plus 5

@ghost
Copy link

ghost commented Oct 22, 2017

Okay, just saw the debugger screenshot. I'll try to see what's hapenning inside for me and update

@DebdeepG
Copy link
Author

I guess that's what is caused due to the multi window mode

@ghost
Copy link

ghost commented Oct 22, 2017 via email

@ghost
Copy link

ghost commented Oct 22, 2017 via email

This pull request was closed.
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.

2 participants