(...args)
| 175 | } |
| 176 | |
| 177 | export function prompt(...args): Promise<PromptResult> { |
| 178 | let options: PromptOptions; |
| 179 | |
| 180 | const defaultOptions = { |
| 181 | title: DialogStrings.PROMPT, |
| 182 | okButtonText: DialogStrings.OK, |
| 183 | cancelButtonText: DialogStrings.CANCEL, |
| 184 | inputType: inputType.text, |
| 185 | }; |
| 186 | const arg = args[0]; |
| 187 | if (args.length === 1) { |
| 188 | if (isString(arg)) { |
| 189 | options = defaultOptions; |
| 190 | options.message = arg; |
| 191 | } else { |
| 192 | options = arg; |
| 193 | } |
| 194 | } else if (args.length === 2) { |
| 195 | if (isString(arg) && isString(args[1])) { |
| 196 | options = defaultOptions; |
| 197 | options.message = arg; |
| 198 | options.defaultText = args[1]; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | return new Promise<PromptResult>((resolve, reject) => { |
| 203 | try { |
| 204 | const alert = createAlertDialog(options); |
| 205 | |
| 206 | const input = new android.widget.EditText(androidUtils.getCurrentActivity()); |
| 207 | |
| 208 | if (options) { |
| 209 | if (options.inputType === inputType.password) { |
| 210 | input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD); |
| 211 | } else if (options.inputType === inputType.email) { |
| 212 | input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); |
| 213 | } else if (options.inputType === inputType.number) { |
| 214 | input.setInputType(android.text.InputType.TYPE_CLASS_NUMBER); |
| 215 | } else if (options.inputType === inputType.decimal) { |
| 216 | input.setInputType(android.text.InputType.TYPE_CLASS_NUMBER | android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL); |
| 217 | } else if (options.inputType === inputType.phone) { |
| 218 | input.setInputType(android.text.InputType.TYPE_CLASS_PHONE); |
| 219 | } |
| 220 | |
| 221 | switch (options.capitalizationType) { |
| 222 | case capitalizationType.all: { |
| 223 | input.setInputType(input.getInputType() | android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS); |
| 224 | break; |
| 225 | } |
| 226 | case capitalizationType.sentences: { |
| 227 | input.setInputType(input.getInputType() | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); |
| 228 | break; |
| 229 | } |
| 230 | case capitalizationType.words: { |
| 231 | input.setInputType(input.getInputType() | android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS); |
| 232 | break; |
| 233 | } |
| 234 | } |
nothing calls this directly
no test coverage detected