OLD | NEW |
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.content.DialogInterface; | 8 import android.content.DialogInterface; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.pm.ApplicationInfo; | 10 import android.content.pm.ApplicationInfo; |
11 import android.content.pm.PackageManager; | 11 import android.content.pm.PackageManager; |
12 import android.content.pm.PackageManager.NameNotFoundException; | 12 import android.content.pm.PackageManager.NameNotFoundException; |
13 import android.os.Build; | 13 import android.os.Build; |
14 import android.os.Bundle; | 14 import android.os.Bundle; |
15 import android.os.Handler; | 15 import android.os.Handler; |
16 import android.support.v7.app.ActionBar.OnMenuVisibilityListener; | 16 import android.support.v7.app.ActionBar.OnMenuVisibilityListener; |
17 import android.support.v7.app.AlertDialog; | 17 import android.support.v7.app.AlertDialog; |
18 import android.support.v7.app.AppCompatActivity; | 18 import android.support.v7.app.AppCompatActivity; |
19 import android.support.v7.widget.Toolbar; | 19 import android.support.v7.widget.Toolbar; |
20 import android.view.KeyEvent; | 20 import android.view.KeyEvent; |
21 import android.view.Menu; | 21 import android.view.Menu; |
22 import android.view.MenuItem; | 22 import android.view.MenuItem; |
23 import android.view.MotionEvent; | 23 import android.view.MotionEvent; |
24 import android.view.View; | 24 import android.view.View; |
25 import android.view.View.OnLayoutChangeListener; | 25 import android.view.View.OnLayoutChangeListener; |
26 import android.view.View.OnTouchListener; | 26 import android.view.View.OnTouchListener; |
| 27 import android.view.ViewGroup; |
27 import android.view.inputmethod.InputMethodManager; | 28 import android.view.inputmethod.InputMethodManager; |
28 | 29 |
29 import org.chromium.chromoting.cardboard.DesktopActivity; | 30 import org.chromium.chromoting.cardboard.DesktopActivity; |
30 import org.chromium.chromoting.help.HelpContext; | 31 import org.chromium.chromoting.help.HelpContext; |
31 import org.chromium.chromoting.help.HelpSingleton; | 32 import org.chromium.chromoting.help.HelpSingleton; |
32 import org.chromium.chromoting.jni.Client; | 33 import org.chromium.chromoting.jni.Client; |
33 | 34 |
34 import java.util.List; | 35 import java.util.List; |
35 | 36 |
36 /** | 37 /** |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 public void onCreate(Bundle savedInstanceState) { | 98 public void onCreate(Bundle savedInstanceState) { |
98 super.onCreate(savedInstanceState); | 99 super.onCreate(savedInstanceState); |
99 setContentView(R.layout.desktop); | 100 setContentView(R.layout.desktop); |
100 | 101 |
101 mClient = Client.getInstance(); | 102 mClient = Client.getInstance(); |
102 mInjector = new InputEventSender(mClient); | 103 mInjector = new InputEventSender(mClient); |
103 | 104 |
104 mToolbar = (Toolbar) findViewById(R.id.toolbar); | 105 mToolbar = (Toolbar) findViewById(R.id.toolbar); |
105 setSupportActionBar(mToolbar); | 106 setSupportActionBar(mToolbar); |
106 | 107 |
107 DesktopView remoteHostDesktop = (DesktopView) findViewById(R.id.desktop_
view); | 108 AbstractDesktopView remoteHostDesktop = mClient.createDesktopView(this); |
| 109 remoteHostDesktop.setLayoutParams(new ViewGroup.LayoutParams( |
| 110 ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATC
H_PARENT)); |
| 111 ((ViewGroup) findViewById(R.id.desktop_view_placeholder)).addView(remote
HostDesktop); |
108 remoteHostDesktop.init(this, mClient); | 112 remoteHostDesktop.init(this, mClient); |
109 mSwitchToCardboardDesktopActivity = false; | 113 mSwitchToCardboardDesktopActivity = false; |
110 | 114 |
111 getSupportActionBar().setDisplayShowTitleEnabled(false); | 115 getSupportActionBar().setDisplayShowTitleEnabled(false); |
112 getSupportActionBar().setDisplayHomeAsUpEnabled(true); | 116 getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
113 | 117 |
114 // For this Activity, the home button in the action bar acts as a Discon
nect button, so | 118 // For this Activity, the home button in the action bar acts as a Discon
nect button, so |
115 // set the description for accessibility/screen readers. | 119 // set the description for accessibility/screen readers. |
116 getSupportActionBar().setHomeActionContentDescription(R.string.disconnec
t_myself_button); | 120 getSupportActionBar().setHomeActionContentDescription(R.string.disconnec
t_myself_button); |
117 | 121 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } else { | 160 } else { |
157 remoteHostDesktop.setFitsSystemWindows(true); | 161 remoteHostDesktop.setFitsSystemWindows(true); |
158 } | 162 } |
159 } | 163 } |
160 | 164 |
161 @Override | 165 @Override |
162 protected void onStart() { | 166 protected void onStart() { |
163 super.onStart(); | 167 super.onStart(); |
164 mActivityLifecycleListener.onActivityStarted(this); | 168 mActivityLifecycleListener.onActivityStarted(this); |
165 mClient.enableVideoChannel(true); | 169 mClient.enableVideoChannel(true); |
166 DesktopView desktopView = (DesktopView) findViewById(R.id.desktop_view); | |
167 desktopView.attachRedrawCallback(); | |
168 mClient.getCapabilityManager().addListener(this); | 170 mClient.getCapabilityManager().addListener(this); |
169 } | 171 } |
170 | 172 |
171 @Override | 173 @Override |
172 protected void onPause() { | 174 protected void onPause() { |
173 if (isFinishing()) mActivityLifecycleListener.onActivityPaused(this); | 175 if (isFinishing()) mActivityLifecycleListener.onActivityPaused(this); |
174 super.onPause(); | 176 super.onPause(); |
175 if (!mSwitchToCardboardDesktopActivity) { | 177 if (!mSwitchToCardboardDesktopActivity) { |
176 mClient.enableVideoChannel(false); | 178 mClient.enableVideoChannel(false); |
177 } | 179 } |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 @Override | 609 @Override |
608 public boolean dispatchKeyEvent(KeyEvent event) { | 610 public boolean dispatchKeyEvent(KeyEvent event) { |
609 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { | 611 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
610 mClient.destroy(); | 612 mClient.destroy(); |
611 return super.dispatchKeyEvent(event); | 613 return super.dispatchKeyEvent(event); |
612 } | 614 } |
613 | 615 |
614 return mInjector.sendKeyEvent(event); | 616 return mInjector.sendKeyEvent(event); |
615 } | 617 } |
616 } | 618 } |
OLD | NEW |