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 52 matching lines...) Loading... | |
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 /** Called when a hardware key is pressed, and usually when a software key i s pressed. */ |
71 @Override | 71 @Override |
72 public boolean dispatchKeyEvent(KeyEvent event) { | 72 public boolean dispatchKeyEvent(KeyEvent event) { |
73 JniInterface.keyboardAction(event.getKeyCode(), event.getAction() == Key Event.ACTION_DOWN); | 73 boolean depressed = event.getAction() == KeyEvent.ACTION_DOWN; |
74 | 74 |
75 if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { | 75 switch (event.getKeyCode()) { |
76 // We stop this event from propagating further to prevent the keyboa rd from closing. | 76 case KeyEvent.KEYCODE_AT: |
77 return true; | 77 JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depress ed); |
78 JniInterface.keyboardAction(KeyEvent.KEYCODE_2, depressed); | |
garykac
2013/07/30 17:50:05
Don't you need to release the SHIFT key here as we
solb
2013/07/30 18:28:54
I do. This method gets invoked once for the key do
| |
79 break; | |
80 case KeyEvent.KEYCODE_POUND: | |
81 JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depress ed); | |
82 JniInterface.keyboardAction(KeyEvent.KEYCODE_3, depressed); | |
83 break; | |
84 case KeyEvent.KEYCODE_STAR: | |
85 JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depress ed); | |
86 JniInterface.keyboardAction(KeyEvent.KEYCODE_8, depressed); | |
87 break; | |
88 case KeyEvent.KEYCODE_PLUS: | |
89 JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depress ed); | |
90 JniInterface.keyboardAction(KeyEvent.KEYCODE_EQUALS, depressed); | |
91 break; | |
92 default: | |
93 // We try to send all other key codes to the host directly. | |
94 JniInterface.keyboardAction(event.getKeyCode(), depressed); | |
95 | |
96 if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { | |
97 // We stop this key from propagating to prevent the keyboard from closing. | |
98 return true; | |
99 } | |
78 } | 100 } |
79 | 101 |
80 return super.dispatchKeyEvent(event); | 102 return super.dispatchKeyEvent(event); |
81 } | 103 } |
82 } | 104 } |
OLD | NEW |