From 350551badce5c8e47d5c32cb805456a2d0b18334 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Tue, 12 Aug 2014 13:14:12 -0700 Subject: Improvements to InCall UI view inflation performance. 1. Flattened the view hierarchy to remove a few layers of nested frames. Removed call_card.xml since it was essentially just nested frames. 2. Deferring inflation of the dialpad until it is actually needed. Bug: 16594582 Change-Id: I34a03dc3d95431bd0ba1d784a64ae3929f240d46 --- InCallUI/res/layout-land/call_card_content.xml | 21 +++++++- InCallUI/res/layout/call_card.xml | 59 -------------------- InCallUI/res/layout/call_card_content.xml | 30 ++++++++++- .../src/com/android/incallui/CallCardFragment.java | 2 +- .../src/com/android/incallui/DialpadPresenter.java | 1 + .../src/com/android/incallui/InCallActivity.java | 63 ++++++++++++++++------ 6 files changed, 95 insertions(+), 81 deletions(-) delete mode 100644 InCallUI/res/layout/call_card.xml diff --git a/InCallUI/res/layout-land/call_card_content.xml b/InCallUI/res/layout-land/call_card_content.xml index b6aac56fd..7d1db8e00 100644 --- a/InCallUI/res/layout-land/call_card_content.xml +++ b/InCallUI/res/layout-land/call_card_content.xml @@ -89,8 +89,9 @@ android:indeterminate="true" /> - + + + + + + diff --git a/InCallUI/res/layout/call_card.xml b/InCallUI/res/layout/call_card.xml deleted file mode 100644 index e0810659c..000000000 --- a/InCallUI/res/layout/call_card.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/InCallUI/res/layout/call_card_content.xml b/InCallUI/res/layout/call_card_content.xml index da21c30dc..ec32d986d 100644 --- a/InCallUI/res/layout/call_card_content.xml +++ b/InCallUI/res/layout/call_card_content.xml @@ -20,6 +20,15 @@ android:layout_width="match_parent" android:layout_height="match_parent" > + + + - + + + + + + diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index cb89b8559..88caab75e 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -143,7 +143,7 @@ public class CallCardFragment extends BaseFragment public void onUiReady(DialpadUi ui) { super.onUiReady(ui); InCallPresenter.getInstance().addListener(this); + mCall = CallList.getInstance().getActiveCall(); } @Override diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index b650e7beb..51fbce7f4 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -64,6 +64,12 @@ public class InCallActivity extends Activity { /** Use to pass 'showDialpad' from {@link #onNewIntent} to {@link #onResume} */ private boolean mShowDialpadRequested; + /** Use to determine if the dialpad should be animated on show. */ + private boolean mAnimateDialpadOnShow; + + /** Use to determine the DTMF Text which should be pre-populated in the dialpad. */ + private String mDtmfText; + /** Use to pass parameters for showing the PostCharDialog to {@link #onResume} */ private boolean mShowPostCharWaitDialogOnResume; private String mShowPostCharWaitDialogCallId; @@ -123,11 +129,15 @@ public class InCallActivity extends Activity { mSlideOut.setInterpolator(AnimUtils.EASE_OUT); mSlideOut.setAnimationListener(mSlideOutListener); + if (icicle != null) { - if (icicle.getBoolean(SHOW_DIALPAD_EXTRA)) { - mCallButtonFragment.displayDialpad(true /* show */, false /* animate */); - } - mDialpadFragment.setDtmfText(icicle.getString(DIALPAD_TEXT_EXTRA)); + // 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; + mDtmfText = icicle.getString(DIALPAD_TEXT_EXTRA); } Log.d(this, "onCreate(): exit"); } @@ -135,7 +145,9 @@ public class InCallActivity extends Activity { @Override protected void onSaveInstanceState(Bundle out) { out.putBoolean(SHOW_DIALPAD_EXTRA, mCallButtonFragment.isDialpadVisible()); - out.putString(DIALPAD_TEXT_EXTRA, mDialpadFragment.getDtmfText()); + if (mDialpadFragment != null) { + out.putString(DIALPAD_TEXT_EXTRA, mDialpadFragment.getDtmfText()); + } } @Override @@ -156,8 +168,15 @@ public class InCallActivity extends Activity { InCallPresenter.getInstance().onUiShowing(true); if (mShowDialpadRequested) { - mCallButtonFragment.displayDialpad(true /* show */, true /* animate */); + mCallButtonFragment.displayDialpad(true /* show */, + mAnimateDialpadOnShow /* animate */); mShowDialpadRequested = false; + mAnimateDialpadOnShow = false; + + if (mDialpadFragment != null) { + mDialpadFragment.setDtmfText(mDtmfText); + mDtmfText = null; + } } if (mShowPostCharWaitDialogOnResume) { @@ -174,7 +193,9 @@ public class InCallActivity extends Activity { mIsForegroundActivity = false; - mDialpadFragment.onDialerKeyUp(null); + if (mDialpadFragment != null ) { + mDialpadFragment.onDialerKeyUp(null); + } InCallPresenter.getInstance().onUiShowing(false); } @@ -262,7 +283,7 @@ public class InCallActivity extends Activity { return; } - if (mDialpadFragment.isVisible()) { + if (mDialpadFragment != null && mDialpadFragment.isVisible()) { mCallButtonFragment.displayDialpad(false /* show */, true /* animate */); return; } else if (mConferenceManagerFragment.isVisible()) { @@ -284,7 +305,8 @@ public class InCallActivity extends Activity { @Override public boolean onKeyUp(int keyCode, KeyEvent event) { // push input to the dialer. - if ((mDialpadFragment.isVisible()) && (mDialpadFragment.onDialerKeyUp(event))){ + if (mDialpadFragment != null && (mDialpadFragment.isVisible()) && + (mDialpadFragment.onDialerKeyUp(event))){ return true; } else if (keyCode == KeyEvent.KEYCODE_CALL) { // Always consume CALL to be sure the PhoneWindow won't do anything with it @@ -356,7 +378,7 @@ public class InCallActivity extends Activity { // As soon as the user starts typing valid dialable keys on the // keyboard (presumably to type DTMF tones) we start passing the // key events to the DTMFDialer's onDialerKeyDown. - if (mDialpadFragment.isVisible()) { + if (mDialpadFragment != null && mDialpadFragment.isVisible()) { return mDialpadFragment.onDialerKeyDown(event); // TODO: If the dialpad isn't currently visible, maybe @@ -432,6 +454,7 @@ public class InCallActivity extends Activity { private void relaunchedFromDialer(boolean showDialpad) { mShowDialpadRequested = showDialpad; + mAnimateDialpadOnShow = true; if (mShowDialpadRequested) { // If there's only one line in use, AND it's on hold, then we're sure the user @@ -462,12 +485,6 @@ public class InCallActivity extends Activity { .findFragmentById(R.id.answerFragment); } - if (mDialpadFragment == null) { - mDialpadFragment = (DialpadFragment) mChildFragmentManager - .findFragmentById(R.id.dialpadFragment); - mChildFragmentManager.beginTransaction().hide(mDialpadFragment).commit(); - } - if (mConferenceManagerFragment == null) { mConferenceManagerFragment = (ConferenceManagerFragment) getFragmentManager() .findFragmentById(R.id.conferenceManagerFragment); @@ -492,6 +509,18 @@ public class InCallActivity extends Activity { } private void showDialpad(boolean showDialpad) { + // If the dialpad is being shown and it has not already been loaded, replace the dialpad + // placeholder with the actual fragment before continuing. + if (mDialpadFragment == null && showDialpad) { + final FragmentTransaction loadTransaction = mChildFragmentManager.beginTransaction(); + View fragmentContainer = findViewById(R.id.dialpadFragmentContainer); + mDialpadFragment = new DialpadFragment(); + loadTransaction.replace(fragmentContainer.getId(), mDialpadFragment, + DialpadFragment.class.getName()); + loadTransaction.commitAllowingStateLoss(); + mChildFragmentManager.executePendingTransactions(); + } + final FragmentTransaction ft = mChildFragmentManager.beginTransaction(); if (showDialpad) { ft.show(mDialpadFragment); @@ -522,7 +551,7 @@ public class InCallActivity extends Activity { } public boolean isDialpadVisible() { - return mDialpadFragment.isVisible(); + return mDialpadFragment != null && mDialpadFragment.isVisible(); } public void displayManageConferencePanel(boolean showPanel) { -- cgit v1.2.3