Skip to content

Commit 6cfddd6

Browse files
maniac103arnavgosain
authored andcommitted
Avoid layout changes on call disconnection.
This avoids showing the call buttons when an incoming call is disconnected remotely while still ringing, which in turn avoids an ugly transition when using the full screen caller photo. Change-Id: If69bce271303ea43dca64925aba895dd3b5b5611
1 parent 923b164 commit 6cfddd6

5 files changed

Lines changed: 56 additions & 36 deletions

File tree

src/com/android/incallui/AnswerFragment.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,6 @@ public void onDestroyView() {
102102
super.onDestroyView();
103103
}
104104

105-
public void setUseTranslucentNavigationBar(boolean useTranslucent) {
106-
mUseTranslucentNavBar = useTranslucent;
107-
View v = getView();
108-
if (v != null) {
109-
updateNavBarTranslucency(v.getVisibility() == View.VISIBLE);
110-
}
111-
}
112-
113105
@Override
114106
public void showAnswerUi(boolean show) {
115107
getView().setVisibility(show ? View.VISIBLE : View.GONE);
@@ -120,16 +112,6 @@ public void showAnswerUi(boolean show) {
120112
} else {
121113
mGlowpad.stopPing();
122114
}
123-
updateNavBarTranslucency(show);
124-
}
125-
126-
private void updateNavBarTranslucency(boolean enable) {
127-
final Window window = getActivity().getWindow();
128-
if (enable && mUseTranslucentNavBar) {
129-
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
130-
} else {
131-
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
132-
}
133115
}
134116

135117
@Override

src/com/android/incallui/CallButtonPresenter.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
4747

4848
private boolean mShowGenericMerge = false;
4949
private boolean mShowManageConference = false;
50+
private boolean mShowButtonsIfIdle = true;
5051

5152
private InCallState mPreviousState = null;
53+
private InCallState mStateBeforeDisconnect = null;
5254

5355
public CallButtonPresenter() {
5456
}
@@ -77,6 +79,9 @@ public void onUiUnready(CallButtonUi ui) {
7779

7880
@Override
7981
public void onStateChange(InCallState state, CallList callList) {
82+
if (state == InCallState.DISCONNECTING && mPreviousState != InCallState.DISCONNECTING) {
83+
mStateBeforeDisconnect = mPreviousState;
84+
}
8085

8186
if (state == InCallState.OUTGOING) {
8287
mCall = callList.getOutgoingCall();
@@ -247,6 +252,10 @@ public void showDialpadClicked(boolean checked) {
247252
updateExtraButtonRow();
248253
}
249254

255+
public void setShowButtonsIfIdle(boolean showIfIdle) {
256+
mShowButtonsIfIdle = showIfIdle;
257+
}
258+
250259
public void modifyCallButtonClicked() {
251260
Call call = CallList.getInstance().getActiveCall();
252261
if (call != null) {
@@ -262,8 +271,19 @@ private void updateUi(InCallState state, Call call) {
262271

263272
final boolean isEnabled = state.isConnectingOrConnected() &&
264273
!state.isIncoming() && call != null;
274+
final boolean isVisible;
275+
276+
if (state.isIncoming()) {
277+
isVisible = false;
278+
} else if (mShowButtonsIfIdle || state.isConnectingOrConnected()) {
279+
isVisible = true;
280+
} else { // DISCONNECTING, NO_CALLS
281+
// Keep UI visible in case it was visible before, don't cause
282+
// unneccessary layout changes
283+
isVisible = mStateBeforeDisconnect == InCallState.INCALL;
284+
}
265285

266-
ui.setEnabled(isEnabled, !state.isIncoming());
286+
ui.setEnabled(isEnabled, isVisible);
267287

268288
Log.d(this, "Updating call UI for call: ", call);
269289

src/com/android/incallui/CallCardPresenter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void onStateChange(InCallState state, CallList callList) {
148148
// getCallToDisplay doesn't go through outgoing or incoming calls. It will return the
149149
// highest priority call to display as the secondary call.
150150
secondary = getCallToDisplay(callList, null, true);
151-
} else if (state == InCallState.INCALL) {
151+
} else if (state == InCallState.INCALL || state == InCallState.DISCONNECTING) {
152152
primary = getCallToDisplay(callList, null, false);
153153
secondary = getCallToDisplay(callList, primary, true);
154154
}

src/com/android/incallui/InCallActivity.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public class InCallActivity extends Activity {
7272
private boolean mShowDialpadRequested;
7373
private boolean mConferenceManagerShown;
7474

75+
private boolean mUseFullScreenCallerPhoto;
76+
7577
// This enum maps to Phone.SuppService defined in telephony
7678
private enum SuppService {
7779
UNKNOWN, SWITCH, SEPARATE, TRANSFER, CONFERENCE, REJECT, HANGUP;
@@ -507,15 +509,21 @@ public void onManageConferenceDoneClicked() {
507509
}
508510
}
509511

510-
private void updateSystemBarTranslucency() {
511-
final boolean doTranslucency = !mConferenceManagerShown;
512+
public void updateSystemBarTranslucency() {
513+
int flags = 0;
512514
final Window window = getWindow();
515+
final InCallPresenter.InCallState inCallState =
516+
InCallPresenter.getInstance().getInCallState();
513517

514-
if (doTranslucency) {
515-
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
516-
} else {
517-
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
518+
if (!mConferenceManagerShown) {
519+
flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
520+
}
521+
if (mUseFullScreenCallerPhoto && inCallState == InCallPresenter.InCallState.INCOMING) {
522+
flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
518523
}
524+
525+
window.setFlags(flags, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS |
526+
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
519527
window.getDecorView().requestFitSystemWindows();
520528
}
521529

@@ -819,10 +827,11 @@ private void updateSettings() {
819827
int incomingCallStyle = Settings.System.getInt(getContentResolver(),
820828
Settings.System.INCOMING_CALL_STYLE,
821829
Settings.System.INCOMING_CALL_STYLE_FULLSCREEN_PHOTO);
822-
boolean useFullscreenCallerPhoto =
830+
mUseFullScreenCallerPhoto =
823831
incomingCallStyle == Settings.System.INCOMING_CALL_STYLE_FULLSCREEN_PHOTO;
824-
mCallButtonFragment.setHideMode(useFullscreenCallerPhoto ? View.GONE : View.INVISIBLE);
825-
mAnswerFragment.setUseTranslucentNavigationBar(useFullscreenCallerPhoto);
832+
mCallButtonFragment.setHideMode(mUseFullScreenCallerPhoto ? View.GONE : View.INVISIBLE);
833+
mCallButtonFragment.getPresenter().setShowButtonsIfIdle(!mUseFullScreenCallerPhoto);
834+
updateSystemBarTranslucency();
826835
}
827836

828837
private void log(String msg) {

src/com/android/incallui/InCallPresenter.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,16 @@ public void onCallListChange(CallList callList) {
379379
listener.onStateChange(mInCallState, callList);
380380
}
381381

382-
if (MSimTelephonyManager.getDefault().getMultiSimConfiguration()
383-
== MSimTelephonyManager.MultiSimVariants.DSDA && (mInCallActivity != null)) {
384-
mInCallActivity.updateDsdaTab();
385-
}
386382
if (isActivityStarted()) {
383+
MSimTelephonyManager tm = MSimTelephonyManager.getDefault();
384+
385+
if (tm.getMultiSimConfiguration() == MSimTelephonyManager.MultiSimVariants.DSDA) {
386+
mInCallActivity.updateDsdaTab();
387+
}
388+
if (newState != InCallState.DISCONNECTING) {
389+
mInCallActivity.updateSystemBarTranslucency();
390+
}
391+
387392
final boolean hasCall = callList.getActiveOrBackgroundCall() != null ||
388393
callList.getOutgoingCall() != null;
389394
mInCallActivity.dismissKeyguard(hasCall);
@@ -457,10 +462,11 @@ public static InCallState getPotentialStateFromCallList(CallList callList) {
457462
} else if (callList.getOutgoingCall() != null) {
458463
newState = InCallState.OUTGOING;
459464
} else if (callList.getActiveCall() != null ||
460-
callList.getBackgroundCall() != null ||
461-
callList.getDisconnectedCall() != null ||
462-
callList.getDisconnectingCall() != null) {
465+
callList.getBackgroundCall() != null) {
463466
newState = InCallState.INCALL;
467+
} else if (callList.getDisconnectedCall() != null ||
468+
callList.getDisconnectingCall() != null) {
469+
newState = InCallState.DISCONNECTING;
464470
}
465471

466472
return newState;
@@ -978,6 +984,9 @@ public enum InCallState {
978984
// In-call experience is showing
979985
INCALL,
980986

987+
// Like in-call, but without a connected call
988+
DISCONNECTING,
989+
981990
// User is dialing out
982991
OUTGOING;
983992

0 commit comments

Comments
 (0)