Loading src/com/android/dialer/calllog/CallLogFragment.java +2 −2 Original line number Diff line number Diff line Loading @@ -432,8 +432,7 @@ public class CallLogFragment extends ListFragment updateOnTransition(true); } // TODO krelease: Figure out if we still need this. If so, it should be probably be moved to // the call log activity instead, or done only in a single call log fragment. // TODO: Move to CallLogActivity private void updateOnTransition(boolean onEntry) { // We don't want to update any call data when keyguard is on because the user has likely not // seen the new calls yet. Loading @@ -441,6 +440,7 @@ public class CallLogFragment extends ListFragment if (mKeyguardManager != null && !mKeyguardManager.inKeyguardRestrictedInputMode()) { // On either of the transitions we update the missed call and voicemail notifications. // While exiting we additionally consume all missed calls (by marking them as read). mCallLogQueryHandler.markNewCallsAsOld(); if (!onEntry) { mCallLogQueryHandler.markMissedCallsAsRead(); } Loading src/com/android/dialer/calllog/CallLogQueryHandler.java +16 −13 Original line number Diff line number Diff line Loading @@ -138,22 +138,14 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { * <p> * It will asynchronously update the content of the list view when the fetch completes. */ public void fetchCalls(int callType) { public void fetchCalls(int callType, long newerThan) { cancelFetch(); int requestId = newCallsRequest(); fetchCalls(QUERY_CALLLOG_TOKEN, requestId, callType , false /* newOnly */); fetchCalls(QUERY_CALLLOG_TOKEN, requestId, callType, false /* newOnly */, newerThan); } /** * Fetches the list of calls from the call log for a given type. * This call fetches only the new (i.e. NEW = 1) ones. * <p> * It will asynchronously update the content of the list view when the fetch completes. */ public void fetchNewCalls(int callType) { cancelFetch(); int requestId = newCallsRequest(); fetchCalls(QUERY_CALLLOG_TOKEN, requestId, callType , true /* newOnly */); public void fetchCalls(int callType) { fetchCalls(callType, 0); } public void fetchVoicemailStatus() { Loading @@ -162,7 +154,8 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { } /** Fetches the list of calls in the call log. */ private void fetchCalls(int token, int requestId, int callType, boolean newOnly) { private void fetchCalls(int token, int requestId, int callType, boolean newOnly, long newerThan) { // We need to check for NULL explicitly otherwise entries with where READ is NULL // may not match either the query or its negation. // We consider the calls that are not yet consumed (i.e. IS_READ = 0) as "new". Loading @@ -180,8 +173,18 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { } // Add a clause to fetch only items of type voicemail. where.append(String.format("(%s = ?)", Calls.TYPE)); // Add a clause to fetch only items newer than the requested date selectionArgs.add(Integer.toString(callType)); } if (newerThan > 0) { if (where.length() > 0) { where.append(" AND "); } where.append(String.format("(%s > ?)", Calls.DATE)); selectionArgs.add(Long.toString(newerThan)); } final int limit = (mLogLimit == -1) ? NUM_LOGS_TO_DISPLAY : mLogLimit; final String selection = where.length() > 0 ? where.toString() : null; Uri uri = Calls.CONTENT_URI_WITH_VOICEMAIL.buildUpon() Loading src/com/android/dialer/list/PhoneFavoriteFragment.java +42 −2 Original line number Diff line number Diff line Loading @@ -18,9 +18,12 @@ package com.android.dialer.list; import android.app.Activity; import android.app.Fragment; import android.app.LoaderManager; import android.content.Context; import android.content.CursorLoader; import android.content.Loader; import android.content.SharedPreferences; import android.database.Cursor; import android.database.MatrixCursor; import android.graphics.Rect; import android.net.Uri; import android.os.Bundle; Loading @@ -42,7 +45,9 @@ import com.android.contacts.common.ContactTileLoaderFactory; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.list.ContactEntry; import com.android.contacts.common.list.ContactTileView; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.calllog.CallLogQuery; import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.calllog.CallLogAdapter; import com.android.dialer.calllog.CallLogQueryHandler; Loading Loading @@ -74,6 +79,9 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen */ private static int LOADER_ID_CONTACT_TILE = 1; private static final String KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE = "key_last_dismissed_call_shortcut_date"; public interface OnShowAllContactsListener { public void onShowAllContacts(); } Loading Loading @@ -157,6 +165,17 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen */ private View mEmptyView; /** * Call shortcuts older than this date (persisted in shared preferences) will not show up in * at the top of the screen */ private long mLastCallShortcutDate = 0; /** * The date of the current call shortcut that is showing on screen. */ private long mCurrentCallShortcutDate = 0; private final ContactTileView.Listener mContactTileAdapterListener = new ContactTileAdapterListener(); private final LoaderManager.LoaderCallbacks<Cursor> mContactTileLoaderListener = Loading Loading @@ -195,6 +214,11 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen @Override public void onResume() { super.onResume(); final SharedPreferences prefs = getActivity().getSharedPreferences( DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE); mLastCallShortcutDate = prefs.getLong(KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE, 0); fetchCalls(); mCallLogAdapter.setLoading(true); getLoaderManager().getLoader(LOADER_ID_CONTACT_TILE).forceLoad(); Loading Loading @@ -231,7 +255,7 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen }); mContactTileAdapter.setEmptyView(mEmptyView); mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), mContactTileAdapter, mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), this, mContactTileAdapter, mCallLogAdapter, mShowAllContactsButton); mListView.setAdapter(mAdapter); Loading Loading @@ -308,13 +332,20 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen @Override public void onCallsFetched(Cursor cursor) { mCallLogAdapter.setLoading(false); // Save the date of the most recent call log item if (cursor != null && cursor.moveToFirst()) { mCurrentCallShortcutDate = cursor.getLong(CallLogQuery.DATE); } mCallLogAdapter.changeCursor(cursor); mAdapter.notifyDataSetChanged(); } @Override public void fetchCalls() { mCallLogQueryHandler.fetchNewCalls(CallLogQueryHandler.CALL_TYPE_ALL); mCallLogQueryHandler.fetchCalls(CallLogQueryHandler.CALL_TYPE_ALL, mLastCallShortcutDate); } @Override Loading Loading @@ -452,4 +483,13 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen public void cacheOffsetsForDatasetChange() { saveOffsets(); } public void dismissShortcut() { mLastCallShortcutDate = mCurrentCallShortcutDate; final SharedPreferences prefs = getActivity().getSharedPreferences( DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE); prefs.edit().putLong(KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE, mLastCallShortcutDate) .apply(); fetchCalls(); } } src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java +4 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { private final PhoneFavoritesTileAdapter mContactTileAdapter; private final CallLogAdapter mCallLogAdapter; private final View mShowAllContactsButton; private final PhoneFavoriteFragment mFragment; private final int mCallLogPadding; Loading @@ -70,7 +71,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { mCallLogQueryHandler.markNewVoicemailsAsOld(); CallLogNotificationsHelper.removeMissedCallNotifications(); CallLogNotificationsHelper.updateVoicemailNotifications(mContext); mCallLogQueryHandler.fetchNewCalls(CallLogQueryHandler.CALL_TYPE_ALL); mFragment.dismissShortcut(); } @Override Loading @@ -96,11 +97,13 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { }; public PhoneFavoriteMergedAdapter(Context context, PhoneFavoriteFragment fragment, PhoneFavoritesTileAdapter contactTileAdapter, CallLogAdapter callLogAdapter, View showAllContactsButton) { final Resources resources = context.getResources(); mContext = context; mFragment = fragment; mCallLogPadding = resources.getDimensionPixelSize(R.dimen.recent_call_log_item_padding); mContactTileAdapter = contactTileAdapter; mCallLogAdapter = callLogAdapter; Loading Loading
src/com/android/dialer/calllog/CallLogFragment.java +2 −2 Original line number Diff line number Diff line Loading @@ -432,8 +432,7 @@ public class CallLogFragment extends ListFragment updateOnTransition(true); } // TODO krelease: Figure out if we still need this. If so, it should be probably be moved to // the call log activity instead, or done only in a single call log fragment. // TODO: Move to CallLogActivity private void updateOnTransition(boolean onEntry) { // We don't want to update any call data when keyguard is on because the user has likely not // seen the new calls yet. Loading @@ -441,6 +440,7 @@ public class CallLogFragment extends ListFragment if (mKeyguardManager != null && !mKeyguardManager.inKeyguardRestrictedInputMode()) { // On either of the transitions we update the missed call and voicemail notifications. // While exiting we additionally consume all missed calls (by marking them as read). mCallLogQueryHandler.markNewCallsAsOld(); if (!onEntry) { mCallLogQueryHandler.markMissedCallsAsRead(); } Loading
src/com/android/dialer/calllog/CallLogQueryHandler.java +16 −13 Original line number Diff line number Diff line Loading @@ -138,22 +138,14 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { * <p> * It will asynchronously update the content of the list view when the fetch completes. */ public void fetchCalls(int callType) { public void fetchCalls(int callType, long newerThan) { cancelFetch(); int requestId = newCallsRequest(); fetchCalls(QUERY_CALLLOG_TOKEN, requestId, callType , false /* newOnly */); fetchCalls(QUERY_CALLLOG_TOKEN, requestId, callType, false /* newOnly */, newerThan); } /** * Fetches the list of calls from the call log for a given type. * This call fetches only the new (i.e. NEW = 1) ones. * <p> * It will asynchronously update the content of the list view when the fetch completes. */ public void fetchNewCalls(int callType) { cancelFetch(); int requestId = newCallsRequest(); fetchCalls(QUERY_CALLLOG_TOKEN, requestId, callType , true /* newOnly */); public void fetchCalls(int callType) { fetchCalls(callType, 0); } public void fetchVoicemailStatus() { Loading @@ -162,7 +154,8 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { } /** Fetches the list of calls in the call log. */ private void fetchCalls(int token, int requestId, int callType, boolean newOnly) { private void fetchCalls(int token, int requestId, int callType, boolean newOnly, long newerThan) { // We need to check for NULL explicitly otherwise entries with where READ is NULL // may not match either the query or its negation. // We consider the calls that are not yet consumed (i.e. IS_READ = 0) as "new". Loading @@ -180,8 +173,18 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { } // Add a clause to fetch only items of type voicemail. where.append(String.format("(%s = ?)", Calls.TYPE)); // Add a clause to fetch only items newer than the requested date selectionArgs.add(Integer.toString(callType)); } if (newerThan > 0) { if (where.length() > 0) { where.append(" AND "); } where.append(String.format("(%s > ?)", Calls.DATE)); selectionArgs.add(Long.toString(newerThan)); } final int limit = (mLogLimit == -1) ? NUM_LOGS_TO_DISPLAY : mLogLimit; final String selection = where.length() > 0 ? where.toString() : null; Uri uri = Calls.CONTENT_URI_WITH_VOICEMAIL.buildUpon() Loading
src/com/android/dialer/list/PhoneFavoriteFragment.java +42 −2 Original line number Diff line number Diff line Loading @@ -18,9 +18,12 @@ package com.android.dialer.list; import android.app.Activity; import android.app.Fragment; import android.app.LoaderManager; import android.content.Context; import android.content.CursorLoader; import android.content.Loader; import android.content.SharedPreferences; import android.database.Cursor; import android.database.MatrixCursor; import android.graphics.Rect; import android.net.Uri; import android.os.Bundle; Loading @@ -42,7 +45,9 @@ import com.android.contacts.common.ContactTileLoaderFactory; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.list.ContactEntry; import com.android.contacts.common.list.ContactTileView; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.calllog.CallLogQuery; import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.calllog.CallLogAdapter; import com.android.dialer.calllog.CallLogQueryHandler; Loading Loading @@ -74,6 +79,9 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen */ private static int LOADER_ID_CONTACT_TILE = 1; private static final String KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE = "key_last_dismissed_call_shortcut_date"; public interface OnShowAllContactsListener { public void onShowAllContacts(); } Loading Loading @@ -157,6 +165,17 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen */ private View mEmptyView; /** * Call shortcuts older than this date (persisted in shared preferences) will not show up in * at the top of the screen */ private long mLastCallShortcutDate = 0; /** * The date of the current call shortcut that is showing on screen. */ private long mCurrentCallShortcutDate = 0; private final ContactTileView.Listener mContactTileAdapterListener = new ContactTileAdapterListener(); private final LoaderManager.LoaderCallbacks<Cursor> mContactTileLoaderListener = Loading Loading @@ -195,6 +214,11 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen @Override public void onResume() { super.onResume(); final SharedPreferences prefs = getActivity().getSharedPreferences( DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE); mLastCallShortcutDate = prefs.getLong(KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE, 0); fetchCalls(); mCallLogAdapter.setLoading(true); getLoaderManager().getLoader(LOADER_ID_CONTACT_TILE).forceLoad(); Loading Loading @@ -231,7 +255,7 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen }); mContactTileAdapter.setEmptyView(mEmptyView); mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), mContactTileAdapter, mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), this, mContactTileAdapter, mCallLogAdapter, mShowAllContactsButton); mListView.setAdapter(mAdapter); Loading Loading @@ -308,13 +332,20 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen @Override public void onCallsFetched(Cursor cursor) { mCallLogAdapter.setLoading(false); // Save the date of the most recent call log item if (cursor != null && cursor.moveToFirst()) { mCurrentCallShortcutDate = cursor.getLong(CallLogQuery.DATE); } mCallLogAdapter.changeCursor(cursor); mAdapter.notifyDataSetChanged(); } @Override public void fetchCalls() { mCallLogQueryHandler.fetchNewCalls(CallLogQueryHandler.CALL_TYPE_ALL); mCallLogQueryHandler.fetchCalls(CallLogQueryHandler.CALL_TYPE_ALL, mLastCallShortcutDate); } @Override Loading Loading @@ -452,4 +483,13 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen public void cacheOffsetsForDatasetChange() { saveOffsets(); } public void dismissShortcut() { mLastCallShortcutDate = mCurrentCallShortcutDate; final SharedPreferences prefs = getActivity().getSharedPreferences( DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE); prefs.edit().putLong(KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE, mLastCallShortcutDate) .apply(); fetchCalls(); } }
src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java +4 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { private final PhoneFavoritesTileAdapter mContactTileAdapter; private final CallLogAdapter mCallLogAdapter; private final View mShowAllContactsButton; private final PhoneFavoriteFragment mFragment; private final int mCallLogPadding; Loading @@ -70,7 +71,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { mCallLogQueryHandler.markNewVoicemailsAsOld(); CallLogNotificationsHelper.removeMissedCallNotifications(); CallLogNotificationsHelper.updateVoicemailNotifications(mContext); mCallLogQueryHandler.fetchNewCalls(CallLogQueryHandler.CALL_TYPE_ALL); mFragment.dismissShortcut(); } @Override Loading @@ -96,11 +97,13 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { }; public PhoneFavoriteMergedAdapter(Context context, PhoneFavoriteFragment fragment, PhoneFavoritesTileAdapter contactTileAdapter, CallLogAdapter callLogAdapter, View showAllContactsButton) { final Resources resources = context.getResources(); mContext = context; mFragment = fragment; mCallLogPadding = resources.getDimensionPixelSize(R.dimen.recent_call_log_item_padding); mContactTileAdapter = contactTileAdapter; mCallLogAdapter = callLogAdapter; Loading