Chromium Code Reviews| 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.app.AlertDialog; | 8 import android.app.AlertDialog; |
| 9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 private DesktopView mRemoteHostDesktop; | 70 private DesktopView mRemoteHostDesktop; |
| 71 | 71 |
| 72 /** Set of pressed keys for which we've sent TextEvent. */ | 72 /** Set of pressed keys for which we've sent TextEvent. */ |
| 73 private Set<Integer> mPressedTextKeys = new TreeSet<Integer>(); | 73 private Set<Integer> mPressedTextKeys = new TreeSet<Integer>(); |
| 74 | 74 |
| 75 private ActivityLifecycleListener mActivityLifecycleListener; | 75 private ActivityLifecycleListener mActivityLifecycleListener; |
| 76 | 76 |
| 77 /** Flag to indicate whether the current activity is switching to Cardboard desktop activity. */ | 77 /** Flag to indicate whether the current activity is switching to Cardboard desktop activity. */ |
| 78 private boolean mSwitchToCardboardDesktopActivity; | 78 private boolean mSwitchToCardboardDesktopActivity; |
| 79 | 79 |
| 80 /** Flag to indicate whether to manually hide the system UI when the OSK is dismissed. */ | |
|
Lambros
2016/01/29 19:09:57
Avoid OSK abbreviation, maybe just "keyboard" or "
joedow
2016/01/29 19:31:17
Done.
| |
| 81 private boolean mHideSystemUIOnOskDismiss = false; | |
| 82 | |
| 80 /** Indicates whether a Soft Input UI (such as a keyboard) is visible. */ | 83 /** Indicates whether a Soft Input UI (such as a keyboard) is visible. */ |
| 81 private boolean mSoftInputVisible = false; | 84 private boolean mSoftInputVisible = false; |
| 82 | 85 |
| 83 /** Holds the scheduled task object which will be called to hide the ActionB ar. */ | 86 /** Holds the scheduled task object which will be called to hide the ActionB ar. */ |
| 84 private Runnable mActionBarAutoHideTask; | 87 private Runnable mActionBarAutoHideTask; |
| 85 | 88 |
| 86 /** The Toolbar instance backing our SupportActionBar. */ | 89 /** The Toolbar instance backing our SupportActionBar. */ |
| 87 private Toolbar mToolbar; | 90 private Toolbar mToolbar; |
| 88 | 91 |
| 89 /** Tracks the current input mode (e.g. trackpad/touch). */ | 92 /** Tracks the current input mode (e.g. trackpad/touch). */ |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 int flags = 0; | 383 int flags = 0; |
| 381 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | 384 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| 382 flags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; | 385 flags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; |
| 383 flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; | 386 flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; |
| 384 flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; | 387 flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; |
| 385 } | 388 } |
| 386 return flags; | 389 return flags; |
| 387 } | 390 } |
| 388 | 391 |
| 389 public void showActionBar() { | 392 public void showActionBar() { |
| 393 mHideSystemUIOnOskDismiss = false; | |
| 394 | |
| 390 // Request exit from any fullscreen mode. The action-bar controls will b e shown in response | 395 // Request exit from any fullscreen mode. The action-bar controls will b e shown in response |
| 391 // to the SystemUiVisibility notification. The visibility of the action- bar should be tied | 396 // to the SystemUiVisibility notification. The visibility of the action- bar should be tied |
| 392 // to the fullscreen state of the system, so there's no need to explicit ly show it here. | 397 // to the fullscreen state of the system, so there's no need to explicit ly show it here. |
| 393 int flags = View.SYSTEM_UI_FLAG_VISIBLE | getImmersiveLayoutFlags(); | 398 int flags = View.SYSTEM_UI_FLAG_VISIBLE | getImmersiveLayoutFlags(); |
| 394 getWindow().getDecorView().setSystemUiVisibility(flags); | 399 getWindow().getDecorView().setSystemUiVisibility(flags); |
| 395 | 400 |
| 396 // The OS will not call onSystemUiVisibilityChange() if the keyboard is visible which means | 401 // The OS will not call onSystemUiVisibilityChange() if the keyboard is visible which means |
| 397 // our ActionBar will not be visible until then. This check allows us t o work around this | 402 // our ActionBar will not be visible until then. This check allows us t o work around this |
| 398 // issue and still allow the system to show the ActionBar normally with the soft keyboard. | 403 // issue and still allow the system to show the ActionBar normally with the soft keyboard. |
| 399 if (mSoftInputVisible) { | 404 if (mSoftInputVisible) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 } | 437 } |
| 433 | 438 |
| 434 getWindow().getDecorView().setSystemUiVisibility(flags); | 439 getWindow().getDecorView().setSystemUiVisibility(flags); |
| 435 | 440 |
| 436 // The OS will not call onSystemUiVisibilityChange() until the keyboard has been dismissed | 441 // The OS will not call onSystemUiVisibilityChange() until the keyboard has been dismissed |
| 437 // which means our ActionBar will still be visible. This check allows u s to work around | 442 // which means our ActionBar will still be visible. This check allows u s to work around |
| 438 // this issue when the keyboard is visible and the user wants additional space on the screen | 443 // this issue when the keyboard is visible and the user wants additional space on the screen |
| 439 // and still allow the system to hide the ActionBar normally when no key board is present. | 444 // and still allow the system to hide the ActionBar normally when no key board is present. |
| 440 if (mSoftInputVisible) { | 445 if (mSoftInputVisible) { |
| 441 hideActionBarWithoutSystemUi(); | 446 hideActionBarWithoutSystemUi(); |
| 447 | |
| 448 // Android OSes prior to Marshmallow do not call onSystemUiVisibilit yChange after the | |
| 449 // OSK is dismissed if the user has interacted with the status bar. | |
|
Lambros
2016/01/29 19:09:57
This comment seems to contradict the first sentenc
joedow
2016/01/29 19:31:17
It doesn't contradict the sentence, it is document
| |
| 450 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { | |
| 451 mHideSystemUIOnOskDismiss = true; | |
| 452 } | |
| 442 } | 453 } |
| 443 } | 454 } |
| 444 | 455 |
| 445 /** Hides the action bar without changing SystemUiVisibility. */ | 456 /** Hides the action bar without changing SystemUiVisibility. */ |
| 446 private void hideActionBarWithoutSystemUi() { | 457 private void hideActionBarWithoutSystemUi() { |
| 447 getSupportActionBar().hide(); | 458 getSupportActionBar().hide(); |
| 448 stopActionBarAutoHideTimer(); | 459 stopActionBarAutoHideTimer(); |
| 449 } | 460 } |
| 450 | 461 |
| 451 /** Called whenever an action bar button is pressed. */ | 462 /** Called whenever an action bar button is pressed. */ |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 } | 538 } |
| 528 | 539 |
| 529 // If the delta between lowest bound we have seen (should be a s ystemUI such as | 540 // If the delta between lowest bound we have seen (should be a s ystemUI such as |
| 530 // the navigation bar) and the current bound does not match, the n we have a form | 541 // the navigation bar) and the current bound does not match, the n we have a form |
| 531 // of soft input displayed. Note that the size of a soft input device can change | 542 // of soft input displayed. Note that the size of a soft input device can change |
| 532 // when the input method is changed so we want to send updates t o the image canvas | 543 // when the input method is changed so we want to send updates t o the image canvas |
| 533 // whenever they occur. | 544 // whenever they occur. |
| 534 mSoftInputVisible = (bottom < mMaxBottomValue); | 545 mSoftInputVisible = (bottom < mMaxBottomValue); |
| 535 mRemoteHostDesktop.onSoftInputMethodVisibilityChanged( | 546 mRemoteHostDesktop.onSoftInputMethodVisibilityChanged( |
| 536 mSoftInputVisible, new Rect(left, top, right, bottom)); | 547 mSoftInputVisible, new Rect(left, top, right, bottom)); |
| 548 | |
| 549 if (!mSoftInputVisible && mHideSystemUIOnOskDismiss) { | |
| 550 // Queue a task which will run after the current action (OSK dismiss) has | |
| 551 // completed, otherwise the hide request will not take effec t. | |
| 552 new Handler().post(new Runnable() { | |
| 553 @Override | |
| 554 public void run() { | |
| 555 if (mHideSystemUIOnOskDismiss) { | |
|
Lambros
2016/01/29 19:09:57
Why do you need to check this flag again? You alre
joedow
2016/01/29 19:31:17
I am checking it here because this task is appende
| |
| 556 mHideSystemUIOnOskDismiss = false; | |
| 557 hideActionBar(); | |
| 558 } | |
| 559 } | |
| 560 }); | |
| 561 } | |
| 537 } | 562 } |
| 538 }); | 563 }); |
| 539 } | 564 } |
| 540 | 565 |
| 541 private void onCardboardItemSelected() { | 566 private void onCardboardItemSelected() { |
| 542 if (getPreferences(MODE_PRIVATE).getBoolean(PREFERENCE_CARDBOARD_DIALOG_ SEEN, false)) { | 567 if (getPreferences(MODE_PRIVATE).getBoolean(PREFERENCE_CARDBOARD_DIALOG_ SEEN, false)) { |
| 543 switchToCardboardMode(); | 568 switchToCardboardMode(); |
| 544 return; | 569 return; |
| 545 } | 570 } |
| 546 | 571 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 JniInterface.sendKeyEvent(0, KeyEvent.KEYCODE_SHIFT_LEFT, presse d); | 679 JniInterface.sendKeyEvent(0, KeyEvent.KEYCODE_SHIFT_LEFT, presse d); |
| 655 JniInterface.sendKeyEvent(0, KeyEvent.KEYCODE_EQUALS, pressed); | 680 JniInterface.sendKeyEvent(0, KeyEvent.KEYCODE_EQUALS, pressed); |
| 656 return true; | 681 return true; |
| 657 | 682 |
| 658 default: | 683 default: |
| 659 // We try to send all other key codes to the host directly. | 684 // We try to send all other key codes to the host directly. |
| 660 return JniInterface.sendKeyEvent(0, keyCode, pressed); | 685 return JniInterface.sendKeyEvent(0, keyCode, pressed); |
| 661 } | 686 } |
| 662 } | 687 } |
| 663 } | 688 } |
| OLD | NEW |