OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
Ted C
2014/03/05 21:14:26
2014
bokan
2014/03/05 22:49:20
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.ui.base; | |
6 | |
7 import android.content.Context; | |
8 import android.content.pm.PackageManager; | |
9 | |
10 import org.chromium.base.CalledByNative; | |
11 import org.chromium.base.JNINamespace; | |
12 | |
13 /** | |
14 * Simple proxy to let us query the touch device from C++ | |
15 */ | |
16 @JNINamespace("ui") | |
17 public class TouchDevice { | |
Ted C
2014/03/05 21:14:26
since this only contains statics, maybe make a pri
bokan
2014/03/05 22:49:20
Done.
| |
18 /** | |
19 * Returns the number of supported touch points. | |
20 * | |
21 * @return Maximum supported touch points. | |
22 */ | |
23 @CalledByNative | |
24 private static int maxTouchPoints(Context context) { | |
25 // Android only tells us if the device belongs to a "Touchscreen Class" | |
26 // which only guarantees a minimum number of touch points. Be | |
27 // conservative and return the minimum, checking membership from the | |
28 // highest class down. | |
29 if (context.getPackageManager().hasSystemFeature( | |
30 PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND)) { | |
Ted C
2014/03/05 21:14:26
Ha! Best constant name ever.
| |
31 return 5; | |
32 } else if (context.getPackageManager().hasSystemFeature( | |
33 PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT)) { | |
34 return 2; | |
35 } else if (context.getPackageManager().hasSystemFeature( | |
36 PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) { | |
37 return 2; | |
38 } else if (context.getPackageManager().hasSystemFeature( | |
39 PackageManager.FEATURE_TOUCHSCREEN)) { | |
40 return 1; | |
41 } else { | |
42 return 0; | |
43 } | |
44 } | |
45 } | |
OLD | NEW |