summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2015-06-30 13:15:59 -0700
committerTyler Gunn <tgunn@google.com>2015-12-06 22:04:51 -0800
commit50d70a614f2f617ed60d24f8d1756b1bcb20bb80 (patch)
tree748a9348328d28d37f5c7f41d1270165c888d164
parentfa0c573d689a16401f1bf801d93b7b37d2380c5c (diff)
Show dialpad button for VT calls, cleanup dialpad on rotation.
1. Show the dialpad button for VT calls (this was easy). 2. In testing I realized there were some other dialpad scenarios that did not work properly: - The dialpad visibility state was not properly restored after rotation. - The auto-fullscreen code could hide the call card when the dialpad was showing, resulting in an inability to hide the dialpad. - In landscape it was possible to tap between the call card and the dialpad and cause the call card to be hidden. - If user goes to background in fullscreen mode and then opens dialer and chooses to show the dialpad, the app is still in fullscreen and it is not possible to hide the dialpad. 3. Noticed an issue related to the fact mIsFullScreen in InCallPresenter is static, and after rotation you're always defaulting to not fullscreen. Fixed by clearing fullscreen state on rotation to match actuality. Bug: 21296950 Change-Id: I2c7a666a50e2284b1d22db43c443b34109cff9b1
-rw-r--r--InCallUI/src/com/android/incallui/CallButtonPresenter.java2
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java5
-rw-r--r--InCallUI/src/com/android/incallui/InCallActivity.java70
-rw-r--r--InCallUI/src/com/android/incallui/InCallPresenter.java45
-rw-r--r--InCallUI/src/com/android/incallui/VideoCallPresenter.java6
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;