| 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.content.Context; | 7 import android.content.Context; |
| 8 import android.text.InputType; | 8 import android.text.InputType; |
| 9 import android.util.AttributeSet; | 9 import android.util.AttributeSet; |
| 10 import android.view.MotionEvent; | 10 import android.view.MotionEvent; |
| 11 import android.view.SurfaceView; | 11 import android.view.SurfaceView; |
| 12 import android.view.inputmethod.EditorInfo; | 12 import android.view.inputmethod.EditorInfo; |
| 13 import android.view.inputmethod.InputConnection; | 13 import android.view.inputmethod.InputConnection; |
| 14 import android.view.inputmethod.InputMethodManager; | |
| 15 | 14 |
| 16 import org.chromium.chromoting.jni.Client; | 15 import org.chromium.chromoting.jni.Client; |
| 17 | 16 |
| 18 /** | 17 /** |
| 19 * The class for viewing and interacting with a specific remote host. | 18 * The class for viewing and interacting with a specific remote host. |
| 20 */ | 19 */ |
| 21 public final class DesktopView extends SurfaceView { | 20 public final class DesktopView extends SurfaceView { |
| 22 | 21 |
| 23 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa
ble<>(); | 22 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa
ble<>(); |
| 24 | 23 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 51 mInputHandler = new TouchInputHandler(this, mDesktop, renderStub, mInput
EventSender); | 50 mInputHandler = new TouchInputHandler(this, mDesktop, renderStub, mInput
EventSender); |
| 52 } | 51 } |
| 53 | 52 |
| 54 /** | 53 /** |
| 55 * Destroys the view. Should be called in {@link android.app.Activity#onDest
roy()}. | 54 * Destroys the view. Should be called in {@link android.app.Activity#onDest
roy()}. |
| 56 */ | 55 */ |
| 57 public void destroy() { | 56 public void destroy() { |
| 58 mInputHandler.detachEventListeners(); | 57 mInputHandler.detachEventListeners(); |
| 59 } | 58 } |
| 60 | 59 |
| 61 // TODO(yuweih): move showActionBar and showKeyboard out of this class. | |
| 62 /** Shows the action bar. */ | |
| 63 public final void showActionBar() { | |
| 64 mDesktop.showSystemUi(); | |
| 65 } | |
| 66 | |
| 67 /** Shows the software keyboard. */ | |
| 68 public final void showKeyboard() { | |
| 69 InputMethodManager inputManager = | |
| 70 (InputMethodManager) getContext().getSystemService(Context.INPUT
_METHOD_SERVICE); | |
| 71 inputManager.showSoftInput(this, 0); | |
| 72 } | |
| 73 | |
| 74 /** An {@link Event} which is triggered when user touches the screen. */ | 60 /** An {@link Event} which is triggered when user touches the screen. */ |
| 75 public final Event<TouchEventParameter> onTouch() { | 61 public final Event<TouchEventParameter> onTouch() { |
| 76 return mOnTouch; | 62 return mOnTouch; |
| 77 } | 63 } |
| 78 | 64 |
| 79 /** Called when a software keyboard is requested, and specifies its options.
*/ | 65 /** Called when a software keyboard is requested, and specifies its options.
*/ |
| 80 @Override | 66 @Override |
| 81 public final InputConnection onCreateInputConnection(EditorInfo outAttrs) { | 67 public final InputConnection onCreateInputConnection(EditorInfo outAttrs) { |
| 82 // Disables rich input support and instead requests simple key events. | 68 // Disables rich input support and instead requests simple key events. |
| 83 outAttrs.inputType = InputType.TYPE_NULL; | 69 outAttrs.inputType = InputType.TYPE_NULL; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 95 } | 81 } |
| 96 | 82 |
| 97 /** Called whenever the user attempts to touch the canvas. */ | 83 /** Called whenever the user attempts to touch the canvas. */ |
| 98 @Override | 84 @Override |
| 99 public final boolean onTouchEvent(MotionEvent event) { | 85 public final boolean onTouchEvent(MotionEvent event) { |
| 100 TouchEventParameter parameter = new TouchEventParameter(event); | 86 TouchEventParameter parameter = new TouchEventParameter(event); |
| 101 mOnTouch.raise(parameter); | 87 mOnTouch.raise(parameter); |
| 102 return parameter.handled; | 88 return parameter.handled; |
| 103 } | 89 } |
| 104 } | 90 } |
| OLD | NEW |