Chromium Code Reviews| 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 DesktopViewInterface remoteHostDesktop = |
| 109 mClient.getDisplay().createDesktopView(getApplicationContext()); | |
|
Lambros
2016/07/08 02:13:41
When creating Views, it's important to use the act
Yuwei
2016/07/08 19:58:56
Done
| |
| 110 remoteHostDesktop.setLayoutParams(new ViewGroup.LayoutParams( | |
| 111 ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATC H_PARENT)); | |
| 112 ((ViewGroup) findViewById(R.id.desktop_view_placeholder)).addView((View) remoteHostDesktop); | |
|
Lambros
2016/07/08 02:13:41
The cast to (View) is ugly, maybe indicates a desi
Yuwei
2016/07/08 19:58:56
Actually I have considered making it an abstract c
Lambros
2016/07/08 22:02:36
I think this is fine. As long as you are rendering
Yuwei
2016/07/08 23:07:54
This sounds like a better approach, but also requi
Yuwei
2016/07/08 23:35:53
CC zijiehe@. There is a discussion about making De
| |
| 108 remoteHostDesktop.init(this, mClient); | 113 remoteHostDesktop.init(this, mClient); |
| 109 mSwitchToCardboardDesktopActivity = false; | 114 mSwitchToCardboardDesktopActivity = false; |
| 110 | 115 |
| 111 getSupportActionBar().setDisplayShowTitleEnabled(false); | 116 getSupportActionBar().setDisplayShowTitleEnabled(false); |
| 112 getSupportActionBar().setDisplayHomeAsUpEnabled(true); | 117 getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
| 113 | 118 |
| 114 // For this Activity, the home button in the action bar acts as a Discon nect button, so | 119 // 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. | 120 // set the description for accessibility/screen readers. |
| 116 getSupportActionBar().setHomeActionContentDescription(R.string.disconnec t_myself_button); | 121 getSupportActionBar().setHomeActionContentDescription(R.string.disconnec t_myself_button); |
| 117 | 122 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 } else { | 161 } else { |
| 157 remoteHostDesktop.setFitsSystemWindows(true); | 162 remoteHostDesktop.setFitsSystemWindows(true); |
| 158 } | 163 } |
| 159 } | 164 } |
| 160 | 165 |
| 161 @Override | 166 @Override |
| 162 protected void onStart() { | 167 protected void onStart() { |
| 163 super.onStart(); | 168 super.onStart(); |
| 164 mActivityLifecycleListener.onActivityStarted(this); | 169 mActivityLifecycleListener.onActivityStarted(this); |
| 165 mClient.enableVideoChannel(true); | 170 mClient.enableVideoChannel(true); |
| 166 DesktopView desktopView = (DesktopView) findViewById(R.id.desktop_view); | |
|
Yuwei
2016/07/08 00:30:00
This logic is unnecessary since attachRedrawCallba
| |
| 167 desktopView.attachRedrawCallback(); | |
| 168 mClient.getCapabilityManager().addListener(this); | 171 mClient.getCapabilityManager().addListener(this); |
| 169 } | 172 } |
| 170 | 173 |
| 171 @Override | 174 @Override |
| 172 protected void onPause() { | 175 protected void onPause() { |
| 173 if (isFinishing()) mActivityLifecycleListener.onActivityPaused(this); | 176 if (isFinishing()) mActivityLifecycleListener.onActivityPaused(this); |
| 174 super.onPause(); | 177 super.onPause(); |
| 175 if (!mSwitchToCardboardDesktopActivity) { | 178 if (!mSwitchToCardboardDesktopActivity) { |
| 176 mClient.enableVideoChannel(false); | 179 mClient.enableVideoChannel(false); |
| 177 } | 180 } |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 @Override | 610 @Override |
| 608 public boolean dispatchKeyEvent(KeyEvent event) { | 611 public boolean dispatchKeyEvent(KeyEvent event) { |
| 609 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { | 612 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
| 610 mClient.destroy(); | 613 mClient.destroy(); |
| 611 return super.dispatchKeyEvent(event); | 614 return super.dispatchKeyEvent(event); |
| 612 } | 615 } |
| 613 | 616 |
| 614 return mInjector.sendKeyEvent(event); | 617 return mInjector.sendKeyEvent(event); |
| 615 } | 618 } |
| 616 } | 619 } |
| OLD | NEW |