diff options
Diffstat (limited to 'src/com')
9 files changed, 143 insertions, 26 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index b3957233c..01af982f3 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -214,8 +214,7 @@ public class CallLogAdapter extends GroupingListAdapter // Only expand if actions are not already expanded, because triggering the expand // function on clicks causes the action views to lose the focus indicator. CallLogListItemViewHolder viewHolder = (CallLogListItemViewHolder) host.getTag(); - if (mVoicemailPlaybackPresenter == null && - mCurrentlyExpandedPosition != viewHolder.getAdapterPosition()) { + if (mCurrentlyExpandedPosition != viewHolder.getAdapterPosition()) { expandViewHolderActions((CallLogListItemViewHolder) host.getTag()); } } diff --git a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java index db52e3134..a8fa06ded 100644 --- a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java +++ b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java @@ -78,6 +78,14 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler { public void onUnblockComplete(int rows, ContentValues values); } + public interface OnHasBlockedNumbersListener { + /** + * @param hasBlockedNumbers {@code true} if any blocked numbers are stored. + * {@code false} otherwise. + */ + public void onHasBlockedNumbers(boolean hasBlockedNumbers); + } + @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { if (cookie != null) { @@ -120,6 +128,21 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler { null, null, null); } + public final void hasBlockedNumbersAsync(final OnHasBlockedNumbersListener listener) { + startQuery(NO_TOKEN, + new Listener() { + @Override + protected void onQueryComplete(int token, Object cookie, Cursor cursor) { + listener.onHasBlockedNumbers(cursor.getCount() > 0); + } + }, + getContentUri(null), + new String[]{ FilteredNumberColumns._ID }, + FilteredNumberColumns.TYPE + "=" + FilteredNumberTypes.BLOCKED_NUMBER, + null, + null); + } + /** * Check if the number + country iso given has been blocked. * This method normalizes the number for the lookup if normalizedNumber is null. 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); diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java index 8fc6f7adb..852e7c916 100644 --- a/src/com/android/dialer/list/BlockedListSearchFragment.java +++ b/src/com/android/dialer/list/BlockedListSearchFragment.java @@ -15,13 +15,11 @@ */ package com.android.dialer.list; -import android.content.ContentUris; -import android.content.ContentValues; -import android.net.Uri; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.text.Editable; +import android.text.TextUtils; import android.text.TextWatcher; import android.util.Log; import android.util.TypedValue; @@ -31,7 +29,6 @@ import android.widget.EditText; import android.widget.Toast; import com.android.contacts.common.GeoUtil; -import com.android.contacts.common.dialog.IndeterminateProgressDialog; import com.android.contacts.common.list.ContactEntryListAdapter; import com.android.contacts.common.list.ContactListItemView; import com.android.dialer.R; @@ -45,9 +42,12 @@ public class BlockedListSearchFragment extends RegularSearchFragment implements FilterNumberDialogFragment.Callback { private static final String TAG = BlockedListSearchFragment.class.getSimpleName(); + private static final String KEY_SEARCH_QUERY = "search_query"; + private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; private EditText mSearchView; + private String mSearchQuery; private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() { @Override @@ -56,7 +56,8 @@ public class BlockedListSearchFragment extends RegularSearchFragment @Override public void onTextChanged(CharSequence s, int start, int before, int count) { - setQueryString(s.toString(), false); + mSearchQuery = s.toString(); + setQueryString(mSearchQuery, false); } @Override @@ -76,7 +77,6 @@ public class BlockedListSearchFragment extends RegularSearchFragment } }; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -86,6 +86,9 @@ public class BlockedListSearchFragment extends RegularSearchFragment mFilteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler( getContext().getContentResolver()); + if (savedInstanceState != null) { + mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY); + } } @Override @@ -94,8 +97,6 @@ public class BlockedListSearchFragment extends RegularSearchFragment ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); actionBar.setCustomView(R.layout.search_edittext); - actionBar.setBackgroundDrawable(null); - actionBar.setElevation(0); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowHomeEnabled(false); @@ -104,21 +105,37 @@ public class BlockedListSearchFragment extends RegularSearchFragment .getCustomView().findViewById(R.id.search_view_container); searchEditTextLayout.expand(false, true); searchEditTextLayout.setCallback(mSearchLayoutCallback); + searchEditTextLayout.setBackgroundDrawable(null); mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view); mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); mSearchView.setHint(R.string.block_number_search_hint); + searchEditTextLayout.findViewById(R.id.search_box_expanded) + .setBackgroundColor(getContext().getResources().getColor(android.R.color.white)); + + if (!TextUtils.isEmpty(mSearchQuery)) { + mSearchView.setText(mSearchQuery); + } + // TODO: Don't set custom text size; use default search text size. mSearchView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.blocked_number_search_text_size)); } @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString(KEY_SEARCH_QUERY, getAdapter().getQueryString()); + } + + @Override protected ContactEntryListAdapter createListAdapter() { BlockedListSearchAdapter adapter = new BlockedListSearchAdapter(getActivity()); adapter.setDisplayPhotos(true); - adapter.setUseCallableUri(usesCallableUri()); + // Don't show SIP addresses. + adapter.setUseCallableUri(false); + adapter.setQueryString(mSearchQuery); return adapter; } diff --git a/src/com/android/dialer/widget/SearchEditTextLayout.java b/src/com/android/dialer/widget/SearchEditTextLayout.java index 544749f33..4f100dc44 100644 --- a/src/com/android/dialer/widget/SearchEditTextLayout.java +++ b/src/com/android/dialer/widget/SearchEditTextLayout.java @@ -230,7 +230,6 @@ public class SearchEditTextLayout extends FrameLayout { setElevation(0); setPaddingRelative(paddingStart, paddingTop, paddingEnd, paddingBottom); - setElevation(0); if (requestFocus) { mSearchView.requestFocus(); } |