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

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

Issue 451973002: Capabilities + Extensions + Cast Host Extension Support for Android client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: FindBugs Pass + Changes after Review Created 6 years, 4 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.app.Activity;
9 import android.content.res.Configuration; 8 import android.content.res.Configuration;
10 import android.os.Build; 9 import android.os.Build;
11 import android.os.Bundle; 10 import android.os.Bundle;
11
Lambros 2014/08/14 23:54:25 nit: remove blank lines
aiguha 2014/08/15 03:37:29 Done.
12 import android.support.v7.app.ActionBarActivity;
13
12 import android.view.KeyCharacterMap; 14 import android.view.KeyCharacterMap;
13 import android.view.KeyEvent; 15 import android.view.KeyEvent;
14 import android.view.Menu; 16 import android.view.Menu;
15 import android.view.MenuItem; 17 import android.view.MenuItem;
16 import android.view.View; 18 import android.view.View;
17 import android.view.inputmethod.InputMethodManager; 19 import android.view.inputmethod.InputMethodManager;
18 import android.widget.ImageButton; 20 import android.widget.ImageButton;
19 21
20 import org.chromium.chromoting.jni.JniInterface; 22 import org.chromium.chromoting.jni.JniInterface;
21 23
22 import java.util.Set; 24 import java.util.Set;
23 import java.util.TreeSet; 25 import java.util.TreeSet;
24 26
25 /** 27 /**
26 * A simple screen that does nothing except display a DesktopView and notify it of rotations. 28 * A simple screen that does nothing except display a DesktopView and notify it of rotations.
27 */ 29 */
28 public class Desktop extends Activity implements View.OnSystemUiVisibilityChange Listener { 30 public class Desktop extends ActionBarActivity implements View.OnSystemUiVisibil ityChangeListener {
29 /** Web page to be displayed in the Help screen when launched from this acti vity. */ 31 /** Web page to be displayed in the Help screen when launched from this acti vity. */
30 private static final String HELP_URL = 32 private static final String HELP_URL =
31 "http://support.google.com/chrome/?p=mobile_crd_connecthost"; 33 "http://support.google.com/chrome/?p=mobile_crd_connecthost";
32 34
33 /** The surface that displays the remote host's desktop feed. */ 35 /** The surface that displays the remote host's desktop feed. */
34 private DesktopView mRemoteHostDesktop; 36 private DesktopView mRemoteHostDesktop;
35 37
36 /** The button used to show the action bar. */ 38 /** The button used to show the action bar. */
37 private ImageButton mOverlayButton; 39 private ImageButton mOverlayButton;
38 40
39 /** Set of pressed keys for which we've sent TextEvent. */ 41 /** Set of pressed keys for which we've sent TextEvent. */
40 private Set<Integer> mPressedTextKeys = new TreeSet<Integer>(); 42 private Set<Integer> mPressedTextKeys = new TreeSet<Integer>();
41 43
44 private ActivityLifecycleListener mActivityLifecycleListener;
45
46
42 /** Called when the activity is first created. */ 47 /** Called when the activity is first created. */
43 @Override 48 @Override
44 public void onCreate(Bundle savedInstanceState) { 49 public void onCreate(Bundle savedInstanceState) {
45 super.onCreate(savedInstanceState); 50 super.onCreate(savedInstanceState);
46 setContentView(R.layout.desktop); 51 setContentView(R.layout.desktop);
47 mRemoteHostDesktop = (DesktopView)findViewById(R.id.desktop_view); 52 mRemoteHostDesktop = (DesktopView)findViewById(R.id.desktop_view);
48 mOverlayButton = (ImageButton)findViewById(R.id.desktop_overlay_button); 53 mOverlayButton = (ImageButton)findViewById(R.id.desktop_overlay_button);
49 mRemoteHostDesktop.setDesktop(this); 54 mRemoteHostDesktop.setDesktop(this);
50 55
51 // Ensure the button is initially hidden. 56 // Ensure the button is initially hidden.
52 showActionBar(); 57 showActionBar();
53 58
54 View decorView = getWindow().getDecorView(); 59 View decorView = getWindow().getDecorView();
55 decorView.setOnSystemUiVisibilityChangeListener(this); 60 decorView.setOnSystemUiVisibilityChangeListener(this);
61
62
Lambros 2014/08/14 23:54:25 nit: only one blank line
aiguha 2014/08/15 03:37:30 Done.
63
64 mActivityLifecycleListener = CapabilityManager.getInstance()
65 .onActivityAcceptingListener(this, Capabilities.CAST_CAPABILITY);
66 mActivityLifecycleListener.onActivityCreated(this, savedInstanceState);
67 }
68
Lambros 2014/08/14 23:54:25 nit: only one blank line
aiguha 2014/08/15 03:37:29 Done.
69
70 @Override
71 protected void onStart() {
72 super.onStart();
73 mActivityLifecycleListener.onActivityStarted(this);
74 }
75
76 @Override
77 protected void onPause() {
78 if (isFinishing()) {
79 mActivityLifecycleListener.onActivityPaused(this);
80 }
81 super.onPause();
82 }
83
84 @Override
85 public void onResume() {
86 super.onResume();
87 mActivityLifecycleListener.onActivityResumed(this);
88 }
89
90 @Override
91 protected void onStop() {
92 mActivityLifecycleListener.onActivityStopped(this);
93 super.onStop();
56 } 94 }
57 95
58 /** Called when the activity is finally finished. */ 96 /** Called when the activity is finally finished. */
59 @Override 97 @Override
60 public void onDestroy() { 98 public void onDestroy() {
61 super.onDestroy(); 99 super.onDestroy();
62 JniInterface.disconnectFromHost(); 100 JniInterface.disconnectFromHost();
63 } 101 }
64 102
65 /** Called when the display is rotated (as registered in the manifest). */ 103 /** Called when the display is rotated (as registered in the manifest). */
66 @Override 104 @Override
67 public void onConfigurationChanged(Configuration newConfig) { 105 public void onConfigurationChanged(Configuration newConfig) {
68 super.onConfigurationChanged(newConfig); 106 super.onConfigurationChanged(newConfig);
69 mRemoteHostDesktop.onScreenConfigurationChanged(); 107 mRemoteHostDesktop.onScreenConfigurationChanged();
70 } 108 }
71 109
72 /** Called to initialize the action bar. */ 110 /** Called to initialize the action bar. */
73 @Override 111 @Override
74 public boolean onCreateOptionsMenu(Menu menu) { 112 public boolean onCreateOptionsMenu(Menu menu) {
75 getMenuInflater().inflate(R.menu.desktop_actionbar, menu); 113 getMenuInflater().inflate(R.menu.desktop_actionbar, menu);
114
115 mActivityLifecycleListener.onActivityCreatedOptionsMenu(this, menu);
116
76 return super.onCreateOptionsMenu(menu); 117 return super.onCreateOptionsMenu(menu);
77 } 118 }
78 119
79 /** Called whenever the visibility of the system status bar or navigation ba r changes. */ 120 /** Called whenever the visibility of the system status bar or navigation ba r changes. */
80 @Override 121 @Override
81 public void onSystemUiVisibilityChange(int visibility) { 122 public void onSystemUiVisibilityChange(int visibility) {
82 // Ensure the action-bar's visibility matches that of the system control s. This 123 // Ensure the action-bar's visibility matches that of the system control s. This
83 // minimizes the number of states the UI can be in, to keep things simpl e for the user. 124 // minimizes the number of states the UI can be in, to keep things simpl e for the user.
84 125
85 // Determine if the system is in fullscreen/lights-out mode. LOW_PROFILE is needed since 126 // Determine if the system is in fullscreen/lights-out mode. LOW_PROFILE is needed since
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 178
138 /** The overlay button's onClick handler. */ 179 /** The overlay button's onClick handler. */
139 public void onOverlayButtonPressed(View view) { 180 public void onOverlayButtonPressed(View view) {
140 showActionBar(); 181 showActionBar();
141 } 182 }
142 183
143 /** Called whenever an action bar button is pressed. */ 184 /** Called whenever an action bar button is pressed. */
144 @Override 185 @Override
145 public boolean onOptionsItemSelected(MenuItem item) { 186 public boolean onOptionsItemSelected(MenuItem item) {
146 int id = item.getItemId(); 187 int id = item.getItemId();
188
189 mActivityLifecycleListener.onActivityOptionsItemSelected(this, item);
190
147 if (id == R.id.actionbar_keyboard) { 191 if (id == R.id.actionbar_keyboard) {
148 ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).toggleS oftInput(0, 0); 192 ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).toggleS oftInput(0, 0);
149 return true; 193 return true;
150 } 194 }
151 if (id == R.id.actionbar_hide) { 195 if (id == R.id.actionbar_hide) {
152 hideActionBar(); 196 hideActionBar();
153 return true; 197 return true;
154 } 198 }
155 if (id == R.id.actionbar_disconnect) { 199 if (id == R.id.actionbar_disconnect) {
156 JniInterface.disconnectFromHost(); 200 JniInterface.disconnectFromHost();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT, pressed); 289 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT, pressed);
246 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_EQUALS, pressed); 290 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_EQUALS, pressed);
247 return true; 291 return true;
248 292
249 default: 293 default:
250 // We try to send all other key codes to the host directly. 294 // We try to send all other key codes to the host directly.
251 return JniInterface.sendKeyEvent(keyCode, pressed); 295 return JniInterface.sendKeyEvent(keyCode, pressed);
252 } 296 }
253 } 297 }
254 } 298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698