| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromoting; | 5 package org.chromium.chromoting; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
| 9 import android.os.Bundle; | 9 import android.os.Bundle; |
| 10 import android.util.Log; | 10 import android.util.Log; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).tog
gleSoftInput(0, 0); | 60 ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).tog
gleSoftInput(0, 0); |
| 61 return true; | 61 return true; |
| 62 case R.id.actionbar_hide: | 62 case R.id.actionbar_hide: |
| 63 getActionBar().hide(); | 63 getActionBar().hide(); |
| 64 return true; | 64 return true; |
| 65 default: | 65 default: |
| 66 return super.onOptionsItemSelected(item); | 66 return super.onOptionsItemSelected(item); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** Called when a hardware key is pressed, and usually when a software key i
s pressed. */ | 70 /** |
| 71 * Called once when a keyboard key is pressed, then again when that same key
is released. This |
| 72 * is not guaranteed to be notified of all soft keyboard events: certian key
boards might not |
| 73 * call it at all, while others might skip it in certain situations (e.g. sw
ipe input). |
| 74 */ |
| 71 @Override | 75 @Override |
| 72 public boolean dispatchKeyEvent(KeyEvent event) { | 76 public boolean dispatchKeyEvent(KeyEvent event) { |
| 73 JniInterface.keyboardAction(event.getKeyCode(), event.getAction() == Key
Event.ACTION_DOWN); | 77 boolean depressed = event.getAction() == KeyEvent.ACTION_DOWN; |
| 74 | 78 |
| 75 if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { | 79 switch (event.getKeyCode()) { |
| 76 // We stop this event from propagating further to prevent the keyboa
rd from closing. | 80 case KeyEvent.KEYCODE_AT: |
| 77 return true; | 81 JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depress
ed); |
| 82 JniInterface.keyboardAction(KeyEvent.KEYCODE_2, depressed); |
| 83 break; |
| 84 case KeyEvent.KEYCODE_POUND: |
| 85 JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depress
ed); |
| 86 JniInterface.keyboardAction(KeyEvent.KEYCODE_3, depressed); |
| 87 break; |
| 88 case KeyEvent.KEYCODE_STAR: |
| 89 JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depress
ed); |
| 90 JniInterface.keyboardAction(KeyEvent.KEYCODE_8, depressed); |
| 91 break; |
| 92 case KeyEvent.KEYCODE_PLUS: |
| 93 JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depress
ed); |
| 94 JniInterface.keyboardAction(KeyEvent.KEYCODE_EQUALS, depressed); |
| 95 break; |
| 96 default: |
| 97 // We try to send all other key codes to the host directly. |
| 98 JniInterface.keyboardAction(event.getKeyCode(), depressed); |
| 99 |
| 100 if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER || |
| 101 event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_ENTER) { |
| 102 // We stop this key from propagating to prevent the keyboard
from closing. |
| 103 return true; |
| 104 } |
| 78 } | 105 } |
| 79 | 106 |
| 80 return super.dispatchKeyEvent(event); | 107 return super.dispatchKeyEvent(event); |
| 81 } | 108 } |
| 82 } | 109 } |
| OLD | NEW |