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

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

Issue 2322623002: [Remoting Android] Refactor GlDesktopView (Closed)
Patch Set: Reviewer's Feedback 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.
31 * It may be recreated for multiple times when the screen is rotated or the app is brought to the
32 * background.
joedow 2016/09/13 00:08:50 Since you removed the attach/detach methods and th
Yuwei 2016/09/13 01:42:26 Removed. Actually this is the activity class...
32 */ 33 */
33 public class Desktop 34 public class Desktop
34 extends AppCompatActivity implements View.OnSystemUiVisibilityChangeList ener, 35 extends AppCompatActivity implements View.OnSystemUiVisibilityChangeList ener,
35 CapabilityManager.CapabilitiesChang edListener { 36 CapabilityManager.CapabilitiesChang edListener {
36 /** Used to set/store the selected input mode. */ 37 /** Used to set/store the selected input mode. */
37 public enum InputMode { 38 public enum InputMode {
38 UNKNOWN, 39 UNKNOWN,
39 TRACKPAD, 40 TRACKPAD,
40 TOUCH; 41 TOUCH;
41 42
(...skipping 28 matching lines...) Expand all
70 /** The Toolbar instance backing our SupportActionBar. */ 71 /** The Toolbar instance backing our SupportActionBar. */
71 private Toolbar mToolbar; 72 private Toolbar mToolbar;
72 73
73 /** Tracks the current input mode (e.g. trackpad/touch). */ 74 /** Tracks the current input mode (e.g. trackpad/touch). */
74 private InputMode mInputMode = InputMode.UNKNOWN; 75 private InputMode mInputMode = InputMode.UNKNOWN;
75 76
76 /** Indicates whether the remote host supports touch injection. */ 77 /** Indicates whether the remote host supports touch injection. */
77 private CapabilityManager.HostCapability mHostTouchCapability = 78 private CapabilityManager.HostCapability mHostTouchCapability =
78 CapabilityManager.HostCapability.UNKNOWN; 79 CapabilityManager.HostCapability.UNKNOWN;
79 80
81 private DesktopView mRemoteHostDesktop;
82
80 /** Called when the activity is first created. */ 83 /** Called when the activity is first created. */
81 @Override 84 @Override
82 public void onCreate(Bundle savedInstanceState) { 85 public void onCreate(Bundle savedInstanceState) {
83 super.onCreate(savedInstanceState); 86 super.onCreate(savedInstanceState);
84 setContentView(R.layout.desktop); 87 setContentView(R.layout.desktop);
85 88
86 mClient = Client.getInstance(); 89 mClient = Client.getInstance();
87 mInjector = new InputEventSender(mClient); 90 mInjector = new InputEventSender(mClient);
88 91
92 Preconditions.notNull(mClient);
93
89 mToolbar = (Toolbar) findViewById(R.id.toolbar); 94 mToolbar = (Toolbar) findViewById(R.id.toolbar);
90 setSupportActionBar(mToolbar); 95 setSupportActionBar(mToolbar);
91 96
92 DesktopView remoteHostDesktop = mClient.createDesktopView(this, mClient) ; 97 mRemoteHostDesktop = (DesktopView) findViewById(R.id.desktop_view);
93 remoteHostDesktop.setLayoutParams(new ViewGroup.LayoutParams( 98 mRemoteHostDesktop.init(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 99
97 getSupportActionBar().setDisplayShowTitleEnabled(false); 100 getSupportActionBar().setDisplayShowTitleEnabled(false);
98 getSupportActionBar().setDisplayHomeAsUpEnabled(true); 101 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
99 102
100 // For this Activity, the home button in the action bar acts as a Discon nect button, so 103 // 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. 104 // set the description for accessibility/screen readers.
102 getSupportActionBar().setHomeActionContentDescription(R.string.disconnec t_myself_button); 105 getSupportActionBar().setHomeActionContentDescription(R.string.disconnec t_myself_button);
103 106
104 // The action bar is already shown when the activity is started however calling the 107 // 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 108 // 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() { 136 getSupportActionBar().addOnMenuVisibilityListener(new OnMenuVisibili tyListener() {
134 public void onMenuVisibilityChanged(boolean isVisible) { 137 public void onMenuVisibilityChanged(boolean isVisible) {
135 if (isVisible) { 138 if (isVisible) {
136 stopActionBarAutoHideTimer(); 139 stopActionBarAutoHideTimer();
137 } else { 140 } else {
138 startActionBarAutoHideTimer(); 141 startActionBarAutoHideTimer();
139 } 142 }
140 } 143 }
141 }); 144 });
142 } else { 145 } else {
143 remoteHostDesktop.setFitsSystemWindows(true); 146 mRemoteHostDesktop.setFitsSystemWindows(true);
144 } 147 }
145 } 148 }
146 149
147 @Override 150 @Override
148 protected void onStart() { 151 protected void onStart() {
149 super.onStart(); 152 super.onStart();
150 mActivityLifecycleListener.onActivityStarted(this); 153 mActivityLifecycleListener.onActivityStarted(this);
151 mClient.enableVideoChannel(true); 154 mClient.enableVideoChannel(true);
152 mClient.getCapabilityManager().addListener(this); 155 mClient.getCapabilityManager().addListener(this);
153 } 156 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 @Override 536 @Override
534 public boolean dispatchKeyEvent(KeyEvent event) { 537 public boolean dispatchKeyEvent(KeyEvent event) {
535 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { 538 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
536 mClient.destroy(); 539 mClient.destroy();
537 return super.dispatchKeyEvent(event); 540 return super.dispatchKeyEvent(event);
538 } 541 }
539 542
540 return mInjector.sendKeyEvent(event); 543 return mInjector.sendKeyEvent(event);
541 } 544 }
542 } 545 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698