summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2014-08-12 13:14:12 -0700
committerTyler Gunn <tgunn@google.com>2014-08-12 13:14:12 -0700
commit350551badce5c8e47d5c32cb805456a2d0b18334 (patch)
tree17275d65b0db5e46928763fbbf1df9dc812a2ef9
parentad4d6914883fae5deaee693e52b68cfaa79097d0 (diff)
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
-rw-r--r--InCallUI/res/layout-land/call_card_content.xml21
-rw-r--r--InCallUI/res/layout/call_card.xml59
-rw-r--r--InCallUI/res/layout/call_card_content.xml30
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java2
-rw-r--r--InCallUI/src/com/android/incallui/DialpadPresenter.java1
-rw-r--r--InCallUI/src/com/android/incallui/InCallActivity.java63
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 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<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 79fe3d6df..758178f74 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) {