summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java4
-rw-r--r--src/com/android/dialer/calllog/CallLogQueryHandler.java29
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteFragment.java44
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java5
4 files changed, 64 insertions, 18 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index ce27ab72a..c8e261358 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -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.
@@ -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();
}
diff --git a/src/com/android/dialer/calllog/CallLogQueryHandler.java b/src/com/android/dialer/calllog/CallLogQueryHandler.java
index 987dedf66..def3c975b 100644
--- a/src/com/android/dialer/calllog/CallLogQueryHandler.java
+++ b/src/com/android/dialer/calllog/CallLogQueryHandler.java
@@ -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() {
@@ -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".
@@ -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()
diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java
index a9613478a..beeb320dd 100644
--- a/src/com/android/dialer/list/PhoneFavoriteFragment.java
+++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java
@@ -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;
@@ -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;
@@ -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();
}
@@ -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 =
@@ -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();
@@ -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);
@@ -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
@@ -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();
+ }
}
diff --git a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
index c7554e212..cf2aeeee9 100644
--- a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
@@ -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;
@@ -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
@@ -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;