diff options
author | linus_lee <llee@cyngn.com> | 2015-01-05 12:45:34 -0800 |
---|---|---|
committer | Linus Lee <llee@cyngn.com> | 2015-01-06 01:32:33 +0000 |
commit | 0aa14c90ab580d1f7185235d2613238235f2ce70 (patch) | |
tree | 1f1c9a0560d372cc4a6c097f674b7ea7d77e3034 /src/com/android | |
parent | 5406f450138cd7e2f355fe6aed6f6df5dab737f1 (diff) | |
download | android_packages_apps_Dialer-0aa14c90ab580d1f7185235d2613238235f2ce70.tar.gz android_packages_apps_Dialer-0aa14c90ab580d1f7185235d2613238235f2ce70.tar.bz2 android_packages_apps_Dialer-0aa14c90ab580d1f7185235d2613238235f2ce70.zip |
Separate blacklist from missed filter in history/stats
Change-Id: I50e2467b7ac8568c6956c2dbc085985fd2f34d99
(cherry picked from commit 2f4890478123a3b6a9ba0a8b23f9a290f6c4ec73)
Diffstat (limited to 'src/com/android')
6 files changed, 72 insertions, 59 deletions
diff --git a/src/com/android/dialer/calllog/CallLogQueryHandler.java b/src/com/android/dialer/calllog/CallLogQueryHandler.java index 293c21e7c..b2399b9ea 100755 --- a/src/com/android/dialer/calllog/CallLogQueryHandler.java +++ b/src/com/android/dialer/calllog/CallLogQueryHandler.java @@ -159,49 +159,7 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { /** Fetches the list of calls in the call log. */ private void fetchCalls(int token, 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". - StringBuilder where = new StringBuilder(); - List<String> selectionArgs = Lists.newArrayList(); - - if (newOnly) { - where.append(Calls.NEW); - where.append(" = 1"); - } - - if (callType > CALL_TYPE_ALL) { - if (where.length() > 0) { - where.append(" AND "); - } - // 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 (callType == Calls.MISSED_TYPE) { - // also query for blacklisted calls as they are 'missed' - where.append(" OR "); - where.append(String.format("(%s = ?)", Calls.TYPE)); - selectionArgs.add(Integer.toString(Calls.BLACKLIST_TYPE)); - } - } - - 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() - .appendQueryParameter(Calls.LIMIT_PARAM_KEY, Integer.toString(limit)) - .build(); - startQuery(token, null, uri, - CallLogQuery._PROJECTION, selection, selectionArgs.toArray(EMPTY_STRING_ARRAY), - Calls.DEFAULT_SORT_ORDER); + fetchCalls(token, callType, newOnly, newerThan, CALL_SUB_ALL); } private void fetchCalls(int token, int callType, boolean newOnly, @@ -225,12 +183,6 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { 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 (callType == Calls.MISSED_TYPE) { - // also query for blacklisted calls as they are 'missed' - where.append(" OR "); - where.append(String.format("(%s = ?)", Calls.TYPE)); - selectionArgs.add(Integer.toString(Calls.BLACKLIST_TYPE)); - } } if (slotId > CALL_SUB_ALL) { diff --git a/src/com/android/dialer/calllog/SpinnerContent.java b/src/com/android/dialer/calllog/SpinnerContent.java index 614b594db..9679dd5db 100644 --- a/src/com/android/dialer/calllog/SpinnerContent.java +++ b/src/com/android/dialer/calllog/SpinnerContent.java @@ -42,7 +42,8 @@ public class SpinnerContent { private static final int INDEX_CALL_TYPE_INCOMING = 1; private static final int INDEX_CALL_TYPE_OUTGOING = 2; private static final int INDEX_CALL_TYPE_MISSED = 3; - private static final int INDEX_CALL_TYPE_VOICEMAIL = 4; + private static final int INDEX_CALL_TYPE_BLACKLIST = 4; + private static final int INDEX_CALL_TYPE_VOICEMAIL = 5; public static void setSpinnerContentValue(Spinner spinner, int value) { for (int i = 0, count = spinner.getCount(); i < count; i++) { @@ -93,7 +94,7 @@ public class SpinnerContent { public static List<SpinnerContent> setupStatusFilterContent(Context context, boolean voicemailAvailable) { // Didn't show the voice mail item if not available. - int statusCount = voicemailAvailable ? 5 : 4; + int statusCount = voicemailAvailable ? 6 : 5; ArrayList<SpinnerContent> values = new ArrayList<SpinnerContent>(statusCount); for (int i = 0; i < statusCount; i++) { int value = CallLogQueryHandler.CALL_TYPE_ALL; @@ -115,6 +116,10 @@ public class SpinnerContent { value = CallLog.Calls.MISSED_TYPE; label = context.getString(R.string.call_log_missed_header); break; + case INDEX_CALL_TYPE_BLACKLIST: + value = CallLog.Calls.BLACKLIST_TYPE; + label = context.getString(R.string.call_log_blacklist_header); + break; case INDEX_CALL_TYPE_VOICEMAIL: value = CallLog.Calls.VOICEMAIL_TYPE; label = context.getString(R.string.call_log_voicemail_header); diff --git a/src/com/android/dialer/callstats/CallStatsDetailActivity.java b/src/com/android/dialer/callstats/CallStatsDetailActivity.java index 2c3bcba91..c2bfad3bd 100644 --- a/src/com/android/dialer/callstats/CallStatsDetailActivity.java +++ b/src/com/android/dialer/callstats/CallStatsDetailActivity.java @@ -70,6 +70,8 @@ public class CallStatsDetailActivity extends Activity { private TextView mOutDuration; private TextView mMissedSummary; private TextView mMissedCount; + private TextView mBlacklistSummary; + private TextView mBlacklistCount; private PieChartView mPieChart; private CallStatsDetails mData; @@ -112,11 +114,14 @@ public class CallStatsDetailActivity extends Activity { mOutDuration = (TextView) findViewById(R.id.out_duration); mMissedSummary = (TextView) findViewById(R.id.missed_summary); mMissedCount = (TextView) findViewById(R.id.missed_count); + mBlacklistSummary = (TextView) findViewById(R.id.blacklist_summary); + mBlacklistCount = (TextView) findViewById(R.id.blacklist_count); mPieChart = (PieChartView) findViewById(R.id.pie_chart); setCallType(R.id.in_icon, Calls.INCOMING_TYPE); setCallType(R.id.out_icon, Calls.OUTGOING_TYPE); setCallType(R.id.missed_icon, Calls.MISSED_TYPE); + setCallType(R.id.blacklist_icon, Calls.BLACKLIST_TYPE); configureActionBar(); Intent launchIntent = getIntent(); @@ -221,6 +226,21 @@ public class CallStatsDetailActivity extends Activity { findViewById(R.id.missed_container).setVisibility(View.GONE); } + if (shouldDisplay(Calls.BLACKLIST_TYPE, false)) { + if (byDuration) { + mBlacklistSummary.setText(getString(R.string.call_stats_blacklist)); + } else { + mBlacklistSummary.setText(getString(R.string.call_stats_blacklist_percent, + mData.getCountPercentage(Calls.BLACKLIST_TYPE))); + mPieChart.addSlice(mData.blacklistCount, + mResources.getColor(R.color.call_stats_blacklist)); + } + mBlacklistCount.setText(CallStatsDetailHelper.getCallCountString( + mResources, mData.blacklistCount)); + } else { + findViewById(R.id.blacklist_container).setVisibility(View.GONE); + } + mPieChart.generatePath(); findViewById(R.id.call_stats_detail).setVisibility(View.VISIBLE); } diff --git a/src/com/android/dialer/callstats/CallStatsDetailHelper.java b/src/com/android/dialer/callstats/CallStatsDetailHelper.java index b6acc92c9..72440c972 100644 --- a/src/com/android/dialer/callstats/CallStatsDetailHelper.java +++ b/src/com/android/dialer/callstats/CallStatsDetailHelper.java @@ -78,7 +78,7 @@ public class CallStatsDetailHelper { labelText = numberFormattedLabel; } - float in = 0, out = 0, missed = 0; + float in = 0, out = 0, missed = 0, blacklist = 0; float ratio = getDetailValue(details, type, byDuration) / getDetailValue(first, type, byDuration); @@ -88,6 +88,7 @@ public class CallStatsDetailHelper { out = getDetailValue(details, Calls.OUTGOING_TYPE, byDuration) * ratio / full; if (!byDuration) { missed = getDetailValue(details, Calls.MISSED_TYPE, byDuration) * ratio / full; + blacklist = getDetailValue(details, Calls.BLACKLIST_TYPE, byDuration) * ratio / full; } } else if (type == Calls.INCOMING_TYPE) { in = ratio; @@ -95,16 +96,22 @@ public class CallStatsDetailHelper { out = ratio; } else if (type == Calls.MISSED_TYPE) { missed = ratio; + } else if (type == Calls.BLACKLIST_TYPE) { + blacklist = ratio; } - views.barView.setRatios(in, out, missed); + views.barView.setRatios(in, out, missed, blacklist); views.nameView.setText(nameText); views.numberView.setText(numberText); views.labelView.setText(labelText); views.labelView.setVisibility(TextUtils.isEmpty(labelText) ? View.GONE : View.VISIBLE); - if (byDuration && type == Calls.MISSED_TYPE) { - views.percentView.setText(getCallCountString(mResources, details.missedCount)); + if (byDuration) { + if (type == Calls.MISSED_TYPE) { + views.percentView.setText(getCallCountString(mResources, details.missedCount)); + } else if (type == Calls.BLACKLIST_TYPE) { + views.percentView.setText(getCallCountString(mResources, details.blacklistCount)); + } } else { float percent = getDetailValue(details, type, byDuration) * 100F / getDetailValue(total, type, byDuration); diff --git a/src/com/android/dialer/callstats/CallStatsDetails.java b/src/com/android/dialer/callstats/CallStatsDetails.java index 80c36ac65..8184be04a 100644 --- a/src/com/android/dialer/callstats/CallStatsDetails.java +++ b/src/com/android/dialer/callstats/CallStatsDetails.java @@ -47,6 +47,7 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable { public int incomingCount; public int outgoingCount; public int missedCount; + public int blacklistCount; public CallStatsDetails(CharSequence number, int numberPresentation, ContactInfo info, String countryIso, String geocode, long date) { @@ -121,7 +122,7 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable { } public int getTotalCount() { - return incomingCount + outgoingCount + missedCount; + return incomingCount + outgoingCount + missedCount + blacklistCount; } public void addTimeOrMissed(int type, long time) { @@ -137,6 +138,9 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable { case Calls.MISSED_TYPE: missedCount++; break; + case Calls.BLACKLIST_TYPE: + blacklistCount++; + break; } } @@ -158,6 +162,8 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable { return outDuration; case Calls.MISSED_TYPE: return (long) missedCount; + case Calls.BLACKLIST_TYPE: + return (long) blacklistCount; default: return getFullDuration(); } @@ -171,6 +177,8 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable { return outgoingCount; case Calls.MISSED_TYPE: return missedCount; + case Calls.BLACKLIST_TYPE: + return blacklistCount; default: return getTotalCount(); } @@ -182,11 +190,12 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable { this.incomingCount += other.incomingCount; this.outgoingCount += other.outgoingCount; this.missedCount += other.missedCount; + this.blacklistCount += other.blacklistCount; } public void reset() { this.inDuration = this.outDuration = 0; - this.incomingCount = this.outgoingCount = this.missedCount = 0; + this.incomingCount = this.outgoingCount = this.missedCount = this.blacklistCount = 0; } /* Parcelable interface */ @@ -215,6 +224,7 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable { out.writeInt(incomingCount); out.writeInt(outgoingCount); out.writeInt(missedCount); + out.writeInt(blacklistCount); } public static final Parcelable.Creator<CallStatsDetails> CREATOR = @@ -246,5 +256,6 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable { incomingCount = in.readInt(); outgoingCount = in.readInt(); missedCount = in.readInt(); + blacklistCount = in.readInt(); } } diff --git a/src/com/android/dialer/widget/LinearColorBar.java b/src/com/android/dialer/widget/LinearColorBar.java index 0b824af55..5ccfccef8 100644 --- a/src/com/android/dialer/widget/LinearColorBar.java +++ b/src/com/android/dialer/widget/LinearColorBar.java @@ -35,11 +35,13 @@ public class LinearColorBar extends LinearLayout { private float mFirstRatio; private float mSecondRatio; private float mThirdRatio; + private float mFourthRatio; private int mBackgroundColor; private int mBlueColor; private int mGreenColor; private int mRedColor; + private int mOrangeColor; final Rect mRect = new Rect(); final Paint mPaint = new Paint(); @@ -76,6 +78,9 @@ public class LinearColorBar extends LinearLayout { case R.styleable.LinearColorBar_blueColor: mBlueColor = a.getInt(attr, 0); break; + case R.styleable.LinearColorBar_orangeColor: + mOrangeColor = a.getInt(attr, 0); + break; } } @@ -91,10 +96,11 @@ public class LinearColorBar extends LinearLayout { mEdgeGradientPaint.setAntiAlias(true); } - public void setRatios(float blue, float green, float red) { + public void setRatios(float blue, float green, float red, float orange) { mFirstRatio = blue; mSecondRatio = green; mThirdRatio = red; + mFourthRatio = orange; invalidate(); } @@ -129,8 +135,9 @@ public class LinearColorBar extends LinearLayout { int right = left + (int) (width * mFirstRatio); int right2 = right + (int) (width * mSecondRatio); int right3 = right2 + (int) (width * mThirdRatio); + int right4 = right3 + (int) (width * mFourthRatio); - int indicatorLeft = right3; + int indicatorLeft = right4; int indicatorRight = width; if (mLastInterestingLeft != indicatorLeft || mLastInterestingRight != indicatorRight) { @@ -199,6 +206,17 @@ public class LinearColorBar extends LinearLayout { left = right; } + right = right4; + + if (left < right) { + mRect.left = left; + mRect.right = right; + mPaint.setColor(mOrangeColor); + canvas.drawRect(mRect, mPaint); + width -= (right - left); + left = right; + } + right = left + width; if (left < right) { mRect.left = left; |