Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.blimp; | 5 package org.chromium.blimp; |
| 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.os.Build; | 9 import android.os.Build; |
| 10 import android.util.AttributeSet; | 10 import android.util.AttributeSet; |
| 11 import android.view.MotionEvent; | 11 import android.view.MotionEvent; |
| 12 import android.view.Surface; | 12 import android.view.Surface; |
| 13 import android.view.SurfaceHolder; | 13 import android.view.SurfaceHolder; |
| 14 import android.view.SurfaceView; | 14 import android.view.SurfaceView; |
| 15 import android.view.WindowManager; | 15 import android.view.WindowManager; |
| 16 | 16 |
| 17 import org.chromium.base.annotations.JNINamespace; | 17 import org.chromium.base.annotations.JNINamespace; |
| 18 import org.chromium.blimp.session.BlimpClientSession; | 18 import org.chromium.blimp.session.BlimpClientSession; |
| 19 import org.chromium.ui.UiUtils; | |
| 19 | 20 |
| 20 /** | 21 /** |
| 21 * A {@link View} that will visually represent the Blimp rendered content. This {@link View} starts | 22 * A {@link View} that will visually represent the Blimp rendered content. This {@link View} starts |
| 22 * a native compositor. | 23 * a native compositor. |
| 23 */ | 24 */ |
| 24 @JNINamespace("blimp::client") | 25 @JNINamespace("blimp::client") |
| 25 public class BlimpView extends SurfaceView implements SurfaceHolder.Callback { | 26 public class BlimpView extends SurfaceView implements SurfaceHolder.Callback { |
| 27 private static final String TAG = "BlimpView"; | |
|
Khushal
2016/04/23 01:29:21
nit: Unused.
shaktisahu
2016/04/23 02:08:05
Just added to help in debugging and logging. I thi
nyquist
2016/04/26 18:28:58
Yeah, but we usually remove it if it ends up not b
shaktisahu
2016/04/26 20:06:42
Done.
| |
| 26 private long mNativeBlimpViewPtr; | 28 private long mNativeBlimpViewPtr; |
| 27 | 29 |
| 28 /** | 30 /** |
| 29 * Builds a new {@link BlimpView}. | 31 * Builds a new {@link BlimpView}. |
| 30 * @param context A {@link Context} instance. | 32 * @param context A {@link Context} instance. |
| 31 * @param attrs An {@link AttributeSet} instance. | 33 * @param attrs An {@link AttributeSet} instance. |
| 32 */ | 34 */ |
| 33 public BlimpView(Context context, AttributeSet attrs) { | 35 public BlimpView(Context context, AttributeSet attrs) { |
| 34 super(context, attrs); | 36 super(context, attrs); |
| 35 setFocusable(true); | 37 setFocusable(true); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 nativeSetVisibility(mNativeBlimpViewPtr, visible); | 91 nativeSetVisibility(mNativeBlimpViewPtr, visible); |
| 90 } | 92 } |
| 91 | 93 |
| 92 // View overrides. | 94 // View overrides. |
| 93 @Override | 95 @Override |
| 94 public boolean onTouchEvent(MotionEvent event) { | 96 public boolean onTouchEvent(MotionEvent event) { |
| 95 if (mNativeBlimpViewPtr == 0) return false; | 97 if (mNativeBlimpViewPtr == 0) return false; |
| 96 | 98 |
| 97 int eventAction = event.getActionMasked(); | 99 int eventAction = event.getActionMasked(); |
| 98 | 100 |
| 101 // Close the IME. It might be open for typing URL into toolbar. | |
| 102 // TODO(shaktisahu): Detect if the IME was open and return immediately. | |
|
Khushal
2016/04/23 01:29:21
Could we use UiUtils.isKeyboardShowing for this in
shaktisahu
2016/04/23 02:08:05
I tried using that. Seems like this method isn't a
| |
| 103 if (eventAction == MotionEvent.ACTION_UP) { | |
|
Khushal
2016/04/23 01:29:21
Why do this only for ACTION_UP? If the user tries
shaktisahu
2016/04/23 02:08:05
Good catch. Initially, I didn't want to call this
| |
| 104 UiUtils.hideKeyboard(this); | |
| 105 } | |
| 106 | |
| 99 if (!isValidTouchEventActionForNative(eventAction)) return false; | 107 if (!isValidTouchEventActionForNative(eventAction)) return false; |
| 100 | 108 |
| 101 int pointerCount = event.getPointerCount(); | 109 int pointerCount = event.getPointerCount(); |
| 102 | 110 |
| 103 float[] touchMajor = {event.getTouchMajor(), pointerCount > 1 ? event.ge tTouchMajor(1) : 0}; | 111 float[] touchMajor = {event.getTouchMajor(), pointerCount > 1 ? event.ge tTouchMajor(1) : 0}; |
| 104 float[] touchMinor = {event.getTouchMinor(), pointerCount > 1 ? event.ge tTouchMinor(1) : 0}; | 112 float[] touchMinor = {event.getTouchMinor(), pointerCount > 1 ? event.ge tTouchMinor(1) : 0}; |
| 105 | 113 |
| 106 for (int i = 0; i < 2; i++) { | 114 for (int i = 0; i < 2; i++) { |
| 107 if (touchMajor[i] < touchMinor[i]) { | 115 if (touchMajor[i] < touchMinor[i]) { |
| 108 float tmp = touchMajor[i]; | 116 float tmp = touchMajor[i]; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 float x0, float y0, float x1, float y1, | 196 float x0, float y0, float x1, float y1, |
| 189 int pointerId0, int pointerId1, | 197 int pointerId0, int pointerId1, |
| 190 float touchMajor0, float touchMajor1, | 198 float touchMajor0, float touchMajor1, |
| 191 float touchMinor0, float touchMinor1, | 199 float touchMinor0, float touchMinor1, |
| 192 float orientation0, float orientation1, | 200 float orientation0, float orientation1, |
| 193 float tilt0, float tilt1, | 201 float tilt0, float tilt1, |
| 194 float rawX, float rawY, | 202 float rawX, float rawY, |
| 195 int androidToolType0, int androidToolType1, | 203 int androidToolType0, int androidToolType1, |
| 196 int androidButtonState, int androidMetaState); | 204 int androidButtonState, int androidMetaState); |
| 197 } | 205 } |
| OLD | NEW |