diff options
author | Sai Cheemalapati <saicheems@google.com> | 2014-07-15 16:25:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-15 16:05:01 +0000 |
commit | 434dbcc2f581619f79a691e1a39c5e69003a9d16 (patch) | |
tree | bc805cf5061d1f2326f3eba25d41614dc3dde78a /src | |
parent | 2bc98d35f3a491b7bc46c27863d266c38abe5ef0 (diff) | |
parent | b77bf5df2b866dd40e330b7c2dedee4a1d51fc78 (diff) |
Merge "DO NOT MERGE Added report button to UI and database." into lmp-dev
Diffstat (limited to 'src')
5 files changed, 53 insertions, 2 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 5bebd4030..f4b9f3a94 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -37,6 +37,7 @@ import android.view.ViewStub; import android.view.ViewTreeObserver; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import com.android.common.widget.GroupingListAdapter; import com.android.contacts.common.ContactPhotoManager; @@ -131,6 +132,7 @@ public class CallLogAdapter extends GroupingListAdapter protected final Context mContext; private final ContactInfoHelper mContactInfoHelper; private final CallFetcher mCallFetcher; + private final Toast mReportedToast; private ViewTreeObserver mViewTreeObserver = null; /** @@ -351,6 +353,9 @@ public class CallLogAdapter extends GroupingListAdapter mIsCallLog = isCallLog; mCallItemExpandedListener = callItemExpandedListener; + mReportedToast = Toast.makeText(mContext, R.string.toast_caller_id_reported, + Toast.LENGTH_SHORT); + mContactInfoCache = ExpirableCache.create(CONTACT_INFO_CACHE_SIZE); mRequests = new LinkedList<ContactInfoRequest>(); @@ -751,6 +756,9 @@ public class CallLogAdapter extends GroupingListAdapter final PhoneCallDetails details; + views.reported = info.isBadData; + views.isExternal = mContactInfoHelper.isExternal(info.sourceType); + if (TextUtils.isEmpty(name)) { details = new PhoneCallDetails(number, numberPresentation, formattedNumber, countryIso, geocode, callTypes, date, @@ -908,7 +916,7 @@ public class CallLogAdapter extends GroupingListAdapter * * @param callLogItem The call log list item view. */ - private void inflateActionViewStub(View callLogItem) { + private void inflateActionViewStub(final View callLogItem) { final CallLogListItemViews views = (CallLogListItemViews)callLogItem.getTag(); ViewStub stub = (ViewStub)callLogItem.findViewById(R.id.call_log_entry_actions_stub); @@ -930,6 +938,19 @@ public class CallLogAdapter extends GroupingListAdapter views.detailsButtonView = (TextView)views.actionsView.findViewById(R.id.details_action); } + if (views.reportButtonView == null) { + views.reportButtonView = (TextView)views.actionsView.findViewById(R.id.report_action); + views.reportButtonView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mReportedToast.show(); + ((CallLogListItemViews) callLogItem.getTag()).reported = true; + v.setVisibility(View.GONE); + // TODO: Set the entry as reported in the database. + } + }); + } + bindActionButtons(views); } @@ -970,7 +991,9 @@ public class CallLogAdapter extends GroupingListAdapter IntentProvider.getCallDetailIntentProvider( views.rowId, views.callIds, null) ); - + if (views.isExternal && !views.reported) { + views.reportButtonView.setVisibility(View.VISIBLE); + } } mCallLogViewsHelper.setActionContentDescriptions(views); diff --git a/src/com/android/dialer/calllog/CallLogListItemViews.java b/src/com/android/dialer/calllog/CallLogListItemViews.java index 8048d83cb..3efa5cbea 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViews.java +++ b/src/com/android/dialer/calllog/CallLogListItemViews.java @@ -48,6 +48,8 @@ public final class CallLogListItemViews { public TextView voicemailButtonView; /** The "details" action button - assigned only when the action section is expanded. */ public TextView detailsButtonView; + /** The "report" action button. */ + public TextView reportButtonView; /** * The row Id for the first call associated with the call log entry. Used as a key for the @@ -98,6 +100,16 @@ public final class CallLogListItemViews { */ public CharSequence nameOrNumber; + /** + * Whether or not the item has been reported by user as incorrect. + */ + public boolean reported; + + /** + * Whether or not the contact info came from a source other than the android contacts provider. + */ + public boolean isExternal; + private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView, PhoneCallDetailsViews phoneCallDetailsViews, View callLogEntryView, TextView dayGroupHeader) { @@ -128,6 +140,7 @@ public final class CallLogListItemViews { views.callBackButtonView = new TextView(context); views.voicemailButtonView = new TextView(context); views.detailsButtonView = new TextView(context); + views.reportButtonView = new TextView(context); views.actionsView = new View(context); return views; } diff --git a/src/com/android/dialer/calllog/ContactInfo.java b/src/com/android/dialer/calllog/ContactInfo.java index 41afa5a77..cf29c5c83 100644 --- a/src/com/android/dialer/calllog/ContactInfo.java +++ b/src/com/android/dialer/calllog/ContactInfo.java @@ -38,6 +38,7 @@ public class ContactInfo { public long photoId; /** The high-res photo for the contact, if available. */ public Uri photoUri; + public boolean isBadData; public static ContactInfo EMPTY = new ContactInfo(); diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 1bebfc416..f09c3657e 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -288,4 +288,16 @@ public class ContactInfoHelper { return mCachedNumberLookupService != null && mCachedNumberLookupService.isBusiness(sourceType); } + + /** + * Given a contact's sourceType, return true if the contact came from an + * external source. + * + * @param sourceType sourceType of the contact. This is usually populated by + * {@link #mCachedNumberLookupService}. + */ + public boolean isExternal(int sourceType) { + return mCachedNumberLookupService != null + && mCachedNumberLookupService.isExternal(sourceType); + } } diff --git a/src/com/android/dialer/service/CachedNumberLookupService.java b/src/com/android/dialer/service/CachedNumberLookupService.java index 73fd8950e..2fec45cd6 100644 --- a/src/com/android/dialer/service/CachedNumberLookupService.java +++ b/src/com/android/dialer/service/CachedNumberLookupService.java @@ -35,6 +35,8 @@ public interface CachedNumberLookupService { public boolean isBusiness(int sourceType); + public boolean isExternal(int sourceType); + public boolean addPhoto(Context context, String number, byte[] photo); /** |