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.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 9 import android.graphics.Canvas; | 9 import android.graphics.Canvas; |
| 10 import android.graphics.Color; | 10 import android.graphics.Color; |
| 11 import android.graphics.Paint; | 11 import android.graphics.Paint; |
| 12 import android.graphics.Point; | 12 import android.graphics.Point; |
| 13 import android.os.Looper; | 13 import android.os.Looper; |
| 14 import android.os.SystemClock; | 14 import android.os.SystemClock; |
| 15 import android.text.InputType; | 15 import android.text.InputType; |
| 16 import android.util.AttributeSet; | |
| 17 import android.view.MotionEvent; | 16 import android.view.MotionEvent; |
| 18 import android.view.SurfaceHolder; | 17 import android.view.SurfaceHolder; |
| 19 import android.view.SurfaceView; | |
| 20 import android.view.inputmethod.EditorInfo; | 18 import android.view.inputmethod.EditorInfo; |
| 21 import android.view.inputmethod.InputConnection; | 19 import android.view.inputmethod.InputConnection; |
| 22 import android.view.inputmethod.InputMethodManager; | 20 import android.view.inputmethod.InputMethodManager; |
| 23 | 21 |
| 24 import org.chromium.base.Log; | 22 import org.chromium.base.Log; |
| 25 import org.chromium.chromoting.jni.Client; | 23 import org.chromium.chromoting.jni.Client; |
| 26 import org.chromium.chromoting.jni.Display; | 24 import org.chromium.chromoting.jni.Display; |
| 27 | 25 |
| 28 /** | 26 /** |
| 29 * The user interface for viewing and interacting with a specific remote host. | 27 * The user interface for viewing and interacting with a specific remote host. |
| 30 * It provides a canvas onto which the video feed is rendered, handles | 28 * It provides a canvas onto which the video feed is rendered, handles |
| 31 * multitouch pan and zoom gestures, and collects and forwards input events. | 29 * multitouch pan and zoom gestures, and collects and forwards input events. |
| 32 */ | 30 */ |
| 33 /** GUI element that holds the drawing canvas. */ | 31 /** GUI element that holds the drawing canvas. */ |
| 34 public class DesktopView extends SurfaceView implements DesktopViewInterface, | 32 public class DesktopView extends AbstractDesktopView implements SurfaceHolder.Ca llback { |
| 35 SurfaceHolder.Callback { | |
| 36 /** Used to define the animation feedback shown when a user touches the scre en. */ | 33 /** Used to define the animation feedback shown when a user touches the scre en. */ |
| 37 public enum InputFeedbackType { NONE, SMALL_ANIMATION, LARGE_ANIMATION } | 34 public enum InputFeedbackType { NONE, SMALL_ANIMATION, LARGE_ANIMATION } |
| 38 | 35 |
| 39 private static final String TAG = "Chromoting"; | 36 private static final String TAG = "Chromoting"; |
| 40 | 37 |
| 41 private final RenderData mRenderData; | 38 private final RenderData mRenderData; |
| 42 private final TouchInputHandler mInputHandler; | 39 private final TouchInputHandler mInputHandler; |
| 43 | 40 |
| 44 /** The parent Desktop activity. */ | 41 /** The parent Desktop activity. */ |
| 45 private Desktop mDesktop; | 42 private Desktop mDesktop; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 68 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); | 65 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); |
| 69 | 66 |
| 70 // Variables to control animation by the TouchInputHandler. | 67 // Variables to control animation by the TouchInputHandler. |
| 71 | 68 |
| 72 /** Protects mInputAnimationRunning. */ | 69 /** Protects mInputAnimationRunning. */ |
| 73 private final Object mAnimationLock = new Object(); | 70 private final Object mAnimationLock = new Object(); |
| 74 | 71 |
| 75 /** Whether the TouchInputHandler has requested animation to be performed. * / | 72 /** Whether the TouchInputHandler has requested animation to be performed. * / |
| 76 private boolean mInputAnimationRunning = false; | 73 private boolean mInputAnimationRunning = false; |
| 77 | 74 |
| 78 public DesktopView(Context context, AttributeSet attributes) { | 75 public DesktopView(Context context, Display display) { |
|
Hzj_jie
2016/07/10 19:23:59
Since we are not using Android internal way to cre
Yuwei
2016/07/11 00:17:09
Sure
| |
| 79 super(context, attributes); | 76 super(context); |
| 77 | |
| 78 Preconditions.notNull(display); | |
| 79 mDisplay = display; | |
| 80 | 80 |
| 81 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. | 81 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. |
| 82 setFocusableInTouchMode(true); | 82 setFocusableInTouchMode(true); |
| 83 | 83 |
| 84 mRenderData = new RenderData(); | 84 mRenderData = new RenderData(); |
| 85 mInputHandler = new TouchInputHandler(this, context, mRenderData); | 85 mInputHandler = new TouchInputHandler(this, context, mRenderData); |
| 86 | 86 |
| 87 mRepaintPending = false; | 87 mRepaintPending = false; |
| 88 | 88 |
| 89 getHolder().addCallback(this); | 89 getHolder().addCallback(this); |
| 90 } | 90 } |
| 91 | 91 |
| 92 @Override | 92 @Override |
| 93 public void init(Desktop desktop, Client client) { | 93 public void init(Desktop desktop, Client client) { |
| 94 Preconditions.isNull(mDesktop); | 94 Preconditions.isNull(mDesktop); |
| 95 Preconditions.isNull(mClient); | 95 Preconditions.isNull(mClient); |
| 96 Preconditions.isNull(mDisplay); | |
| 97 Preconditions.notNull(desktop); | 96 Preconditions.notNull(desktop); |
| 98 Preconditions.notNull(client); | 97 Preconditions.notNull(client); |
| 99 Preconditions.notNull(client.getDisplay()); | |
| 100 Preconditions.isTrue(client.getDisplay() instanceof Display); | |
| 101 mDesktop = desktop; | 98 mDesktop = desktop; |
| 102 mClient = client; | 99 mClient = client; |
| 103 mDisplay = (Display) client.getDisplay(); | |
| 104 mInputHandler.init(desktop, new InputEventSender(client)); | 100 mInputHandler.init(desktop, new InputEventSender(client)); |
| 105 } | 101 } |
| 106 | 102 |
| 107 public Event<PaintEventParameter> onPaint() { | 103 public Event<PaintEventParameter> onPaint() { |
| 108 return mOnPaint; | 104 return mOnPaint; |
| 109 } | 105 } |
| 110 | 106 |
| 111 public Event<SizeChangedEventParameter> onClientSizeChanged() { | 107 public Event<SizeChangedEventParameter> onClientSizeChanged() { |
| 112 return mOnClientSizeChanged; | 108 return mOnClientSizeChanged; |
| 113 } | 109 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 @Override | 339 @Override |
| 344 public void setAnimationEnabled(boolean enabled) { | 340 public void setAnimationEnabled(boolean enabled) { |
| 345 synchronized (mAnimationLock) { | 341 synchronized (mAnimationLock) { |
| 346 if (enabled && !mInputAnimationRunning) { | 342 if (enabled && !mInputAnimationRunning) { |
| 347 requestRepaint(); | 343 requestRepaint(); |
| 348 } | 344 } |
| 349 mInputAnimationRunning = enabled; | 345 mInputAnimationRunning = enabled; |
| 350 } | 346 } |
| 351 } | 347 } |
| 352 } | 348 } |
| OLD | NEW |