Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/Desktop.java

Issue 2393073003: [Remoting Android] Fading transition animation for desktop actionbar (Closed)
Patch Set: Reviewer's Feedback Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.os.Build; 8 import android.os.Build;
9 import android.os.Bundle; 9 import android.os.Bundle;
10 import android.os.Handler; 10 import android.os.Handler;
11 import android.support.v7.app.ActionBar.OnMenuVisibilityListener; 11 import android.support.v7.app.ActionBar.OnMenuVisibilityListener;
12 import android.support.v7.app.AppCompatActivity; 12 import android.support.v7.app.AppCompatActivity;
13 import android.support.v7.widget.Toolbar; 13 import android.support.v7.widget.Toolbar;
14 import android.view.KeyEvent; 14 import android.view.KeyEvent;
15 import android.view.Menu; 15 import android.view.Menu;
16 import android.view.MenuItem; 16 import android.view.MenuItem;
17 import android.view.MotionEvent; 17 import android.view.MotionEvent;
18 import android.view.View; 18 import android.view.View;
19 import android.view.View.OnLayoutChangeListener; 19 import android.view.View.OnLayoutChangeListener;
20 import android.view.View.OnTouchListener; 20 import android.view.View.OnTouchListener;
21 import android.view.animation.Animation;
22 import android.view.animation.AnimationUtils;
21 import android.view.inputmethod.InputMethodManager; 23 import android.view.inputmethod.InputMethodManager;
22 24
23 import org.chromium.chromoting.help.HelpContext; 25 import org.chromium.chromoting.help.HelpContext;
24 import org.chromium.chromoting.help.HelpSingleton; 26 import org.chromium.chromoting.help.HelpSingleton;
25 import org.chromium.chromoting.jni.Client; 27 import org.chromium.chromoting.jni.Client;
26 28
27 import java.util.List; 29 import java.util.List;
28 30
29 /** 31 /**
30 * A simple screen that does nothing except display a DesktopView and notify it of rotations. 32 * A simple screen that does nothing except display a DesktopView and notify it of rotations.
(...skipping 11 matching lines...) Expand all
42 return this != UNKNOWN; 44 return this != UNKNOWN;
43 } 45 }
44 } 46 }
45 47
46 /** Preference used to track the last input mode selected by the user. */ 48 /** Preference used to track the last input mode selected by the user. */
47 private static final String PREFERENCE_INPUT_MODE = "input_mode"; 49 private static final String PREFERENCE_INPUT_MODE = "input_mode";
48 50
49 /** The amount of time to wait to hide the ActionBar after user input is see n. */ 51 /** The amount of time to wait to hide the ActionBar after user input is see n. */
50 private static final int ACTIONBAR_AUTO_HIDE_DELAY_MS = 3000; 52 private static final int ACTIONBAR_AUTO_HIDE_DELAY_MS = 3000;
51 53
54 /** Duration for fade-in and fade-out animations for the ActionBar. */
55 private static final int ACTIONBAR_ANIMATION_DURATION_MS = 250;
56
52 private final Event.Raisable<SystemUiVisibilityChangedEventParameter> 57 private final Event.Raisable<SystemUiVisibilityChangedEventParameter>
53 mOnSystemUiVisibilityChanged = new Event.Raisable<>(); 58 mOnSystemUiVisibilityChanged = new Event.Raisable<>();
54 59
55 private final Event.Raisable<InputModeChangedEventParameter> mOnInputModeCha nged = 60 private final Event.Raisable<InputModeChangedEventParameter> mOnInputModeCha nged =
56 new Event.Raisable<>(); 61 new Event.Raisable<>();
57 62
58 private Client mClient; 63 private Client mClient;
59 private InputEventSender mInjector; 64 private InputEventSender mInjector;
60 65
61 private ActivityLifecycleListener mActivityLifecycleListener; 66 private ActivityLifecycleListener mActivityLifecycleListener;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 398
394 // The OS will not call onSystemUiVisibilityChange() if the soft keyboar d is visible which 399 // The OS will not call onSystemUiVisibilityChange() if the soft keyboar d is visible which
395 // means our ActionBar will not be shown if this function is called in t hat scenario. 400 // means our ActionBar will not be shown if this function is called in t hat scenario.
396 if (mSoftInputVisible) { 401 if (mSoftInputVisible) {
397 showActionBar(); 402 showActionBar();
398 } 403 }
399 } 404 }
400 405
401 /** Shows the action bar without changing SystemUiVisibility. */ 406 /** Shows the action bar without changing SystemUiVisibility. */
402 private void showActionBar() { 407 private void showActionBar() {
408 Animation animation = AnimationUtils.loadAnimation(this, android.R.anim. fade_in);
409 animation.setDuration(ACTIONBAR_ANIMATION_DURATION_MS);
410 mToolbar.startAnimation(animation);
411
403 getSupportActionBar().show(); 412 getSupportActionBar().show();
404 startActionBarAutoHideTimer(); 413 startActionBarAutoHideTimer();
405 } 414 }
406 415
407 @SuppressLint("InlinedApi") 416 @SuppressLint("InlinedApi")
408 public void hideSystemUi() { 417 public void hideSystemUi() {
409 // If a soft input device is present, then hide the ActionBar but do not hide the rest of 418 // If a soft input device is present, then hide the ActionBar but do not hide the rest of
410 // system UI. A second call will be made once the soft input device is hidden. 419 // system UI. A second call will be made once the soft input device is hidden.
411 if (mSoftInputVisible) { 420 if (mSoftInputVisible) {
412 hideActionBar(); 421 hideActionBar();
(...skipping 17 matching lines...) Expand all
430 flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; 439 flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
431 flags |= View.SYSTEM_UI_FLAG_IMMERSIVE; 440 flags |= View.SYSTEM_UI_FLAG_IMMERSIVE;
432 } 441 }
433 flags |= getLayoutFlags(); 442 flags |= getLayoutFlags();
434 443
435 getWindow().getDecorView().setSystemUiVisibility(flags); 444 getWindow().getDecorView().setSystemUiVisibility(flags);
436 } 445 }
437 446
438 /** Hides the action bar without changing SystemUiVisibility. */ 447 /** Hides the action bar without changing SystemUiVisibility. */
439 private void hideActionBar() { 448 private void hideActionBar() {
449 Animation animation = AnimationUtils.loadAnimation(this, android.R.anim. fade_out);
450 animation.setDuration(ACTIONBAR_ANIMATION_DURATION_MS);
451 mToolbar.startAnimation(animation);
452
440 getSupportActionBar().hide(); 453 getSupportActionBar().hide();
441 stopActionBarAutoHideTimer(); 454 stopActionBarAutoHideTimer();
442 } 455 }
443 456
444 /** Called whenever an action bar button is pressed. */ 457 /** Called whenever an action bar button is pressed. */
445 @Override 458 @Override
446 public boolean onOptionsItemSelected(MenuItem item) { 459 public boolean onOptionsItemSelected(MenuItem item) {
447 int id = item.getItemId(); 460 int id = item.getItemId();
448 461
449 mActivityLifecycleListener.onActivityOptionsItemSelected(this, item); 462 mActivityLifecycleListener.onActivityOptionsItemSelected(this, item);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 @Override 553 @Override
541 public boolean dispatchKeyEvent(KeyEvent event) { 554 public boolean dispatchKeyEvent(KeyEvent event) {
542 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { 555 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
543 mClient.destroy(); 556 mClient.destroy();
544 return super.dispatchKeyEvent(event); 557 return super.dispatchKeyEvent(event);
545 } 558 }
546 559
547 return mInjector.sendKeyEvent(event); 560 return mInjector.sendKeyEvent(event);
548 } 561 }
549 } 562 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698