summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/filterednumber
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/dialer/filterednumber')
-rw-r--r--src/com/android/dialer/filterednumber/BlockedNumbersFragment.java11
-rw-r--r--src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java6
-rw-r--r--src/com/android/dialer/filterednumber/FilteredNumbersUtil.java80
-rw-r--r--src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java6
-rw-r--r--src/com/android/dialer/filterednumber/ViewNumbersToImportFragment.java4
5 files changed, 93 insertions, 14 deletions
diff --git a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
index 7788cbe1b..b57aa5ae5 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
@@ -79,6 +79,13 @@ public class BlockedNumbersFragment extends ListFragment
FilteredNumbersUtil.setShouldHideBlockedCalls(getActivity(), isChecked);
}
});
+ getActivity().findViewById(R.id.hide_blocked_calls_setting).setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(final View view) {
+ mHideSettingSwitch.toggle();
+ }
+ });
mImportSettings = getActivity().findViewById(R.id.import_settings);
mBlockedNumbersDisabledForEmergency =
@@ -109,7 +116,6 @@ public class BlockedNumbersFragment extends ListFragment
ColorDrawable backgroundDrawable =
new ColorDrawable(getActivity().getColor(R.color.dialer_theme_color));
actionBar.setBackgroundDrawable(backgroundDrawable);
- actionBar.setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation));
actionBar.setDisplayShowCustomEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
@@ -138,8 +144,7 @@ public class BlockedNumbersFragment extends ListFragment
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.blocked_number_fragment, container, false);
- return view;
+ return inflater.inflate(R.layout.blocked_number_fragment, container, false);
}
@Override
diff --git a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
index 4a45be24a..d7608d8f9 100644
--- a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
+++ b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
@@ -21,6 +21,7 @@ import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentManager;
import android.content.ContentValues;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.net.Uri;
@@ -192,6 +193,7 @@ public class FilterNumberDialogFragment extends DialogFragment {
final String undoMessage = getUnblockedMessage();
final Callback callback = mCallback;
final int actionTextColor = getActionTextColor();
+ final Context context = getContext();
final OnUnblockNumberListener onUndoListener = new OnUnblockNumberListener() {
@Override
@@ -222,6 +224,10 @@ public class FilterNumberDialogFragment extends DialogFragment {
if (callback != null) {
callback.onChangeFilteredNumberSuccess();
}
+
+ if (context != null && FilteredNumbersUtil.hasRecentEmergencyCall(context)) {
+ FilteredNumbersUtil.maybeNotifyCallBlockingDisabled(context);
+ }
}
};
diff --git a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
index 45fa6b73d..4492c51e3 100644
--- a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
+++ b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
@@ -15,8 +15,12 @@
*/
package com.android.dialer.filterednumber;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
import android.content.ContentValues;
import android.content.Context;
+import android.content.Intent;
import android.database.Cursor;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
@@ -33,8 +37,10 @@ import java.util.LinkedList;
import java.util.List;
import com.android.contacts.common.testing.NeededForTesting;
+import com.android.contacts.common.util.PhoneNumberHelper;
import com.android.dialer.R;
import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
+import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnHasBlockedNumbersListener;
import com.android.dialer.database.FilteredNumberContract.FilteredNumber;
import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
@@ -43,13 +49,21 @@ import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
*/
public class FilteredNumbersUtil {
- private static final String HIDE_BLOCKED_CALLS_PREF_KEY = "hide_blocked_calls";
- // Pref key for storing the time, in milliseconds after epoch, of end of the last emergency call.
- private static final String LAST_EMERGENCY_CALL_PREF_KEY = "last_emergency_call";
-
// Disable incoming call blocking if there was a call within the past 2 days.
private static final long RECENT_EMERGENCY_CALL_THRESHOLD_MS = 1000 * 60 * 60 * 24 * 2;
+ private static final String HIDE_BLOCKED_CALLS_PREF_KEY = "hide_blocked_calls";
+ // Pref key for storing the time of end of the last emergency call in milliseconds after epoch.
+ private static final String LAST_EMERGENCY_CALL_MS_PREF_KEY = "last_emergency_call_ms";
+
+ // Pref key for storing whether a notification has been dispatched to notify the user that call
+ // blocking has been disabled because of a recent emergency call.
+ private static final String NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY =
+ "notified_call_blocking_disabled_by_emergency_call";
+
+ public static final String CALL_BLOCKING_NOTIFICATION_TAG = "call_blocking";
+ public static final int CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_NOTIFICATION_ID = 10;
+
/**
* Used for testing to specify that a custom threshold should be used instead of the default.
* This custom threshold will only be used when setting this log tag to VERBOSE:
@@ -256,7 +270,7 @@ public class FilteredNumbersUtil {
return false;
}
return PreferenceManager.getDefaultSharedPreferences(context)
- .getBoolean(FilteredNumbersUtil.HIDE_BLOCKED_CALLS_PREF_KEY, false);
+ .getBoolean(HIDE_BLOCKED_CALLS_PREF_KEY, false);
}
public static void setShouldHideBlockedCalls(Context context, boolean shouldHide) {
@@ -275,7 +289,7 @@ public class FilteredNumbersUtil {
}
Long lastEmergencyCallTime = PreferenceManager.getDefaultSharedPreferences(context)
- .getLong(LAST_EMERGENCY_CALL_PREF_KEY, 0);
+ .getLong(LAST_EMERGENCY_CALL_MS_PREF_KEY, 0);
if (lastEmergencyCallTime == 0) {
return false;
}
@@ -288,14 +302,64 @@ public class FilteredNumbersUtil {
if (context == null) {
return;
}
+
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
- .putLong(LAST_EMERGENCY_CALL_PREF_KEY, System.currentTimeMillis())
+ .putLong(LAST_EMERGENCY_CALL_MS_PREF_KEY, System.currentTimeMillis())
+ .putBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, false)
.apply();
+
+ maybeNotifyCallBlockingDisabled(context);
+ }
+
+ public static void maybeNotifyCallBlockingDisabled(final Context context) {
+ // Skip if the user has already received a notification for the most recent emergency call.
+ if (PreferenceManager.getDefaultSharedPreferences(context)
+ .getBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, false)) {
+ return;
+ }
+
+ // If the user has blocked numbers, notify that call blocking is temporarily disabled.
+ FilteredNumberAsyncQueryHandler queryHandler =
+ new FilteredNumberAsyncQueryHandler(context.getContentResolver());
+ queryHandler.hasBlockedNumbersAsync(new OnHasBlockedNumbersListener() {
+ @Override
+ public void onHasBlockedNumbers(boolean hasBlockedNumbers) {
+ if (context == null || !hasBlockedNumbers) {
+ return;
+ }
+
+ NotificationManager notificationManager = (NotificationManager)
+ context.getSystemService(Context.NOTIFICATION_SERVICE);
+ Notification.Builder builder = new Notification.Builder(context)
+ .setSmallIcon(R.drawable.ic_block_24dp)
+ .setContentTitle(context.getString(
+ R.string.call_blocking_disabled_notification_title))
+ .setContentText(context.getString(
+ R.string.call_blocking_disabled_notification_text));
+
+ final Intent contentIntent =
+ new Intent(context, ManageBlockedNumbersActivity.class);
+ builder.setContentIntent(PendingIntent.getActivity(
+ context, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT));
+
+ notificationManager.notify(
+ CALL_BLOCKING_NOTIFICATION_TAG,
+ CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_NOTIFICATION_ID,
+ builder.build());
+
+ // Record that the user has been notified for this emergency call.
+ PreferenceManager.getDefaultSharedPreferences(context)
+ .edit()
+ .putBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, true)
+ .apply();
+ }
+ });
}
public static boolean canBlockNumber(Context context, String number) {
- return !PhoneNumberUtils.isEmergencyNumber(number) && !TextUtils.isEmpty(number);
+ return !TextUtils.isEmpty(number) && !PhoneNumberUtils.isEmergencyNumber(number)
+ && !PhoneNumberHelper.isUriNumber(number);
}
private static long getRecentEmergencyCallThresholdMs(Context context) {
diff --git a/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java b/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java
index f785cf77a..109fd97b5 100644
--- a/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java
+++ b/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java
@@ -120,7 +120,7 @@ public class ManageBlockedNumbersActivity extends AppCompatActivity
@Override
public boolean isActionBarShowing() {
- return true;
+ return false;
}
@Override
@@ -135,11 +135,11 @@ public class ManageBlockedNumbersActivity extends AppCompatActivity
@Override
public int getActionBarHideOffset() {
- return getSupportActionBar().getHideOffset();
+ return 0;
}
@Override
public int getActionBarHeight() {
- return getSupportActionBar().getHeight();
+ return 0;
}
}
diff --git a/src/com/android/dialer/filterednumber/ViewNumbersToImportFragment.java b/src/com/android/dialer/filterednumber/ViewNumbersToImportFragment.java
index 947dc6793..9912416ec 100644
--- a/src/com/android/dialer/filterednumber/ViewNumbersToImportFragment.java
+++ b/src/com/android/dialer/filterednumber/ViewNumbersToImportFragment.java
@@ -72,6 +72,10 @@ public class ViewNumbersToImportFragment extends ListFragment
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
actionBar.setTitle(R.string.import_send_to_voicemail_numbers_label);
+ actionBar.setDisplayShowCustomEnabled(false);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ actionBar.setDisplayShowTitleEnabled(true);
getActivity().findViewById(R.id.cancel_button).setOnClickListener(this);
getActivity().findViewById(R.id.import_button).setOnClickListener(this);