diff options
author | Nancy Chen <nancychen@google.com> | 2015-08-31 17:18:41 -0700 |
---|---|---|
committer | Nancy Chen <nancychen@google.com> | 2015-09-01 16:10:00 -0700 |
commit | ea7c0b859a57a5c61c701bf0b710b44775f537c3 (patch) | |
tree | c025115708ef6547ef12ebc59ecd0c88c9cdab38 /src/com/android/dialer/list/ListsFragment.java | |
parent | 7de107bff21b046c50a42bebf57eb244772412e9 (diff) |
Display unread count for voicemail and update when vm is read.
Query for number of unread voicemails when dialer starts and update this
number when the user reads the voicemails.
Pass the tab icons into the ViewPagerTabs class: changed so that the raw
image is passed instead of the modified drawable because the ripple is
applied in through the ViewPagerTabs layout instead of through the
drawable containing the icons.
Bug: 21086059
Change-Id: Ie426b042d72926ea3feb7baa4717108776152754
Diffstat (limited to 'src/com/android/dialer/list/ListsFragment.java')
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index feab201f3..09a4cb21e 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -110,6 +110,7 @@ public class ListsFragment extends Fragment * The position of the currently selected tab. */ private int mTabIndex = TAB_INDEX_SPEED_DIAL; + private CallLogQueryHandler mCallLogQueryHandler; public class ViewPagerAdapter extends FragmentPagerAdapter { public ViewPagerAdapter(FragmentManager fm) { @@ -199,9 +200,9 @@ public class ListsFragment extends Fragment } // Fetch voicemail status to determine if we should show the voicemail tab. - CallLogQueryHandler callLogQueryHandler = + mCallLogQueryHandler = new CallLogQueryHandler(getActivity(), getActivity().getContentResolver(), this); - callLogQueryHandler.fetchVoicemailStatus(); + mCallLogQueryHandler.fetchVoicemailStatus(); Trace.endSection(); } @@ -227,13 +228,13 @@ public class ListsFragment extends Fragment mTabTitles[TAB_INDEX_VOICEMAIL] = getResources().getString(R.string.tab_voicemail); mTabIcons = new int[TAB_COUNT_WITH_VOICEMAIL]; - mTabIcons[TAB_INDEX_SPEED_DIAL] = R.drawable.tab_speed_dial; - mTabIcons[TAB_INDEX_HISTORY] = R.drawable.tab_history; - mTabIcons[TAB_INDEX_ALL_CONTACTS] = R.drawable.tab_contacts; - mTabIcons[TAB_INDEX_VOICEMAIL] = R.drawable.tab_voicemail; + mTabIcons[TAB_INDEX_SPEED_DIAL] = R.drawable.ic_grade_24dp; + mTabIcons[TAB_INDEX_HISTORY] = R.drawable.ic_schedule_24dp; + mTabIcons[TAB_INDEX_ALL_CONTACTS] = R.drawable.ic_people_24dp; + mTabIcons[TAB_INDEX_VOICEMAIL] = R.drawable.ic_voicemail_24dp; mViewPagerTabs = (ViewPagerTabs) parentView.findViewById(R.id.lists_pager_header); - mViewPagerTabs.setTabIcons(mTabIcons); + mViewPagerTabs.configureTabIcons(mTabIcons); mViewPagerTabs.setViewPager(mViewPager); addOnPageChangeListener(mViewPagerTabs); @@ -319,8 +320,12 @@ public class ListsFragment extends Fragment mViewPagerTabs.setViewPager(mViewPager); mPrefs.edit() - .putBoolean(PREF_KEY_HAS_ACTIVE_VOICEMAIL_PROVIDER, hasActiveVoicemailProvider) - .commit(); + .putBoolean(PREF_KEY_HAS_ACTIVE_VOICEMAIL_PROVIDER, hasActiveVoicemailProvider) + .commit(); + } + + if (hasActiveVoicemailProvider) { + mCallLogQueryHandler.fetchVoicemailUnreadCount(); } if (mHasActiveVoicemailProvider && mShowVoicemailTabAfterVoicemailStatusIsFetched) { @@ -330,6 +335,23 @@ public class ListsFragment extends Fragment } @Override + public void onVoicemailUnreadCountFetched(Cursor cursor) { + if (getActivity() == null || getActivity().isFinishing() || cursor == null) { + return; + } + + int count = 0; + try { + count = cursor.getCount(); + } finally { + cursor.close(); + } + + mViewPagerTabs.setUnreadCount(count, TAB_INDEX_VOICEMAIL); + mViewPagerTabs.setViewPager(mViewPager); + } + + @Override public boolean onCallsFetched(Cursor statusCursor) { // Return false; did not take ownership of cursor return false; @@ -339,6 +361,16 @@ public class ListsFragment extends Fragment return mTabIndex; } + /** + * External method to update unread count because the unread count changes when the user + * expands a voicemail in the call log. + */ + public void updateTabUnreadCounts() { + if (mHasActiveVoicemailProvider) { + mCallLogQueryHandler.fetchVoicemailUnreadCount(); + } + } + public void showRemoveView(boolean show) { mRemoveViewContent.setVisibility(show ? View.VISIBLE : View.GONE); mRemoveView.setAlpha(show ? 0 : 1); |