| 226 | } |
| 227 | |
| 228 | private void setupEntry() { |
| 229 | runOnUiThread(new Runnable() { |
| 230 | @Override |
| 231 | public void run() { |
| 232 | mTextEdit = new EditText(goNativeActivity); |
| 233 | mTextEdit.setVisibility(View.GONE); |
| 234 | mTextEdit.setInputType(DEFAULT_INPUT_TYPE); |
| 235 | |
| 236 | FrameLayout.LayoutParams mEditTextLayoutParams = new FrameLayout.LayoutParams( |
| 237 | FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); |
| 238 | mTextEdit.setLayoutParams(mEditTextLayoutParams); |
| 239 | addContentView(mTextEdit, mEditTextLayoutParams); |
| 240 | |
| 241 | // always place one character so all keyboards can send backspace |
| 242 | mTextEdit.setText("0"); |
| 243 | mTextEdit.setSelection(mTextEdit.getText().length()); |
| 244 | |
| 245 | mTextEdit.addTextChangedListener(new TextWatcher() { |
| 246 | @Override |
| 247 | public void onTextChanged(CharSequence s, int start, int before, int count) { |
| 248 | if (ignoreKey) { |
| 249 | return; |
| 250 | } |
| 251 | if (count > 0) { |
| 252 | keyboardTyped(s.subSequence(start, start + count).toString()); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | @Override |
| 257 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
| 258 | if (ignoreKey) { |
| 259 | return; |
| 260 | } |
| 261 | if (count > 0) { |
| 262 | for (int i = 0; i < count; i++) { |
| 263 | // send a backspace |
| 264 | keyboardDelete(); |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | @Override |
| 270 | public void afterTextChanged(Editable s) { |
| 271 | // always place one character so all keyboards can send backspace |
| 272 | if (s.length() < 1) { |
| 273 | ignoreKey = true; |
| 274 | mTextEdit.setText("0"); |
| 275 | mTextEdit.setSelection(mTextEdit.getText().length()); |
| 276 | ignoreKey = false; |
| 277 | return; |
| 278 | } |
| 279 | } |
| 280 | }); |
| 281 | } |
| 282 | }); |
| 283 | } |
| 284 | |
| 285 | @Override |