summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-04-16 18:58:11 -0700
committerYorke Lee <yorkelee@google.com>2014-04-17 16:05:54 -0700
commitd45aaa40aa6b929f7bc644d649b3474fcf82cfa2 (patch)
tree568fc6b0b9da5bbb0d59e0e3b2380562e797aef1 /src
parent33932ff9433bcd172749d416c23655c8d8bdafc2 (diff)
Add call log fragment to ListsFragment
Also move the initialization of CallLogAdapter to onCreate instead of onCreateView. onCreateView is called everytime the fragment is detached from the childManagerView, and causes the CallLogFragment to create a new CallLogAdapter every time, losing all the previous call log entries. Bug: 14136111 Change-Id: I057bb7441df2974604066d5d62716fdd628990f3
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java8
-rw-r--r--src/com/android/dialer/list/ListsFragment.java18
2 files changed, 19 insertions, 7 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index 18f37f211..d0350f0ce 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -126,6 +126,10 @@ public class CallLogFragment extends ListFragment
public void onCreate(Bundle state) {
super.onCreate(state);
+ String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity());
+ mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, new ContactInfoHelper(
+ getActivity(), currentCountryIso), true, true);
+ setListAdapter(mAdapter);
mCallLogQueryHandler = new CallLogQueryHandler(getActivity().getContentResolver(),
this, mLogLimit);
mKeyguardManager =
@@ -229,10 +233,6 @@ public class CallLogFragment extends ListFragment
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
updateEmptyMessage(mCallTypeFilter);
- String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity());
- mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, new ContactInfoHelper(
- getActivity(), currentCountryIso), true, true);
- setListAdapter(mAdapter);
getListView().setItemsCanFocus(true);
}
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java
index f1d421c46..513272741 100644
--- a/src/com/android/dialer/list/ListsFragment.java
+++ b/src/com/android/dialer/list/ListsFragment.java
@@ -12,6 +12,8 @@ import android.view.ViewGroup;
import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
import com.android.dialer.R;
+import com.android.dialer.calllog.CallLogFragment;
+import com.android.dialer.calllog.CallLogQueryHandler;
/**
* Fragment that is used as the main screen of the Dialer.
@@ -26,14 +28,19 @@ public class ListsFragment extends Fragment {
private ViewPager mViewPager;
private ViewPagerAdapter mViewPagerAdapter;
private PhoneFavoriteFragment mSpeedDialFragment;
+ private CallLogFragment mRecentsFragment;
private AllContactsFragment mAllContactsFragment;
private static final int TAB_INDEX_SPEED_DIAL = 0;
- private static final int TAB_INDEX_ALL_CONTACTS = 1;
+ private static final int TAB_INDEX_RECENTS = 1;
+ private static final int TAB_INDEX_ALL_CONTACTS = 2;
private String[] mTabTitles;
- private static final int TAB_INDEX_COUNT = 2;
+ private static final int TAB_INDEX_COUNT = 3;
+
+ // TODO: Replace with a date limit (e.g. 2 weeks)
+ private static final int MAX_ENTRIES = 20;
public class ViewPagerAdapter extends FragmentPagerAdapter {
public ViewPagerAdapter(FragmentManager fm) {
@@ -46,6 +53,10 @@ public class ListsFragment extends Fragment {
case TAB_INDEX_SPEED_DIAL:
mSpeedDialFragment = new PhoneFavoriteFragment();
return mSpeedDialFragment;
+ case TAB_INDEX_RECENTS:
+ mRecentsFragment = new CallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL,
+ MAX_ENTRIES);
+ return mRecentsFragment;
case TAB_INDEX_ALL_CONTACTS:
mAllContactsFragment = new AllContactsFragment();
return mAllContactsFragment;
@@ -71,10 +82,11 @@ public class ListsFragment extends Fragment {
mViewPager = (ViewPager) parentView.findViewById(R.id.lists_pager);
mViewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager());
mViewPager.setAdapter(mViewPagerAdapter);
- mViewPager.setOffscreenPageLimit(1);
+ mViewPager.setOffscreenPageLimit(2);
mTabTitles = new String[TAB_INDEX_COUNT];
mTabTitles[TAB_INDEX_SPEED_DIAL] = getResources().getString(R.string.tab_speed_dial);
+ mTabTitles[TAB_INDEX_RECENTS] = getResources().getString(R.string.tab_recents);
mTabTitles[TAB_INDEX_ALL_CONTACTS] = getResources().getString(R.string.tab_all_contacts);
ViewPagerTabs tabs = (ViewPagerTabs) parentView.findViewById(R.id.lists_pager_header);