summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-05-21 19:58:22 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-21 19:58:22 +0000
commit10b8308de4a329ea7ac4165fe2a1fa7a8fa3dca0 (patch)
tree493bb9a38b8d5506b14624d8049344da5291b97f /src
parent9138834059797469f73390c9faa71ce98b4434c1 (diff)
parenteab73d62a2107030890f94d58e23d59ead3883b5 (diff)
Merge "Correctly save CallLogFragment state"
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java66
-rw-r--r--src/com/android/dialer/list/ListsFragment.java19
2 files changed, 51 insertions, 34 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index cc22a752b..232aa3992 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -17,8 +17,6 @@
package com.android.dialer.calllog;
import android.animation.Animator;
-import android.animation.AnimatorSet;
-import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.animation.Animator.AnimatorListener;
import android.app.Activity;
@@ -35,14 +33,12 @@ import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
import android.provider.VoicemailContract.Status;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
+import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
@@ -51,6 +47,7 @@ import com.android.contacts.common.CallUtil;
import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.util.PhoneNumberHelper;
import com.android.dialer.R;
+import com.android.dialer.list.ListsFragment.HostInterface;
import com.android.dialer.util.EmptyLoader;
import com.android.dialer.voicemail.VoicemailStatusHelper;
import com.android.dialer.voicemail.VoicemailStatusHelper.StatusMessage;
@@ -74,6 +71,11 @@ public class CallLogFragment extends ListFragment
*/
private static final int EMPTY_LOADER_ID = 0;
+ private static final String KEY_FILTER_TYPE = "filter_type";
+ private static final String KEY_LOG_LIMIT = "log_limit";
+ private static final String KEY_DATE_LIMIT = "date_limit";
+ private static final String KEY_SHOW_FOOTER = "show_footer";
+
private CallLogAdapter mAdapter;
private CallLogQueryHandler mCallLogQueryHandler;
private boolean mScrollToTop;
@@ -126,6 +128,9 @@ public class CallLogFragment extends ListFragment
// the date filter are included. If zero, no date-based filtering occurs.
private long mDateLimit = 0;
+ // Whether or not to show the Show call history footer view
+ private boolean mHasFooterView = false;
+
public CallLogFragment() {
this(CallLogQueryHandler.CALL_TYPE_ALL, -1);
}
@@ -166,6 +171,13 @@ public class CallLogFragment extends ListFragment
public void onCreate(Bundle state) {
super.onCreate(state);
+ if (state != null) {
+ mCallTypeFilter = state.getInt(KEY_FILTER_TYPE, mCallTypeFilter);
+ mLogLimit = state.getInt(KEY_LOG_LIMIT, mLogLimit);
+ mDateLimit = state.getLong(KEY_DATE_LIMIT, mDateLimit);
+ mHasFooterView = state.getBoolean(KEY_SHOW_FOOTER, mHasFooterView);
+ }
+
String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity());
mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, new ContactInfoHelper(
getActivity(), currentCountryIso), this, true);
@@ -276,7 +288,7 @@ public class CallLogFragment extends ListFragment
super.onViewCreated(view, savedInstanceState);
updateEmptyMessage(mCallTypeFilter);
getListView().setItemsCanFocus(true);
- assignFooterViewToListView();
+ maybeAddFooterView();
}
/**
@@ -362,6 +374,15 @@ public class CallLogFragment extends ListFragment
}
@Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt(KEY_FILTER_TYPE, mCallTypeFilter);
+ outState.putInt(KEY_LOG_LIMIT, mLogLimit);
+ outState.putLong(KEY_DATE_LIMIT, mDateLimit);
+ outState.putBoolean(KEY_SHOW_FOOTER, mHasFooterView);
+ }
+
+ @Override
public void fetchCalls() {
mCallLogQueryHandler.fetchCalls(mCallTypeFilter, mDateLimit);
}
@@ -498,23 +519,36 @@ public class CallLogFragment extends ListFragment
}
/**
- * Assigns a view to be used as a footer view in the call log.
+ * Enables/disables the showing of the view full call history footer
*
- * @param view View to be used as the footer view.
+ * @param hasFooterView Whether or not to show the footer
+ */
+ public void setHasFooterView(boolean hasFooterView) {
+ mHasFooterView = hasFooterView;
+ maybeAddFooterView();
+ }
+
+ /**
+ * Determine whether or not the footer view should be added to the listview. If getView()
+ * is null, which means onCreateView hasn't been called yet, defer the addition of the footer
+ * until onViewCreated has been called.
*/
- public void setFooterView(View view) {
- mFooterView = view;
- // Content view not created yet, defer addition of the footerview to onCreate
- if (getView() == null) {
+ private void maybeAddFooterView() {
+ if (!mHasFooterView || getView() == null) {
return;
}
- assignFooterViewToListView();
- }
- private void assignFooterViewToListView() {
if (mFooterView == null) {
- return;
+ mFooterView = getActivity().getLayoutInflater().inflate(
+ R.layout.recents_list_footer, (ViewGroup) getView(), false);
+ mFooterView.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ((HostInterface) getActivity()).showCallHistory();
+ }
+ });
}
+
final ListView listView = getListView();
listView.removeFooterView(mFooterView);
listView.addFooterView(mFooterView);
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java
index f2be6ab55..ac3818c8b 100644
--- a/src/com/android/dialer/list/ListsFragment.java
+++ b/src/com/android/dialer/list/ListsFragment.java
@@ -177,24 +177,7 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
case TAB_INDEX_RECENTS:
mRecentsFragment = new CallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL,
MAX_RECENTS_ENTRIES, System.currentTimeMillis() - OLDEST_RECENTS_DATE);
-
- /*
- * Provide mViewPager as a parent viewgroup for the inflation of the footer,
- * to ensure that the footer view is inflated with the correct LayoutParams.
- * If root is null in
- * inflate(XmlPullParser parser, ViewGroup root, boolean attachToRoot),
- * the layout parameters specified in R.layout.recents_list_footer are not
- * correctly applied. The footer view is ultimately not attached to mViewPager.
- */
- final View viewFullHistoryFooter = getActivity().getLayoutInflater().inflate(
- R.layout.recents_list_footer, mViewPager, false);
- viewFullHistoryFooter.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- ((HostInterface) getActivity()).showCallHistory();
- }
- });
- mRecentsFragment.setFooterView(viewFullHistoryFooter);
+ mRecentsFragment.setHasFooterView(true);
return mRecentsFragment;
case TAB_INDEX_ALL_CONTACTS:
mAllContactsFragment = new AllContactsFragment();