diff options
author | Winson Chung <winsonc@google.com> | 2011-11-23 15:38:34 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-23 15:38:34 -0800 |
commit | 97d6f9a705711870ee9a06fe4f28050228fcfb13 (patch) | |
tree | b33ea043ba2cc32937bdb9ceadaa02106308f0a6 | |
parent | ea49c1c8610ad7eb0367d073a410e989c8998160 (diff) | |
parent | bb185bdd57fcdb2c8ff9eee00347b116bab7db23 (diff) | |
download | android_packages_apps_Trebuchet-97d6f9a705711870ee9a06fe4f28050228fcfb13.tar.gz android_packages_apps_Trebuchet-97d6f9a705711870ee9a06fe4f28050228fcfb13.tar.bz2 android_packages_apps_Trebuchet-97d6f9a705711870ee9a06fe4f28050228fcfb13.zip |
Merge "Fixing an issue where qsb press states could be out of sync. (Bug 5627327)" into ics-mr1
-rw-r--r-- | src/com/android/launcher2/HolographicImageView.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/HolographicLinearLayout.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/HolographicViewHelper.java | 16 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 24 |
4 files changed, 42 insertions, 6 deletions
diff --git a/src/com/android/launcher2/HolographicImageView.java b/src/com/android/launcher2/HolographicImageView.java index 1d34cd6ba..9e551e047 100644 --- a/src/com/android/launcher2/HolographicImageView.java +++ b/src/com/android/launcher2/HolographicImageView.java @@ -39,6 +39,10 @@ public class HolographicImageView extends ImageView { mHolographicHelper = new HolographicViewHelper(context); } + void invalidatePressedFocusedStates() { + mHolographicHelper.invalidatePressedFocusedStates(this); + } + @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); diff --git a/src/com/android/launcher2/HolographicLinearLayout.java b/src/com/android/launcher2/HolographicLinearLayout.java index c6a8d6aff..a40c727b5 100644 --- a/src/com/android/launcher2/HolographicLinearLayout.java +++ b/src/com/android/launcher2/HolographicLinearLayout.java @@ -66,6 +66,10 @@ public class HolographicLinearLayout extends LinearLayout { } } + void invalidatePressedFocusedStates() { + mHolographicHelper.invalidatePressedFocusedStates(mImageView); + } + @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); diff --git a/src/com/android/launcher2/HolographicViewHelper.java b/src/com/android/launcher2/HolographicViewHelper.java index 11e81b4d3..fd499082f 100644 --- a/src/com/android/launcher2/HolographicViewHelper.java +++ b/src/com/android/launcher2/HolographicViewHelper.java @@ -42,7 +42,7 @@ public class HolographicViewHelper { void generatePressedFocusedStates(ImageView v) { if (!mStatesUpdated && v != null) { mStatesUpdated = true; - Bitmap outline = createGlowingOutline(v, mTempCanvas); + Bitmap outline = createPressImage(v, mTempCanvas); FastBitmapDrawable d = new FastBitmapDrawable(outline); StateListDrawable states = new StateListDrawable(); @@ -54,10 +54,20 @@ public class HolographicViewHelper { } /** - * Returns a new bitmap to be used as the object outline, e.g. to visualize the drop location. + * Invalidates the pressed/focused states. + */ + void invalidatePressedFocusedStates(ImageView v) { + mStatesUpdated = false; + if (v != null) { + v.invalidate(); + } + } + + /** + * Creates a new press state image which is the old image with a blue overlay. * Responsibility for the bitmap is transferred to the caller. */ - private Bitmap createGlowingOutline(ImageView v, Canvas canvas) { + private Bitmap createPressImage(ImageView v, Canvas canvas) { final int padding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS; final Bitmap b = Bitmap.createBitmap( v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888); diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 809b0b957..33ead5cf8 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -1714,6 +1714,8 @@ public final class Launcher extends Activity * @param v The view that was clicked. */ public void onClickSearchButton(View v) { + v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); + onSearchRequested(); } @@ -1723,10 +1725,8 @@ public final class Launcher extends Activity * @param v The view that was clicked. */ public void onClickVoiceButton(View v) { - startVoiceSearch(); - } + v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); - private void startVoiceSearch() { Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(intent); @@ -2674,6 +2674,16 @@ public final class Launcher extends Activity button.setImageDrawable(d.newDrawable(getResources())); } + private void invalidatePressedFocusedStates(View container, View button) { + if (container instanceof HolographicLinearLayout) { + HolographicLinearLayout layout = (HolographicLinearLayout) container; + layout.invalidatePressedFocusedStates(); + } else if (button instanceof HolographicImageView) { + HolographicImageView view = (HolographicImageView) button; + view.invalidatePressedFocusedStates(); + } + } + private boolean updateGlobalSearchIcon() { final View searchButtonContainer = findViewById(R.id.search_button_container); final ImageView searchButton = (ImageView) findViewById(R.id.search_button); @@ -2691,6 +2701,7 @@ public final class Launcher extends Activity if (searchDivider != null) searchDivider.setVisibility(View.VISIBLE); if (searchButtonContainer != null) searchButtonContainer.setVisibility(View.VISIBLE); searchButton.setVisibility(View.VISIBLE); + invalidatePressedFocusedStates(searchButtonContainer, searchButton); return true; } else { // We disable both search and voice search when there is no global search provider @@ -2704,7 +2715,10 @@ public final class Launcher extends Activity } private void updateGlobalSearchIcon(Drawable.ConstantState d) { + final View searchButtonContainer = findViewById(R.id.search_button_container); + final View searchButton = (ImageView) findViewById(R.id.search_button); updateButtonWithDrawable(R.id.search_button, d); + invalidatePressedFocusedStates(searchButtonContainer, searchButton); } private boolean updateVoiceSearchIcon(boolean searchVisible) { @@ -2722,6 +2736,7 @@ public final class Launcher extends Activity if (searchDivider != null) searchDivider.setVisibility(View.VISIBLE); if (voiceButtonContainer != null) voiceButtonContainer.setVisibility(View.VISIBLE); voiceButton.setVisibility(View.VISIBLE); + invalidatePressedFocusedStates(voiceButtonContainer, voiceButton); return true; } else { if (searchDivider != null) searchDivider.setVisibility(View.GONE); @@ -2732,7 +2747,10 @@ public final class Launcher extends Activity } private void updateVoiceSearchIcon(Drawable.ConstantState d) { + final View voiceButtonContainer = findViewById(R.id.voice_button_container); + final View voiceButton = findViewById(R.id.voice_button); updateButtonWithDrawable(R.id.voice_button, d); + invalidatePressedFocusedStates(voiceButtonContainer, voiceButton); } /** |