diff options
5 files changed, 103 insertions, 25 deletions
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 29cdd4ddc..ca186b34d 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -387,7 +387,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto ui.showButton(BUTTON_UPGRADE_TO_VIDEO, showUpgradeToVideo); ui.showButton(BUTTON_SWITCH_CAMERA, isVideo); ui.showButton(BUTTON_PAUSE_VIDEO, isVideo); - ui.showButton(BUTTON_DIALPAD, !isVideo); + ui.showButton(BUTTON_DIALPAD, true); ui.showButton(BUTTON_MERGE, showMerge); ui.updateButtonStates(); diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 705a1da02..46f8a7ead 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -379,6 +379,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr */ @Override public void setCallCardVisible(final boolean visible) { + Log.v(this, "setCallCardVisible : isVisible = " + visible); // When animating the hide/show of the views in a landscape layout, we need to take into // account whether we are in a left-to-right locale or a right-to-left locale and adjust // the animations accordingly. @@ -400,9 +401,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr @Override public boolean onPreDraw() { // We don't want to continue getting called. - if (observer.isAlive()) { - observer.removeOnPreDrawListener(this); - } + getView().getViewTreeObserver().removeOnPreDrawListener(this); float videoViewTranslation = 0f; diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 714db0977..3dcaa392b 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -82,6 +82,10 @@ public class InCallActivity extends TransactionSafeActivity implements FragmentD private static final String TAG_ANSWER_FRAGMENT = "tag_answer_fragment"; private static final String TAG_SELECT_ACCT_FRAGMENT = "tag_select_acct_fragment"; + private static final int DIALPAD_REQUEST_NONE = 1; + private static final int DIALPAD_REQUEST_SHOW = 2; + private static final int DIALPAD_REQUEST_HIDE = 3; + private CallButtonFragment mCallButtonFragment; private CallCardFragment mCallCardFragment; private AnswerFragment mAnswerFragment; @@ -93,9 +97,12 @@ public class InCallActivity extends TransactionSafeActivity implements FragmentD private InCallOrientationEventListener mInCallOrientationEventListener; /** - * Use to pass 'showDialpad' from {@link #onNewIntent} to {@link #onResume} + * Used to indicate whether the dialpad should be hidden or shown {@link #onResume}. + * {@code #DIALPAD_REQUEST_SHOW} indicates that the dialpad should be shown. + * {@code #DIALPAD_REQUEST_HIDE} indicates that the dialpad should be hidden. + * {@code #DIALPAD_REQUEST_NONE} indicates no change should be made to dialpad visibility. */ - private boolean mShowDialpadRequested; + private int mShowDialpadRequest = DIALPAD_REQUEST_NONE; /** * Use to determine if the dialpad should be animated on show. @@ -193,13 +200,24 @@ public class InCallActivity extends TransactionSafeActivity implements FragmentD mSlideOut.setAnimationListener(mSlideOutListener); + // If the dialpad fragment already exists, retrieve it. This is important when rotating as + // we will not be able to hide or show the dialpad after the rotation otherwise. + Fragment existingFragment = + mChildFragmentManager.findFragmentByTag(DialpadFragment.class.getName()); + if (existingFragment != null) { + mDialpadFragment = (DialpadFragment) existingFragment; + } + if (icicle != null) { // If the dialpad was shown before, set variables indicating it should be shown and // populated with the previous DTMF text. The dialpad is actually shown and populated // in onResume() to ensure the hosting CallCardFragment has been inflated and is ready // to receive it. - mShowDialpadRequested = icicle.getBoolean(SHOW_DIALPAD_EXTRA); - mAnimateDialpadOnShow = false; + if (icicle.containsKey(SHOW_DIALPAD_EXTRA)) { + boolean showDialpad = icicle.getBoolean(SHOW_DIALPAD_EXTRA); + mShowDialpadRequest = showDialpad ? DIALPAD_REQUEST_SHOW : DIALPAD_REQUEST_HIDE; + mAnimateDialpadOnShow = false; + } mDtmfText = icicle.getString(DIALPAD_TEXT_EXTRA); SelectPhoneAccountDialogFragment dialogFragment = (SelectPhoneAccountDialogFragment) @@ -246,16 +264,31 @@ public class InCallActivity extends TransactionSafeActivity implements FragmentD InCallPresenter.getInstance().setThemeColors(); InCallPresenter.getInstance().onUiShowing(true); - if (mShowDialpadRequested) { - mCallButtonFragment.displayDialpad(true /* show */, - mAnimateDialpadOnShow /* animate */); - mShowDialpadRequested = false; - mAnimateDialpadOnShow = false; + // Clear fullscreen state onResume; the stored value may not match reality. + InCallPresenter.getInstance().clearFullscreen(); - if (mDialpadFragment != null) { - mDialpadFragment.setDtmfText(mDtmfText); - mDtmfText = null; + // If there is a pending request to show or hide the dialpad, handle that now. + if (mShowDialpadRequest != DIALPAD_REQUEST_NONE) { + if (mShowDialpadRequest == DIALPAD_REQUEST_SHOW) { + // Exit fullscreen so that the user has access to the dialpad hide/show button and + // can hide the dialpad. Important when showing the dialpad from within dialer. + InCallPresenter.getInstance().setFullScreen(false, true /* force */); + + mCallButtonFragment.displayDialpad(true /* show */, + mAnimateDialpadOnShow /* animate */); + mAnimateDialpadOnShow = false; + + if (mDialpadFragment != null) { + mDialpadFragment.setDtmfText(mDtmfText); + mDtmfText = null; + } + } else { + Log.v(this, "onResume : force hide dialpad"); + if (mDialpadFragment != null) { + mCallButtonFragment.displayDialpad(false /* show */, false /* animate */); + } } + mShowDialpadRequest = DIALPAD_REQUEST_NONE; } if (mShowPostCharWaitDialogOnResume) { @@ -592,16 +625,23 @@ public class InCallActivity extends TransactionSafeActivity implements FragmentD } else if (!newOutgoingCall) { showCallCardFragment(true); } - return; } } + /** + * When relaunching from the dialer app, {@code showDialpad} indicates whether the dialpad + * should be shown on launch. + * + * @param showDialpad {@code true} to indicate the dialpad should be shown on launch, and + * {@code false} to indicate no change should be made to the + * dialpad visibility. + */ private void relaunchedFromDialer(boolean showDialpad) { - mShowDialpadRequested = showDialpad; + mShowDialpadRequest = showDialpad ? DIALPAD_REQUEST_SHOW : DIALPAD_REQUEST_NONE; mAnimateDialpadOnShow = true; - if (mShowDialpadRequested) { + if (mShowDialpadRequest == DIALPAD_REQUEST_SHOW) { // If there's only one line in use, AND it's on hold, then we're sure the user // wants to use the dialpad toward the exact line, so un-hold the holding line. final Call call = CallList.getInstance().getActiveOrBackgroundCall(); diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 836c9242e..ab6c24221 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -1132,21 +1132,46 @@ public class InCallPresenter implements CallList.Listener, * @return {@code true} if in-call is now in fullscreen mode. */ public boolean toggleFullscreenMode() { - mIsFullScreen = !mIsFullScreen; - Log.v(this, "toggleFullscreenMode = " + mIsFullScreen); - notifyFullscreenModeChange(mIsFullScreen); + boolean isFullScreen = !mIsFullScreen; + Log.v(this, "toggleFullscreenMode = " + isFullScreen); + setFullScreen(isFullScreen); return mIsFullScreen; } /** + * Clears the previous fullscreen state. + */ + public void clearFullscreen() { + mIsFullScreen = false; + } + + /** * Changes the fullscreen mode of the in-call UI. * * @param isFullScreen {@code true} if in-call should be in fullscreen mode, {@code false} * otherwise. */ public void setFullScreen(boolean isFullScreen) { + setFullScreen(isFullScreen, false /* force */); + } + + /** + * Changes the fullscreen mode of the in-call UI. + * + * @param isFullScreen {@code true} if in-call should be in fullscreen mode, {@code false} + * otherwise. + * @param force {@code true} if fullscreen mode should be set regardless of its current state. + */ + public void setFullScreen(boolean isFullScreen, boolean force) { Log.v(this, "setFullScreen = " + isFullScreen); - if (mIsFullScreen == isFullScreen) { + + // As a safeguard, ensure we cannot enter fullscreen if the dialpad is shown. + if (isDialpadVisible()) { + isFullScreen = false; + Log.v(this, "setFullScreen overridden as dialpad is shown = " + isFullScreen); + } + + if (mIsFullScreen == isFullScreen && !force) { Log.v(this, "setFullScreen ignored as already in that state."); return; } @@ -1627,6 +1652,18 @@ public class InCallPresenter implements CallList.Listener, } /** + * Determines if the dialpad is visible. + * + * @return {@code true} if the dialpad is visible, {@code false} otherwise. + */ + public boolean isDialpadVisible() { + if (mInCallActivity == null) { + return false; + } + return mInCallActivity.isDialpadVisible(); + } + + /** * @return True if the application is currently running in a right-to-left locale. */ public static boolean isRtl() { diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 262adb46d..b663bb8bd 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -75,12 +75,14 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi public static final boolean DEBUG = false; /** - * Runnable which is posted to schedule automatically entering fullscreen mode. + * Runnable which is posted to schedule automatically entering fullscreen mode. Will not auto + * enter fullscreen mode if the dialpad is visible (doing so would make it impossible to exit + * the dialpad). */ private Runnable mAutoFullscreenRunnable = new Runnable() { @Override public void run() { - if (mAutoFullScreenPending) { + if (mAutoFullScreenPending && !InCallPresenter.getInstance().isDialpadVisible()) { Log.v(this, "Automatically entering fullscreen mode."); InCallPresenter.getInstance().setFullScreen(true); mAutoFullScreenPending = false; |