diff options
author | Andrew Lee <anwlee@google.com> | 2014-08-19 23:39:26 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-08-19 23:39:26 +0000 |
commit | 861213a904da877a613ea5896f2d5712a8d8a719 (patch) | |
tree | 840f28803434d347d9566e94ce8c09a65a4a14f3 /InCallUI | |
parent | 6cbafb44dab578ae3d14a6cb96308b682a4f4ae9 (diff) | |
parent | c44f654b992c6ab8a4acff9cb5aa2678c58755d9 (diff) |
am b8249f37: Move hold "bar" to the bottom of the screen.
* commit 'b8249f3727e4d233215f4cfbecdd7ed175ce5231':
Move hold "bar" to the bottom of the screen.
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/res/layout/call_card_content.xml | 12 | ||||
-rw-r--r-- | InCallUI/res/layout/dtmf_twelve_key_dialer_view.xml | 3 | ||||
-rw-r--r-- | InCallUI/res/layout/secondary_call_info.xml | 1 | ||||
-rw-r--r-- | InCallUI/res/values/dimens.xml | 1 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 106 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardPresenter.java | 6 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallActivity.java | 4 |
7 files changed, 85 insertions, 48 deletions
diff --git a/InCallUI/res/layout/call_card_content.xml b/InCallUI/res/layout/call_card_content.xml index 5437ef04d..605d6300f 100644 --- a/InCallUI/res/layout/call_card_content.xml +++ b/InCallUI/res/layout/call_card_content.xml @@ -18,7 +18,7 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent" > + android:layout_height="match_parent"> <!-- The main content of the CallCard is either one or two "call info" blocks, depending on whether one or two lines are in use. @@ -39,7 +39,7 @@ android:background="@color/incall_call_banner_background_color" android:paddingTop="@dimen/call_banner_primary_call_container_top_padding" android:clipChildren="false" - android:clipToPadding="false" > + android:clipToPadding="false"> <include layout="@layout/primary_call_info" /> @@ -84,7 +84,7 @@ android:layout_height="fill_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" - android:visibility="gone" > + android:visibility="gone"> <ProgressBar android:id="@+id/progress_bar" @@ -97,9 +97,9 @@ <!-- Secondary "Call info" block, for the background ("on hold") call. --> <include layout="@layout/secondary_call_info" - android:layout_below="@id/primary_call_info_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true"/> <!-- Placeholder for the dialpad which is replaced with the dialpad fragment when shown. --> <FrameLayout diff --git a/InCallUI/res/layout/dtmf_twelve_key_dialer_view.xml b/InCallUI/res/layout/dtmf_twelve_key_dialer_view.xml index cd9977eeb..efd698286 100644 --- a/InCallUI/res/layout/dtmf_twelve_key_dialer_view.xml +++ b/InCallUI/res/layout/dtmf_twelve_key_dialer_view.xml @@ -19,8 +19,7 @@ android:id="@+id/dtmf_twelve_key_dialer_view" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - android:layout_marginTop="1dip" > + android:orientation="vertical"> <view class="com.android.incallui.DialpadFragment$HoverIgnoringLinearLayout" android:orientation="vertical" diff --git a/InCallUI/res/layout/secondary_call_info.xml b/InCallUI/res/layout/secondary_call_info.xml index c562ae292..cbe1fa2f9 100644 --- a/InCallUI/res/layout/secondary_call_info.xml +++ b/InCallUI/res/layout/secondary_call_info.xml @@ -20,6 +20,7 @@ android:id="@+id/secondary_call_info" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_alignParentBottom="true" android:orientation="horizontal" android:paddingStart="@dimen/call_banner_side_padding" android:paddingEnd="@dimen/secondary_call_banner_right_padding" diff --git a/InCallUI/res/values/dimens.xml b/InCallUI/res/values/dimens.xml index 87dd66756..6bf80f314 100644 --- a/InCallUI/res/values/dimens.xml +++ b/InCallUI/res/values/dimens.xml @@ -103,7 +103,6 @@ <dimen name="translucent_shadow_height">2dp</dimen> <dimen name="end_call_button_margin_bottom">8dp</dimen> - <dimen name="end_call_button_hide_offset">80dp</dimen> <dimen name="call_card_anim_translate_y_offset">50dp</dimen> diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index d79330e4b..8ca1dd67c 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -61,6 +61,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private int mFabNormalDiameter; private int mFabSmallDiameter; private boolean mIsLandscape; + private boolean mIsDialpadShowing; // Primary caller info private TextView mPhoneNumber; @@ -96,13 +97,13 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private View mFloatingActionButtonContainer; private ImageButton mFloatingActionButton; private int mFloatingActionButtonVerticalOffset; - private int mFloatingActionButtonHideOffset; // Cached DisplayMetrics density. private float mDensity; private float mTranslationOffset; private Animation mPulseAnimation; + private int mVideoAnimationDuration; @Override @@ -124,8 +125,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mVideoAnimationDuration = getResources().getInteger(R.integer.video_animation_duration); mFloatingActionButtonVerticalOffset = getResources().getDimensionPixelOffset( R.dimen.floating_action_bar_vertical_offset); - mFloatingActionButtonHideOffset = getResources().getDimensionPixelOffset( - R.dimen.end_call_button_hide_offset); mFabNormalDiameter = getResources().getDimensionPixelOffset( R.dimen.end_call_floating_action_button_diameter); mFabSmallDiameter = getResources().getDimensionPixelOffset( @@ -195,7 +194,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr int floatingActionButtonWidth = getResources().getDimensionPixelSize( R.dimen.floating_action_button_width); mFloatingActionButtonController = new FloatingActionButtonController(getActivity(), - mFloatingActionButtonContainer); + mFloatingActionButtonContainer, mFloatingActionButton); final ViewGroup parent = (ViewGroup) mPrimaryCallCardContainer.getParent(); final ViewTreeObserver observer = getView().getViewTreeObserver(); observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @@ -211,7 +210,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_END : FloatingActionButtonController.ALIGN_MIDDLE, 0 /* offsetX */, - 0 /* offsetY */, + mFloatingActionButtonVerticalOffset /* offsetY */, false); } }); @@ -448,6 +447,10 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr public void setSecondary(boolean show, String name, boolean nameIsNumber, String label, String providerLabel, Drawable providerIcon, boolean isConference, boolean isGeneric) { + if (show != mSecondaryCallInfo.isShown()) { + updateFabPositionOnSecondaryCallInfoLayout(); + } + if (show) { if (isConference) { name = getConferenceString(isGeneric); @@ -778,6 +781,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr @Override public void onClick(View v) { getPresenter().secondaryInfoClicked(); + updateFabPositionOnSecondaryCallInfoLayout(); } }); } @@ -800,15 +804,25 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } @Override - public void setEndCallButtonEnabled(boolean enabled) { - mFloatingActionButtonController.align( - mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_END - : FloatingActionButtonController.ALIGN_MIDDLE, - 0 /* offsetX */, - enabled ? mFloatingActionButtonVerticalOffset /* offsetY */ - : mFloatingActionButtonHideOffset, - true); - mFloatingActionButton.setEnabled(enabled); + public void setEndCallButtonEnabled(boolean enabled, boolean animate) { + if (enabled != mFloatingActionButton.isEnabled()) { + if (animate) { + if (enabled) { + mFloatingActionButtonController.scaleIn(); + } else { + mFloatingActionButtonController.scaleOut(); + } + } else { + if (enabled) { + mFloatingActionButtonContainer.setScaleX(1); + mFloatingActionButtonContainer.setScaleY(1); + mFloatingActionButtonContainer.setVisibility(View.VISIBLE); + } else { + mFloatingActionButtonContainer.setVisibility(View.GONE); + } + } + mFloatingActionButton.setEnabled(enabled); + } } /** @@ -854,15 +868,14 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mPrimaryCallCardContainer.setBottom(parent.getHeight()); // Set up FAB. + mFloatingActionButtonContainer.setVisibility(View.GONE); mFloatingActionButtonController.setScreenWidth(parent.getWidth()); - // Move it below the screen. - mFloatingActionButtonController.manuallyTranslate( - mFloatingActionButtonController.getTranslationXForAlignment( - mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_END - : FloatingActionButtonController.ALIGN_MIDDLE - ), - mFloatingActionButtonHideOffset - ); + mFloatingActionButtonController.align( + mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_END + : FloatingActionButtonController.ALIGN_MIDDLE, + 0 /* offsetX */, + mFloatingActionButtonVerticalOffset /* offsetY */, + false); mCallButtonsContainer.setAlpha(0); mCallStateLabel.setAlpha(0); mPrimaryName.setAlpha(0); @@ -879,11 +892,13 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr @Override public void onAnimationCancel(Animator animation) { mPrimaryCallCardContainer.removeOnLayoutChangeListener(listener); + mFloatingActionButtonController.scaleIn(); } @Override public void onAnimationEnd(Animator animation) { mPrimaryCallCardContainer.removeOnLayoutChangeListener(listener); + mFloatingActionButtonController.scaleIn(); } }); set.start(); @@ -891,24 +906,47 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr }); } - public void onDialpadShow() { + public void onDialpadVisiblityChange(boolean isShown) { + mIsDialpadShowing = isShown; + + int offsetY = 0; + if (!mIsDialpadShowing) { + offsetY = mFloatingActionButtonVerticalOffset; + if (mSecondaryCallInfo.isShown()) { + offsetY -= mSecondaryCallInfo.getHeight(); + } + } + mFloatingActionButtonController.align( mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_END : FloatingActionButtonController.ALIGN_MIDDLE, 0 /* offsetX */, - 0 /* offsetY */, + offsetY, true); - mFloatingActionButtonController.resize(mFabSmallDiameter, true); + + mFloatingActionButtonController.resize( + mIsDialpadShowing ? mFabSmallDiameter : mFabNormalDiameter, true); } - public void onDialpadHide() { - mFloatingActionButtonController.align( - mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_END - : FloatingActionButtonController.ALIGN_MIDDLE, - 0 /* offsetX */, - mFloatingActionButtonVerticalOffset /* offsetY */, - true); - mFloatingActionButtonController.resize(mFabNormalDiameter, true); + /** + * Adds a global layout listener to update the FAB's positioning on the next layout. This allows + * us to position the FAB after the secondary call info's height has been calculated. + */ + private void updateFabPositionOnSecondaryCallInfoLayout() { + mSecondaryCallInfo.getViewTreeObserver().addOnGlobalLayoutListener( + new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + final ViewTreeObserver observer = + mSecondaryCallInfo.getViewTreeObserver(); + if (!observer.isAlive()) { + return; + } + observer.removeOnGlobalLayoutListener(this); + + onDialpadVisiblityChange(mIsDialpadShowing); + } + }); } /** @@ -929,7 +967,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr assignTranslateAnimation(mCallTypeLabel, 4); assignTranslateAnimation(mCallButtonsContainer, 5); - setEndCallButtonEnabled(true); + mFloatingActionButton.setEnabled(true); } }); shrinkAnimator.setInterpolator(AnimUtils.EASE_IN); diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index ce17109e1..930818901 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -252,7 +252,9 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> final boolean enableEndCallButton = Call.State.isConnectingOrConnected(callState) && callState != Call.State.INCOMING && mPrimary != null; - getUi().setEndCallButtonEnabled(enableEndCallButton); + // Hide the end call button instantly if we're receiving an incoming call. + getUi().setEndCallButtonEnabled( + enableEndCallButton, callState != Call.State.INCOMING /* animate */); } @Override @@ -653,7 +655,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> void setPrimaryImage(Drawable image); void setPrimaryPhoneNumber(String phoneNumber); void setPrimaryLabel(String label); - void setEndCallButtonEnabled(boolean enabled); + void setEndCallButtonEnabled(boolean enabled, boolean animate); void setCallbackNumber(String number, boolean isEmergencyCalls); void setPhotoVisible(boolean isVisible); void setProgressSpinnerVisible(boolean visible); diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 8930837dc..cbb2af280 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -568,10 +568,8 @@ public class InCallActivity extends Activity { if (showDialpad) { showDialpad(true); mDialpadFragment.animateShowDialpad(); - mCallCardFragment.onDialpadShow(); - } else { - mCallCardFragment.onDialpadHide(); } + mCallCardFragment.onDialpadVisiblityChange(showDialpad); mDialpadFragment.getView().startAnimation(showDialpad ? mSlideIn : mSlideOut); } |