Chromium Code Reviews| Index: remoting/android/java/src/org/chromium/chromoting/DesktopView.java |
| diff --git a/remoting/android/java/src/org/chromium/chromoting/DesktopView.java b/remoting/android/java/src/org/chromium/chromoting/DesktopView.java |
| index 84b0421361b4ca3e755449ce21c60f481f40630a..674a26bc95c15b6154e3b0a8c35a439d30e1f9d8 100644 |
| --- a/remoting/android/java/src/org/chromium/chromoting/DesktopView.java |
| +++ b/remoting/android/java/src/org/chromium/chromoting/DesktopView.java |
| @@ -5,9 +5,8 @@ |
| package org.chromium.chromoting; |
| import android.content.Context; |
| -import android.graphics.Matrix; |
| -import android.graphics.PointF; |
| import android.text.InputType; |
| +import android.util.AttributeSet; |
| import android.view.MotionEvent; |
| import android.view.SurfaceView; |
| import android.view.inputmethod.EditorInfo; |
| @@ -17,45 +16,42 @@ import android.view.inputmethod.InputMethodManager; |
| import org.chromium.chromoting.jni.Client; |
| /** |
| - * The abstract class for viewing and interacting with a specific remote host. Handles logic |
| - * for touch input and render data. |
| + * The class for viewing and interacting with a specific remote host. |
| */ |
| -public abstract class DesktopView extends SurfaceView { |
| +public class DesktopView extends SurfaceView { |
| - protected final TouchInputHandler mInputHandler; |
| - |
| - /** |
| - * Subclass should trigger this event when the client view size is changed. |
| - */ |
| - protected final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChanged = |
| - new Event.Raisable<>(); |
| + private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisable<>(); |
| - /** |
| - * Subclass should trigger this event when the host (desktop frame) size is changed. |
| - */ |
| - protected final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged = |
| - new Event.Raisable<>(); |
| + /** The parent Desktop activity. */ |
| + private Desktop mDesktop; |
| - /** |
| - * Subclass should trigger this event when a frame is rendered. |
| - */ |
| - protected final Event.Raisable<Void> mOnCanvasRendered = new Event.Raisable<>(); |
| + private TouchInputHandler mInputHandler; |
| - /** The parent Desktop activity. */ |
| - private final Desktop mDesktop; |
| + public DesktopView(Context context, AttributeSet attributeSet) { |
| + super(context, attributeSet); |
| - private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisable<>(); |
| + // Give this view keyboard focus, allowing us to customize the soft keyboard's settings. |
| + setFocusableInTouchMode(true); |
| + } |
| - public DesktopView(Desktop desktop, Client client) { |
| - super(desktop); |
| - Preconditions.notNull(desktop); |
| + /** |
| + * Initializes the view and attaches listeners to RenderStub's events. |
| + */ |
| + public void attach(Client client, Desktop desktop, RenderStub renderStub) { |
| Preconditions.notNull(client); |
| + Preconditions.notNull(desktop); |
| + Preconditions.notNull(renderStub); |
|
Hzj_jie
2016/09/10 02:06:32
You do not need to notNull renderStub, as the it w
Yuwei
2016/09/10 05:29:14
You mean checking whether mDesktop is null so that
Yuwei
2016/09/12 18:56:13
Done.
Hzj_jie
2016/09/12 21:28:04
Yes, I think so. Is my understanding correct?
Yuwei
2016/09/12 21:50:04
Asserting mDesktop is null? Yes.
|
| mDesktop = desktop; |
| - mInputHandler = new TouchInputHandler(this, desktop); |
| - mInputHandler.init(desktop, new InputEventSender(client)); |
| + renderStub.setDesktopView(this); |
| + mInputHandler = new TouchInputHandler(this, desktop, renderStub, |
| + new InputEventSender(client)); |
| + } |
| - // Give this view keyboard focus, allowing us to customize the soft keyboard's settings. |
| - setFocusableInTouchMode(true); |
| + /** |
| + * Detaches listeners from the RenderStub's events. |
| + */ |
| + public void detach() { |
| + mInputHandler.detach(); |
| } |
| // TODO(yuweih): move showActionBar and showKeyboard out of this abstract class. |
| @@ -76,22 +72,6 @@ public abstract class DesktopView extends SurfaceView { |
| return mOnTouch; |
| } |
| - /** An {@link Event} which is triggered when the client size is changed. */ |
| - public final Event<SizeChangedEventParameter> onClientSizeChanged() { |
| - return mOnClientSizeChanged; |
| - } |
| - |
| - /** An {@link Event} which is triggered when the host size is changed. */ |
| - public final Event<SizeChangedEventParameter> onHostSizeChanged() { |
| - return mOnHostSizeChanged; |
| - } |
| - |
| - /** An {@link Event} which is triggered when a frame is rendered. */ |
| - public final Event<Void> onCanvasRendered() { |
| - return mOnCanvasRendered; |
| - } |
| - |
| - // View overrides. |
| /** Called when a software keyboard is requested, and specifies its options. */ |
| @Override |
| public final InputConnection onCreateInputConnection(EditorInfo outAttrs) { |
| @@ -117,25 +97,4 @@ public abstract class DesktopView extends SurfaceView { |
| mOnTouch.raise(parameter); |
| return parameter.handled; |
| } |
| - |
| - /** Triggers a brief animation to indicate the existence and location of an input event. */ |
| - public abstract void showInputFeedback(RenderStub.InputFeedbackType feedbackToShow, PointF pos); |
| - |
| - /** |
| - * Informs the view that its transformation matrix (for rendering the remote desktop bitmap) |
| - * has been changed by the TouchInputHandler, which requires repainting. |
| - */ |
| - public abstract void transformationChanged(Matrix matrix); |
| - |
| - /** |
| - * Informs the view that the cursor has been moved by the TouchInputHandler, which requires |
| - * repainting. |
| - */ |
| - public abstract void cursorMoved(PointF position); |
| - |
| - /** |
| - * Informs the view that the cursor visibility has been changed (for different input mode) by |
| - * the TouchInputHandler, which requires repainting. |
| - */ |
| - public abstract void cursorVisibilityChanged(boolean visible); |
| } |