summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/app/Gallery.java
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2013-01-18 16:00:45 -0800
committerJohn Reck <jreck@google.com>2013-01-18 16:00:45 -0800
commit4ea5c27007e38fa8583add4bacf268ba67b9f0ad (patch)
tree60167bc2ed475a4fa57f5fb4c17548c9073b85f3 /src/com/android/gallery3d/app/Gallery.java
parentb1cabf78e719ef8c40dad44eee38b9884e8f9258 (diff)
downloadandroid_packages_apps_Gallery2-4ea5c27007e38fa8583add4bacf268ba67b9f0ad.tar.gz
android_packages_apps_Gallery2-4ea5c27007e38fa8583add4bacf268ba67b9f0ad.tar.bz2
android_packages_apps_Gallery2-4ea5c27007e38fa8583add4bacf268ba67b9f0ad.zip
Tweaks for canvas
Change-Id: I9aecf757047f93159212441e5317ef2b3b304a70
Diffstat (limited to 'src/com/android/gallery3d/app/Gallery.java')
-rw-r--r--src/com/android/gallery3d/app/Gallery.java27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java
index f9414bb3b..baef56b44 100644
--- a/src/com/android/gallery3d/app/Gallery.java
+++ b/src/com/android/gallery3d/app/Gallery.java
@@ -17,15 +17,15 @@
package com.android.gallery3d.app;
import android.app.Dialog;
-import android.content.AsyncQueryHandler;
import android.content.ContentResolver;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
-import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
-import android.provider.OpenableColumns;
+import android.view.InputDevice;
+import android.view.MotionEvent;
+import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
@@ -250,4 +250,25 @@ public final class Gallery extends AbstractGalleryActivity implements OnCancelLi
mVersionCheckDialog = null;
}
}
+
+ @Override
+ public boolean onGenericMotionEvent(MotionEvent event) {
+ final boolean isTouchPad = (event.getSource()
+ & InputDevice.SOURCE_CLASS_POSITION) != 0;
+ if (isTouchPad) {
+ float maxX = event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax();
+ float maxY = event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax();
+ View decor = getWindow().getDecorView();
+ float scaleX = decor.getWidth() / maxX;
+ float scaleY = decor.getHeight() / maxY;
+ float x = event.getX() * scaleX;
+ //x = decor.getWidth() - x; // invert x
+ float y = event.getY() * scaleY;
+ //y = decor.getHeight() - y; // invert y
+ MotionEvent touchEvent = MotionEvent.obtain(event.getDownTime(),
+ event.getEventTime(), event.getAction(), x, y, event.getMetaState());
+ return dispatchTouchEvent(touchEvent);
+ }
+ return super.onGenericMotionEvent(event);
+ }
}