summaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-11-10 15:25:15 +0000
committerThomas Martitz <kugel@rockbox.org>2010-11-10 15:25:15 +0000
commit33af0dec28cf31be0ce7195b90546861efcce76f (patch)
treef106c9118c9191bff00e1468c98540787081c0e8 /android
parente134021e1b05f797cffd28c6b4ee72a963ff3812 (diff)
downloadrockbox-33af0dec28cf31be0ce7195b90546861efcce76f.tar.gz
rockbox-33af0dec28cf31be0ce7195b90546861efcce76f.tar.bz2
rockbox-33af0dec28cf31be0ce7195b90546861efcce76f.zip
Touchscreen: Improved scroll threshold
Remove the hardcoded (and way too small) scroll threshold (the distance moved in pixels before we think the users wants to scroll) and replace it with something based on the actual DPI of the screen. On Android we call the API for that, on other touchscreens we reimplemented Android's formula (as of 2.2) and calculate it. Flyspray: 11727 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28548 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android')
-rw-r--r--android/src/org/rockbox/RockboxFramebuffer.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/android/src/org/rockbox/RockboxFramebuffer.java b/android/src/org/rockbox/RockboxFramebuffer.java
index 0a60182502..8c99725e7d 100644
--- a/android/src/org/rockbox/RockboxFramebuffer.java
+++ b/android/src/org/rockbox/RockboxFramebuffer.java
@@ -28,16 +28,20 @@ import org.rockbox.Helper.MediaButtonReceiver;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewConfiguration;
public class RockboxFramebuffer extends View
{
private Bitmap btm;
private ByteBuffer native_buf;
private MediaButtonReceiver media_monitor;
+ private final DisplayMetrics metrics;
+ private final ViewConfiguration view_config;
public RockboxFramebuffer(Context c, int lcd_width,
int lcd_height, ByteBuffer native_fb)
@@ -53,6 +57,9 @@ public class RockboxFramebuffer extends View
media_monitor.register();
/* the service needs to know the about us */
((RockboxService)c).set_fb(this);
+
+ metrics = c.getResources().getDisplayMetrics();
+ view_config = ViewConfiguration.get(c);
}
public void onDraw(Canvas c)
@@ -132,6 +139,18 @@ public class RockboxFramebuffer extends View
break;
}
}
+
+ @SuppressWarnings("unused")
+ private int getDpi()
+ {
+ return metrics.densityDpi;
+ }
+
+ @SuppressWarnings("unused")
+ private int getScrollThreshold()
+ {
+ return view_config.getScaledTouchSlop();
+ }
private native void set_lcd_active(int active);
private native void touchHandler(boolean down, int x, int y);