Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: ui/android/java/src/org/chromium/ui/base/TouchDevice.java

Issue 186943002: Plumbing maxTouchPoints for Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/base/android/ui_base_jni_registrar.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6801655c25e727c4e4654999450e26f046e59a04
--- /dev/null
+++ b/ui/android/java/src/org/chromium/ui/base/TouchDevice.java
@@ -0,0 +1,51 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// 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 {
+
+ /**
+ * Static methods only so make constructor private.
+ */
+ private TouchDevice() { }
+
+ /**
+ * 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)) {
+ 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;
+ }
+ }
+}
« no previous file with comments | « no previous file | ui/base/android/ui_base_jni_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698