diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-01-09 16:40:28 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-01-09 16:40:28 +0000 |
commit | 8c19b0ac8f79eb7f653ee3e07018ca7342f4e190 (patch) | |
tree | 92e2a480370fd53fdb210d1035a6c3d666628819 /java/com/android/dialer/calllog/ui | |
parent | 455a7c27d5c5d4c25236d940f088a25a5bf57c2a (diff) | |
parent | 517fbff5c15c9270323b4099a39514d2487eec99 (diff) |
Merge changes Iddf5ef33,I1b718e30,I0c7386f6,I81069948,I3bec477d, ...
* changes:
Update strings for Duo "Set up" and "Invite" buttons
Hide emergency calls in the call log
Simplifying implementation of the coalescing logic in the new call log.
Updating Dialer v16 licenses.
Use ContactsContract.PhoneLookup for invalid numbers in Cp2PhoneLookup.
Add RTT call chat window.
Updated T9 search bolding to include wrapping to the next word.
Initial setup of voicemail error messages
Automated rollback of changelist 178323108
Add "delete" option in the 3-dot menu of the new call log
Diffstat (limited to 'java/com/android/dialer/calllog/ui')
3 files changed, 128 insertions, 0 deletions
diff --git a/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java b/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java new file mode 100644 index 000000000..ac2e3b3da --- /dev/null +++ b/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.calllog.ui.menu; + +import android.Manifest.permission; +import android.content.Context; +import android.provider.CallLog; +import android.provider.CallLog.Calls; +import android.support.annotation.Nullable; +import android.support.annotation.RequiresPermission; +import com.android.dialer.CoalescedIds; +import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.DialerExecutor.Worker; +import com.android.dialer.common.concurrent.DialerExecutorComponent; +import com.android.dialer.common.database.Selection; +import com.android.dialer.contactactions.ContactActionModule; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; + +/** {@link ContactActionModule} for deleting a call log item in the new call log. */ +public final class DeleteCallLogItemModule implements ContactActionModule { + private static final String TAG = DeleteCallLogItemModule.class.getName(); + + private final Context context; + private final CoalescedIds coalescedIds; + + public DeleteCallLogItemModule(Context context, CoalescedIds coalescedIds) { + this.context = context; + this.coalescedIds = coalescedIds; + } + + @Override + public int getStringId() { + return R.string.delete; + } + + @Override + public int getDrawableId() { + return R.drawable.quantum_ic_delete_vd_theme_24; + } + + @Override + public boolean onClick() { + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new CallLogItemDeletionWorker(context)) + .build() + .executeSerial(coalescedIds); + return true; + } + + /** + * A {@link Worker} that deletes a call log item. + * + * <p>It takes as input the IDs of all call log records that are coalesced into the item to be + * deleted. + */ + private static class CallLogItemDeletionWorker implements Worker<CoalescedIds, Void> { + private final WeakReference<Context> contextWeakReference; + + CallLogItemDeletionWorker(Context context) { + contextWeakReference = new WeakReference<>(context); + } + + @Nullable + @Override + @RequiresPermission(value = permission.WRITE_CALL_LOG) + public Void doInBackground(CoalescedIds coalescedIds) throws Throwable { + Context context = contextWeakReference.get(); + if (context == null) { + LogUtil.e(TAG, "Unable to delete an call log item due to null context."); + return null; + } + + Selection selection = + Selection.builder() + .and(Selection.column(CallLog.Calls._ID).in(getCallLogIdsAsStrings(coalescedIds))) + .build(); + int numRowsDeleted = + context + .getContentResolver() + .delete(Calls.CONTENT_URI, selection.getSelection(), selection.getSelectionArgs()); + + if (numRowsDeleted != coalescedIds.getCoalescedIdCount()) { + LogUtil.e( + TAG, + "Deleting call log item is unsuccessful. %d of %d rows are deleted.", + numRowsDeleted, + coalescedIds.getCoalescedIdCount()); + } + + return null; + } + + private static List<String> getCallLogIdsAsStrings(CoalescedIds coalescedIds) { + Assert.checkArgument(coalescedIds.getCoalescedIdCount() > 0); + + List<String> idStrings = new ArrayList<>(coalescedIds.getCoalescedIdCount()); + + for (long callLogId : coalescedIds.getCoalescedIdList()) { + idStrings.add(String.valueOf(callLogId)); + } + + return idStrings; + } + } +} diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java index d62cc2082..3d667fc79 100644 --- a/java/com/android/dialer/calllog/ui/menu/Modules.java +++ b/java/com/android/dialer/calllog/ui/menu/Modules.java @@ -64,6 +64,8 @@ final class Modules { // it use a ContactPrimaryActionInfo instead? addModuleForAccessingCallDetails(context, modules, row); + modules.add(new DeleteCallLogItemModule(context, row.coalescedIds())); + return modules; } diff --git a/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml b/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml index 46fbae3bc..7c1835f1b 100644 --- a/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml +++ b/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml @@ -21,4 +21,7 @@ can view details for the call log entry. [CHAR LIMIT=30] --> <string name="call_details_menu_label">Call details</string> + <!-- Option displayed in call log to delete a call log item. [CHAR LIMIT=30] --> + <string name="delete">Delete</string> + </resources>
\ No newline at end of file |