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

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

Powered by Google App Engine
This is Rietveld 408576698