| 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.graphics.Color; | 9 import android.graphics.Color; |
| 10 import android.graphics.drawable.ColorDrawable; | 10 import android.graphics.drawable.ColorDrawable; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 * Indicates whether the device is connected to a non-hidden physical qwerty
keyboard. This is | 91 * Indicates whether the device is connected to a non-hidden physical qwerty
keyboard. This is |
| 92 * set by {@link Desktop#setKeyboardState(Configuration)}. DO NOT request a
soft keyboard when a | 92 * set by {@link Desktop#setKeyboardState(Configuration)}. DO NOT request a
soft keyboard when a |
| 93 * physical keyboard exists, otherwise the activity will enter an undefined
state where the soft | 93 * physical keyboard exists, otherwise the activity will enter an undefined
state where the soft |
| 94 * keyboard never shows up meanwhile request to hide status bar always fails
. | 94 * keyboard never shows up meanwhile request to hide status bar always fails
. |
| 95 */ | 95 */ |
| 96 private boolean mHasPhysicalKeyboard; | 96 private boolean mHasPhysicalKeyboard; |
| 97 | 97 |
| 98 /** Tracks whether the activity is in the resumed (running) state. */ | 98 /** Tracks whether the activity is in the resumed (running) state. */ |
| 99 private boolean mIsActivityRunning = false; | 99 private boolean mIsActivityRunning = false; |
| 100 | 100 |
| 101 /** |
| 102 * Tracks whether the activity is in windowed mode. This mode cannot change
during the lifetime |
| 103 * of the activity so it does not receive a value until the first time it is
initialized. |
| 104 */ |
| 105 private Boolean mIsInWindowedMode = null; |
| 106 |
| 101 /** Called when the activity is first created. */ | 107 /** Called when the activity is first created. */ |
| 102 @Override | 108 @Override |
| 103 public void onCreate(Bundle savedInstanceState) { | 109 public void onCreate(Bundle savedInstanceState) { |
| 104 super.onCreate(savedInstanceState); | 110 super.onCreate(savedInstanceState); |
| 105 setContentView(R.layout.desktop); | 111 setContentView(R.layout.desktop); |
| 106 | 112 |
| 107 mClient = Client.getInstance(); | 113 mClient = Client.getInstance(); |
| 108 mInjector = new InputEventSender(mClient); | 114 mInjector = new InputEventSender(mClient); |
| 109 | 115 |
| 110 Preconditions.notNull(mClient); | 116 Preconditions.notNull(mClient); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 default: | 343 default: |
| 338 // Ignore. | 344 // Ignore. |
| 339 break; | 345 break; |
| 340 } | 346 } |
| 341 | 347 |
| 342 return false; | 348 return false; |
| 343 } | 349 } |
| 344 }); | 350 }); |
| 345 } | 351 } |
| 346 | 352 |
| 347 private Boolean inWindowedMode() { | 353 private boolean inWindowedMode() { |
| 348 // NOTE: This method should only be called after OnResume() is called, o
therwise | 354 if (mIsInWindowedMode == null) { |
| 349 // isInMultiWindowMode() may not be accurate. The value returned by thi
s method is updated | 355 // NOTE: This method should only be called after OnResume() is calle
d, otherwise |
| 350 // on a background thread and there is a race-condition between when the
UX changes and this | 356 // isInMultiWindowMode() may not be accurate. The value returned by
this method is |
| 351 // value is updated. Hence, calling this method from onCreate() is not
safe and we need to | 357 // updated on a background thread and there is a race-condition betw
een when the UX |
| 352 // be careful when we query this value. | 358 // changes and this value is updated. Hence, calling this method fr
om onCreate() is not |
| 353 Preconditions.isTrue(mIsActivityRunning); | 359 // safe and we need to be careful when we query this value. |
| 360 Preconditions.isTrue(mIsActivityRunning); |
| 354 | 361 |
| 355 return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInMultiWindow
Mode(); | 362 mIsInWindowedMode = |
| 363 Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInMultiW
indowMode(); |
| 364 } |
| 365 |
| 366 return mIsInWindowedMode; |
| 356 } | 367 } |
| 357 | 368 |
| 358 private void setUpAutoHideToolbar() { | 369 private void setUpAutoHideToolbar() { |
| 359 // Configure the auto-hiding taskbar if the activity is not in multi-win
dow mode and the | 370 // Configure the auto-hiding taskbar if the activity is not in multi-win
dow mode and the |
| 360 // application is run on an OS which supports fullscreen mode (KitKat or
higher). | 371 // application is run on an OS which supports fullscreen mode (KitKat or
higher). |
| 361 Preconditions.isTrue(!inWindowedMode()); | 372 Preconditions.isTrue(!inWindowedMode()); |
| 362 if (mActionBarAutoHideTask != null || Build.VERSION.SDK_INT < Build.VERS
ION_CODES.KITKAT) { | 373 if (mActionBarAutoHideTask != null || Build.VERSION.SDK_INT < Build.VERS
ION_CODES.KITKAT) { |
| 363 return; | 374 return; |
| 364 } | 375 } |
| 365 | 376 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 return; | 601 return; |
| 591 } | 602 } |
| 592 | 603 |
| 593 // If the delta between lowest bound we have seen (should be a S
ystem UI such as | 604 // If the delta between lowest bound we have seen (should be a S
ystem UI such as |
| 594 // the navigation bar) and the current bound does not match, the
n we have a form | 605 // the navigation bar) and the current bound does not match, the
n we have a form |
| 595 // of soft input displayed. Note that the size of a soft input
device can change | 606 // of soft input displayed. Note that the size of a soft input
device can change |
| 596 // when the input method is changed so we want to send updates t
o the image canvas | 607 // when the input method is changed so we want to send updates t
o the image canvas |
| 597 // whenever they occur. | 608 // whenever they occur. |
| 598 boolean oldSoftInputVisible = mSoftInputVisible; | 609 boolean oldSoftInputVisible = mSoftInputVisible; |
| 599 mSoftInputVisible = (bottom < mMaxBottomValue); | 610 mSoftInputVisible = (bottom < mMaxBottomValue); |
| 600 mOnSystemUiVisibilityChanged.raise(new SystemUiVisibilityChanged
EventParameter( | 611 |
| 601 isSystemUiVisible(), mSoftInputVisible, left, top, right
, bottom)); | 612 // Send the System UI sizes if either the Soft Keyboard is displ
ayed or if we are in |
| 613 // windowed mode and there is System UI present. The user needs
to be able to move |
| 614 // the canvas so they can see where they are typing in the first
case and in the |
| 615 // second, the System UI is always present so the user needs a w
ay to position the |
| 616 // canvas so all parts of the desktop can be made visible. |
| 617 if (mSoftInputVisible || (inWindowedMode() && isSystemUiVisible(
))) { |
| 618 mOnSystemUiVisibilityChanged.raise( |
| 619 new SystemUiVisibilityChangedEventParameter(left, to
p, right, bottom)); |
| 620 } else { |
| 621 mOnSystemUiVisibilityChanged.raise( |
| 622 new SystemUiVisibilityChangedEventParameter(0, 0, 0,
0)); |
| 623 } |
| 602 | 624 |
| 603 boolean softInputVisibilityChanged = oldSoftInputVisible != mSof
tInputVisible; | 625 boolean softInputVisibilityChanged = oldSoftInputVisible != mSof
tInputVisible; |
| 604 if (!mSoftInputVisible && softInputVisibilityChanged && !isActio
nBarVisible()) { | 626 if (!mSoftInputVisible && softInputVisibilityChanged && !isActio
nBarVisible()) { |
| 605 // Queue a task which will run after the current action (OSK
dismiss) has | 627 // Queue a task which will run after the current action (OSK
dismiss) has |
| 606 // completed, otherwise the hide request will not take effec
t. | 628 // completed, otherwise the hide request will not take effec
t. |
| 607 new Handler().post(new Runnable() { | 629 new Handler().post(new Runnable() { |
| 608 @Override | 630 @Override |
| 609 public void run() { | 631 public void run() { |
| 610 if (!mSoftInputVisible && !isActionBarVisible()) { | 632 if (!mSoftInputVisible && !isActionBarVisible()) { |
| 611 hideSystemUi(); | 633 hideSystemUi(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 625 @Override | 647 @Override |
| 626 public boolean dispatchKeyEvent(KeyEvent event) { | 648 public boolean dispatchKeyEvent(KeyEvent event) { |
| 627 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { | 649 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
| 628 mClient.destroy(); | 650 mClient.destroy(); |
| 629 return super.dispatchKeyEvent(event); | 651 return super.dispatchKeyEvent(event); |
| 630 } | 652 } |
| 631 | 653 |
| 632 return mInjector.sendKeyEvent(event); | 654 return mInjector.sendKeyEvent(event); |
| 633 } | 655 } |
| 634 } | 656 } |
| OLD | NEW |