summaryrefslogtreecommitdiff
path: root/InCallUI/src/com
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2014-08-18 12:56:36 -0700
committerAndrew Lee <anwlee@google.com>2014-08-19 14:54:27 -0700
commitc44f654b992c6ab8a4acff9cb5aa2678c58755d9 (patch)
treec729341b64f883376a552538c6395f7685d79b8d /InCallUI/src/com
parentedd93afc109cd404154ca92e89d71b08b8da0745 (diff)
Move hold "bar" to the bottom of the screen.
+ Adjust FAB positioning scenarios; scale in and out instead of translating when showing/hiding. + Translate FAB depending on whether secondary call info is shown. Bug: 16399233 Bug: 15862303 Change-Id: Ibbf89f717a38f2ed6d4d995544e290da4d4d7462
Diffstat (limited to 'InCallUI/src/com')
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java106
-rw-r--r--InCallUI/src/com/android/incallui/CallCardPresenter.java6
-rw-r--r--InCallUI/src/com/android/incallui/InCallActivity.java4
3 files changed, 77 insertions, 39 deletions
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);
}