Chromium Code Reviews| Index: ui/android/java/src/org/chromium/ui/base/TouchDevice.java |
| diff --git a/ui/android/java/src/org/chromium/ui/base/TouchDevice.java b/ui/android/java/src/org/chromium/ui/base/TouchDevice.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e4c836cde5d2c62243279330721b184e708a62d8 |
| --- /dev/null |
| +++ b/ui/android/java/src/org/chromium/ui/base/TouchDevice.java |
| @@ -0,0 +1,45 @@ |
| +// 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.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.ui.base; |
| + |
| +import android.content.Context; |
| +import android.content.pm.PackageManager; |
| + |
| +import org.chromium.base.CalledByNative; |
| +import org.chromium.base.JNINamespace; |
| + |
| +/** |
| + * Simple proxy to let us query the touch device from C++ |
| + */ |
| +@JNINamespace("ui") |
| +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.
|
| + /** |
| + * Returns the number of supported touch points. |
| + * |
| + * @return Maximum supported touch points. |
| + */ |
| + @CalledByNative |
| + private static int maxTouchPoints(Context context) { |
| + // Android only tells us if the device belongs to a "Touchscreen Class" |
| + // which only guarantees a minimum number of touch points. Be |
| + // conservative and return the minimum, checking membership from the |
| + // highest class down. |
| + if (context.getPackageManager().hasSystemFeature( |
| + PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND)) { |
|
Ted C
2014/03/05 21:14:26
Ha! Best constant name ever.
|
| + return 5; |
| + } else if (context.getPackageManager().hasSystemFeature( |
| + PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT)) { |
| + return 2; |
| + } else if (context.getPackageManager().hasSystemFeature( |
| + PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) { |
| + return 2; |
| + } else if (context.getPackageManager().hasSystemFeature( |
| + PackageManager.FEATURE_TOUCHSCREEN)) { |
| + return 1; |
| + } else { |
| + return 0; |
| + } |
| + } |
| +} |