summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-09-30 15:58:20 -0700
committerAdam Cohen <adamcohen@google.com>2013-09-30 16:21:00 -0700
commit61f560d92ab4b11a61beeb8df97b9952027e08e4 (patch)
tree06f9c9c02f64c8638fafb5e90bdbaac37de9bf06 /src
parentf9e8640fcc02a4f1e85ff371d3938a04b24564a4 (diff)
downloadandroid_packages_apps_Trebuchet-61f560d92ab4b11a61beeb8df97b9952027e08e4.tar.gz
android_packages_apps_Trebuchet-61f560d92ab4b11a61beeb8df97b9952027e08e4.tar.bz2
android_packages_apps_Trebuchet-61f560d92ab4b11a61beeb8df97b9952027e08e4.zip
Fixing AllApps pressed state (issue 10845969)
-> Adding haptic feedback to overview mode buttons (issue 10917359) Change-Id: Iaf7ac31521ae08f4223aa0d0ffc2f6511b85567f
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Hotseat.java29
-rw-r--r--src/com/android/launcher3/Launcher.java36
-rw-r--r--src/com/android/launcher3/Utilities.java4
3 files changed, 45 insertions, 24 deletions
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index fbbb09f51..986a89b5d 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -28,6 +28,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
+import android.widget.TextView;
import java.util.ArrayList;
@@ -126,27 +127,17 @@ public class Hotseat extends FrameLayout {
// Add the Apps button
Context context = getContext();
- Drawable rawIcon =
- context.getResources().getDrawable(R.drawable.all_apps_button_icon);
- Bitmap icon = Utilities.createIconBitmap(rawIcon, context);
-
LayoutInflater inflater = LayoutInflater.from(context);
- BubbleTextView allAppsButton = (BubbleTextView)
- inflater.inflate(R.layout.application, mContent, false);
- allAppsButton.setCompoundDrawablesWithIntrinsicBounds(null,
- new FastBitmapDrawable(icon), null, null);
- allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
- allAppsButton.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- if (mLauncher != null &&
- (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
- mLauncher.onTouchDownAllAppsButton(v);
- }
- return false;
- }
- });
+ TextView allAppsButton = (TextView)
+ inflater.inflate(R.layout.all_apps_button, mContent, false);
+ Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
+ d.setBounds(0, 0, Utilities.sIconTextureWidth, Utilities.sIconTextureHeight);
+ allAppsButton.setCompoundDrawables(null, d, null, null);
+ allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
+ if (mLauncher != null) {
+ allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
+ }
allAppsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 5047e9e05..62e05e8d8 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -281,6 +281,8 @@ public class Launcher extends Activity
private static HashMap<Long, FolderInfo> sFolders = new HashMap<Long, FolderInfo>();
+ private View.OnTouchListener mHapticFeedbackTouchListener;
+
// Related to the auto-advancing of widgets
private final int ADVANCE_MSG = 1;
private final int mAdvanceInterval = 20000;
@@ -1148,24 +1150,32 @@ public class Launcher extends Activity
}
mOverviewPanel = findViewById(R.id.overview_panel);
- findViewById(R.id.widget_button).setOnClickListener(new OnClickListener() {
+ View widgetButton = findViewById(R.id.widget_button);
+ widgetButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
showAllApps(true, AppsCustomizePagedView.ContentType.Widgets);
}
});
- findViewById(R.id.wallpaper_button).setOnClickListener(new OnClickListener() {
+ widgetButton.setOnTouchListener(getHapticFeedbackTouchListener());
+
+ View wallpaperButton = findViewById(R.id.wallpaper_button);
+ wallpaperButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
startWallpaper();
}
});
- findViewById(R.id.settings_button).setOnClickListener(new OnClickListener() {
+ wallpaperButton.setOnTouchListener(getHapticFeedbackTouchListener());
+
+ View settingsButton = findViewById(R.id.settings_button);
+ settingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
startSettings();
}
});
+ settingsButton.setOnTouchListener(getHapticFeedbackTouchListener());
mOverviewPanel.setAlpha(0f);
// Setup the workspace
@@ -2274,6 +2284,26 @@ public class Launcher extends Activity
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
+ public void performHapticFeedbackOnTouchDown(View v) {
+ // Provide the same haptic feedback that the system offers for virtual keys.
+ v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+ }
+
+ public View.OnTouchListener getHapticFeedbackTouchListener() {
+ if (mHapticFeedbackTouchListener == null) {
+ mHapticFeedbackTouchListener = new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
+ v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+ }
+ return false;
+ }
+ };
+ }
+ return mHapticFeedbackTouchListener;
+ }
+
public void onClickAppMarketButton(View v) {
if (!DISABLE_MARKET_BUTTON) {
if (mAppMarketIntent != null) {
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 4a8a237d6..b6900fe52 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -48,8 +48,8 @@ final class Utilities {
private static int sIconWidth = -1;
private static int sIconHeight = -1;
- private static int sIconTextureWidth = -1;
- private static int sIconTextureHeight = -1;
+ public static int sIconTextureWidth = -1;
+ public static int sIconTextureHeight = -1;
private static final Paint sBlurPaint = new Paint();
private static final Paint sGlowColorPressedPaint = new Paint();