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.Point; | 8 import android.graphics.Point; |
| 9 import android.text.InputType; | 9 import android.text.InputType; |
| 10 import android.view.MotionEvent; | 10 import android.view.MotionEvent; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 */ | 31 */ |
| 32 protected final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChang ed = | 32 protected final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChang ed = |
| 33 new Event.Raisable<>(); | 33 new Event.Raisable<>(); |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Subclass should trigger this event when the host (desktop frame) size is changed. | 36 * Subclass should trigger this event when the host (desktop frame) size is changed. |
| 37 */ | 37 */ |
| 38 protected final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged = | 38 protected final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged = |
| 39 new Event.Raisable<>(); | 39 new Event.Raisable<>(); |
| 40 | 40 |
| 41 protected final int mSmallFeedbackPixelRadius; | |
| 42 protected final int mLargeFeedbackPixelRadius; | |
| 43 | |
| 41 /** The parent Desktop activity. */ | 44 /** The parent Desktop activity. */ |
| 42 private final Desktop mDesktop; | 45 private final Desktop mDesktop; |
| 43 | 46 |
| 44 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); | 47 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); |
| 45 | 48 |
| 46 public AbstractDesktopView(Desktop desktop, Client client) { | 49 public AbstractDesktopView(Desktop desktop, Client client) { |
| 47 super(desktop); | 50 super(desktop); |
| 48 Preconditions.notNull(desktop); | 51 Preconditions.notNull(desktop); |
| 49 Preconditions.notNull(client); | 52 Preconditions.notNull(client); |
| 50 mDesktop = desktop; | 53 mDesktop = desktop; |
| 51 mRenderData = new RenderData(); | 54 mRenderData = new RenderData(); |
| 52 mInputHandler = new TouchInputHandler(this, desktop, mRenderData); | 55 mInputHandler = new TouchInputHandler(this, desktop, mRenderData); |
| 53 mInputHandler.init(desktop, new InputEventSender(client)); | 56 mInputHandler.init(desktop, new InputEventSender(client)); |
| 54 | 57 |
| 55 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. | 58 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. |
| 56 setFocusableInTouchMode(true); | 59 setFocusableInTouchMode(true); |
| 60 | |
| 61 mSmallFeedbackPixelRadius = getResources() | |
| 62 .getDimensionPixelSize(R.dimen.feedback_animation_radius_small); | |
| 63 | |
| 64 mLargeFeedbackPixelRadius = getResources() | |
| 65 .getDimensionPixelSize(R.dimen.feedback_animation_radius_large); | |
| 57 } | 66 } |
| 58 | 67 |
| 59 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass. | 68 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass. |
| 60 /** Shows the action bar. */ | 69 /** Shows the action bar. */ |
| 61 public final void showActionBar() { | 70 public final void showActionBar() { |
| 62 mDesktop.showSystemUi(); | 71 mDesktop.showSystemUi(); |
| 63 } | 72 } |
| 64 | 73 |
| 65 /** Shows the software keyboard. */ | 74 /** Shows the software keyboard. */ |
| 66 public final void showKeyboard() { | 75 public final void showKeyboard() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 | 114 |
| 106 /** Called whenever the user attempts to touch the canvas. */ | 115 /** Called whenever the user attempts to touch the canvas. */ |
| 107 @Override | 116 @Override |
| 108 public final boolean onTouchEvent(MotionEvent event) { | 117 public final boolean onTouchEvent(MotionEvent event) { |
| 109 TouchEventParameter parameter = new TouchEventParameter(event); | 118 TouchEventParameter parameter = new TouchEventParameter(event); |
| 110 mOnTouch.raise(parameter); | 119 mOnTouch.raise(parameter); |
| 111 return parameter.handled; | 120 return parameter.handled; |
| 112 } | 121 } |
| 113 | 122 |
| 114 /** Triggers a brief animation to indicate the existence and location of an input event. */ | 123 /** Triggers a brief animation to indicate the existence and location of an input event. */ |
| 115 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi nt pos); | 124 public final void showInputFeedback(InputFeedbackType feedbackToShow, Point pos) { |
| 125 float radius; | |
| 126 switch (feedbackToShow) { | |
| 127 case SMALL_ANIMATION: | |
| 128 radius = mSmallFeedbackPixelRadius; | |
| 129 break; | |
| 130 case LARGE_ANIMATION: | |
| 131 radius = mLargeFeedbackPixelRadius; | |
| 132 break; | |
| 133 default: | |
| 134 // Unreachable, but required by Google Java style and findbugs. | |
| 135 assert false : "Unreached"; | |
| 136 radius = 0.0f; | |
| 137 } | |
| 138 showInputFeedback(radius, pos); | |
| 139 } | |
| 140 | |
| 141 /** | |
| 142 * Triggers a brief animation to indicate the existence and location of an i nput event. | |
| 143 * Subclass should implement this function to draw the animation on the canv as. | |
| 144 */ | |
| 145 public abstract void showInputFeedback(float feedbackRadius, Point pos); | |
|
Lambros
2016/07/26 01:53:58
It's better to keep the original abstract interfac
Yuwei
2016/07/26 18:47:26
I'm not sure whether we want to have different fee
| |
| 116 | 146 |
| 117 /** | 147 /** |
| 118 * Informs the view that its transformation matrix (for rendering the remote desktop bitmap) | 148 * Informs the view that its transformation matrix (for rendering the remote desktop bitmap) |
| 119 * has been changed by the TouchInputHandler, which requires repainting. | 149 * has been changed by the TouchInputHandler, which requires repainting. |
| 120 */ | 150 */ |
| 121 public abstract void transformationChanged(); | 151 public abstract void transformationChanged(); |
| 122 | 152 |
| 123 /** | 153 /** |
| 124 * Informs the view that the cursor has been moved by the TouchInputHandler, which requires | 154 * Informs the view that the cursor has been moved by the TouchInputHandler, which requires |
| 125 * repainting. | 155 * repainting. |
| 126 */ | 156 */ |
| 127 public abstract void cursorMoved(); | 157 public abstract void cursorMoved(); |
| 128 | 158 |
| 129 /** | 159 /** |
| 130 * Informs the view that the cursor visibility has been changed (for differe nt input mode) by | 160 * Informs the view that the cursor visibility has been changed (for differe nt input mode) by |
| 131 * the TouchInputHandler, which requires repainting. | 161 * the TouchInputHandler, which requires repainting. |
| 132 */ | 162 */ |
| 133 public abstract void cursorVisibilityChanged(); | 163 public abstract void cursorVisibilityChanged(); |
| 134 | 164 |
| 135 /** | 165 /** |
| 136 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will | 166 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will |
| 137 * periodically call TouchInputHandler.processAnimation() and repaint itself . | 167 * periodically call TouchInputHandler.processAnimation() and repaint itself . |
| 138 */ | 168 */ |
| 139 public abstract void setAnimationEnabled(boolean enabled); | 169 public abstract void setAnimationEnabled(boolean enabled); |
| 140 } | 170 } |
| OLD | NEW |