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

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

Issue 2322623002: [Remoting Android] Refactor GlDesktopView (Closed)
Patch Set: Fix processAnimation bug. Abort animation when detach Created 4 years, 3 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
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.ViewGroup;
22 import android.view.inputmethod.InputMethodManager; 21 import android.view.inputmethod.InputMethodManager;
23 22
24 import org.chromium.chromoting.help.HelpContext; 23 import org.chromium.chromoting.help.HelpContext;
25 import org.chromium.chromoting.help.HelpSingleton; 24 import org.chromium.chromoting.help.HelpSingleton;
26 import org.chromium.chromoting.jni.Client; 25 import org.chromium.chromoting.jni.Client;
27 26
28 import java.util.List; 27 import java.util.List;
29 28
30 /** 29 /**
31 * A simple screen that does nothing except display a DesktopView and notify it of rotations. 30 * A simple screen that does nothing except display a DesktopView and notify it of rotations.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 /** The Toolbar instance backing our SupportActionBar. */ 69 /** The Toolbar instance backing our SupportActionBar. */
71 private Toolbar mToolbar; 70 private Toolbar mToolbar;
72 71
73 /** Tracks the current input mode (e.g. trackpad/touch). */ 72 /** Tracks the current input mode (e.g. trackpad/touch). */
74 private InputMode mInputMode = InputMode.UNKNOWN; 73 private InputMode mInputMode = InputMode.UNKNOWN;
75 74
76 /** Indicates whether the remote host supports touch injection. */ 75 /** Indicates whether the remote host supports touch injection. */
77 private CapabilityManager.HostCapability mHostTouchCapability = 76 private CapabilityManager.HostCapability mHostTouchCapability =
78 CapabilityManager.HostCapability.UNKNOWN; 77 CapabilityManager.HostCapability.UNKNOWN;
79 78
79 private DesktopView mRemoteHostDesktop;
80
80 /** Called when the activity is first created. */ 81 /** Called when the activity is first created. */
81 @Override 82 @Override
82 public void onCreate(Bundle savedInstanceState) { 83 public void onCreate(Bundle savedInstanceState) {
83 super.onCreate(savedInstanceState); 84 super.onCreate(savedInstanceState);
84 setContentView(R.layout.desktop); 85 setContentView(R.layout.desktop);
85 86
86 mClient = Client.getInstance(); 87 mClient = Client.getInstance();
87 mInjector = new InputEventSender(mClient); 88 mInjector = new InputEventSender(mClient);
88 89
89 mToolbar = (Toolbar) findViewById(R.id.toolbar); 90 mToolbar = (Toolbar) findViewById(R.id.toolbar);
90 setSupportActionBar(mToolbar); 91 setSupportActionBar(mToolbar);
91 92
92 DesktopView remoteHostDesktop = mClient.createDesktopView(this, mClient) ; 93 mRemoteHostDesktop = (DesktopView) findViewById(R.id.desktop_view);
93 remoteHostDesktop.setLayoutParams(new ViewGroup.LayoutParams( 94 mRemoteHostDesktop.attach(mClient, this, mClient.getRenderStub());
94 ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATC H_PARENT));
95 ((ViewGroup) findViewById(R.id.desktop_view_placeholder)).addView(remote HostDesktop);
96 95
97 getSupportActionBar().setDisplayShowTitleEnabled(false); 96 getSupportActionBar().setDisplayShowTitleEnabled(false);
98 getSupportActionBar().setDisplayHomeAsUpEnabled(true); 97 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
99 98
100 // For this Activity, the home button in the action bar acts as a Discon nect button, so 99 // For this Activity, the home button in the action bar acts as a Discon nect button, so
101 // set the description for accessibility/screen readers. 100 // set the description for accessibility/screen readers.
102 getSupportActionBar().setHomeActionContentDescription(R.string.disconnec t_myself_button); 101 getSupportActionBar().setHomeActionContentDescription(R.string.disconnec t_myself_button);
103 102
104 // The action bar is already shown when the activity is started however calling the 103 // The action bar is already shown when the activity is started however calling the
105 // function below will set our preferred system UI flags which will adju st the layout 104 // function below will set our preferred system UI flags which will adju st the layout
(...skipping 27 matching lines...) Expand all
133 getSupportActionBar().addOnMenuVisibilityListener(new OnMenuVisibili tyListener() { 132 getSupportActionBar().addOnMenuVisibilityListener(new OnMenuVisibili tyListener() {
134 public void onMenuVisibilityChanged(boolean isVisible) { 133 public void onMenuVisibilityChanged(boolean isVisible) {
135 if (isVisible) { 134 if (isVisible) {
136 stopActionBarAutoHideTimer(); 135 stopActionBarAutoHideTimer();
137 } else { 136 } else {
138 startActionBarAutoHideTimer(); 137 startActionBarAutoHideTimer();
139 } 138 }
140 } 139 }
141 }); 140 });
142 } else { 141 } else {
143 remoteHostDesktop.setFitsSystemWindows(true); 142 mRemoteHostDesktop.setFitsSystemWindows(true);
144 } 143 }
145 } 144 }
146 145
147 @Override 146 @Override
147 public void onDestroy() {
148 super.onDestroy();
Hzj_jie 2016/09/10 02:06:32 Though there should be zero impact, super.onDestro
Yuwei 2016/09/12 18:56:13 Done.
149 mRemoteHostDesktop.detach();
150 }
151
152 @Override
148 protected void onStart() { 153 protected void onStart() {
149 super.onStart(); 154 super.onStart();
150 mActivityLifecycleListener.onActivityStarted(this); 155 mActivityLifecycleListener.onActivityStarted(this);
151 mClient.enableVideoChannel(true); 156 mClient.enableVideoChannel(true);
152 mClient.getCapabilityManager().addListener(this); 157 mClient.getCapabilityManager().addListener(this);
153 } 158 }
154 159
155 @Override 160 @Override
156 protected void onPause() { 161 protected void onPause() {
157 if (isFinishing()) mActivityLifecycleListener.onActivityPaused(this); 162 if (isFinishing()) mActivityLifecycleListener.onActivityPaused(this);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 @Override 538 @Override
534 public boolean dispatchKeyEvent(KeyEvent event) { 539 public boolean dispatchKeyEvent(KeyEvent event) {
535 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { 540 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
536 mClient.destroy(); 541 mClient.destroy();
537 return super.dispatchKeyEvent(event); 542 return super.dispatchKeyEvent(event);
538 } 543 }
539 544
540 return mInjector.sendKeyEvent(event); 545 return mInjector.sendKeyEvent(event);
541 } 546 }
542 } 547 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698