Skip to content

Commit d1474c3

Browse files
authored
Add prop to change the title of IntentChooser on Android (#159)
* Allow custom IntentChooser Title on Android * customChooserTitle prop added to example * Add default value to comment in example
1 parent 8c289a6 commit d1474c3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export default class App extends Component {
124124
ccRecipients: ['supportCC@example.com'],
125125
bccRecipients: ['supportBCC@example.com'],
126126
body: '<b>A Bold Body</b>',
127+
customChooserTitle: "This is my new title", // Android only (defaults to "Send Mail")
127128
isHTML: true,
128129
attachments: [{
129130
path: '', // The absolute path of the file from which to read data.

android/src/main/java/com/chirag/RNMail/RNMailModule.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,13 @@ public void mail(ReadableMap options, Callback callback) {
122122
callback.invoke("error");
123123
}
124124
} else {
125-
Intent chooser = Intent.createChooser(i, "Send Mail");
125+
String chooserTitle = "Send Mail";
126+
127+
if (options.hasKey("customChooserTitle") && !options.isNull("customChooserTitle")) {
128+
chooserTitle = options.getString("customChooserTitle");
129+
}
130+
131+
Intent chooser = Intent.createChooser(i, chooserTitle);
126132
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
127133

128134
try {

0 commit comments

Comments
 (0)