From c2831f31282a1075612449cc38d0af8069329160 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Wed, 4 Jun 2014 12:57:53 -0700 Subject: Update InCallUi styles to redline. - Add pulse animation for the call status. - Rename AnimationUtils to InCallAnimationUtils to avoid name conflict. - Adjust sizes/positions of fields in the call card. Condensed a RelativeLayout and LinearLayout in the primary call info into a LinearLayout, which is all that's needed. - Styled color of status bar. Bug: 15389408 Change-Id: I46f26e2a1bfaebde82f68f054ed68fcbe3eff3bb --- InCallUI/res/anim/call_status_pulse.xml | 22 +++ InCallUI/res/layout/call_button_fragment.xml | 2 +- InCallUI/res/layout/call_card.xml | 8 +- InCallUI/res/layout/primary_call_info.xml | 116 ++++++------- InCallUI/res/values/colors.xml | 6 +- InCallUI/res/values/dimens.xml | 4 +- InCallUI/res/values/styles.xml | 9 +- .../src/com/android/incallui/AnimationUtils.java | 185 --------------------- .../src/com/android/incallui/CallCardFragment.java | 18 +- .../com/android/incallui/InCallAnimationUtils.java | 184 ++++++++++++++++++++ 10 files changed, 289 insertions(+), 265 deletions(-) create mode 100644 InCallUI/res/anim/call_status_pulse.xml delete mode 100644 InCallUI/src/com/android/incallui/AnimationUtils.java create mode 100644 InCallUI/src/com/android/incallui/InCallAnimationUtils.java (limited to 'InCallUI') diff --git a/InCallUI/res/anim/call_status_pulse.xml b/InCallUI/res/anim/call_status_pulse.xml new file mode 100644 index 000000000..6bbcb6383 --- /dev/null +++ b/InCallUI/res/anim/call_status_pulse.xml @@ -0,0 +1,22 @@ + + + \ No newline at end of file diff --git a/InCallUI/res/layout/call_button_fragment.xml b/InCallUI/res/layout/call_button_fragment.xml index 315a90e33..8969cbb37 100644 --- a/InCallUI/res/layout/call_button_fragment.xml +++ b/InCallUI/res/layout/call_button_fragment.xml @@ -61,7 +61,7 @@ android:paddingStart="@dimen/button_cluster_horizontal_padding" android:paddingEnd="@dimen/button_cluster_horizontal_padding" android:background="@color/button_background_color" - android:gravity="center"> + android:gravity="bottom|center_horizontal"> diff --git a/InCallUI/res/layout/primary_call_info.xml b/InCallUI/res/layout/primary_call_info.xml index bed46dc25..369f70216 100644 --- a/InCallUI/res/layout/primary_call_info.xml +++ b/InCallUI/res/layout/primary_call_info.xml @@ -20,61 +20,55 @@ of info about a single call, including the contact name, phone number, call time counter, and other status info. This info is shown as a "banner" overlaid across the top of contact photo. --> - + android:clipToPadding="false" + android:animateLayoutChanges="true" + android:gravity="center"> + + - + android:layout_marginTop="-5dp" + android:fontFamily="sans-serif-light" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textSize="@dimen/call_name_text_size" + android:singleLine="true" /> - - + - + - - - + android:layout_weight="1" + android:orientation="horizontal"> - - - - - - - + android:singleLine="true" /> - - + + android:textColor="@color/incall_call_banner_subtext_color" + android:textSize="@dimen/call_label_text_size" + android:singleLine="true" + android:visibility="gone" /> - \ No newline at end of file + + + + diff --git a/InCallUI/res/values/colors.xml b/InCallUI/res/values/colors.xml index e740b8428..e2eeceaea 100644 --- a/InCallUI/res/values/colors.xml +++ b/InCallUI/res/values/colors.xml @@ -24,7 +24,7 @@ @color/incall_background_color #ffffff - #99ffffff + #b2ebf2 #f5f5f5 #808080 @@ -81,6 +81,6 @@ #a3a3a3 #ffffff - - #26eeff41 + + #66eeff41 diff --git a/InCallUI/res/values/dimens.xml b/InCallUI/res/values/dimens.xml index cef0ee5ff..95f110118 100644 --- a/InCallUI/res/values/dimens.xml +++ b/InCallUI/res/values/dimens.xml @@ -20,7 +20,7 @@ - 128dp + 122dp @@ -31,7 +31,7 @@ 24dp - 24dp + 16dp 24dp diff --git a/InCallUI/res/values/styles.xml b/InCallUI/res/values/styles.xml index 7b305ec45..511bae83f 100644 --- a/InCallUI/res/values/styles.xml +++ b/InCallUI/res/values/styles.xml @@ -55,7 +55,6 @@ @dimen/in_call_button_dimension @dimen/in_call_button_dimension @dimen/call_button_margin_vertical - @dimen/call_button_margin_vertical @dimen/call_button_margin_horizontal @dimen/call_button_margin_horizontal ?android:attr/selectableItemBackground @@ -116,16 +115,14 @@ circular reveal animation for a new outgoing call to work correctly. We don't just use Theme.Black.NoTitleBar directly, since we want any popups or dialogs from the InCallActivity to have the correct holo style. --> - - - diff --git a/InCallUI/src/com/android/incallui/AnimationUtils.java b/InCallUI/src/com/android/incallui/AnimationUtils.java deleted file mode 100644 index b5546de14..000000000 --- a/InCallUI/src/com/android/incallui/AnimationUtils.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.incallui; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; -import android.graphics.Canvas; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; -import android.view.View; -import android.view.ViewPropertyAnimator; -import android.widget.ImageView; - -/** - * Utilities for Animation. - */ -public class AnimationUtils { - private static final String LOG_TAG = AnimationUtils.class.getSimpleName(); - /** - * Turn on when you're interested in fading animation. Intentionally untied from other debug - * settings. - */ - private static final boolean FADE_DBG = false; - - /** - * Duration for animations in msec, which can be used with - * {@link ViewPropertyAnimator#setDuration(long)} for example. - */ - public static final int ANIMATION_DURATION = 250; - - private AnimationUtils() { - } - - /** - * Drawable achieving cross-fade, just like TransitionDrawable. We can have - * call-backs via animator object (see also {@link CrossFadeDrawable#getAnimator()}). - */ - private static class CrossFadeDrawable extends LayerDrawable { - private final ObjectAnimator mAnimator; - - public CrossFadeDrawable(Drawable[] layers) { - super(layers); - mAnimator = ObjectAnimator.ofInt(this, "crossFadeAlpha", 0xff, 0); - } - - private int mCrossFadeAlpha; - - /** - * This will be used from ObjectAnimator. - * Note: this method is protected by proguard.flags so that it won't be removed - * automatically. - */ - @SuppressWarnings("unused") - public void setCrossFadeAlpha(int alpha) { - mCrossFadeAlpha = alpha; - invalidateSelf(); - } - - public ObjectAnimator getAnimator() { - return mAnimator; - } - - @Override - public void draw(Canvas canvas) { - Drawable first = getDrawable(0); - Drawable second = getDrawable(1); - - if (mCrossFadeAlpha > 0) { - first.setAlpha(mCrossFadeAlpha); - first.draw(canvas); - first.setAlpha(255); - } - - if (mCrossFadeAlpha < 0xff) { - second.setAlpha(0xff - mCrossFadeAlpha); - second.draw(canvas); - second.setAlpha(0xff); - } - } - } - - private static CrossFadeDrawable newCrossFadeDrawable(Drawable first, Drawable second) { - Drawable[] layers = new Drawable[2]; - layers[0] = first; - layers[1] = second; - return new CrossFadeDrawable(layers); - } - - /** - * Starts cross-fade animation using TransitionDrawable. Nothing will happen if "from" and "to" - * are the same. - */ - public static void startCrossFade( - final ImageView imageView, final Drawable from, final Drawable to) { - // We skip the cross-fade when those two Drawables are equal, or they are BitmapDrawables - // pointing to the same Bitmap. - final boolean drawableIsEqual = (from != null && to != null && from.equals(to)); - final boolean hasFromImage = ((from instanceof BitmapDrawable) && - ((BitmapDrawable) from).getBitmap() != null); - final boolean hasToImage = ((to instanceof BitmapDrawable) && - ((BitmapDrawable) to).getBitmap() != null); - final boolean areSameImage = drawableIsEqual || (hasFromImage && hasToImage && - ((BitmapDrawable) from).getBitmap().equals(((BitmapDrawable) to).getBitmap())); - - if (!areSameImage) { - if (FADE_DBG) { - log("Start cross-fade animation for " + imageView - + "(" + Integer.toHexString(from.hashCode()) + " -> " - + Integer.toHexString(to.hashCode()) + ")"); - } - - CrossFadeDrawable crossFadeDrawable = newCrossFadeDrawable(from, to); - ObjectAnimator animator = crossFadeDrawable.getAnimator(); - imageView.setImageDrawable(crossFadeDrawable); - animator.setDuration(ANIMATION_DURATION); - animator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animation) { - if (FADE_DBG) { - log("cross-fade animation start (" - + Integer.toHexString(from.hashCode()) + " -> " - + Integer.toHexString(to.hashCode()) + ")"); - } - } - - @Override - public void onAnimationEnd(Animator animation) { - if (FADE_DBG) { - log("cross-fade animation ended (" - + Integer.toHexString(from.hashCode()) + " -> " - + Integer.toHexString(to.hashCode()) + ")"); - } - animation.removeAllListeners(); - // Workaround for issue 6300562; this will force the drawable to the - // resultant one regardless of animation glitch. - imageView.setImageDrawable(to); - } - }); - animator.start(); - - /* We could use TransitionDrawable here, but it may cause some weird animation in - * some corner cases. See issue 6300562 - * TODO: decide which to be used in the long run. TransitionDrawable is old but system - * one. Ours uses new animation framework and thus have callback (great for testing), - * while no framework support for the exact class. - - Drawable[] layers = new Drawable[2]; - layers[0] = from; - layers[1] = to; - TransitionDrawable transitionDrawable = new TransitionDrawable(layers); - imageView.setImageDrawable(transitionDrawable); - transitionDrawable.startTransition(ANIMATION_DURATION); */ - imageView.setTag(to); - } else if (!hasFromImage && hasToImage) { - imageView.setImageDrawable(to); - imageView.setTag(to); - } else { - if (FADE_DBG) { - log("*Not* start cross-fade. " + imageView); - } - } - } - - // Debugging / testing code - - private static void log(String msg) { - Log.d(LOG_TAG, msg); - } -} \ No newline at end of file diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 94224253f..02f70db87 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -35,8 +35,8 @@ import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.accessibility.AccessibilityEvent; -import android.view.animation.Interpolator; -import android.view.animation.PathInterpolator; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; @@ -82,6 +82,7 @@ public class CallCardFragment extends BaseFragment 0) { + first.setAlpha(mCrossFadeAlpha); + first.draw(canvas); + first.setAlpha(255); + } + + if (mCrossFadeAlpha < 0xff) { + second.setAlpha(0xff - mCrossFadeAlpha); + second.draw(canvas); + second.setAlpha(0xff); + } + } + } + + private static CrossFadeDrawable newCrossFadeDrawable(Drawable first, Drawable second) { + Drawable[] layers = new Drawable[2]; + layers[0] = first; + layers[1] = second; + return new CrossFadeDrawable(layers); + } + + /** + * Starts cross-fade animation using TransitionDrawable. Nothing will happen if "from" and "to" + * are the same. + */ + public static void startCrossFade( + final ImageView imageView, final Drawable from, final Drawable to) { + // We skip the cross-fade when those two Drawables are equal, or they are BitmapDrawables + // pointing to the same Bitmap. + final boolean drawableIsEqual = (from != null && to != null && from.equals(to)); + final boolean hasFromImage = ((from instanceof BitmapDrawable) && + ((BitmapDrawable) from).getBitmap() != null); + final boolean hasToImage = ((to instanceof BitmapDrawable) && + ((BitmapDrawable) to).getBitmap() != null); + final boolean areSameImage = drawableIsEqual || (hasFromImage && hasToImage && + ((BitmapDrawable) from).getBitmap().equals(((BitmapDrawable) to).getBitmap())); + + if (!areSameImage) { + if (FADE_DBG) { + log("Start cross-fade animation for " + imageView + + "(" + Integer.toHexString(from.hashCode()) + " -> " + + Integer.toHexString(to.hashCode()) + ")"); + } + + CrossFadeDrawable crossFadeDrawable = newCrossFadeDrawable(from, to); + ObjectAnimator animator = crossFadeDrawable.getAnimator(); + imageView.setImageDrawable(crossFadeDrawable); + animator.setDuration(ANIMATION_DURATION); + animator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + if (FADE_DBG) { + log("cross-fade animation start (" + + Integer.toHexString(from.hashCode()) + " -> " + + Integer.toHexString(to.hashCode()) + ")"); + } + } + + @Override + public void onAnimationEnd(Animator animation) { + if (FADE_DBG) { + log("cross-fade animation ended (" + + Integer.toHexString(from.hashCode()) + " -> " + + Integer.toHexString(to.hashCode()) + ")"); + } + animation.removeAllListeners(); + // Workaround for issue 6300562; this will force the drawable to the + // resultant one regardless of animation glitch. + imageView.setImageDrawable(to); + } + }); + animator.start(); + + /* We could use TransitionDrawable here, but it may cause some weird animation in + * some corner cases. See issue 6300562 + * TODO: decide which to be used in the long run. TransitionDrawable is old but system + * one. Ours uses new animation framework and thus have callback (great for testing), + * while no framework support for the exact class. + + Drawable[] layers = new Drawable[2]; + layers[0] = from; + layers[1] = to; + TransitionDrawable transitionDrawable = new TransitionDrawable(layers); + imageView.setImageDrawable(transitionDrawable); + transitionDrawable.startTransition(ANIMATION_DURATION); */ + imageView.setTag(to); + } else if (!hasFromImage && hasToImage) { + imageView.setImageDrawable(to); + imageView.setTag(to); + } else { + if (FADE_DBG) { + log("*Not* start cross-fade. " + imageView); + } + } + } + + // Debugging / testing code + + private static void log(String msg) { + Log.d(LOG_TAG, msg); + } +} \ No newline at end of file -- cgit v1.2.3