macaca-android
Advanced tools
Comparing version 1.1.26 to 1.1.27
@@ -8,2 +8,3 @@ 'use strict'; | ||
const _ = require('./helper'); | ||
const keyMap = require('./key-map'); | ||
const pkg = require('../package.json'); | ||
@@ -78,26 +79,27 @@ | ||
value = value.join(''); | ||
var content = ''; | ||
if (!!~value.indexOf('[ADB_INPUT_TEXT]')) { | ||
value = value.replace('[ADB_INPUT_TEXT]', ''); | ||
content = `am broadcast -a ADB_INPUT_TEXT --es msg '${value}'`; | ||
yield this.adb.shell(content); | ||
} else if (!!~value.indexOf('[ADB_INPUT_CHARS]')) { | ||
value = value.replace('[ADB_INPUT_CHARS]', ''); | ||
content = `am broadcast -a ADB_INPUT_CHARS --eia chars '${value}'`; | ||
yield this.adb.shell(content); | ||
} else if (!!~value.indexOf('[ADB_INPUT_CODE]')) { | ||
value = value.replace('[ADB_INPUT_CODE]', ''); | ||
content = `am broadcast -a ADB_INPUT_CODE --ei code '${value}'`; | ||
yield this.adb.shell(content); | ||
} else if (!!~value.indexOf('[ADB_EDITOR_CODE]')) { | ||
value = value.replace('[ADB_EDITOR_CODE]', ''); | ||
content = `am broadcast -a ADB_EDITOR_CODE --ei code '${value}'`; | ||
yield this.adb.shell(content); | ||
} else { | ||
value = value.split(''); | ||
const keyActions = value.map(key => { | ||
return () => this.adb.input(`text "${key}"`); | ||
}); | ||
yield _.serialTasks.apply(null, keyActions); | ||
var text = ''; | ||
for (var i = 0; i < value.length; i++) { | ||
var key = value.charAt(i); | ||
const keyEvent = keyMap[key]; | ||
if (keyEvent) { | ||
yield this.adb.input(`keyevent ${keyEvent}`); | ||
} else { | ||
text = text + key; | ||
if (i + 1 < value.length) { | ||
var nextKeyEvent = keyMap[value.charAt(i + 1)]; | ||
if (nextKeyEvent) { | ||
yield this.setValue('', text.split('')); | ||
text = ''; | ||
} | ||
} | ||
} | ||
} | ||
if (text !== '') { | ||
yield this.setValue('', text.split('')); | ||
} | ||
return null; | ||
@@ -104,0 +106,0 @@ }; |
{ | ||
"name": "macaca-android", | ||
"version": "1.1.26", | ||
"version": "1.1.27", | ||
"description": "Macaca Android driver", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
13
666
22063