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

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: Minor Fix 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 import android.support.v7.app.ActionBarActivity;
12 import android.view.KeyCharacterMap; 12 import android.view.KeyCharacterMap;
13 import android.view.KeyEvent; 13 import android.view.KeyEvent;
14 import android.view.Menu; 14 import android.view.Menu;
15 import android.view.MenuItem; 15 import android.view.MenuItem;
16 import android.view.View; 16 import android.view.View;
17 import android.view.inputmethod.InputMethodManager; 17 import android.view.inputmethod.InputMethodManager;
18 import android.widget.ImageButton; 18 import android.widget.ImageButton;
19 19
20 import org.chromium.chromoting.jni.JniInterface; 20 import org.chromium.chromoting.jni.JniInterface;
21 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 mActivityLifecycleListener = CapabilityManager.getInstance()
61 .onActivityAcceptingListener(this, Capabilities.CAST_CAPABILITY);
62 mActivityLifecycleListener.onActivityCreated(this, savedInstanceState);
63 }
64
65 @Override
66 protected void onStart() {
67 super.onStart();
68 mActivityLifecycleListener.onActivityStarted(this);
69 }
70
71 @Override
72 protected void onPause() {
73 if (isFinishing()) {
74 mActivityLifecycleListener.onActivityPaused(this);
75 }
76 super.onPause();
77 }
78
79 @Override
80 public void onResume() {
81 super.onResume();
82 mActivityLifecycleListener.onActivityResumed(this);
83 }
84
85 @Override
86 protected void onStop() {
87 mActivityLifecycleListener.onActivityStopped(this);
88 super.onStop();
56 } 89 }
57 90
58 /** Called when the activity is finally finished. */ 91 /** Called when the activity is finally finished. */
59 @Override 92 @Override
60 public void onDestroy() { 93 public void onDestroy() {
61 super.onDestroy(); 94 super.onDestroy();
62 JniInterface.disconnectFromHost(); 95 JniInterface.disconnectFromHost();
63 } 96 }
64 97
65 /** Called when the display is rotated (as registered in the manifest). */ 98 /** Called when the display is rotated (as registered in the manifest). */
66 @Override 99 @Override
67 public void onConfigurationChanged(Configuration newConfig) { 100 public void onConfigurationChanged(Configuration newConfig) {
68 super.onConfigurationChanged(newConfig); 101 super.onConfigurationChanged(newConfig);
69 mRemoteHostDesktop.onScreenConfigurationChanged(); 102 mRemoteHostDesktop.onScreenConfigurationChanged();
70 } 103 }
71 104
72 /** Called to initialize the action bar. */ 105 /** Called to initialize the action bar. */
73 @Override 106 @Override
74 public boolean onCreateOptionsMenu(Menu menu) { 107 public boolean onCreateOptionsMenu(Menu menu) {
75 getMenuInflater().inflate(R.menu.desktop_actionbar, menu); 108 getMenuInflater().inflate(R.menu.desktop_actionbar, menu);
109
110 mActivityLifecycleListener.onActivityCreatedOptionsMenu(this, menu);
111
76 return super.onCreateOptionsMenu(menu); 112 return super.onCreateOptionsMenu(menu);
77 } 113 }
78 114
79 /** Called whenever the visibility of the system status bar or navigation ba r changes. */ 115 /** Called whenever the visibility of the system status bar or navigation ba r changes. */
80 @Override 116 @Override
81 public void onSystemUiVisibilityChange(int visibility) { 117 public void onSystemUiVisibilityChange(int visibility) {
82 // Ensure the action-bar's visibility matches that of the system control s. This 118 // 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. 119 // minimizes the number of states the UI can be in, to keep things simpl e for the user.
84 120
85 // Determine if the system is in fullscreen/lights-out mode. LOW_PROFILE is needed since 121 // 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 173
138 /** The overlay button's onClick handler. */ 174 /** The overlay button's onClick handler. */
139 public void onOverlayButtonPressed(View view) { 175 public void onOverlayButtonPressed(View view) {
140 showActionBar(); 176 showActionBar();
141 } 177 }
142 178
143 /** Called whenever an action bar button is pressed. */ 179 /** Called whenever an action bar button is pressed. */
144 @Override 180 @Override
145 public boolean onOptionsItemSelected(MenuItem item) { 181 public boolean onOptionsItemSelected(MenuItem item) {
146 int id = item.getItemId(); 182 int id = item.getItemId();
183
184 mActivityLifecycleListener.onActivityOptionsItemSelected(this, item);
185
147 if (id == R.id.actionbar_keyboard) { 186 if (id == R.id.actionbar_keyboard) {
148 ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).toggleS oftInput(0, 0); 187 ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).toggleS oftInput(0, 0);
149 return true; 188 return true;
150 } 189 }
151 if (id == R.id.actionbar_hide) { 190 if (id == R.id.actionbar_hide) {
152 hideActionBar(); 191 hideActionBar();
153 return true; 192 return true;
154 } 193 }
155 if (id == R.id.actionbar_disconnect) { 194 if (id == R.id.actionbar_disconnect) {
156 JniInterface.disconnectFromHost(); 195 JniInterface.disconnectFromHost();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT, pressed); 284 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT, pressed);
246 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_EQUALS, pressed); 285 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_EQUALS, pressed);
247 return true; 286 return true;
248 287
249 default: 288 default:
250 // We try to send all other key codes to the host directly. 289 // We try to send all other key codes to the host directly.
251 return JniInterface.sendKeyEvent(keyCode, pressed); 290 return JniInterface.sendKeyEvent(keyCode, pressed);
252 } 291 }
253 } 292 }
254 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698