GitHub user chemerisuk opened a pull request:
https://github.com/apache/cordova-plugin-dialogs/pull/69
Added options to customize keyboard for prompt and theme on Andorid
Hi. I found that ability to customize keyboard on the `prompt` dialog is
very useful. For example, if you expect a user to enter PIN code or phone
number you do not need letters etc. There are
[some](https://github.com/Paldom/PinDialog)
[plugins](https://www.npmjs.com/package/cordova-plugin-number-dialog) that aim
to solve this problem, but the solution they provide is limited. I prefer
flexibility.
Every platform has its own mechanic to customize keyboard for a text input,
but at least Android and iOS have common part - both use some kind of `flags`
parameter (check
http://developer.android.com/reference/android/text/InputType.html and
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/#//apple_ref/c/tdef/UIKeyboardType).
I've done very basic implementation and put extra parameter `inputType` which
is of course a platform specific.
This is how you can implement a prompt for a phone number:
```js
navigator.notification.promptPhone = function(message, callback,
dialogTitle, buttonLabels, defaultText) {
var inputType;
if (cordova.platformId === "ios") {
inputType = 5;
} else if (cordova.platformId === "android") {
inputType = 3;
}
return navigator.notification.prompt(message, callback, dialogTitle,
buttonLabels, defaultText, inputType);
}
```
I think the implementation can be improved, because I haven't done anything
for other platforms. So feel free to make your comments.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/chemerisuk/cordova-plugin-dialogs master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cordova-plugin-dialogs/pull/69.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #69
----
commit 4c2d0732b254887edb521670a529160e0ef8a90b
Author: Maksim Chemerisuk <[email protected]>
Date: 2016-03-01T14:17:17Z
add themes support for android
commit d0be912ac17e876ed64e4ca53e81919c8435884f
Author: Maksim Chemerisuk <[email protected]>
Date: 2016-03-01T14:20:21Z
add inputType support for android
commit 4e10a31ca913dd455a0e80def8d491e861580959
Author: Maksim Chemerisuk <[email protected]>
Date: 2016-03-01T14:31:42Z
fix typo
commit 23ec6345fae405d8cc66eb6db44065d1175e5031
Author: Maksim Chemerisuk <[email protected]>
Date: 2016-03-01T14:47:41Z
update arguments order for prompt dialog
commit b35b536b3c794d1336dd4c0731c26b711fb183cb
Author: Maksim Chemerisuk <[email protected]>
Date: 2016-03-02T11:12:34Z
implement inputType argumnet support for iOS
commit acc411c8420a52ef8706e392c9bc479020011e14
Author: Maksim Chemerisuk <[email protected]>
Date: 2016-03-02T12:33:38Z
update jsdocs for the inputType parameter
commit dae3ef6f45485dafe43646d3e33653c9a49f387f
Author: Maksim Chemerisuk <[email protected]>
Date: 2016-03-18T10:50:10Z
default inputType is undefined
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]