diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-19 16:53:54 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-06-23 17:02:54 -0700 |
commit | 75d5b2d7d73e184ed813cc5b42b19d7e21b6bd8c (patch) | |
tree | e4848d6ac3003753547a110ccec8853820870a71 /src/com/android/dialer/list/ListsFragment.java | |
parent | af7d8bbd51a315a500796d397a28afecc2358d1e (diff) |
Add extra to jump to DialtactsActivity tab.
+ For the voicemail notification, jump to voicemail tab.
+ Jump through some hoops to handle this properly when waiting for the voicemail
status to be retrieved.
Bug: 21120186
Change-Id: I5a82f3ecafadb45246e6637e8275a09f78cc188a
Diffstat (limited to 'src/com/android/dialer/list/ListsFragment.java')
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index 0e3df5284..e45da0ce0 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -84,6 +84,8 @@ public class ListsFragment extends Fragment private SharedPreferences mPrefs; private boolean mHasActiveVoicemailProvider; + private boolean mHasFetchedVoicemailStatus; + private boolean mShowVoicemailTabAfterVoicemailStatusIsFetched; private VoicemailStatusHelper mVoicemailStatusHelper; private ArrayList<OnPageChangeListener> mOnPageChangeListeners = @@ -167,6 +169,7 @@ public class ListsFragment extends Fragment Trace.endSection(); mVoicemailStatusHelper = new VoicemailStatusHelperImpl(); + mHasFetchedVoicemailStatus = false; mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); mHasActiveVoicemailProvider = mPrefs.getBoolean( @@ -204,7 +207,7 @@ public class ListsFragment extends Fragment mViewPager.setAdapter(mViewPagerAdapter); mViewPager.setOffscreenPageLimit(TAB_COUNT_WITH_VOICEMAIL - 1); mViewPager.setOnPageChangeListener(this); - mViewPager.setCurrentItem(getRtlPosition(TAB_INDEX_SPEED_DIAL)); + showTab(TAB_INDEX_SPEED_DIAL); mTabTitles = new String[TAB_COUNT_WITH_VOICEMAIL]; mTabTitles[TAB_INDEX_SPEED_DIAL] = getResources().getString(R.string.tab_speed_dial); @@ -237,6 +240,24 @@ public class ListsFragment extends Fragment } } + /** + * Shows the tab with the specified index. If the voicemail tab index is specified, but the + * voicemail status hasn't been fetched, it will try to show the tab after the voicemail status + * has been fetched. + */ + public void showTab(int index) { + if (index == TAB_INDEX_VOICEMAIL) { + if (mHasActiveVoicemailProvider) { + mViewPager.setCurrentItem(getRtlPosition(TAB_INDEX_VOICEMAIL)); + } else if (!mHasFetchedVoicemailStatus) { + // Try to show the voicemail tab after the voicemail status returns. + mShowVoicemailTabAfterVoicemailStatusIsFetched = true; + } + } else { + mViewPager.setCurrentItem(getRtlPosition(index)); + } + } + @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { mTabIndex = getRtlPosition(position); @@ -252,6 +273,9 @@ public class ListsFragment extends Fragment public void onPageSelected(int position) { mTabIndex = getRtlPosition(position); + // Show the tab which has been selected instead. + mShowVoicemailTabAfterVoicemailStatusIsFetched = false; + final int count = mOnPageChangeListeners.size(); for (int i = 0; i < count; i++) { mOnPageChangeListeners.get(i).onPageSelected(position); @@ -269,6 +293,8 @@ public class ListsFragment extends Fragment @Override public void onVoicemailStatusFetched(Cursor statusCursor) { + mHasFetchedVoicemailStatus = true; + if (getActivity() == null || getActivity().isFinishing()) { return; } @@ -285,6 +311,11 @@ public class ListsFragment extends Fragment .putBoolean(PREF_KEY_HAS_ACTIVE_VOICEMAIL_PROVIDER, hasActiveVoicemailProvider) .commit(); } + + if (mHasActiveVoicemailProvider && mShowVoicemailTabAfterVoicemailStatusIsFetched) { + mShowVoicemailTabAfterVoicemailStatusIsFetched = false; + showTab(TAB_INDEX_VOICEMAIL); + } } @Override |