diff options
author | yueg <yueg@google.com> | 2018-01-25 14:17:06 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-25 15:55:08 -0800 |
commit | 02dd493e62f22a488c4bc8438471e30d9b84b936 (patch) | |
tree | f3cb8137b97a643dd8a13b5ad883b04c5fa47e98 /java/com/android/newbubble/NewBubble.java | |
parent | a0cfd3965218696493c5ed06c2ef69e2b61368e8 (diff) |
Set avatar as background instead of src.
Since we don't need background any more, setting avatar as background makes elevation work on the same view. So we don't need setOutlineProvider() which might provide a different outline to the image's.
Also fix an windowParams NPE.
Test: manual
PiperOrigin-RevId: 183289973
Change-Id: I452b3f2b66b1810839626f57449be7d10662f2c5
Diffstat (limited to 'java/com/android/newbubble/NewBubble.java')
-rw-r--r-- | java/com/android/newbubble/NewBubble.java | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/java/com/android/newbubble/NewBubble.java b/java/com/android/newbubble/NewBubble.java index 2e98ad17b..54e56ba61 100644 --- a/java/com/android/newbubble/NewBubble.java +++ b/java/com/android/newbubble/NewBubble.java @@ -25,7 +25,6 @@ import android.annotation.SuppressLint; import android.app.PendingIntent.CanceledException; import android.content.Context; import android.content.Intent; -import android.graphics.Outline; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.drawable.Animatable; @@ -47,7 +46,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.View.AccessibilityDelegate; import android.view.ViewGroup; -import android.view.ViewOutlineProvider; import android.view.ViewTreeObserver.OnPreDrawListener; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; @@ -525,7 +523,7 @@ public class NewBubble { public void updateAvatar(@NonNull Drawable avatar) { if (!avatar.equals(currentInfo.getAvatar())) { currentInfo = NewBubbleInfo.from(currentInfo).setAvatar(avatar).build(); - viewHolder.getPrimaryAvatar().setImageDrawable(currentInfo.getAvatar()); + viewHolder.getPrimaryAvatar().setBackground(currentInfo.getAvatar()); } } @@ -560,7 +558,7 @@ public class NewBubble { savedYPosition = -1; viewHolder - .getPrimaryButton() + .getPrimaryAvatar() .animate() .translationZ( context @@ -569,7 +567,7 @@ public class NewBubble { } void onMoveFinish() { - viewHolder.getPrimaryButton().animate().translationZ(0); + viewHolder.getPrimaryAvatar().animate().translationZ(0); } void primaryButtonClick() { @@ -669,17 +667,9 @@ public class NewBubble { primaryIconMoveDistance = context.getResources().getDimensionPixelSize(R.dimen.bubble_size) - context.getResources().getDimensionPixelSize(R.dimen.bubble_small_icon_size); - // Set boundary for primary button to show elevation (background is transparent) - viewHolder - .getPrimaryButton() - .setOutlineProvider( - new ViewOutlineProvider() { - @Override - public void getOutline(View view, Outline outline) { - ViewOutlineProvider.BACKGROUND.getOutline(view, outline); - outline.setAlpha(1); - } - }); + + // Avatar + viewHolder.getPrimaryAvatar().setBackground(currentInfo.getAvatar()); // Small icon Drawable smallIconBackgroundCircle = @@ -689,7 +679,6 @@ public class NewBubble { smallIconBackgroundCircle.setTint(context.getColor(R.color.bubble_button_color_blue)); viewHolder.getPrimaryIcon().setBackground(smallIconBackgroundCircle); viewHolder.getPrimaryIcon().setImageIcon(currentInfo.getPrimaryIcon()); - viewHolder.getPrimaryAvatar().setImageDrawable(currentInfo.getAvatar()); updatePrimaryIconAnimation(); updateButtonStates(); @@ -873,6 +862,9 @@ public class NewBubble { xValueAnimator.setInterpolator(new LinearOutSlowInInterpolator()); xValueAnimator.addUpdateListener( (valueAnimator) -> { + if (windowParams == null) { + return; + } // Update windowParams and the root layout. // We can't do ViewPropertyAnimation since it clips children. float newX = (float) valueAnimator.getAnimatedValue(); |