| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/gfx/android/view_configuration.h" | 5 #include "ui/gfx/android/view_configuration.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/threading/non_thread_safe.h" | 9 #include "base/threading/non_thread_safe.h" |
| 10 #include "jni/ViewConfigurationHelper_jni.h" | 10 #include "jni/ViewConfigurationHelper_jni.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 j_view_configuration_helper_.Reset( | 32 j_view_configuration_helper_.Reset( |
| 33 Java_ViewConfigurationHelper_createWithListener( | 33 Java_ViewConfigurationHelper_createWithListener( |
| 34 env, base::android::GetApplicationContext())); | 34 env, base::android::GetApplicationContext())); |
| 35 | 35 |
| 36 double_tap_timeout_in_ms_ = | 36 double_tap_timeout_in_ms_ = |
| 37 Java_ViewConfigurationHelper_getDoubleTapTimeout(env); | 37 Java_ViewConfigurationHelper_getDoubleTapTimeout(env); |
| 38 long_press_timeout_in_ms_ = | 38 long_press_timeout_in_ms_ = |
| 39 Java_ViewConfigurationHelper_getLongPressTimeout(env); | 39 Java_ViewConfigurationHelper_getLongPressTimeout(env); |
| 40 tap_timeout_in_ms_ = Java_ViewConfigurationHelper_getTapTimeout(env); | 40 tap_timeout_in_ms_ = Java_ViewConfigurationHelper_getTapTimeout(env); |
| 41 scroll_friction_ = Java_ViewConfigurationHelper_getScrollFriction(env); | 41 scroll_friction_ = Java_ViewConfigurationHelper_getScrollFriction(env); |
| 42 should_use_touch_major_in_scaling_span_ = | |
| 43 Java_ViewConfigurationHelper_shouldUseTouchMajorInScalingSpan(env); | |
| 44 | 42 |
| 45 jobject obj = j_view_configuration_helper_.obj(); | 43 jobject obj = j_view_configuration_helper_.obj(); |
| 46 Update( | 44 Update( |
| 47 Java_ViewConfigurationHelper_getScaledMaximumFlingVelocity(env, obj), | 45 Java_ViewConfigurationHelper_getScaledMaximumFlingVelocity(env, obj), |
| 48 Java_ViewConfigurationHelper_getScaledMinimumFlingVelocity(env, obj), | 46 Java_ViewConfigurationHelper_getScaledMinimumFlingVelocity(env, obj), |
| 49 Java_ViewConfigurationHelper_getScaledTouchSlop(env, obj), | 47 Java_ViewConfigurationHelper_getScaledTouchSlop(env, obj), |
| 50 Java_ViewConfigurationHelper_getScaledDoubleTapSlop(env, obj), | 48 Java_ViewConfigurationHelper_getScaledDoubleTapSlop(env, obj), |
| 51 Java_ViewConfigurationHelper_getScaledMinScalingSpan(env, obj), | 49 Java_ViewConfigurationHelper_getScaledMinScalingSpan(env, obj), |
| 52 Java_ViewConfigurationHelper_getScaledMinScalingTouchMajor(env, obj)); | 50 Java_ViewConfigurationHelper_getScaledMinScalingTouchMajor(env, obj)); |
| 53 } | 51 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 66 scaled_touch_slop, | 64 scaled_touch_slop, |
| 67 scaled_double_tap_slop, | 65 scaled_double_tap_slop, |
| 68 scaled_min_scaling_span, | 66 scaled_min_scaling_span, |
| 69 scaled_min_scaling_touch_major); | 67 scaled_min_scaling_touch_major); |
| 70 } | 68 } |
| 71 | 69 |
| 72 int double_tap_timeout_in_ms() const { return double_tap_timeout_in_ms_; } | 70 int double_tap_timeout_in_ms() const { return double_tap_timeout_in_ms_; } |
| 73 int long_press_timeout_in_ms() const { return long_press_timeout_in_ms_; } | 71 int long_press_timeout_in_ms() const { return long_press_timeout_in_ms_; } |
| 74 int tap_timeout_in_ms() const { return tap_timeout_in_ms_; } | 72 int tap_timeout_in_ms() const { return tap_timeout_in_ms_; } |
| 75 float scroll_friction() const { return scroll_friction_; } | 73 float scroll_friction() const { return scroll_friction_; } |
| 76 bool should_use_touch_major_in_scaling_span() const { | |
| 77 return should_use_touch_major_in_scaling_span_; | |
| 78 } | |
| 79 | 74 |
| 80 int max_fling_velocity_in_pixels_s() { | 75 int max_fling_velocity_in_pixels_s() { |
| 81 base::AutoLock autolock(lock_); | 76 base::AutoLock autolock(lock_); |
| 82 return max_fling_velocity_in_pixels_s_; | 77 return max_fling_velocity_in_pixels_s_; |
| 83 } | 78 } |
| 84 | 79 |
| 85 int min_fling_velocity_in_pixels_s() { | 80 int min_fling_velocity_in_pixels_s() { |
| 86 base::AutoLock autolock(lock_); | 81 base::AutoLock autolock(lock_); |
| 87 return min_fling_velocity_in_pixels_s_; | 82 return min_fling_velocity_in_pixels_s_; |
| 88 } | 83 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 120 |
| 126 base::Lock lock_; | 121 base::Lock lock_; |
| 127 base::android::ScopedJavaGlobalRef<jobject> j_view_configuration_helper_; | 122 base::android::ScopedJavaGlobalRef<jobject> j_view_configuration_helper_; |
| 128 | 123 |
| 129 // These values will remain constant throughout the lifetime of the app, so | 124 // These values will remain constant throughout the lifetime of the app, so |
| 130 // read-access needn't be synchronized. | 125 // read-access needn't be synchronized. |
| 131 int double_tap_timeout_in_ms_; | 126 int double_tap_timeout_in_ms_; |
| 132 int long_press_timeout_in_ms_; | 127 int long_press_timeout_in_ms_; |
| 133 int tap_timeout_in_ms_; | 128 int tap_timeout_in_ms_; |
| 134 float scroll_friction_; | 129 float scroll_friction_; |
| 135 bool should_use_touch_major_in_scaling_span_; | |
| 136 | 130 |
| 137 // These values may vary as view-specific parameters (DPI scale) are changed, | 131 // These values may vary as view-specific parameters (DPI scale) are changed, |
| 138 // so read/write access must be synchronized. | 132 // so read/write access must be synchronized. |
| 139 int max_fling_velocity_in_pixels_s_; | 133 int max_fling_velocity_in_pixels_s_; |
| 140 int min_fling_velocity_in_pixels_s_; | 134 int min_fling_velocity_in_pixels_s_; |
| 141 int touch_slop_in_pixels_; | 135 int touch_slop_in_pixels_; |
| 142 int double_tap_slop_in_pixels_; | 136 int double_tap_slop_in_pixels_; |
| 143 int min_scaling_span_in_pixels_; | 137 int min_scaling_span_in_pixels_; |
| 144 int min_scaling_touch_major_in_pixels_; | 138 int min_scaling_touch_major_in_pixels_; |
| 145 | 139 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 196 } |
| 203 | 197 |
| 204 int ViewConfiguration::GetMinScalingSpanInPixels() { | 198 int ViewConfiguration::GetMinScalingSpanInPixels() { |
| 205 return g_view_configuration.Get().min_scaling_span_in_pixels(); | 199 return g_view_configuration.Get().min_scaling_span_in_pixels(); |
| 206 } | 200 } |
| 207 | 201 |
| 208 int ViewConfiguration::GetMinScalingTouchMajorInPixels() { | 202 int ViewConfiguration::GetMinScalingTouchMajorInPixels() { |
| 209 return g_view_configuration.Get().min_scaling_touch_major_in_pixels(); | 203 return g_view_configuration.Get().min_scaling_touch_major_in_pixels(); |
| 210 } | 204 } |
| 211 | 205 |
| 212 bool ViewConfiguration::ShouldUseTouchMajorInScalingSpan() { | |
| 213 return g_view_configuration.Get().should_use_touch_major_in_scaling_span(); | |
| 214 } | |
| 215 | |
| 216 bool ViewConfiguration::RegisterViewConfiguration(JNIEnv* env) { | 206 bool ViewConfiguration::RegisterViewConfiguration(JNIEnv* env) { |
| 217 return RegisterNativesImpl(env); | 207 return RegisterNativesImpl(env); |
| 218 } | 208 } |
| 219 | 209 |
| 220 } // namespace gfx | 210 } // namespace gfx |
| OLD | NEW |