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

add style, to readme. and also added the properties i just added of h… #31

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
97f27bf
add style, to readme. and also added the properties i just added of h…
Noitidart Feb 22, 2018
5d68e7f
Update RNPromptFragment.java
Noitidart Feb 22, 2018
4d870b7
Update RNPromptModule.java
Noitidart Feb 22, 2018
9b16846
RNPromptFragment.java updated for buttonColor and cust style name
Noitidart Mar 9, 2018
f9ab93b
RNPromptModule.java update for buttonColor
Noitidart Mar 9, 2018
cddf659
index.android.js for buttonColor
Noitidart Mar 9, 2018
8d4b760
Delete prompt_color.xml
Noitidart Mar 9, 2018
97f5166
Create colors.xml
Noitidart Mar 9, 2018
51a4b24
Update style.xml
Noitidart Mar 9, 2018
1dd31e5
Create cust_edit_text.xml
Noitidart Mar 9, 2018
7ee8ae5
how to use cust and also added buttonColor
Noitidart Mar 9, 2018
1293f23
Update index.android.js
Noitidart Mar 9, 2018
0a6c21b
Update index.android.js
Noitidart Mar 9, 2018
9b13e6c
Update RNPromptFragment.java
Noitidart Mar 9, 2018
8a3b945
added manual linking instructions to readme
Noitidart Mar 9, 2018
37f3e0c
Update README.md
Noitidart Mar 9, 2018
aa95548
Update README.md
Noitidart Mar 9, 2018
e8092ab
Update README.md
Noitidart Mar 9, 2018
a08841b
Fixes https://github.com/shimohq/react-native-prompt-android/issues/24
Noitidart Mar 9, 2018
dd428a8
Fixes https://github.com/shimohq/react-native-prompt-android/issues/26
Noitidart Mar 10, 2018
1aac796
fix typo disableFullscreenUI
Noitidart Mar 13, 2018
37ceddd
allow null buttonColor
Noitidart Mar 13, 2018
a3c1199
add screenshot with android options
Noitidart Mar 13, 2018
a1ab4db
add screenshot to readme
Noitidart Mar 13, 2018
3e2e89f
readme
Noitidart Mar 13, 2018
47c5cba
support the full color format (named, rgba, etc) thanks @jeanregisser!
Noitidart Mar 13, 2018
dcc7a0b
remove Color.parseColor as we do processColor now
Noitidart Mar 13, 2018
515e307
swithced to Integer type for colors - tested and it compiles
Noitidart Mar 13, 2018
e724872
better readme
Noitidart Mar 13, 2018
88ea270
added android options of onDismiss and onAny - closes https://github.…
Noitidart Mar 23, 2018
2f428e6
fixed readme typo highlightColor AARRGGBB to rgba
Noitidart Mar 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions android/src/main/java/im/shimo/react/prompt/RNPromptFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ public class RNPromptFragment extends DialogFragment implements DialogInterface.
/* package */ static final String ARG_DISABLE_FULL_SCREEN_UI = "disableFullscreenUI";
/* package */ static final String ARG_HIGHLIGHT_COLOR = "highlightColor";
/* package */ static final String ARG_COLOR = "color";
/* package */ static final String ARG_BUTTON_COLOR = "buttonColor";

private EditText mInputText;

private String mButtonColor;

public enum PromptTypes {
TYPE_DEFAULT("default"),
PLAIN_TEXT("plain-text"),
Expand Down Expand Up @@ -101,6 +104,12 @@ public Dialog createDialog(Context activityContext, Bundle arguments) {
builder.setItems(arguments.getCharSequenceArray(ARG_ITEMS), this);
}

if (arguments.containsKey(ARG_BUTTON_COLOR)) {
mButtonColor = arguments.getString(ARG_BUTTON_COLOR);
} else {
mButtonColor = "";
}

AlertDialog alertDialog = builder.create();

// input style
Expand All @@ -110,6 +119,9 @@ public Dialog createDialog(Context activityContext, Bundle arguments) {
case "shimo":
input = (EditText) inflater.inflate(R.layout.edit_text, null);
break;
case "cust":
input = (EditText) inflater.inflate(R.layout.cust_edit_text, null);
break;
default:
input = new EditText(activityContext);
}
Expand Down Expand Up @@ -198,6 +210,17 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
return dialog;
}

@Override
public void onStart() {

Choose a reason for hiding this comment

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

why not put code after to line 113?

Copy link
Author

@Noitidart Noitidart Mar 12, 2018

Choose a reason for hiding this comment

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

I wanted to. I actually tried to put it on line 91 - https://github.com/Noitidart/react-native-prompt-android/blob/dd428a864880209114ff9708f76e21e9d1937aa5/android/src/main/java/im/shimo/react/prompt/RNPromptFragment.java#L91 - where we initially work with postive button. However d.getButton returns null until after dialog shows. :(

This person here also encountered same issue - https://tassioauad.com/2016/06/02/dialogfragmentalertdialog-dismiss-automatically-on-click-button/

He says:

You will need to set this in the onResume() method because getButton() will return null until after the dialog has been shown! This should cause your custom action method to only be called once, and the dialog won’t be dismissed by default.

I also tried to ask on Stackoverflow, and other people have the same issue:

https://stackoverflow.com/questions/27520967/how-to-change-the-colour-of-positive-and-negative-button-in-custom-alert-dialog/27521470#comment85378535_27521470

Copy link
Author

Choose a reason for hiding this comment

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

@greedbell @wsong910 would you rather i make the change before accpeting PR? or would you like to find null cases and work around it?

super.onStart();

if (!mButtonColor.isEmpty()) {

Choose a reason for hiding this comment

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

I just tested this and it crashes as mButtonColor is null when not specifying this prop or when passed an empty string.

In JS buttonColor: options.buttonColor || null will set buttonColor to null if not specified or if it's an empty string.

Copy link
Author

Choose a reason for hiding this comment

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

Oh shoot i forgot to test for null. Thanks so much on this right away.

Copy link
Author

Choose a reason for hiding this comment

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

fixed thanks @jeanregisser!

AlertDialog d = (AlertDialog) getDialog();
d.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.parseColor(mButtonColor));

Choose a reason for hiding this comment

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

Since you now use processColor on the JS side, you need to remove all Color.parseColor and just take the Int value from the arguments.

Copy link
Author

Choose a reason for hiding this comment

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

done

d.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(Color.parseColor(mButtonColor));
}
}

@Override
public void onClick(DialogInterface dialog, int which) {
if (mListener != null) {
Expand Down