summaryrefslogtreecommitdiffstats
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
commit76595d7ee48d63ca5c1766239f822a0c6dbcdc6f (patch)
tree351d7a0ed1de327670c825c25b5ddced69804e60
parentcdbd61532909eb2168c74b6a9d0e0aa5b95c0274 (diff)
downloadandroid_packages_apps_Snap-76595d7ee48d63ca5c1766239f822a0c6dbcdc6f.tar.gz
android_packages_apps_Snap-76595d7ee48d63ca5c1766239f822a0c6dbcdc6f.tar.bz2
android_packages_apps_Snap-76595d7ee48d63ca5c1766239f822a0c6dbcdc6f.zip
Tweaks for canvas
Change-Id: I9aecf757047f93159212441e5317ef2b3b304a70
-rw-r--r--src/com/android/gallery3d/app/Gallery.java27
-rw-r--r--src/com/android/gallery3d/app/MovieActivity.java3
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java6
-rw-r--r--src/com/android/gallery3d/data/MediaSet.java6
4 files changed, 33 insertions, 9 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);
+ }
}
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index 3123644c7..40edbbe4d 100644
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -127,6 +127,9 @@ public class MovieActivity extends Activity {
private void initializeActionBar(Intent intent) {
mUri = intent.getData();
final ActionBar actionBar = getActionBar();
+ if (actionBar == null) {
+ return;
+ }
setActionBarLogoFromIntent(intent);
actionBar.setDisplayOptions(
ActionBar.DISPLAY_HOME_AS_UP,
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 8896cd188..c110a8ccc 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -23,6 +23,7 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.res.Configuration;
import android.graphics.Rect;
import android.net.Uri;
import android.nfc.NfcAdapter;
@@ -839,6 +840,11 @@ public abstract class PhotoPage extends ActivityState implements
// No bars if it's not allowed.
if (!mActionBarAllowed) return false;
+ Configuration config = mActivity.getResources().getConfiguration();
+ if (config.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH) {
+ return false;
+ }
+
return true;
}
diff --git a/src/com/android/gallery3d/data/MediaSet.java b/src/com/android/gallery3d/data/MediaSet.java
index cc8a4a71a..d27adb8e9 100644
--- a/src/com/android/gallery3d/data/MediaSet.java
+++ b/src/com/android/gallery3d/data/MediaSet.java
@@ -153,16 +153,10 @@ public abstract class MediaSet extends MediaObject {
// listener is automatically removed when there is no other reference to
// the listener.
public void addContentListener(ContentListener listener) {
- if (mListeners.containsKey(listener)) {
- throw new IllegalArgumentException();
- }
mListeners.put(listener, null);
}
public void removeContentListener(ContentListener listener) {
- if (!mListeners.containsKey(listener)) {
- throw new IllegalArgumentException();
- }
mListeners.remove(listener);
}