From d5c512afca0341039e494e4df976b18ff07d146a Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Fri, 30 Jan 2015 14:42:53 -0800 Subject: Add DialpadFragment on-demand instead at on startup Add the DialpadFragment dynamically instead of everything at startup. Once added, it is then shown/hidden instead of removed for performance reasons. Reduces startup time on a N5 from 603ms to 440ms. Bug: 18431193 Change-Id: I0482bd8277896ed8a6956fc03b6afaf44b442eb3 --- src/com/android/dialer/dialpad/DialpadFragment.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/com/android/dialer/dialpad/DialpadFragment.java') diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 71b9ae822..87501fbcb 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -45,13 +45,10 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.PhoneNumberUtils; -import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.text.Editable; -import android.text.SpannableString; import android.text.TextUtils; import android.text.TextWatcher; -import android.text.style.RelativeSizeSpan; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; @@ -318,7 +315,9 @@ public class DialpadFragment extends Fragment public void onCreate(Bundle state) { Trace.beginSection(TAG + " onCreate"); super.onCreate(state); - mFirstLaunch = true; + + mFirstLaunch = state == null; + mCurrentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); try { @@ -358,7 +357,6 @@ public class DialpadFragment extends Fragment Trace.endSection(); Trace.beginSection(TAG + " setup views"); - Resources r = getResources(); mDialpadView = (DialpadView) fragmentView.findViewById(R.id.dialpad_view); mDialpadView.setCanDigitsBeEdited(true); @@ -654,8 +652,6 @@ public class DialpadFragment extends Fragment showDialpadChooser(false); } - mFirstLaunch = false; - stopWatch.lap("hnt"); updateDeleteButtonEnabledState(); @@ -674,6 +670,14 @@ public class DialpadFragment extends Fragment mOverflowMenuButton.setOnTouchListener(mOverflowPopupMenu.getDragToOpenListener()); mOverflowMenuButton.setOnClickListener(this); mOverflowMenuButton.setVisibility(isDigitsEmpty() ? View.INVISIBLE : View.VISIBLE); + + if (mFirstLaunch) { + // The onHiddenChanged callback does not get called the first time the fragment is + // attached, so call it ourselves here. + onHiddenChanged(false); + } + + mFirstLaunch = false; Trace.endSection(); } -- cgit v1.2.3