diff options
-rw-r--r-- | InCallUI/res/layout/call_card.xml | 203 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 120 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/animation/ResizeAnimation.java | 52 |
3 files changed, 154 insertions, 221 deletions
diff --git a/InCallUI/res/layout/call_card.xml b/InCallUI/res/layout/call_card.xml index a112d66f0..cfcd98073 100644 --- a/InCallUI/res/layout/call_card.xml +++ b/InCallUI/res/layout/call_card.xml @@ -16,144 +16,119 @@ ~ limitations under the License --> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/call_card" android:layout_width="match_parent" - android:layout_height="match_parent" > - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > + android:layout_height="match_parent" + android:orientation="vertical" > - <!-- The main content of the CallCard is either one or two "call info" - blocks, depending on whether one or two lines are in use. + <!-- The main content of the CallCard is either one or two "call info" + blocks, depending on whether one or two lines are in use. - The call_info blocks are stacked vertically inside a CallCard (LinearLayout), - each with layout_weight="1". If only one line is in use (i.e. the - common case) then the 2nd call info will be GONE and thus the 1st one - will expand to fill the full height of the CallCard. --> + The call_info blocks are stacked vertically inside a CallCard (LinearLayout), + each with layout_weight="1". If only one line is in use (i.e. the + common case) then the 2nd call info will be GONE and thus the 1st one + will expand to fill the full height of the CallCard. --> - <!-- Primary "call card" block, for the foreground call. --> - <FrameLayout + <!-- Primary "call card" block, for the foreground call. --> + <FrameLayout + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="5" > + + <LinearLayout android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="5" > + android:layout_height="match_parent" + android:orientation="vertical" > <LinearLayout + android:id="@+id/primary_call_info_container" android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <LinearLayout - android:id="@+id/primary_call_info_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:translationZ="@dimen/primary_call_translation_z" - android:background="@color/incall_call_banner_background_color" - > - - <include layout="@layout/primary_call_info" /> - - <fragment android:name="com.android.incallui.CallButtonFragment" - android:id="@+id/callButtonFragment" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> + android:layout_height="wrap_content" + android:orientation="vertical" + android:translationZ="@dimen/primary_call_translation_z" + android:background="@color/incall_call_banner_background_color" + > - </LinearLayout> + <include layout="@layout/primary_call_info" /> - <FrameLayout + <fragment android:name="com.android.incallui.CallButtonFragment" + android:id="@+id/callButtonFragment" android:layout_width="match_parent" - android:layout_height="match_parent" > - - <!-- Contact photo for primary call info --> - <ImageView android:id="@+id/photo" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="top|center_horizontal" - android:scaleType="centerCrop" - android:contentDescription="@string/contactPhoto" - android:src="@drawable/picture_unknown"/> - - <fragment android:name="com.android.incallui.DialpadFragment" - android:id="@+id/dialpadFragment" - android:layout_width="match_parent" - android:layout_height="match_parent" /> - - <fragment android:name="com.android.incallui.AnswerFragment" - android:id="@+id/answerFragment" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_alignParentBottom="true" - android:layout_centerHorizontal="true" - android:gravity="top" - android:layout_gravity="bottom|center_horizontal" - android:layout_marginBottom="@dimen/glowpadview_margin_bottom" - android:visibility="gone" /> - - </FrameLayout> + android:layout_height="wrap_content" /> </LinearLayout> <FrameLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="bottom|center"> + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <!-- Contact photo for primary call info --> + <ImageView android:id="@+id/photo" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="top|center_horizontal" + android:scaleType="centerCrop" + android:contentDescription="@string/contactPhoto" + android:src="@drawable/picture_unknown"/> + + <fragment android:name="com.android.incallui.DialpadFragment" + android:id="@+id/dialpadFragment" + android:layout_width="match_parent" + android:layout_height="match_parent" /> - <ImageButton android:id="@+id/endButton" - android:layout_width="@dimen/floating_action_button_width" - android:layout_height="@dimen/floating_action_button_height" - android:layout_marginBottom="@dimen/end_call_button_margin_bottom" - android:background="@drawable/end_call_background" - android:src="@drawable/fab_ic_end_call" - android:contentDescription="@string/onscreenEndCallText" /> + <fragment android:name="com.android.incallui.AnswerFragment" + android:id="@+id/answerFragment" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" + android:gravity="top" + android:layout_gravity="bottom|center_horizontal" + android:layout_marginBottom="@dimen/glowpadview_margin_bottom" + android:visibility="gone" /> </FrameLayout> - <!-- Insert a CallService indicator (which controls handoff, too) --> - <FrameLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="bottom|right"> - - <ImageButton android:id="@+id/handoffButton" - android:enabled="false" - android:layout_width="@dimen/floating_action_button_width" - android:layout_height="@dimen/floating_action_button_height" - android:layout_marginBottom="@dimen/end_call_button_margin_bottom" - android:background="@drawable/floating_handoff_button_compound_background" - android:src="@drawable/ic_in_call_pstn" /> - </FrameLayout> + </LinearLayout> + + <FrameLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom|center"> + + <ImageButton android:id="@+id/endButton" + android:layout_width="@dimen/floating_action_button_width" + android:layout_height="@dimen/floating_action_button_height" + android:layout_marginBottom="@dimen/end_call_button_margin_bottom" + android:background="@drawable/end_call_background" + android:src="@drawable/fab_ic_end_call" + android:contentDescription="@string/onscreenEndCallText" /> </FrameLayout> - <!-- Secondary "Call info" block, for the background ("on hold") call. --> - <ViewStub android:id="@+id/secondary_call_info" - android:layout="@layout/secondary_call_info" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" /> + <!-- Insert a CallService indicator (which controls handoff, too) --> + <FrameLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom|right"> + + <ImageButton android:id="@+id/handoffButton" + android:enabled="false" + android:layout_width="@dimen/floating_action_button_width" + android:layout_height="@dimen/floating_action_button_height" + android:layout_marginBottom="@dimen/end_call_button_margin_bottom" + android:background="@drawable/floating_handoff_button_compound_background" + android:src="@drawable/ic_in_call_pstn" /> + </FrameLayout> - </LinearLayout> + </FrameLayout> - <!-- Animated scrim that fills the whole screen and then shrinks to show call details --> - <LinearLayout - android:id="@+id/animated_scrim" + <!-- Secondary "Call info" block, for the background ("on hold") call. --> + <ViewStub android:id="@+id/secondary_call_info" + android:layout="@layout/secondary_call_info" android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="gone" - android:orientation="vertical"> - - <Space - android:id="@+id/animated_scrim_spacer" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="0" /> - <View - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:background="@color/incall_call_banner_background_color" /> - </LinearLayout> + android:layout_height="0dp" + android:layout_weight="1" /> -</FrameLayout> +</LinearLayout> diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 3cebb7fe8..60575c89d 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -16,9 +16,10 @@ package com.android.incallui; -import android.animation.Animator.AnimatorListener; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.app.Activity; import android.content.Context; @@ -32,18 +33,10 @@ import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; import android.view.ViewStub; import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.accessibility.AccessibilityEvent; -import android.view.animation.Animation; -import android.widget.ImageView; -import android.widget.TextView; - -import com.android.contacts.common.animation.AnimationListenerAdapter; -import com.android.contacts.common.util.ViewUtil; -import com.android.incallui.animation.ResizeAnimation; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; @@ -59,7 +52,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr implements CallCardPresenter.CallCardUi { private static final int REVEAL_ANIMATION_DURATION = 800; - private static final int SLIDE_ANIMATION_DURATION = 400; + private static final int SHRINK_ANIMATION_DURATION = 400; // Primary caller info private TextView mPhoneNumber; @@ -82,16 +75,12 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private ImageView mSecondaryPhoto; private View mSecondaryPhotoOverlay; - private View mAnimatedScrim; - private View mEndCallButton; private ImageButton mHandoffButton; // Cached DisplayMetrics density. private float mDensity; - private final AnimatorListener mAnimatedScrimListener = new AnimatedScrimListener(); - @Override CallCardPresenter.CallCardUi getUi() { return this; @@ -141,7 +130,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mElapsedTime = (TextView) view.findViewById(R.id.elapsedTime); mPrimaryCallCardContainer = view.findViewById(R.id.primary_call_info_container); mPrimaryCallInfo = view.findViewById(R.id.primary_call_banner); - mAnimatedScrim = view.findViewById(R.id.animated_scrim); mCallButtonsContainer = view.findViewById(R.id.callButtonFragment); mEndCallButton = view.findViewById(R.id.endButton); @@ -544,6 +532,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr return; } + @Override public void setEndCallButtonEnabled(boolean enabled) { mEndCallButton.setVisibility(enabled ? View.VISIBLE : View.GONE); } @@ -560,11 +549,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } public void animateForNewOutgoingCall() { - final View animatedSpacer = getView().findViewById(R.id.animated_scrim_spacer); - - mAnimatedScrim.setVisibility(View.VISIBLE); - mAnimatedScrim.getLayoutParams().height = LayoutParams.MATCH_PARENT; - mAnimatedScrim.requestLayout(); + final ViewGroup parent = (ViewGroup) mPrimaryCallCardContainer.getParent(); final ViewTreeObserver observer = getView().getViewTreeObserver(); observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @@ -576,20 +561,58 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } observer.removeOnGlobalLayoutListener(this); - // Prepare the state of views before the circular reveal animation - final int targetHeight = mPrimaryCallCardContainer.getHeight(); - animatedSpacer.getLayoutParams().height = targetHeight; - animatedSpacer.requestLayout(); + final int originalHeight = mPrimaryCallCardContainer.getHeight(); + final LayoutIgnoringListener listener = new LayoutIgnoringListener(); + mPrimaryCallCardContainer.addOnLayoutChangeListener(listener); + // Prepare the state of views before the circular reveal animation + mPrimaryCallCardContainer.setBottom(parent.getHeight()); + mEndCallButton.setTranslationY(200); mPrimaryCallInfo.setAlpha(0); mCallButtonsContainer.setAlpha(0); - performAnimatedReveal(mAnimatedScrimListener); + final Animator revealAnimator = getRevealAnimator(); + final Animator shrinkAnimator = + getShrinkAnimator(parent.getHeight(), originalHeight); + + final AnimatorSet set = new AnimatorSet(); + set.playSequentially(revealAnimator, shrinkAnimator); + set.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationCancel(Animator animation) { + mPrimaryCallCardContainer.removeOnLayoutChangeListener(listener); + } + + @Override + public void onAnimationEnd(Animator animation) { + mPrimaryCallCardContainer.removeOnLayoutChangeListener(listener); + } + }); + set.start(); + } + }); + } + + private Animator getShrinkAnimator(int startHeight, int endHeight) { + final Animator shrinkAnimator = + ObjectAnimator.ofInt(mPrimaryCallCardContainer, "bottom", + startHeight, endHeight); + shrinkAnimator.setDuration(SHRINK_ANIMATION_DURATION); + shrinkAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + mEndCallButton.animate().translationY(0) + .setDuration(SHRINK_ANIMATION_DURATION); + mPrimaryCallInfo.animate().alpha(1).withLayer() + .setDuration(SHRINK_ANIMATION_DURATION); + mCallButtonsContainer.animate().alpha(1).withLayer() + .setDuration(SHRINK_ANIMATION_DURATION); } }); + return shrinkAnimator; } - private void performAnimatedReveal(AnimatorListener listener) { + private Animator getRevealAnimator() { final Activity activity = getActivity(); final View view = activity.getWindow().getDecorView(); final Display display = activity.getWindowManager().getDefaultDisplay(); @@ -599,37 +622,24 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr final ValueAnimator valueAnimator = view.createRevealAnimator(size.x / 2, size.y / 2, 0, Math.max(size.x, size.y)); valueAnimator.setDuration(REVEAL_ANIMATION_DURATION); - valueAnimator.addListener(listener); - valueAnimator.start(); + return valueAnimator; } - private final class AnimatedScrimListener extends AnimatorListenerAdapter { + private final class LayoutIgnoringListener implements View.OnLayoutChangeListener { @Override - public void onAnimationEnd(Animator animation) { - final int width = mAnimatedScrim.getWidth(); - ResizeAnimation resizeAnimation = - new ResizeAnimation(mAnimatedScrim, width, width, mAnimatedScrim.getHeight(), - 0); - resizeAnimation.setDuration(SLIDE_ANIMATION_DURATION); - resizeAnimation.setAnimationListener(new AnimationListenerAdapter() { - @Override - public void onAnimationStart(Animation animation) { - // Prepare the state of views before the scrim's sliding up animation - mEndCallButton.setTranslationY(200); - mEndCallButton.animate().translationY(0) - .setDuration(SLIDE_ANIMATION_DURATION); - mPrimaryCallInfo.animate().alpha(1).withLayer() - .setDuration(SLIDE_ANIMATION_DURATION); - mCallButtonsContainer.animate().alpha(1).withLayer() - .setDuration(SLIDE_ANIMATION_DURATION); - } - - @Override - public void onAnimationEnd(Animation animation) { - mAnimatedScrim.setVisibility(View.GONE); - } - }); - mAnimatedScrim.startAnimation(resizeAnimation); + public void onLayoutChange(View v, + int left, + int top, + int right, + int bottom, + int oldLeft, + int oldTop, + int oldRight, + int oldBottom) { + v.setLeft(oldLeft); + v.setRight(oldRight); + v.setTop(oldTop); + v.setBottom(oldBottom); } - }; + } } diff --git a/InCallUI/src/com/android/incallui/animation/ResizeAnimation.java b/InCallUI/src/com/android/incallui/animation/ResizeAnimation.java deleted file mode 100644 index 3151ffbf7..000000000 --- a/InCallUI/src/com/android/incallui/animation/ResizeAnimation.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2014 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.animation; - -import android.view.View; -import android.view.animation.Animation; -import android.view.animation.Transformation; - -public class ResizeAnimation extends Animation { - private final int mStartWidth; - private final int mStartHeight; - private final int mEndWidth; - private final int mEndHeight; - private final View mView; - - public ResizeAnimation(View view, int startWidth, int endWidth, int startHeight, - int endHeight) { - this.mView = view; - this.mStartWidth = startWidth; - this.mStartHeight = startHeight; - this.mEndWidth = endWidth; - this.mEndHeight = endHeight; - } - - @Override - protected void applyTransformation(float interpolatedTime, Transformation t) { - int width = (int) (mStartWidth + (mEndWidth - mStartWidth) * interpolatedTime); - int height = (int) (mStartHeight + (mEndHeight - mStartHeight) * interpolatedTime); - mView.getLayoutParams().width = width; - mView.getLayoutParams().height = height; - mView.requestLayout(); - } - - @Override - public boolean willChangeBounds() { - return true; - } -}
\ No newline at end of file |