Merge "Hide the hide blocked call settings if no VVM." into ub-contactsdialer-a-dev
diff --git a/res/layout/blocked_number_fragment.xml b/res/layout/blocked_number_fragment.xml
index 50c4f44..f8d3030 100644
--- a/res/layout/blocked_number_fragment.xml
+++ b/res/layout/blocked_number_fragment.xml
@@ -53,36 +53,28 @@
</android.support.v7.widget.CardView>
- <android.support.v7.widget.CardView
+
+ <LinearLayout
+ android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- card_view:cardCornerRadius="0dp">
+ android:background="@color/background_dialer_white">
- <LinearLayout
- android:orientation="vertical"
+ <ListView android:id="@+id/blocked_numbers_list"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@color/background_dialer_white">
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:drawSelectorOnTop="false"
+ android:headerDividersEnabled="false" />
- <include layout="@layout/blocked_number_header" />
+ <TextView android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingStart="@dimen/blocked_number_horizontal_margin"
+ android:paddingTop="@dimen/blocked_number_top_margin"
+ android:paddingBottom="@dimen/blocked_number_bottom_margin"
+ android:text="@string/listNoBlockedNumbers" />
- <ListView android:id="@id/android:list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:drawSelectorOnTop="false"
- android:headerDividersEnabled="false" />
-
- <TextView android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingStart="@dimen/blocked_number_horizontal_margin"
- android:paddingTop="@dimen/blocked_number_top_margin"
- android:paddingBottom="@dimen/blocked_number_bottom_margin"
- android:text="@string/listNoBlockedNumbers" />
-
- </LinearLayout>
-
- </android.support.v7.widget.CardView>
+ </LinearLayout>
</LinearLayout>
diff --git a/res/layout/blocked_number_header.xml b/res/layout/blocked_number_header.xml
index e16efbc..0c8c086 100644
--- a/res/layout/blocked_number_header.xml
+++ b/res/layout/blocked_number_header.xml
@@ -13,7 +13,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
+<android.support.v7.widget.CardView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:card_view="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ card_view:cardCornerRadius="0dp">
<TextView android:id="@+id/textView"
android:layout_width="wrap_content"
@@ -72,4 +77,4 @@
android:layout_marginTop="8dp"
android:text="@string/blockNumber" />
-</merge>
+</android.support.v7.widget.CardView>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 8b7b150..bf7bfb2 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -24,6 +24,7 @@
<color name="dialer_button_text_color">#fff</color>
<color name="dialer_flat_button_text_color">@color/dialer_theme_color</color>
+ <color name="dialer_snackbar_action_text_color">@color/dialer_theme_color</color>
<!-- Color for the setting text. -->
<color name="setting_primary_color">@color/dialtacts_primary_text_color</color>
diff --git a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
index 594ceeb..1987b80 100644
--- a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
+++ b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
@@ -131,8 +131,13 @@
NewCall newCall = itr.next();
// Skip notifying for numbers which are blocked.
- if (FilteredNumbersUtil.isBlocked(mContext, newCall.number, newCall.countryIso)) {
+ if (FilteredNumbersUtil.shouldBlockVoicemail(
+ mContext, newCall.number, newCall.countryIso, newCall.dateMs)) {
itr.remove();
+
+ if (FilteredNumbersUtil.shouldHideBlockedCalls(mContext)) {
+ mContext.getContentResolver().delete(newCall.voicemailUri, null, null);
+ }
continue;
}
@@ -236,6 +241,7 @@
public final String accountId;
public final String transcription;
public final String countryIso;
+ public final long dateMs;
public NewCall(
Uri callsUri,
@@ -245,7 +251,8 @@
String accountComponentName,
String accountId,
String transcription,
- String countryIso) {
+ String countryIso,
+ long dateMs) {
this.callsUri = callsUri;
this.voicemailUri = voicemailUri;
this.number = number;
@@ -254,6 +261,7 @@
this.accountId = accountId;
this.transcription = transcription;
this.countryIso = countryIso;
+ this.dateMs = dateMs;
}
}
@@ -284,7 +292,8 @@
Calls.PHONE_ACCOUNT_COMPONENT_NAME,
Calls.PHONE_ACCOUNT_ID,
Calls.TRANSCRIPTION,
- Calls.COUNTRY_ISO
+ Calls.COUNTRY_ISO,
+ Calls.DATE
};
private static final int ID_COLUMN_INDEX = 0;
private static final int NUMBER_COLUMN_INDEX = 1;
@@ -294,6 +303,7 @@
private static final int PHONE_ACCOUNT_ID_COLUMN_INDEX = 5;
private static final int TRANSCRIPTION_COLUMN_INDEX = 6;
private static final int COUNTRY_ISO_COLUMN_INDEX = 7;
+ private static final int DATE_COLUMN_INDEX = 8;
private final ContentResolver mContentResolver;
private final Context mContext;
@@ -345,7 +355,8 @@
cursor.getString(PHONE_ACCOUNT_COMPONENT_NAME_COLUMN_INDEX),
cursor.getString(PHONE_ACCOUNT_ID_COLUMN_INDEX),
cursor.getString(TRANSCRIPTION_COLUMN_INDEX),
- cursor.getString(COUNTRY_ISO_COLUMN_INDEX));
+ cursor.getString(COUNTRY_ISO_COLUMN_INDEX),
+ cursor.getLong(DATE_COLUMN_INDEX));
}
}
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
index 96dfb71..cee7a0d 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
@@ -17,12 +17,14 @@
import android.app.ListFragment;
import android.app.LoaderManager;
+import android.content.Context;
import android.content.CursorLoader;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.CompoundButton;
+import android.widget.ListView;
import android.widget.Switch;
import android.view.LayoutInflater;
import android.view.View;
@@ -97,6 +99,12 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ LayoutInflater inflater =
+ (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ ListView listView = (ListView) getActivity().findViewById(R.id.blocked_numbers_list);
+ listView.addHeaderView(inflater.inflate(R.layout.blocked_number_header, null));
+
getLoaderManager().initLoader(0, null, this);
}
diff --git a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
index affb37b..8473e32 100644
--- a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
+++ b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
@@ -178,10 +178,15 @@
return getString(R.string.snackbar_number_unblocked, mDisplayNumber);
}
+ private int getActionTextColor() {
+ return getContext().getResources().getColor(R.color.dialer_snackbar_action_text_color);
+ }
+
private void blockNumber() {
final String message = getBlockedMessage();
final String undoMessage = getUnblockedMessage();
final Callback callback = mCallback;
+ final int actionTextColor = getActionTextColor();
final OnUnblockNumberListener onUndoListener = new OnUnblockNumberListener() {
@Override
@@ -206,6 +211,7 @@
Snackbar.make(mParentView, message, Snackbar.LENGTH_LONG)
.setAction(R.string.block_number_undo, undoListener)
+ .setActionTextColor(actionTextColor)
.show();
if (callback != null) {
@@ -225,6 +231,7 @@
final String message = getUnblockedMessage();
final String undoMessage = getBlockedMessage();
final Callback callback = mCallback;
+ final int actionTextColor = getActionTextColor();
final OnBlockNumberListener onUndoListener = new OnBlockNumberListener() {
@Override
@@ -249,6 +256,7 @@
Snackbar.make(mParentView, message, Snackbar.LENGTH_LONG)
.setAction(R.string.block_number_undo, undoListener)
+ .setActionTextColor(actionTextColor)
.show();
if (callback != null) {
diff --git a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
index 0e162ac..ac3d16e 100644
--- a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
+++ b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
@@ -191,7 +191,8 @@
* WARNING: This method should NOT be executed on the UI thread.
* Use {@code FilteredNumberAsyncQueryHandler} to asynchronously check if a number is blocked.
*/
- public static boolean isBlocked(Context context, String number, String countryIso) {
+ public static boolean shouldBlockVoicemail(
+ Context context, String number, String countryIso, long dateMs) {
final String normalizedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso);
if (TextUtils.isEmpty(normalizedNumber)) {
return false;
@@ -199,21 +200,26 @@
final Cursor cursor = context.getContentResolver().query(
FilteredNumber.CONTENT_URI,
- new String[] { FilteredNumberColumns._ID },
+ new String[] {
+ FilteredNumberColumns.CREATION_TIME
+ },
FilteredNumberColumns.NORMALIZED_NUMBER + "=?",
new String[] { normalizedNumber },
null);
- boolean isBlocked = false;
+ boolean shouldBlock = false;
if (cursor != null) {
try {
- isBlocked = cursor.getCount() > 0;
+ cursor.moveToFirst();
+
+ // Block if number is found and it was added before this voicemail was received.
+ shouldBlock = cursor.getCount() > 0 && dateMs > cursor.getLong(0);
} finally {
cursor.close();
}
}
- return isBlocked;
+ return shouldBlock;
}
public static boolean shouldHideBlockedCalls(Context context) {
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java
index f86fc55..33210d3 100644
--- a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java
+++ b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java
@@ -209,6 +209,8 @@
// window.
handler.postDelayed(deleteCallback, VOICEMAIL_DELETE_DELAY_MS + 50);
+ final int actionTextColor =
+ mContext.getResources().getColor(R.color.dialer_snackbar_action_text_color);
Snackbar.make(VoicemailPlaybackLayout.this, R.string.snackbar_voicemail_deleted,
Snackbar.LENGTH_LONG)
.setDuration(VOICEMAIL_DELETE_DELAY_MS)
@@ -220,6 +222,7 @@
handler.removeCallbacks(deleteCallback);
}
})
+ .setActionTextColor(actionTextColor)
.show();
}
};