summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2012-10-31 16:33:56 -0700
committerBobby Georgescu <georgescu@google.com>2012-10-31 16:57:39 -0700
commit37dfa8109d0147a076bdc64bca696a494dce756e (patch)
tree8e65371958c484a0469fb8b53ccadb1edb7b0e8b
parent1d0d5cbf663a76f5cb2769621d39a83256943de9 (diff)
downloadandroid_packages_apps_Snap-37dfa8109d0147a076bdc64bca696a494dce756e.tar.gz
android_packages_apps_Snap-37dfa8109d0147a076bdc64bca696a494dce756e.tar.bz2
android_packages_apps_Snap-37dfa8109d0147a076bdc64bca696a494dce756e.zip
Use the system-standard long press vibration pattern
Bug: 7216819 Change-Id: I575868583777a7a953d767d0cdaa91a439d908ff
-rw-r--r--src/com/android/gallery3d/app/ActivityState.java20
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java6
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java6
3 files changed, 10 insertions, 22 deletions
diff --git a/src/com/android/gallery3d/app/ActivityState.java b/src/com/android/gallery3d/app/ActivityState.java
index 2e440df25..e74c0174f 100644
--- a/src/com/android/gallery3d/app/ActivityState.java
+++ b/src/com/android/gallery3d/app/ActivityState.java
@@ -18,15 +18,13 @@ package com.android.gallery3d.app;
import android.app.Activity;
import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.os.BatteryManager;
import android.os.Bundle;
-import android.provider.Settings;
-import android.provider.Settings.SettingNotFoundException;
+import android.view.HapticFeedbackConstants;
import android.view.Window;
import android.view.WindowManager;
@@ -63,9 +61,6 @@ abstract public class ActivityState {
public Intent resultData;
}
- protected boolean mHapticsEnabled;
- private ContentResolver mContentResolver;
-
private boolean mDestroyed = false;
private boolean mPlugged = false;
boolean mIsFinishing = false;
@@ -93,7 +88,6 @@ abstract public class ActivityState {
void initialize(AbstractGalleryActivity activity, Bundle data) {
mActivity = activity;
mData = data;
- mContentResolver = activity.getAndroidContext().getContentResolver();
}
public Bundle getData() {
@@ -185,6 +179,11 @@ abstract public class ActivityState {
}
}
+ protected void performHapticFeedback(int feedbackConstant) {
+ mActivity.getWindow().getDecorView().performHapticFeedback(feedbackConstant,
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
+ }
+
protected void onPause() {
if (0 != (mFlags & FLAG_SCREEN_ON_WHEN_PLUGGED)) {
((Activity) mActivity).unregisterReceiver(mPowerIntentReceiver);
@@ -232,13 +231,6 @@ abstract public class ActivityState {
activity.registerReceiver(mPowerIntentReceiver, filter);
}
- try {
- mHapticsEnabled = Settings.System.getInt(mContentResolver,
- Settings.System.HAPTIC_FEEDBACK_ENABLED) != 0;
- } catch (SettingNotFoundException e) {
- mHapticsEnabled = false;
- }
-
onResume();
// the transition store should be cleared after resume;
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index 9e9ce044c..dd31b04e6 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -24,8 +24,8 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.os.Vibrator;
import android.provider.MediaStore;
+import android.view.HapticFeedbackConstants;
import android.widget.Toast;
import com.actionbarsherlock.view.Menu;
@@ -89,7 +89,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
private AlbumDataLoader mAlbumDataAdapter;
protected SelectionManager mSelectionManager;
- private Vibrator mVibrator;
private boolean mGetContent;
private boolean mShowClusterMenu;
@@ -371,7 +370,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
mShowClusterMenu = data.getBoolean(KEY_SHOW_CLUSTER_MENU, false);
mDetailsSource = new MyDetailsSource();
Context context = mActivity.getAndroidContext();
- mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
// Enable auto-select-all for mtp album
if (data.getBoolean(KEY_AUTO_SELECT_ALL)) {
@@ -662,7 +660,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
switch (mode) {
case SelectionManager.ENTER_SELECTION_MODE: {
mActionModeHandler.startActionMode();
- if (mHapticsEnabled) mVibrator.vibrate(100);
+ performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
break;
}
case SelectionManager.LEAVE_SELECTION_MODE: {
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index fcec604cc..038d34895 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -23,7 +23,7 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.os.Vibrator;
+import android.view.HapticFeedbackConstants;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@@ -92,7 +92,6 @@ public class AlbumSetPage extends ActivityState implements
private boolean mShowClusterMenu;
private GalleryActionBar mActionBar;
private int mSelectedAction;
- private Vibrator mVibrator;
protected SelectionManager mSelectionManager;
private AlbumSetDataLoader mAlbumSetDataAdapter;
@@ -332,7 +331,6 @@ public class AlbumSetPage extends ActivityState implements
mSubtitle = data.getString(AlbumSetPage.KEY_SET_SUBTITLE);
mEyePosition = new EyePosition(context, this);
mDetailsSource = new MyDetailsSource();
- mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
mActionBar = mActivity.getGalleryActionBar();
mSelectedAction = data.getInt(AlbumSetPage.KEY_SELECTED_CLUSTER_TYPE,
FilterUtils.CLUSTER_BY_ALBUM);
@@ -655,7 +653,7 @@ public class AlbumSetPage extends ActivityState implements
case SelectionManager.ENTER_SELECTION_MODE: {
mActionBar.disableClusterMenu(true);
mActionModeHandler.startActionMode();
- if (mHapticsEnabled) mVibrator.vibrate(100);
+ performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
break;
}
case SelectionManager.LEAVE_SELECTION_MODE: {