diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-02-28 02:25:26 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-02-28 02:25:26 +0000 |
commit | 37434b495f1e53612d4279288f6fa3ac5e795615 (patch) | |
tree | f9427ee9449664e50d8974d1fba2bae06a62f08c /java/com/android/dialer/calllog/ui | |
parent | 9a2265a70b2d2e46391aa37e118f8ae6e5b5dbdf (diff) | |
parent | f80d8afdb0f5ef6d24b8bb76442cab8cef38da8f (diff) |
Merge changes I9ab50a7a,I8a57b632
* changes:
Do not show the voicemail tab if the VM toggle is turned off.
Internal cleanup for the new UI's bottom sheet.
Diffstat (limited to 'java/com/android/dialer/calllog/ui')
4 files changed, 69 insertions, 55 deletions
diff --git a/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java b/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java index ac2e3b3da..ad5671e45 100644 --- a/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java +++ b/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java @@ -28,13 +28,13 @@ 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 com.android.dialer.historyitemactions.HistoryItemActionModule; 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 { +/** {@link HistoryItemActionModule} for deleting a call log item in the new call log. */ +public final class DeleteCallLogItemModule implements HistoryItemActionModule { private static final String TAG = DeleteCallLogItemModule.class.getName(); private final Context context; diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java index d86c04dd5..147972710 100644 --- a/java/com/android/dialer/calllog/ui/menu/Modules.java +++ b/java/com/android/dialer/calllog/ui/menu/Modules.java @@ -25,36 +25,42 @@ import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.calllogutils.CallLogContactTypes; import com.android.dialer.calllogutils.PhoneNumberDisplayUtil; -import com.android.dialer.contactactions.ContactActionModule; -import com.android.dialer.contactactions.DividerModule; -import com.android.dialer.contactactions.IntentModule; -import com.android.dialer.contactactions.SharedModules; import com.android.dialer.dialercontact.DialerContact; +import com.android.dialer.historyitemactions.DividerModule; +import com.android.dialer.historyitemactions.HistoryItemActionModule; +import com.android.dialer.historyitemactions.IntentModule; +import com.android.dialer.historyitemactions.SharedModules; import com.android.dialer.logging.ReportingLocation; import com.android.dialer.phonenumberutil.PhoneNumberHelper; import com.android.dialer.telecom.TelecomUtil; import com.google.common.base.Optional; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** * Configures the modules for the bottom sheet; these are the rows below the top row (primary * action) in the bottom sheet. */ +@SuppressWarnings("Guava") final class Modules { - static List<ContactActionModule> fromRow(Context context, CoalescedRow row) { + static List<HistoryItemActionModule> fromRow(Context context, CoalescedRow row) { // Conditionally add each module, which are items in the bottom sheet's menu. - List<ContactActionModule> modules = new ArrayList<>(); + List<HistoryItemActionModule> modules = new ArrayList<>(); String normalizedNumber = row.number().getNormalizedNumber(); boolean canPlaceCalls = PhoneNumberHelper.canPlaceCallsTo(normalizedNumber, row.numberPresentation()); if (canPlaceCalls) { - addModuleForCalls(context, modules, row, normalizedNumber); - SharedModules.maybeAddModuleForSendingTextMessage( - context, modules, normalizedNumber, row.numberAttributes().getIsBlocked()); + modules.addAll(createModulesForCalls(context, row, normalizedNumber)); + Optional<HistoryItemActionModule> moduleForSendingTextMessage = + SharedModules.createModuleForSendingTextMessage( + context, normalizedNumber, row.numberAttributes().getIsBlocked()); + if (moduleForSendingTextMessage.isPresent()) { + modules.add(moduleForSendingTextMessage.get()); + } } if (!modules.isEmpty()) { @@ -65,45 +71,52 @@ final class Modules { // TODO(zachh): Module for CallComposer. if (canPlaceCalls) { - SharedModules.maybeAddModuleForAddingToContacts( - context, - modules, - row.number(), - row.numberAttributes().getName(), - row.numberAttributes().getLookupUri(), - row.numberAttributes().getIsBlocked(), - row.numberAttributes().getIsSpam()); - SharedModules.addModulesHandlingBlockedOrSpamNumber( - context, - modules, - row.number().getNormalizedNumber(), - row.number().getCountryIso(), - row.callType(), - row.numberAttributes().getIsBlocked(), - row.numberAttributes().getIsSpam(), - ReportingLocation.Type.CALL_LOG_HISTORY); - SharedModules.maybeAddModuleForCopyingNumber(context, modules, normalizedNumber); + Optional<HistoryItemActionModule> moduleForAddingToContacts = + SharedModules.createModuleForAddingToContacts( + context, + row.number(), + row.numberAttributes().getName(), + row.numberAttributes().getLookupUri(), + row.numberAttributes().getIsBlocked(), + row.numberAttributes().getIsSpam()); + if (moduleForAddingToContacts.isPresent()) { + modules.add(moduleForAddingToContacts.get()); + } + + modules.addAll( + SharedModules.createModulesHandlingBlockedOrSpamNumber( + context, + row.number().getNormalizedNumber(), + row.number().getCountryIso(), + row.callType(), + row.numberAttributes().getIsBlocked(), + row.numberAttributes().getIsSpam(), + ReportingLocation.Type.CALL_LOG_HISTORY)); + + Optional<HistoryItemActionModule> moduleForCopyingNumber = + SharedModules.createModuleForCopyingNumber(context, normalizedNumber); + if (moduleForCopyingNumber.isPresent()) { + modules.add(moduleForCopyingNumber.get()); + } } // TODO(zachh): Revisit if DialerContact is the best thing to pass to CallDetails; could - // it use a ContactPrimaryActionInfo instead? - addModuleForAccessingCallDetails(context, modules, row); + // it use a HistoryItemPrimaryActionInfo instead? + modules.add(createModuleForAccessingCallDetails(context, row)); modules.add(new DeleteCallLogItemModule(context, row.coalescedIds())); return modules; } - private static void addModuleForCalls( - Context context, - List<ContactActionModule> modules, - CoalescedRow row, - String normalizedNumber) { + private static List<HistoryItemActionModule> createModulesForCalls( + Context context, CoalescedRow row, String normalizedNumber) { // Don't add call options if a number is blocked. if (row.numberAttributes().getIsBlocked()) { - return; + return Collections.emptyList(); } + List<HistoryItemActionModule> modules = new ArrayList<>(); PhoneAccountHandle phoneAccountHandle = TelecomUtil.composePhoneAccountHandle( row.phoneAccountComponentName(), row.phoneAccountId()); @@ -123,24 +136,25 @@ final class Modules { // TODO(zachh): Also show video option if the call log entry is for an audio call but video // capabilities are present? + + return modules; } - private static void addModuleForAccessingCallDetails( - Context context, List<ContactActionModule> modules, CoalescedRow row) { + private static HistoryItemActionModule createModuleForAccessingCallDetails( + Context context, CoalescedRow row) { boolean canReportAsInvalidNumber = row.numberAttributes().getCanReportAsInvalidNumber(); boolean canSupportAssistedDialing = !TextUtils.isEmpty(row.numberAttributes().getLookupUri()); - modules.add( - new IntentModule( + return new IntentModule( + context, + CallDetailsActivity.newInstance( context, - CallDetailsActivity.newInstance( - context, - row.coalescedIds(), - createDialerContactFromRow(context, row), - canReportAsInvalidNumber, - canSupportAssistedDialing), - R.string.call_details_menu_label, - R.drawable.quantum_ic_info_outline_vd_theme_24)); + row.coalescedIds(), + createDialerContactFromRow(context, row), + canReportAsInvalidNumber, + canSupportAssistedDialing), + R.string.call_details_menu_label, + R.drawable.quantum_ic_info_outline_vd_theme_24); } private static DialerContact createDialerContactFromRow(Context context, CoalescedRow row) { diff --git a/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java b/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java index 02724e628..9efe907e3 100644 --- a/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java +++ b/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java @@ -22,8 +22,8 @@ import android.view.View; import com.android.dialer.calllog.CallLogComponent; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.common.concurrent.DefaultFutureCallback; -import com.android.dialer.contactactions.ContactActionBottomSheet; import com.android.dialer.glidephotomanager.GlidePhotoManager; +import com.android.dialer.historyitemactions.HistoryItemActionBottomSheet; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; @@ -34,7 +34,7 @@ public final class NewCallLogMenu { public static View.OnClickListener createOnClickListener( Context context, CoalescedRow row, GlidePhotoManager glidePhotoManager) { return view -> { - ContactActionBottomSheet.show( + HistoryItemActionBottomSheet.show( context, PrimaryAction.fromRow(context, row), Modules.fromRow(context, row), diff --git a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java index 92a8453f4..de4a70c30 100644 --- a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java +++ b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java @@ -22,14 +22,14 @@ import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.calllogutils.CallLogEntryText; import com.android.dialer.calllogutils.CallLogIntents; import com.android.dialer.calllogutils.NumberAttributesConverter; -import com.android.dialer.contactactions.ContactPrimaryActionInfo; +import com.android.dialer.historyitemactions.HistoryItemPrimaryActionInfo; /** Configures the primary action row (top row) for the bottom sheet. */ final class PrimaryAction { - static ContactPrimaryActionInfo fromRow(Context context, CoalescedRow row) { + static HistoryItemPrimaryActionInfo fromRow(Context context, CoalescedRow row) { CharSequence primaryText = CallLogEntryText.buildPrimaryText(context, row); - return ContactPrimaryActionInfo.builder() + return HistoryItemPrimaryActionInfo.builder() .setNumber(row.number()) .setPhotoInfo( NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) |