summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2014-09-26 16:17:35 -0700
committerAndrew Lee <anwlee@google.com>2014-09-29 14:23:04 -0700
commit61cd731e15ca8b8a9c7044f4a692f566f6ab7bc0 (patch)
tree1456185adbaa7d68394d0c413bee1dd7af6cd95f /InCallUI
parent0b5f566a6054d1e73310214736e14fbb136d321f (diff)
Fix FAB positioning for incoming calls.
We aren't setting the screen width in onResume, which means that repositions would fail for incoming calls, or resumes. Now, set the screen width when resuming the app. I also cleaned up some of the method naming to be more precise; there shouldn't be a change in behavior resulting from it. The OnGlobalLayout listener wasn't triggering if the observer wasn't alive, so address this by checking for a new observer. Bug: 17673299 Change-Id: I1d454f4a5d1561bc73c12a6c74edbc075e1f1a18
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java38
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