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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
9 import android.os.Build; | 9 import android.os.Build; |
10 import android.os.Bundle; | 10 import android.os.Bundle; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 @Override | 65 @Override |
66 protected void onStart() { | 66 protected void onStart() { |
67 super.onStart(); | 67 super.onStart(); |
68 mActivityLifecycleListener.onActivityStarted(this); | 68 mActivityLifecycleListener.onActivityStarted(this); |
69 } | 69 } |
70 | 70 |
71 @Override | 71 @Override |
72 protected void onPause() { | 72 protected void onPause() { |
73 if (isFinishing()) { | 73 if (isFinishing()) mActivityLifecycleListener.onActivityPaused(this); |
74 mActivityLifecycleListener.onActivityPaused(this); | 74 super.onPause(); |
75 } | |
76 super.onPause(); | |
77 } | 75 } |
78 | 76 |
79 @Override | 77 @Override |
80 public void onResume() { | 78 public void onResume() { |
81 super.onResume(); | 79 super.onResume(); |
82 mActivityLifecycleListener.onActivityResumed(this); | 80 mActivityLifecycleListener.onActivityResumed(this); |
83 } | 81 } |
84 | 82 |
85 @Override | 83 @Override |
86 protected void onStop() { | 84 protected void onStop() { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 boolean pressed = event.getAction() == KeyEvent.ACTION_DOWN; | 243 boolean pressed = event.getAction() == KeyEvent.ACTION_DOWN; |
246 | 244 |
247 // For Enter getUnicodeChar() returns 10 (line feed), but we still | 245 // For Enter getUnicodeChar() returns 10 (line feed), but we still |
248 // want to send it as KeyEvent. | 246 // want to send it as KeyEvent. |
249 int unicode = keyCode != KeyEvent.KEYCODE_ENTER ? event.getUnicodeChar()
: 0; | 247 int unicode = keyCode != KeyEvent.KEYCODE_ENTER ? event.getUnicodeChar()
: 0; |
250 | 248 |
251 boolean no_modifiers = !event.isAltPressed() && | 249 boolean no_modifiers = !event.isAltPressed() && |
252 !event.isCtrlPressed() && !event.isMetaPressed(); | 250 !event.isCtrlPressed() && !event.isMetaPressed(); |
253 | 251 |
254 if (event.getDeviceId() == KeyCharacterMap.VIRTUAL_KEYBOARD && | 252 if (event.getDeviceId() == KeyCharacterMap.VIRTUAL_KEYBOARD && |
255 pressed && unicode != 0 && no_modifiers) { | 253 pressed && unicode != 0 && no_modifiers) { |
256 mPressedTextKeys.add(keyCode); | 254 mPressedTextKeys.add(keyCode); |
257 int[] codePoints = { unicode }; | 255 int[] codePoints = { unicode }; |
258 JniInterface.sendTextEvent(new String(codePoints, 0, 1)); | 256 JniInterface.sendTextEvent(new String(codePoints, 0, 1)); |
259 return true; | 257 return true; |
260 } | 258 } |
261 | 259 |
262 if (!pressed && mPressedTextKeys.contains(keyCode)) { | 260 if (!pressed && mPressedTextKeys.contains(keyCode)) { |
263 mPressedTextKeys.remove(keyCode); | 261 mPressedTextKeys.remove(keyCode); |
264 return true; | 262 return true; |
265 } | 263 } |
(...skipping 18 matching lines...) Expand all Loading... |
284 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT, pressed); | 282 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT, pressed); |
285 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_EQUALS, pressed); | 283 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_EQUALS, pressed); |
286 return true; | 284 return true; |
287 | 285 |
288 default: | 286 default: |
289 // We try to send all other key codes to the host directly. | 287 // We try to send all other key codes to the host directly. |
290 return JniInterface.sendKeyEvent(keyCode, pressed); | 288 return JniInterface.sendKeyEvent(keyCode, pressed); |
291 } | 289 } |
292 } | 290 } |
293 } | 291 } |
OLD | NEW |