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

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: Not using AnimationListener, which made onSystemUiVisibilityChange flaky (why?) 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 /** Animation duration for fade-in and fade-out. */
joedow 2016/10/05 22:10:25 I'd change this to 'Duration for fade-in and fade-
Yuwei 2016/10/05 22:22:22 Done.
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;
62 67
63 /** Indicates whether a Soft Input UI (such as a keyboard) is visible. */ 68 /** Indicates whether a Soft Input UI (such as a keyboard) is visible. */
64 private boolean mSoftInputVisible = false; 69 private boolean mSoftInputVisible = false;
65 70
66 /** Holds the scheduled task object which will be called to hide the ActionB ar. */ 71 /** Holds the scheduled task object which will be called to hide the ActionB ar. */
67 private Runnable mActionBarAutoHideTask; 72 private Runnable mActionBarAutoHideTask;
68 73
69 /** The Toolbar instance backing our SupportActionBar. */ 74 /** The Toolbar instance backing our SupportActionBar. */
70 private Toolbar mToolbar; 75 private Toolbar mToolbar;
71 76
72 /** Tracks the current input mode (e.g. trackpad/touch). */ 77 /** Tracks the current input mode (e.g. trackpad/touch). */
73 private InputMode mInputMode = InputMode.UNKNOWN; 78 private InputMode mInputMode = InputMode.UNKNOWN;
74 79
75 /** Indicates whether the remote host supports touch injection. */ 80 /** Indicates whether the remote host supports touch injection. */
76 private CapabilityManager.HostCapability mHostTouchCapability = 81 private CapabilityManager.HostCapability mHostTouchCapability =
77 CapabilityManager.HostCapability.UNKNOWN; 82 CapabilityManager.HostCapability.UNKNOWN;
78 83
79 private DesktopView mRemoteHostDesktop; 84 private DesktopView mRemoteHostDesktop;
80 85
86 private Animation createAnimation(int animationId) {
joedow 2016/10/05 22:10:25 rename to 'createToolbarVisibilityAnimation'? It
Yuwei 2016/10/05 22:22:22 Done.
87 Animation animation = AnimationUtils.loadAnimation(this, animationId);
88 animation.setDuration(ACTIONBAR_ANIMATION_DURATION_MS);
89 return animation;
90 }
91
81 /** Called when the activity is first created. */ 92 /** Called when the activity is first created. */
82 @Override 93 @Override
83 public void onCreate(Bundle savedInstanceState) { 94 public void onCreate(Bundle savedInstanceState) {
84 super.onCreate(savedInstanceState); 95 super.onCreate(savedInstanceState);
85 setContentView(R.layout.desktop); 96 setContentView(R.layout.desktop);
86 97
87 mClient = Client.getInstance(); 98 mClient = Client.getInstance();
88 mInjector = new InputEventSender(mClient); 99 mInjector = new InputEventSender(mClient);
89 100
90 Preconditions.notNull(mClient); 101 Preconditions.notNull(mClient);
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 404
394 // The OS will not call onSystemUiVisibilityChange() if the soft keyboar d is visible which 405 // 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. 406 // means our ActionBar will not be shown if this function is called in t hat scenario.
396 if (mSoftInputVisible) { 407 if (mSoftInputVisible) {
397 showActionBar(); 408 showActionBar();
398 } 409 }
399 } 410 }
400 411
401 /** Shows the action bar without changing SystemUiVisibility. */ 412 /** Shows the action bar without changing SystemUiVisibility. */
402 private void showActionBar() { 413 private void showActionBar() {
414 mToolbar.startAnimation(createAnimation(android.R.anim.fade_in));
415
403 getSupportActionBar().show(); 416 getSupportActionBar().show();
404 startActionBarAutoHideTimer(); 417 startActionBarAutoHideTimer();
405 } 418 }
406 419
407 @SuppressLint("InlinedApi") 420 @SuppressLint("InlinedApi")
408 public void hideSystemUi() { 421 public void hideSystemUi() {
409 // If a soft input device is present, then hide the ActionBar but do not hide the rest of 422 // 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. 423 // system UI. A second call will be made once the soft input device is hidden.
411 if (mSoftInputVisible) { 424 if (mSoftInputVisible) {
412 hideActionBar(); 425 hideActionBar();
(...skipping 17 matching lines...) Expand all
430 flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; 443 flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
431 flags |= View.SYSTEM_UI_FLAG_IMMERSIVE; 444 flags |= View.SYSTEM_UI_FLAG_IMMERSIVE;
432 } 445 }
433 flags |= getLayoutFlags(); 446 flags |= getLayoutFlags();
434 447
435 getWindow().getDecorView().setSystemUiVisibility(flags); 448 getWindow().getDecorView().setSystemUiVisibility(flags);
436 } 449 }
437 450
438 /** Hides the action bar without changing SystemUiVisibility. */ 451 /** Hides the action bar without changing SystemUiVisibility. */
439 private void hideActionBar() { 452 private void hideActionBar() {
453 mToolbar.startAnimation(createAnimation(android.R.anim.fade_out));
454
440 getSupportActionBar().hide(); 455 getSupportActionBar().hide();
441 stopActionBarAutoHideTimer(); 456 stopActionBarAutoHideTimer();
442 } 457 }
443 458
444 /** Called whenever an action bar button is pressed. */ 459 /** Called whenever an action bar button is pressed. */
445 @Override 460 @Override
446 public boolean onOptionsItemSelected(MenuItem item) { 461 public boolean onOptionsItemSelected(MenuItem item) {
447 int id = item.getItemId(); 462 int id = item.getItemId();
448 463
449 mActivityLifecycleListener.onActivityOptionsItemSelected(this, item); 464 mActivityLifecycleListener.onActivityOptionsItemSelected(this, item);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 @Override 555 @Override
541 public boolean dispatchKeyEvent(KeyEvent event) { 556 public boolean dispatchKeyEvent(KeyEvent event) {
542 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { 557 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
543 mClient.destroy(); 558 mClient.destroy();
544 return super.dispatchKeyEvent(event); 559 return super.dispatchKeyEvent(event);
545 } 560 }
546 561
547 return mInjector.sendKeyEvent(event); 562 return mInjector.sendKeyEvent(event);
548 } 563 }
549 } 564 }
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