diff options
author | Andrew Lee <anwlee@google.com> | 2014-10-01 00:51:20 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-01 00:51:20 +0000 |
commit | a3986e83222b9d14dd02b6a752fc42a034d181f2 (patch) | |
tree | 20bae134e93a3a8b6fbfb3dcf45759219daff356 /InCallUI | |
parent | 629255c72d223e344ccdfc01712a3a57bbaa9e4b (diff) | |
parent | 61cd731e15ca8b8a9c7044f4a692f566f6ab7bc0 (diff) |
am 610a186b: Fix FAB positioning for incoming calls.
* commit '610a186b12f95c3b94789c4afa1e019f4e46684f':
Fix FAB positioning for incoming calls.
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index f984aa836..6643128b3 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -135,8 +135,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr R.dimen.end_call_floating_action_button_diameter); mFabSmallDiameter = getResources().getDimensionPixelOffset( R.dimen.end_call_floating_action_button_small_diameter); - mIsLandscape = getResources().getConfiguration().orientation - == Configuration.ORIENTATION_LANDSCAPE; } @@ -196,8 +194,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr getPresenter().endCallClicked(); } }); - int floatingActionButtonWidth = getResources().getDimensionPixelSize( - R.dimen.floating_action_button_width); mFloatingActionButtonController = new FloatingActionButtonController(getActivity(), mFloatingActionButtonContainer, mFloatingActionButton); @@ -205,7 +201,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr @Override public void onClick(View v) { getPresenter().secondaryInfoClicked(); - updateFabPosition(); + updateFabPositionForSecondaryCallInfo(); } }); @@ -454,7 +450,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr boolean canManageConference) { if (show != mSecondaryCallInfo.isShown()) { - updateFabPosition(); + updateFabPositionForSecondaryCallInfo(); } if (show) { @@ -771,6 +767,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } } mFloatingActionButton.setEnabled(enabled); + updateFabPosition(); } } @@ -832,12 +829,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr // Set up FAB. mFloatingActionButtonContainer.setVisibility(View.GONE); mFloatingActionButtonController.setScreenWidth(parent.getWidth()); - mFloatingActionButtonController.align( - mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_END - : FloatingActionButtonController.ALIGN_MIDDLE, - 0 /* offsetX */, - mFloatingActionButtonVerticalOffset /* offsetY */, - false); mCallButtonsContainer.setAlpha(0); mCallStateLabel.setAlpha(0); mPrimaryName.setAlpha(0); @@ -863,7 +854,10 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr public void onDialpadVisiblityChange(boolean isShown) { mIsDialpadShowing = isShown; + updateFabPosition(); + } + private void updateFabPosition() { int offsetY = 0; if (!mIsDialpadShowing) { offsetY = mFloatingActionButtonVerticalOffset; @@ -892,14 +886,30 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mAnimatorSet.cancel(); } - updateFabPosition(); + mIsLandscape = getResources().getConfiguration().orientation + == Configuration.ORIENTATION_LANDSCAPE; + + final ViewGroup parent = ((ViewGroup) mPrimaryCallCardContainer.getParent()); + final ViewTreeObserver observer = parent.getViewTreeObserver(); + parent.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + ViewTreeObserver viewTreeObserver = observer; + if (!viewTreeObserver.isAlive()) { + viewTreeObserver = parent.getViewTreeObserver(); + } + viewTreeObserver.removeOnGlobalLayoutListener(this); + mFloatingActionButtonController.setScreenWidth(parent.getWidth()); + updateFabPosition(); + } + }); } /** * 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 updateFabPosition() { + private void updateFabPositionForSecondaryCallInfo() { mSecondaryCallInfo.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override |