diff options
author | Yorke Lee <yorkelee@google.com> | 2015-03-20 14:42:14 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2015-03-25 09:45:03 -0700 |
commit | fd0b577edffa5413adfda1503038a3bff3247106 (patch) | |
tree | 0cc2cecc7c5dcca6afcc68d4f3ea768fdd1afbf1 | |
parent | 628fd8eed29497cf7295bf5fb84709960492a4a1 (diff) |
Dynamically add/remove CallCardFragment
Only show the CallCardFragment when it is needed:
1) Incoming calls
2) After completion of circular reveal
Also make Calls class public so that it can be mocked with
Mockito
Change-Id: Ife7ed38bde25daf5a9fd0329ade5e794fa1bff65
10 files changed, 37 insertions, 43 deletions
diff --git a/InCallUI/res/layout-land/call_card_fragment.xml b/InCallUI/res/layout-land/call_card_fragment.xml index ed4d41162..aa04840c1 100644 --- a/InCallUI/res/layout-land/call_card_fragment.xml +++ b/InCallUI/res/layout-land/call_card_fragment.xml @@ -18,7 +18,9 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent" > + android:layout_height="match_parent" + android:layout_alignParentTop="true" + android:layout_alignParentStart="true" > <LinearLayout android:id="@+id/primary_call_info_container" diff --git a/InCallUI/res/layout/call_button_fragment.xml b/InCallUI/res/layout/call_button_fragment.xml index e8feca68a..18906dda2 100644 --- a/InCallUI/res/layout/call_button_fragment.xml +++ b/InCallUI/res/layout/call_button_fragment.xml @@ -38,8 +38,7 @@ android:background="@color/button_background_color" android:layout_height="wrap_content" android:layout_alignParentBottom="true" - android:animateLayoutChanges="true" - android:visibility="invisible" > + android:animateLayoutChanges="true" > <LinearLayout android:orientation="horizontal" diff --git a/InCallUI/res/layout/call_card_fragment.xml b/InCallUI/res/layout/call_card_fragment.xml index 548eed4ed..17906f730 100644 --- a/InCallUI/res/layout/call_card_fragment.xml +++ b/InCallUI/res/layout/call_card_fragment.xml @@ -18,7 +18,9 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:layout_alignParentTop="true" + android:layout_alignParentStart="true"> <!-- The main content of the CallCard is either one or two "call info" blocks, depending on whether one or two lines are in use. diff --git a/InCallUI/res/layout/incall_screen.xml b/InCallUI/res/layout/incall_screen.xml index fe97e1914..d46778c1c 100644 --- a/InCallUI/res/layout/incall_screen.xml +++ b/InCallUI/res/layout/incall_screen.xml @@ -19,12 +19,4 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/main" > - - <fragment android:name="com.android.incallui.CallCardFragment" - android:id="@+id/callCardFragment" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_alignParentTop="true" - android:layout_alignParentStart="true" /> - </FrameLayout> diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index b6cfb9e7b..9a5228f7e 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -36,7 +36,8 @@ import java.util.Locale; /** * Describes a single call and its state. */ -class Call { +@NeededForTesting +public class Call { /* Defines different states of this call */ public static class State { public static final int INVALID = 0; diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index aac10e330..78956cbb9 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -312,10 +312,6 @@ public class CallButtonFragment @Override public void setEnabled(boolean isEnabled) { mIsEnabled = isEnabled; - View view = getView(); - if (view.getVisibility() != View.VISIBLE) { - view.setVisibility(View.VISIBLE); - } mAudioButton.setEnabled(isEnabled); mChangeToVoiceButton.setEnabled(isEnabled); diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 7dd36ff41..5f5146e19 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -27,6 +27,7 @@ import android.content.res.Configuration; import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.Trace; import android.telecom.DisconnectCause; import android.telecom.VideoProfile; import android.telephony.PhoneNumberUtils; @@ -57,6 +58,8 @@ import java.util.List; */ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPresenter.CallCardUi> implements CallCardPresenter.CallCardUi { + private static final String TAG = "CallCardFragment"; + private AnimatorSet mAnimatorSet; private int mShrinkAnimationDuration; private int mFabNormalDiameter; @@ -146,10 +149,12 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + Trace.beginSection(TAG + " onCreate"); mTranslationOffset = getResources().getDimensionPixelSize(R.dimen.call_card_anim_translate_y_offset); - - return inflater.inflate(R.layout.call_card_fragment, container, false); + final View view = inflater.inflate(R.layout.call_card_fragment, container, false); + Trace.endSection(); + return view; } @Override diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 139398a0c..647cdfdff 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -125,6 +125,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> updateContactEntry(null, true); } } + + onStateChange(null, InCallPresenter.getInstance().getInCallState(), CallList.getInstance()); } @Override diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index da3d692f0..7d1059f58 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -141,8 +141,6 @@ public class InCallActivity extends Activity implements FragmentDisplayManager { setContentView(R.layout.incall_screen); - initializeInCall(); - internalResolveIntent(getIntent()); mCurrentOrientation = getResources().getConfiguration().orientation; @@ -272,8 +270,11 @@ public class InCallActivity extends Activity implements FragmentDisplayManager { mAnswerFragment = (AnswerFragment) fragment; } else if (fragment instanceof CallCardFragment) { mCallCardFragment = (CallCardFragment) fragment; + mChildFragmentManager = mCallCardFragment.getChildFragmentManager(); } else if (fragment instanceof ConferenceManagerFragment) { mConferenceManagerFragment = (ConferenceManagerFragment) fragment; + } else if (fragment instanceof CallButtonFragment) { + mCallButtonFragment = (CallButtonFragment) fragment; } } @@ -473,8 +474,7 @@ public class InCallActivity extends Activity implements FragmentDisplayManager { private void internalResolveIntent(Intent intent) { final String action = intent.getAction(); - - if (action.equals(intent.ACTION_MAIN)) { + if (action.equals(Intent.ACTION_MAIN)) { // This action is the normal way to bring up the in-call UI. // // But we do check here for one extra that can come along with the @@ -491,6 +491,7 @@ public class InCallActivity extends Activity implements FragmentDisplayManager { relaunchedFromDialer(showDialpad); } + boolean newOutgoingCall = false; if (intent.getBooleanExtra(NEW_OUTGOING_CALL_EXTRA, false)) { intent.removeExtra(NEW_OUTGOING_CALL_EXTRA); Call call = CallList.getInstance().getOutgoingCall(); @@ -529,11 +530,12 @@ public class InCallActivity extends Activity implements FragmentDisplayManager { } dismissKeyguard(true); + newOutgoingCall = true; } Call pendingAccountSelectionCall = CallList.getInstance().getWaitingForAccountCall(); if (pendingAccountSelectionCall != null) { - mCallCardFragment.setVisible(false); + showCallCardFragment(false); Bundle extras = pendingAccountSelectionCall .getTelecommCall().getDetails().getExtras(); @@ -561,8 +563,8 @@ public class InCallActivity extends Activity implements FragmentDisplayManager { SelectPhoneAccountDialogFragment.showAccountDialog(getFragmentManager(), R.string.select_phone_account_for_calls, true, phoneAccountHandles, listener); - } else { - mCallCardFragment.setVisible(true); + } else if (!newOutgoingCall) { + showCallCardFragment(true); } return; @@ -583,21 +585,6 @@ public class InCallActivity extends Activity implements FragmentDisplayManager { } } - private void initializeInCall() { - if (mCallCardFragment == null) { - mCallCardFragment = (CallCardFragment) getFragmentManager() - .findFragmentById(R.id.callCardFragment); - } - - mChildFragmentManager = mCallCardFragment.getChildFragmentManager(); - - if (mCallButtonFragment == null) { - mCallButtonFragment = (CallButtonFragment) mChildFragmentManager - .findFragmentById(R.id.callButtonFragment); - mCallButtonFragment.getView().setVisibility(View.INVISIBLE); - } - } - public void dismissKeyguard(boolean dismiss) { if (mDismissKeyguard == dismiss) { return; @@ -712,6 +699,10 @@ public class InCallActivity extends Activity implements FragmentDisplayManager { return mDialpadFragment != null && mDialpadFragment.isVisible(); } + public void showCallCardFragment(boolean show) { + showFragment(TAG_CALLCARD_FRAGMENT, show, true); + } + /** * Hides or shows the conference manager fragment. * diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 3478b7dde..225b1a259 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -508,6 +508,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener, @Override public void onCircularRevealComplete(FragmentManager fm) { if (mInCallActivity != null) { + mInCallActivity.showCallCardFragment(true); mInCallActivity.getCallCardFragment().animateForNewOutgoingCall(); CircularRevealFragment.endCircularReveal(mInCallActivity.getFragmentManager()); } @@ -1281,7 +1282,10 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener, * @return The space beside the call card. */ public float getSpaceBesideCallCard() { - return mInCallActivity.getCallCardFragment().getSpaceBesideCallCard(); + if (mInCallActivity != null && mInCallActivity.getCallCardFragment() != null) { + return mInCallActivity.getCallCardFragment().getSpaceBesideCallCard(); + } + return 0; } /** @@ -1290,7 +1294,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener, * @return True if the call card fragment is visible. */ public boolean getCallCardFragmentVisible() { - if (mInCallActivity != null) { + if (mInCallActivity != null && mInCallActivity.getCallCardFragment() != null) { return mInCallActivity.getCallCardFragment().isVisible(); } return false; |