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

3.3.1 update causes text to render weirdly with alpha effected by view background #201

Closed
peterdk opened this issue Nov 6, 2021 · 4 comments · Fixed by #202
Closed

3.3.1 update causes text to render weirdly with alpha effected by view background #201

peterdk opened this issue Nov 6, 2021 · 4 comments · Fixed by #202

Comments

@peterdk
Copy link
Contributor

peterdk commented Nov 6, 2021

Describe the bug
I updated from 3.3.0 to 3.3.1, without changing anything else. I now have my white text in the popups being blended with the background making it unreadable. I wanted to go for 3.3.1 since the text popup outside the circle at start was bothering me. Great library!

To Reproduce
Steps to reproduce the behaviour including how the prompt builder is created:

                 MaterialTapTargetPrompt.Builder(activity).setTarget(target)
                .setPrimaryText(primaryText)
                .setSecondaryText(secondaryText)
                .setFocalColour(activity.getResources().getColor(R.color.umito_orange_transparent))
                .setBackgroundColour(
                    activity.getResources().getColor(R.color.actionbar_grey_transparent)
                )
                .setPromptStateChangeListener { prompt, state ->
                    if (state == MaterialTapTargetPrompt.STATE_DISMISSED) {
                        showNextPrompt()
                    } else if (state == MaterialTapTargetPrompt.STATE_FOCAL_PRESSED) {
                        prompt.dismiss()
                    }
                }
                .setCaptureTouchEventOnFocal(true)
                .setCaptureTouchEventOutsidePrompt(true)
                .show()

Expected behavior
Text shows without being affected by views under background of the prompt

Screenshots
3.3.0:
3 3 0
3.3.1:
3 3 1

Smartphone (please complete the following information):

  • Device: Pixel 3a
  • OS: Android 12
  • Library version 3.3.1

Additional context
I think it has to do with the Xtransfer mode being set in #146

@peterdk
Copy link
Contributor Author

peterdk commented Nov 6, 2021

I did some tinkering with the code, and instead of the Xtransfermode in the PromptText, I just clip the text in MaterialTapTargetPrompt class with a new property of PromptBackground that supplies the background's path. Now hardware layer works as well, and no weird effects. I would say that is a better approach.

 //Draw the text
            Path backgroundPath = mPromptOptions.getPromptBackground().getPath();
            if (backgroundPath != null) {
                canvas.save();

                canvas.clipPath(backgroundPath, Region.Op.INTERSECT );
            }
            mPromptOptions.getPromptText().draw(canvas);
            if (backgroundPath != null) {
                canvas.restore();
            }

I can make a more official PR for it, and testing with the other backgrounds as well and implementing the path for them.

@peterdk
Copy link
Contributor Author

peterdk commented Nov 6, 2021

I created a PR, it fixes the issue. Let me know if it is acceptable or needs changing.

@danilodanicomendes
Copy link
Contributor

Damn, seems like I only thought of my use case with that xfermode change. Sorry about that.
To fix this, keeping PorterDuff, would definitely add a lot of complexity (if fixable at all)

I looked at your PR and I do agree that this is a better approach and more bullet proof for other use cases.

@peterdk
Copy link
Contributor Author

peterdk commented Nov 7, 2021

No problem, it was nice seeing someone having the same intent to fix the issue! You can't account for all cases, and I assume it worked for your case.

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