summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/CallDetailActivity.java6
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java6
-rw-r--r--src/com/android/dialer/calllog/CallLogListItemViewHolder.java4
-rw-r--r--src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java37
-rw-r--r--src/com/android/dialer/filterednumber/FilteredNumbersUtil.java2
-rw-r--r--src/com/android/dialer/list/BlockedListSearchAdapter.java4
-rw-r--r--src/com/android/dialer/list/BlockedListSearchFragment.java6
7 files changed, 29 insertions, 36 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 4e7e7b3c0..ab63ddc21 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -394,7 +394,7 @@ public class CallDetailActivity extends AppCompatActivity
return;
}
- boolean failed = mFilteredNumberAsyncQueryHandler.startBlockedQuery(
+ final boolean success = mFilteredNumberAsyncQueryHandler.isBlockedNumber(
new OnCheckBlockedListener() {
@Override
public void onCheckComplete(Integer id) {
@@ -403,9 +403,9 @@ public class CallDetailActivity extends AppCompatActivity
updateContactPhoto();
updateBlockActionItem();
}
- }, null, mNumber, mDetails.countryIso);
+ }, mNumber, mDetails.countryIso);
- if (failed) {
+ if (!success) {
updateContactPhoto();
updateBlockActionItem();
}
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 7999ee0f5..9f1af83ee 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -526,7 +526,7 @@ public class CallLogAdapter extends GroupingListAdapter
views.updatePhoto();
} else {
views.blockId = null;
- boolean failed = mFilteredNumberAsyncQueryHandler.startBlockedQuery(
+ final boolean success = mFilteredNumberAsyncQueryHandler.isBlockedNumber(
new OnCheckBlockedListener() {
@Override
public void onCheckComplete(Integer id) {
@@ -534,8 +534,8 @@ public class CallLogAdapter extends GroupingListAdapter
views.blockId = id;
views.updatePhoto();
}
- }, null, number, countryIso);
- if (failed) {
+ }, number, countryIso);
+ if (!success) {
views.updatePhoto();
}
}
diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
index 28e406fd5..afe82087a 100644
--- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
+++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
@@ -304,7 +304,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
}
if (FilteredNumbersUtil.canBlockNumber(mContext, number, countryIso)) {
- mFilteredNumberAsyncQueryHandler.startBlockedQuery(
+ mFilteredNumberAsyncQueryHandler.isBlockedNumber(
new FilteredNumberAsyncQueryHandler.OnCheckBlockedListener() {
@Override
public void onCheckComplete(Integer id) {
@@ -319,7 +319,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
blockItem.setOnMenuItemClickListener(
CallLogListItemViewHolder.this);
}
- }, info.normalizedNumber, number, countryIso);
+ }, number, countryIso);
}
}
diff --git a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java
index 3a717fd56..06aca78b5 100644
--- a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java
+++ b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java
@@ -25,6 +25,7 @@ import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabaseCorruptException;
import android.net.Uri;
import android.telephony.PhoneNumberUtils;
+import android.text.TextUtils;
import com.android.contacts.common.util.PhoneNumberHelper;
import com.android.dialer.database.FilteredNumberContract.FilteredNumber;
@@ -128,7 +129,7 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler {
null, null, null);
}
- public final void hasBlockedNumbersAsync(final OnHasBlockedNumbersListener listener) {
+ public final void hasBlockedNumbers(final OnHasBlockedNumbersListener listener) {
startQuery(NO_TOKEN,
new Listener() {
@Override
@@ -144,28 +145,18 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler {
}
/**
- * Check if the number + country iso given has been blocked.
- * This method normalizes the number for the lookup if normalizedNumber is null.
- * @return {@code true} if the number was invalid and couldn't be checked,
- * {@code false} otherwise,
+ * Check if this number has been blocked.
+ *
+ * @return {@code false} if the number was invalid and couldn't be checked,
+ * {@code true} otherwise,
*/
- public final boolean startBlockedQuery(final OnCheckBlockedListener listener,
- String normalizedNumber, String number, String countryIso) {
- if (normalizedNumber == null) {
- normalizedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso);
- if (normalizedNumber == null) {
- return true;
- }
+ public final boolean isBlockedNumber(
+ final OnCheckBlockedListener listener, String number, String countryIso) {
+ final String normalizedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso);
+ if (TextUtils.isEmpty(normalizedNumber)) {
+ return false;
}
- startBlockedQuery(listener, normalizedNumber);
- return false;
- }
- /**
- * Check if the normalized number given has been blocked.
- */
- public final void startBlockedQuery(final OnCheckBlockedListener listener,
- String normalizedNumber) {
startQuery(NO_TOKEN,
new Listener() {
@Override
@@ -185,10 +176,12 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler {
}
},
getContentUri(null),
- new String[]{FilteredNumberColumns._ID, FilteredNumberColumns.TYPE},
+ new String[]{ FilteredNumberColumns._ID, FilteredNumberColumns.TYPE },
FilteredNumberColumns.NORMALIZED_NUMBER + " = ?",
- new String[]{normalizedNumber},
+ new String[]{ normalizedNumber },
null);
+
+ return true;
}
public final void blockNumber(
diff --git a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
index 67e7ee36b..a9bb98321 100644
--- a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
+++ b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
@@ -303,7 +303,7 @@ public class FilteredNumbersUtil {
// If the user has blocked numbers, notify that call blocking is temporarily disabled.
FilteredNumberAsyncQueryHandler queryHandler =
new FilteredNumberAsyncQueryHandler(context.getContentResolver());
- queryHandler.hasBlockedNumbersAsync(new OnHasBlockedNumbersListener() {
+ queryHandler.hasBlockedNumbers(new OnHasBlockedNumbersListener() {
@Override
public void onHasBlockedNumbers(boolean hasBlockedNumbers) {
if (context == null || !hasBlockedNumbers) {
diff --git a/src/com/android/dialer/list/BlockedListSearchAdapter.java b/src/com/android/dialer/list/BlockedListSearchAdapter.java
index aaea40bf8..1618826bd 100644
--- a/src/com/android/dialer/list/BlockedListSearchAdapter.java
+++ b/src/com/android/dialer/list/BlockedListSearchAdapter.java
@@ -84,7 +84,7 @@ public class BlockedListSearchAdapter extends RegularSearchListAdapter {
}
}
};
- mFilteredNumberAsyncQueryHandler.startBlockedQuery(
- onCheckListener, null, number, countryIso);
+ mFilteredNumberAsyncQueryHandler.isBlockedNumber(
+ onCheckListener, number, countryIso);
}
}
diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java
index 24945b9f9..58de5d3c8 100644
--- a/src/com/android/dialer/list/BlockedListSearchFragment.java
+++ b/src/com/android/dialer/list/BlockedListSearchFragment.java
@@ -189,9 +189,9 @@ public class BlockedListSearchFragment extends RegularSearchFragment
}
}
};
- boolean failed = mFilteredNumberAsyncQueryHandler.startBlockedQuery(
- onCheckListener, null, number, countryIso);
- if (failed) {
+ final boolean success = mFilteredNumberAsyncQueryHandler.isBlockedNumber(
+ onCheckListener, number, countryIso);
+ if (!success) {
Toast.makeText(getContext(), getString(R.string.invalidNumber, number),
Toast.LENGTH_SHORT).show();
}