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
3 // found in the LICENSE file.
5 #include "ui/events/gesture_detection/gesture_configuration.h"
7 #include "base/memory/singleton.h"
8 #include "ui/gfx/android/view_configuration.h"
9 #include "ui/gfx/screen.h"
11 using gfx::ViewConfiguration
;
15 // This was the minimum tap/press size used on Android before the new gesture
16 // detection pipeline.
17 const float kMinGestureBoundsLengthDips
= 24.f
;
19 // This value is somewhat arbitrary, but provides a reasonable maximum
20 // approximating a large thumb depression.
21 const float kMaxGestureBoundsLengthDips
= kMinGestureBoundsLengthDips
* 4.f
;
23 class GestureConfigurationAndroid
: public GestureConfiguration
{
25 ~GestureConfigurationAndroid() override
{
28 static GestureConfigurationAndroid
* GetInstance() {
29 return Singleton
<GestureConfigurationAndroid
>::get();
33 GestureConfigurationAndroid() : GestureConfiguration() {
34 set_double_tap_enabled(true);
35 set_double_tap_timeout_in_ms(ViewConfiguration::GetDoubleTapTimeoutInMs());
36 set_gesture_begin_end_types_enabled(false);
37 set_long_press_time_in_ms(ViewConfiguration::GetLongPressTimeoutInMs());
38 set_max_distance_between_taps_for_double_tap(
39 ViewConfiguration::GetDoubleTapSlopInDips());
40 set_max_fling_velocity(
41 ViewConfiguration::GetMaximumFlingVelocityInDipsPerSecond());
42 set_max_gesture_bounds_length(kMaxGestureBoundsLengthDips
);
43 set_max_touch_move_in_pixels_for_click(
44 ViewConfiguration::GetTouchSlopInDips());
45 set_min_fling_velocity(
46 ViewConfiguration::GetMinimumFlingVelocityInDipsPerSecond());
47 set_min_gesture_bounds_length(kMinGestureBoundsLengthDips
);
48 set_min_pinch_update_span_delta(0.f
);
49 set_min_scaling_span_in_pixels(
50 ViewConfiguration::GetMinScalingSpanInDips());
51 set_min_scaling_touch_major(
52 ViewConfiguration::GetMinScalingTouchMajorInDips());
53 set_show_press_delay_in_ms(ViewConfiguration::GetTapTimeoutInMs());
54 set_span_slop(ViewConfiguration::GetTouchSlopInDips() * 2.f
);
57 friend struct DefaultSingletonTraits
<GestureConfigurationAndroid
>;
58 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationAndroid
);
63 // Create a GestureConfigurationAura singleton instance when using Android.
64 GestureConfiguration
* GestureConfiguration::GetPlatformSpecificInstance() {
65 return GestureConfigurationAndroid::GetInstance();