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.content.DialogInterface; | 8 import android.content.DialogInterface; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.content.pm.ApplicationInfo; | 10 import android.content.pm.ApplicationInfo; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 * Cardboard function. | 55 * Cardboard function. |
| 56 */ | 56 */ |
| 57 private static final String PREFERENCE_CARDBOARD_DIALOG_SEEN = "cardboard_di alog_seen"; | 57 private static final String PREFERENCE_CARDBOARD_DIALOG_SEEN = "cardboard_di alog_seen"; |
| 58 | 58 |
| 59 /** Preference used to track the last input mode selected by the user. */ | 59 /** Preference used to track the last input mode selected by the user. */ |
| 60 private static final String PREFERENCE_INPUT_MODE = "input_mode"; | 60 private static final String PREFERENCE_INPUT_MODE = "input_mode"; |
| 61 | 61 |
| 62 /** The amount of time to wait to hide the ActionBar after user input is see n. */ | 62 /** The amount of time to wait to hide the ActionBar after user input is see n. */ |
| 63 private static final int ACTIONBAR_AUTO_HIDE_DELAY_MS = 3000; | 63 private static final int ACTIONBAR_AUTO_HIDE_DELAY_MS = 3000; |
| 64 | 64 |
| 65 private final Event.Raisable<SoftInputMethodVisibilityChangedEventParameter> | 65 private final Event.Raisable<SystemUiVisibilityChangedEventParameter> |
| 66 mOnSoftInputMethodVisibilityChanged = new Event.Raisable<>(); | 66 mOnSystemUiVisibilityChanged = new Event.Raisable<>(); |
| 67 | 67 |
| 68 private final Event.Raisable<InputModeChangedEventParameter> mOnInputModeCha nged = | 68 private final Event.Raisable<InputModeChangedEventParameter> mOnInputModeCha nged = |
| 69 new Event.Raisable<>(); | 69 new Event.Raisable<>(); |
| 70 | 70 |
| 71 private Client mClient; | 71 private Client mClient; |
| 72 private InputEventSender mInjector; | 72 private InputEventSender mInjector; |
| 73 | 73 |
| 74 private ActivityLifecycleListener mActivityLifecycleListener; | 74 private ActivityLifecycleListener mActivityLifecycleListener; |
| 75 | 75 |
| 76 /** Flag to indicate whether the current activity is switching to Cardboard desktop activity. */ | 76 /** Flag to indicate whether the current activity is switching to Cardboard desktop activity. */ |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 } | 246 } |
| 247 | 247 |
| 248 ChromotingUtil.tintMenuIcons(this, menu); | 248 ChromotingUtil.tintMenuIcons(this, menu); |
| 249 | 249 |
| 250 // Wait to set the input mode until after the default tinting has been a pplied. | 250 // Wait to set the input mode until after the default tinting has been a pplied. |
| 251 setInputMode(mInputMode); | 251 setInputMode(mInputMode); |
| 252 | 252 |
| 253 return super.onCreateOptionsMenu(menu); | 253 return super.onCreateOptionsMenu(menu); |
| 254 } | 254 } |
| 255 | 255 |
| 256 public Event<SoftInputMethodVisibilityChangedEventParameter> | 256 public Event<SystemUiVisibilityChangedEventParameter> onSystemUiVisibilityCh anged() { |
| 257 onSoftInputMethodVisibilityChanged() { | 257 return mOnSystemUiVisibilityChanged; |
| 258 return mOnSoftInputMethodVisibilityChanged; | |
| 259 } | 258 } |
| 260 | 259 |
| 261 public Event<InputModeChangedEventParameter> onInputModeChanged() { | 260 public Event<InputModeChangedEventParameter> onInputModeChanged() { |
| 262 return mOnInputModeChanged; | 261 return mOnInputModeChanged; |
| 263 } | 262 } |
| 264 | 263 |
| 265 private InputMode getInitialInputModeValue() { | 264 private InputMode getInitialInputModeValue() { |
| 266 // Load the previously-selected input mode from Preferences. | 265 // Load the previously-selected input mode from Preferences. |
| 267 // TODO(joedow): Evaluate and determine if we should use a different inp ut mode based on | 266 // TODO(joedow): Evaluate and determine if we should use a different inp ut mode based on |
| 268 // a device characteristic such as screen size. | 267 // a device characteristic such as screen size. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 // power or activity lifecycle event in which the current System UI state ha s changed but we | 364 // power or activity lifecycle event in which the current System UI state ha s changed but we |
| 366 // never received the notification. | 365 // never received the notification. |
| 367 private void syncActionBarToSystemUiState() { | 366 private void syncActionBarToSystemUiState() { |
| 368 onSystemUiVisibilityChange(getWindow().getDecorView().getSystemUiVisibil ity()); | 367 onSystemUiVisibilityChange(getWindow().getDecorView().getSystemUiVisibil ity()); |
| 369 } | 368 } |
| 370 | 369 |
| 371 private boolean isActionBarVisible() { | 370 private boolean isActionBarVisible() { |
| 372 return getSupportActionBar() != null && getSupportActionBar().isShowing( ); | 371 return getSupportActionBar() != null && getSupportActionBar().isShowing( ); |
| 373 } | 372 } |
| 374 | 373 |
| 374 private boolean isSystemUiVisible() { | |
| 375 return ((getWindow().getDecorView().getSystemUiVisibility() & getFullscr eenFlags()) == 0); | |
|
Lambros
2016/06/29 20:43:36
Remove outermost parentheses.
joedow
2016/06/30 16:03:26
Done.
| |
| 376 } | |
| 377 | |
| 375 /** Called whenever the visibility of the system status bar or navigation ba r changes. */ | 378 /** Called whenever the visibility of the system status bar or navigation ba r changes. */ |
| 376 @Override | 379 @Override |
| 377 public void onSystemUiVisibilityChange(int visibility) { | 380 public void onSystemUiVisibilityChange(int visibility) { |
| 378 // Ensure the action-bar's visibility matches that of the system control s. This | 381 // Ensure the action-bar's visibility matches that of the system control s. This |
| 379 // minimizes the number of states the UI can be in, to keep things simpl e for the user. | 382 // minimizes the number of states the UI can be in, to keep things simpl e for the user. |
| 380 | 383 |
| 381 // Check if the system is in fullscreen/lights-out mode then update the ActionBar to match. | 384 // Check if the system is in fullscreen/lights-out mode then update the ActionBar to match. |
| 382 int fullscreenFlags = getFullscreenFlags(); | 385 int fullscreenFlags = getFullscreenFlags(); |
| 383 if ((visibility & fullscreenFlags) != 0) { | 386 if ((visibility & fullscreenFlags) != 0) { |
| 384 hideActionBar(); | 387 hideActionBar(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 return; | 537 return; |
| 535 } | 538 } |
| 536 | 539 |
| 537 // If the delta between lowest bound we have seen (should be a S ystem UI such as | 540 // If the delta between lowest bound we have seen (should be a S ystem UI such as |
| 538 // 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 |
| 539 // 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 |
| 540 // 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 |
| 541 // whenever they occur. | 544 // whenever they occur. |
| 542 boolean oldSoftInputVisible = mSoftInputVisible; | 545 boolean oldSoftInputVisible = mSoftInputVisible; |
| 543 mSoftInputVisible = (bottom < mMaxBottomValue); | 546 mSoftInputVisible = (bottom < mMaxBottomValue); |
| 544 mOnSoftInputMethodVisibilityChanged.raise( | 547 mOnSystemUiVisibilityChanged.raise(new SystemUiVisibilityChanged EventParameter( |
| 545 new SoftInputMethodVisibilityChangedEventParameter( | 548 isSystemUiVisible(), mSoftInputVisible, left, top, right , bottom)); |
| 546 mSoftInputVisible, left, top, right, bottom)); | |
| 547 | 549 |
| 548 boolean softInputVisibilityChanged = oldSoftInputVisible != mSof tInputVisible; | 550 boolean softInputVisibilityChanged = oldSoftInputVisible != mSof tInputVisible; |
| 549 if (!mSoftInputVisible && softInputVisibilityChanged && !isActio nBarVisible()) { | 551 if (!mSoftInputVisible && softInputVisibilityChanged && !isActio nBarVisible()) { |
| 550 // Queue a task which will run after the current action (OSK dismiss) has | 552 // Queue a task which will run after the current action (OSK dismiss) has |
| 551 // completed, otherwise the hide request will not take effec t. | 553 // completed, otherwise the hide request will not take effec t. |
| 552 new Handler().post(new Runnable() { | 554 new Handler().post(new Runnable() { |
| 553 @Override | 555 @Override |
| 554 public void run() { | 556 public void run() { |
| 555 if (!mSoftInputVisible && !isActionBarVisible()) { | 557 if (!mSoftInputVisible && !isActionBarVisible()) { |
| 556 hideSystemUi(); | 558 hideSystemUi(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 @Override | 607 @Override |
| 606 public boolean dispatchKeyEvent(KeyEvent event) { | 608 public boolean dispatchKeyEvent(KeyEvent event) { |
| 607 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { | 609 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
| 608 mClient.destroy(); | 610 mClient.destroy(); |
| 609 return super.dispatchKeyEvent(event); | 611 return super.dispatchKeyEvent(event); |
| 610 } | 612 } |
| 611 | 613 |
| 612 return mInjector.sendKeyEvent(event); | 614 return mInjector.sendKeyEvent(event); |
| 613 } | 615 } |
| 614 } | 616 } |
| OLD | NEW |