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

feat(alert): use support library for alert dialog #29832

Closed
wants to merge 7 commits into from

Conversation

DomiR
Copy link

@DomiR DomiR commented Sep 2, 2020

Summary

Instead of using the AlertDialog from the android library we use the AlertDialog from the support library to render dialogs properly on Lollipop phones.

Changelog

[Android] [Fixed] - Fix AlertDialog for older android devices by using AlertDialog from the androidx support library

Test Plan

Visual inspection.
With old AlertDialog:
ddd1692b-2bcb-424a-9355-1b54515c6618 - Donald Duck (1)

With compat AlertDialog:
Screenshot_1973-06-21-21-23-28

@facebook-github-bot
Copy link
Contributor

Hi @DomiR!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Sep 2, 2020
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 2, 2020
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@analysis-bot
Copy link

analysis-bot commented Sep 2, 2020

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 02fed06

@safaiyeh
Copy link
Contributor

safaiyeh commented Sep 2, 2020

cc @dulmandakh

Copy link
Contributor

@dulmandakh dulmandakh left a comment

Choose a reason for hiding this comment

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

LGTM

@DomiR
Copy link
Author

DomiR commented Sep 2, 2020

I don't know how to fix the BUCK files... circleci doesn't seem to build properly, but I compiled it on my machine and the result can be seen above.

@DomiR
Copy link
Author

DomiR commented Sep 2, 2020

I can't wait for the next release and I'm scared to roll with my own fork for my app release 😅

Here https://github.com/DomiR/react-native-compat-alert is reimplementation of the module, that uses androidx.appcompat.app.AlertDialog. Would be nice to see this in the next release.

@dulmandakh
Copy link
Contributor

Please remove everything in provided_deps, and add react_native_dep("third-party/android/androidx:appcompat")

@DomiR
Copy link
Author

DomiR commented Sep 3, 2020

@dulmandakh there is still some BUCK file for the test build that needs updating... any ideas?

@dulmandakh
Copy link
Contributor

You find a file that fails to compile, and usually there is a BUCK file in the same folder which might require change.

@dulmandakh
Copy link
Contributor

I dug a little bit, and couldn't a fix the test failure. It seems like AppCompat components require themed context, ThemedReactContext in RN case, but RN passes ReactApplicationContext to modules constructor which is used by DialogModule to show AlertDialog. Thus tests are failing. Please help @mdvacca

@camilossantos2809
Copy link

Any updates? I have an app that is used a lot on devices with android 5/lollipop, this improvement would help me a lot. Thanks!

@DomiR
Copy link
Author

DomiR commented Jan 6, 2021

Sucks that internal Facebook build tools are not the OS way. It builds for me, but BUCK needs to be configured differently to allow those tests to pass.

In the meantime you can use my fork, which only replaces that import, with the one from androidx: https://github.com/DomiR/react-native-compat-alert

@safaiyeh
Copy link
Contributor

safaiyeh commented Jan 6, 2021

What versions of Android does this aim to fix?

@DomiR
Copy link
Author

DomiR commented Jan 6, 2021

I think Lollipop and earlier... other components also use the androidx compact lib, so it's not something unusual. Without compat the Alert works on older phones with the limitations mentioned above (no vertical button stacking, overflow on small devices).

@github-actions
Copy link

github-actions bot commented Jul 7, 2023

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 7, 2023
@github-actions
Copy link

This PR was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants