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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 } | 113 } |
| 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 |
| 123 /** Returns the radius of the given feedback type. 0.0f will be returned if no feedback should | |
|
Lambros
2016/07/26 18:54:17
Format this as multi-line:
/**
* Returns...
* bl
Yuwei
2016/07/26 19:05:42
Done.
| |
| 124 * be shown. */ | |
| 125 protected final float getFeedbackRadius(InputFeedbackType feedbackToShow) { | |
| 126 if (feedbackToShow == InputFeedbackType.NONE) { | |
|
Lambros
2016/07/26 18:54:17
Move this into the switch..case.
Yuwei
2016/07/26 19:05:42
Done.
| |
| 127 return 0.0f; | |
| 128 } | |
| 129 switch (feedbackToShow) { | |
| 130 case SMALL_ANIMATION: | |
| 131 return mSmallFeedbackPixelRadius; | |
| 132 case LARGE_ANIMATION: | |
| 133 return mLargeFeedbackPixelRadius; | |
| 134 default: | |
| 135 // Unreachable, but required by Google Java style and findbugs. | |
| 136 assert false : "Unreached"; | |
| 137 return 0.0f; | |
| 138 } | |
| 139 } | |
| 140 | |
| 114 /** Triggers a brief animation to indicate the existence and location of an input event. */ | 141 /** Triggers a brief animation to indicate the existence and location of an input event. */ |
| 115 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi nt pos); | 142 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi nt pos); |
| 116 | 143 |
| 117 /** | 144 /** |
| 118 * Informs the view that its transformation matrix (for rendering the remote desktop bitmap) | 145 * Informs the view that its transformation matrix (for rendering the remote desktop bitmap) |
| 119 * has been changed by the TouchInputHandler, which requires repainting. | 146 * has been changed by the TouchInputHandler, which requires repainting. |
| 120 */ | 147 */ |
| 121 public abstract void transformationChanged(); | 148 public abstract void transformationChanged(); |
| 122 | 149 |
| 123 /** | 150 /** |
| 124 * Informs the view that the cursor has been moved by the TouchInputHandler, which requires | 151 * Informs the view that the cursor has been moved by the TouchInputHandler, which requires |
| 125 * repainting. | 152 * repainting. |
| 126 */ | 153 */ |
| 127 public abstract void cursorMoved(); | 154 public abstract void cursorMoved(); |
| 128 | 155 |
| 129 /** | 156 /** |
| 130 * Informs the view that the cursor visibility has been changed (for differe nt input mode) by | 157 * Informs the view that the cursor visibility has been changed (for differe nt input mode) by |
| 131 * the TouchInputHandler, which requires repainting. | 158 * the TouchInputHandler, which requires repainting. |
| 132 */ | 159 */ |
| 133 public abstract void cursorVisibilityChanged(); | 160 public abstract void cursorVisibilityChanged(); |
| 134 | 161 |
| 135 /** | 162 /** |
| 136 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will | 163 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will |
| 137 * periodically call TouchInputHandler.processAnimation() and repaint itself . | 164 * periodically call TouchInputHandler.processAnimation() and repaint itself . |
| 138 */ | 165 */ |
| 139 public abstract void setAnimationEnabled(boolean enabled); | 166 public abstract void setAnimationEnabled(boolean enabled); |
| 140 } | 167 } |
| OLD | NEW |