summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSai Cheemalapati <saicheems@google.com>2014-07-16 18:35:42 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-16 02:25:05 +0000
commit0c41ef04d2d5ad0bbe5f498f9492052a4a4725b8 (patch)
tree6e1e0439c101bc169d90897dec04de2e8a118958
parent04cad7101069d5e6c14c1a4a8f364c26567b4524 (diff)
parent9686330691f1216edff0ffa779138bda43388c47 (diff)
Merge "Added a dialog to confirm caller id reporting (1/2)." into lmp-dev
-rw-r--r--src/com/android/dialer/calllog/CallLogActivity.java2
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java31
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java21
-rw-r--r--src/com/android/dialer/list/ListsFragment.java2
-rw-r--r--src/com/android/dialerbind/ObjectFactory.java17
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogAdapterTest.java2
6 files changed, 54 insertions, 21 deletions
diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java
index 13d5f0356..f743f7ab5 100644
--- a/src/com/android/dialer/calllog/CallLogActivity.java
+++ b/src/com/android/dialer/calllog/CallLogActivity.java
@@ -179,4 +179,4 @@ public class CallLogActivity extends Activity implements CallLogQueryHandler.Lis
public void onCallsFetched(Cursor statusCursor) {
// Do nothing. Implemented to satisfy CallLogQueryHandler.Listener.
}
-} \ No newline at end of file
+}
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index d70a40dea..16be30871 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -89,6 +89,11 @@ public class CallLogAdapter extends GroupingListAdapter
public void fetchCalls();
}
+ /** Implements onClickListener for the report button. */
+ public interface OnReportButtonClickListener {
+ public void onReportButtonClick(String number);
+ }
+
/**
* Stores a phone number of a call with the country code where it originally occurred.
* <p>
@@ -133,6 +138,7 @@ public class CallLogAdapter extends GroupingListAdapter
private final ContactInfoHelper mContactInfoHelper;
private final CallFetcher mCallFetcher;
private final Toast mReportedToast;
+ private final OnReportButtonClickListener mOnReportButtonClickListener;
private ViewTreeObserver mViewTreeObserver = null;
/**
@@ -344,7 +350,7 @@ public class CallLogAdapter extends GroupingListAdapter
public CallLogAdapter(Context context, CallFetcher callFetcher,
ContactInfoHelper contactInfoHelper, CallItemExpandedListener callItemExpandedListener,
- boolean isCallLog) {
+ OnReportButtonClickListener onReportButtonClickListener, boolean isCallLog) {
super(context);
mContext = context;
@@ -353,6 +359,7 @@ public class CallLogAdapter extends GroupingListAdapter
mIsCallLog = isCallLog;
mCallItemExpandedListener = callItemExpandedListener;
+ mOnReportButtonClickListener = onReportButtonClickListener;
mReportedToast = Toast.makeText(mContext, R.string.toast_caller_id_reported,
Toast.LENGTH_SHORT);
@@ -697,10 +704,6 @@ public class CallLogAdapter extends GroupingListAdapter
// when the user expands the actions ViewStub.
}
- // Restore expansion state of the row on rebind. Inflate the actions ViewStub if required,
- // and set its visibility state accordingly.
- expandOrCollapseActions(callLogItemView, isExpanded(rowId));
-
// Lookup contacts with this number
NumberWithCountryIso numberCountryIso = new NumberWithCountryIso(number, countryIso);
ExpirableCache.CachedValue<ContactInfo> cachedInfo =
@@ -759,6 +762,10 @@ public class CallLogAdapter extends GroupingListAdapter
views.reported = info.isBadData;
views.isExternal = mContactInfoHelper.isExternal(info.sourceType);
+ // Restore expansion state of the row on rebind. Inflate the actions ViewStub if required,
+ // and set its visibility state accordingly.
+ expandOrCollapseActions(callLogItemView, isExpanded(rowId));
+
if (TextUtils.isEmpty(name)) {
details = new PhoneCallDetails(number, numberPresentation,
formattedNumber, countryIso, geocode, callTypes, date,
@@ -949,10 +956,9 @@ public class CallLogAdapter extends GroupingListAdapter
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.
+ if (mOnReportButtonClickListener != null) {
+ mOnReportButtonClickListener.onReportButtonClick(views.number);
+ }
}
});
}
@@ -1014,6 +1020,8 @@ public class CallLogAdapter extends GroupingListAdapter
if (views.isExternal && !views.reported) {
views.reportButtonView.setVisibility(View.VISIBLE);
+ } else {
+ views.reportButtonView.setVisibility(View.GONE);
}
}
@@ -1413,4 +1421,9 @@ public class CallLogAdapter extends GroupingListAdapter
return mContext.getResources().getString(R.string.call_log_header_other);
}
}
+
+ public void onBadDataReported(String number) {
+ mContactInfoCache.expireAll();
+ mReportedToast.show();
+ }
}
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index 1668895ef..852370566 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -20,6 +20,7 @@ import android.animation.Animator;
import android.animation.ValueAnimator;
import android.animation.Animator.AnimatorListener;
import android.app.Activity;
+import android.app.DialogFragment;
import android.app.KeyguardManager;
import android.app.ListFragment;
import android.content.Context;
@@ -65,7 +66,7 @@ import java.util.List;
* (all, missed or voicemails), specify it in the constructor.
*/
public class CallLogFragment extends ListFragment
- implements CallLogQueryHandler.Listener,
+ implements CallLogQueryHandler.Listener, CallLogAdapter.OnReportButtonClickListener,
CallLogAdapter.CallFetcher,
CallLogAdapter.CallItemExpandedListener {
private static final String TAG = "CallLogFragment";
@@ -178,7 +179,6 @@ public class CallLogFragment extends ListFragment
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
-
if (state != null) {
mCallTypeFilter = state.getInt(KEY_FILTER_TYPE, mCallTypeFilter);
mLogLimit = state.getInt(KEY_LOG_LIMIT, mLogLimit);
@@ -187,8 +187,8 @@ public class CallLogFragment extends ListFragment
}
String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity());
- mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, new ContactInfoHelper(
- getActivity(), currentCountryIso), this, true);
+ mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this,
+ new ContactInfoHelper(getActivity(), currentCountryIso), this, this, true);
setListAdapter(mAdapter);
mCallLogQueryHandler = new CallLogQueryHandler(getActivity().getContentResolver(),
this, mLogLimit);
@@ -666,4 +666,17 @@ public class CallLogFragment extends ListFragment
return null;
}
+
+ public void onBadDataReported(String number) {
+ mAdapter.onBadDataReported(number);
+ mAdapter.notifyDataSetChanged();
+ }
+
+ public void onReportButtonClick(String number) {
+ DialogFragment df = ObjectFactory.getReportDialogFragment(number);
+ if (df != null) {
+ df.setTargetFragment(this, 0);
+ df.show(getActivity().getFragmentManager(), "report_dialog");
+ }
+ }
}
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java
index e94555e2f..103eef780 100644
--- a/src/com/android/dialer/list/ListsFragment.java
+++ b/src/com/android/dialer/list/ListsFragment.java
@@ -220,7 +220,7 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste
this, 1);
final String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity());
mCallLogAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this,
- new ContactInfoHelper(getActivity(), currentCountryIso), null, false);
+ new ContactInfoHelper(getActivity(), currentCountryIso), null, null, false);
mMergedAdapter = new ShortcutCardsAdapter(getActivity(), this, mCallLogAdapter);
}
diff --git a/src/com/android/dialerbind/ObjectFactory.java b/src/com/android/dialerbind/ObjectFactory.java
index 97863116b..54a5821df 100644
--- a/src/com/android/dialerbind/ObjectFactory.java
+++ b/src/com/android/dialerbind/ObjectFactory.java
@@ -18,10 +18,12 @@ package com.android.dialerbind;
import static com.android.dialer.calllog.CallLogAdapter.CallFetcher;
+import android.app.DialogFragment;
import android.content.Context;
import com.android.dialer.calllog.CallLogAdapter;
import com.android.dialer.calllog.CallLogAdapter.CallItemExpandedListener;
+import com.android.dialer.calllog.CallLogAdapter.OnReportButtonClickListener;
import com.android.dialer.calllog.ContactInfoHelper;
import com.android.dialer.service.CachedNumberLookupService;
@@ -43,10 +45,15 @@ public class ObjectFactory {
* @param isCallLog Is this call log adapter being used on the call log?
* @return Instance of CallLogAdapter.
*/
- public static CallLogAdapter newCallLogAdapter(Context context, CallFetcher callFetcher,
- ContactInfoHelper contactInfoHelper, CallItemExpandedListener callItemExpandedListener,
- boolean isCallLog) {
- return new CallLogAdapter(context, callFetcher, contactInfoHelper, callItemExpandedListener,
- isCallLog);
+ public static CallLogAdapter newCallLogAdapter(Context context,
+ CallFetcher callFetcher, ContactInfoHelper contactInfoHelper,
+ CallItemExpandedListener callItemExpandedListener,
+ OnReportButtonClickListener onReportButtonClickListener, boolean isCallLog) {
+ return new CallLogAdapter(context, callFetcher, contactInfoHelper,
+ callItemExpandedListener, onReportButtonClickListener, isCallLog);
+ }
+
+ public static DialogFragment getReportDialogFragment(String number) {
+ return null;
}
}
diff --git a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
index f3679d4ed..b7f06d31c 100644
--- a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
@@ -212,7 +212,7 @@ public class CallLogAdapterTest extends AndroidTestCase {
public TestCallLogAdapter(Context context, CallFetcher callFetcher,
ContactInfoHelper contactInfoHelper) {
- super(context, callFetcher, contactInfoHelper, null, false);
+ super(context, callFetcher, contactInfoHelper, null, null, false);
}
@Override