diff options
author | Tyler Gunn <tgunn@google.com> | 2014-08-12 20:27:01 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-11 17:59:47 +0000 |
commit | 531d1de3e0a80685bf6aeea626defdf989f32e6d (patch) | |
tree | 5d14b900adb5c0a649f472a9f82a9a65ebd9fa79 | |
parent | 86a7f5639fd0798c3b4500166f97649949237215 (diff) | |
parent | 350551badce5c8e47d5c32cb805456a2d0b18334 (diff) |
Merge "Improvements to InCall UI view inflation performance." into lmp-dev
-rw-r--r-- | InCallUI/res/layout-land/call_card_content.xml | 21 | ||||
-rw-r--r-- | InCallUI/res/layout/call_card.xml | 59 | ||||
-rw-r--r-- | InCallUI/res/layout/call_card_content.xml | 30 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 2 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/DialpadPresenter.java | 1 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallActivity.java | 63 |
6 files changed, 95 insertions, 81 deletions
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" /> </FrameLayout> - <fragment android:name="com.android.incallui.DialpadFragment" - android:id="@+id/dialpadFragment" + <!-- Placeholder for the dialpad which is replaced with the dialpad fragment when shown. --> + <FrameLayout + android:id="@+id/dialpadFragmentContainer" android:layout_toEndOf="@id/primary_call_info_container" android:layout_gravity="end|center_vertical" android:layout_alignParentEnd="true" @@ -106,4 +107,20 @@ android:layout_gravity="end|center_vertical" android:layout_marginBottom="@dimen/glowpadview_margin_bottom" android:visibility="gone" /> + + <FrameLayout + android:id="@+id/floating_end_call_action_button_container" + android:layout_width="@dimen/floating_action_button_width" + android:layout_height="@dimen/floating_action_button_height" + android:layout_marginBottom="@dimen/end_call_button_margin_bottom" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" > + + <ImageButton android:id="@+id/floating_end_call_action_button" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/end_call_background" + android:src="@drawable/fab_ic_end_call" + android:contentDescription="@string/onscreenEndCallText" /> + </FrameLayout> </RelativeLayout> 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 @@ -<?xml version="1.0" encoding="utf-8"?> - -<!-- - ~ Copyright (C) 2013 The Android Open Source Project - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License - --> - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/call_card" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <!-- The main content of the CallCard is either one or two "call info" - blocks, depending on whether one or two lines are in use. - - The call_info blocks are stacked vertically inside a CallCard (LinearLayout), - each with layout_weight="1". If only one line is in use (i.e. the - common case) then the 2nd call info will be GONE and thus the 1st one - will expand to fill the full height of the CallCard. --> - - <!-- Primary "call card" block, for the foreground call. --> - <FrameLayout - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="5" > - - <include layout="@layout/call_card_content" /> - - <FrameLayout - android:id="@+id/floating_end_call_action_button_container" - android:layout_width="@dimen/floating_action_button_width" - android:layout_height="@dimen/floating_action_button_height" - android:layout_marginBottom="@dimen/end_call_button_margin_bottom" - android:layout_gravity="bottom|center"> - - <ImageButton android:id="@+id/floating_end_call_action_button" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@drawable/end_call_background" - android:src="@drawable/fab_ic_end_call" - android:contentDescription="@string/onscreenEndCallText" /> - - </FrameLayout> - - </FrameLayout> - -</LinearLayout> 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" > + <!-- The main content of the CallCard is either one or two "call info" + blocks, depending on whether one or two lines are in use. + + The call_info blocks are stacked vertically inside a CallCard (LinearLayout), + each with layout_weight="1". If only one line is in use (i.e. the + common case) then the 2nd call info will be GONE and thus the 1st one + will expand to fill the full height of the CallCard. --> + + <!-- Primary "call card" block, for the foreground call. --> <LinearLayout android:id="@+id/primary_call_info_container" android:layout_width="match_parent" @@ -92,8 +101,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - <fragment android:name="com.android.incallui.DialpadFragment" - android:id="@+id/dialpadFragment" + <!-- Placeholder for the dialpad which is replaced with the dialpad fragment when shown. --> + <FrameLayout + android:id="@+id/dialpadFragmentContainer" android:layout_below="@id/primary_call_info_container" android:layout_gravity="bottom|center_horizontal" android:layout_alignParentBottom="true" @@ -108,4 +118,20 @@ android:layout_gravity="bottom|center_horizontal" android:layout_marginBottom="@dimen/glowpadview_margin_bottom" android:visibility="gone" /> + + <FrameLayout + android:id="@+id/floating_end_call_action_button_container" + android:layout_width="@dimen/floating_action_button_width" + android:layout_height="@dimen/floating_action_button_height" + android:layout_marginBottom="@dimen/end_call_button_margin_bottom" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" > + + <ImageButton android:id="@+id/floating_end_call_action_button" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/end_call_background" + android:src="@drawable/fab_ic_end_call" + android:contentDescription="@string/onscreenEndCallText" /> + </FrameLayout> </RelativeLayout> diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 0c5a10fb0..33ff04a95 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<CallCardPresenter, CallCardPr mTranslationOffset = getResources().getDimensionPixelSize(R.dimen.call_card_anim_translate_y_offset); - return inflater.inflate(R.layout.call_card, container, false); + return inflater.inflate(R.layout.call_card_content, container, false); } @Override diff --git a/InCallUI/src/com/android/incallui/DialpadPresenter.java b/InCallUI/src/com/android/incallui/DialpadPresenter.java index f612a7384..c36ead7a8 100644 --- a/InCallUI/src/com/android/incallui/DialpadPresenter.java +++ b/InCallUI/src/com/android/incallui/DialpadPresenter.java @@ -30,6 +30,7 @@ public class DialpadPresenter extends Presenter<DialpadPresenter.DialpadUi> 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) { |