diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-03-01 08:23:08 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-03-01 08:23:08 +0000 |
commit | 511786627ba3e4ad121b23219d1e4ce6daee6ca1 (patch) | |
tree | 91d6fe3a68a328bc09efa34033d2815e04be5f1d | |
parent | 987a859e3f68318c675cbca79be595e22062b375 (diff) | |
parent | 49a49630a62ca66f9c1d8aa85d9180ad56b75374 (diff) | |
download | android_packages_apps_Dialer-511786627ba3e4ad121b23219d1e4ce6daee6ca1.tar.gz android_packages_apps_Dialer-511786627ba3e4ad121b23219d1e4ce6daee6ca1.tar.bz2 android_packages_apps_Dialer-511786627ba3e4ad121b23219d1e4ce6daee6ca1.zip |
Snap for 4628106 from 49a49630a62ca66f9c1d8aa85d9180ad56b75374 to pi-release
Change-Id: I045a721b4a8f5af72576f56477acbff2aee98a94
26 files changed, 390 insertions, 199 deletions
diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java index b8fd57159..37b241bcd 100644 --- a/java/com/android/dialer/app/DialtactsActivity.java +++ b/java/com/android/dialer/app/DialtactsActivity.java @@ -1454,6 +1454,12 @@ public class DialtactsActivity extends TransactionSafeActivity } @Override + public boolean shouldShowDialpadChooser() { + // Show the dialpad chooser if we're in a call + return true; + } + + @Override public void onSearchListTouch() { if (isDialpadShown) { PerformanceReport.recordClick(UiAction.Type.CLOSE_DIALPAD); diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java index 11c249944..7e49cc965 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -222,18 +222,6 @@ public class CallLogFragment extends Fragment final Activity activity = getActivity(); final ContentResolver resolver = activity.getContentResolver(); callLogQueryHandler = new CallLogQueryHandler(activity, resolver, this, logLimit); - - if (PermissionsUtil.hasCallLogReadPermissions(getContext())) { - resolver.registerContentObserver(CallLog.CONTENT_URI, true, callLogObserver); - } else { - LogUtil.w("CallLogFragment.onCreate", "call log permission not available"); - } - if (PermissionsUtil.hasContactsReadPermissions(getContext())) { - resolver.registerContentObserver( - ContactsContract.Contacts.CONTENT_URI, true, contactsObserver); - } else { - LogUtil.w("CallLogFragment.onCreate", "contacts permission not available."); - } setHasOptionsMenu(true); } @@ -412,6 +400,19 @@ public class CallLogFragment extends Fragment updateEmptyMessage(callTypeFilter); } + ContentResolver resolver = getActivity().getContentResolver(); + if (PermissionsUtil.hasCallLogReadPermissions(getContext())) { + resolver.registerContentObserver(CallLog.CONTENT_URI, true, callLogObserver); + } else { + LogUtil.w("CallLogFragment.onCreate", "call log permission not available"); + } + if (PermissionsUtil.hasContactsReadPermissions(getContext())) { + resolver.registerContentObserver( + ContactsContract.Contacts.CONTENT_URI, true, contactsObserver); + } else { + LogUtil.w("CallLogFragment.onCreate", "contacts permission not available."); + } + this.hasReadCallLogPermission = hasReadCallLogPermission; /* @@ -432,6 +433,8 @@ public class CallLogFragment extends Fragment @Override public void onPause() { LogUtil.enterBlock("CallLogFragment.onPause"); + getActivity().getContentResolver().unregisterContentObserver(callLogObserver); + getActivity().getContentResolver().unregisterContentObserver(contactsObserver); if (getUserVisibleHint()) { onNotVisible(); } @@ -465,9 +468,6 @@ public class CallLogFragment extends Fragment if (adapter != null) { adapter.changeCursor(null); } - - getActivity().getContentResolver().unregisterContentObserver(callLogObserver); - getActivity().getContentResolver().unregisterContentObserver(contactsObserver); super.onDestroy(); } diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java index 82c98156b..1f27e5b69 100644 --- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java +++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java @@ -329,10 +329,8 @@ public class PhoneCallDetailsHelper // Use a custom title to prevent truncation, sigh TextView title = new TextView(context); - title.setText( - ratingValue == TranscriptionRatingValue.GOOD_TRANSCRIPTION - ? R.string.voicemail_donation_promo_good_title - : R.string.voicemail_donation_promo_bad_title); + title.setText(R.string.voicemail_donation_promo_title); + title.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL)); title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20); title.setTextColor(ContextCompat.getColor(context, R.color.dialer_primary_text_color)); @@ -383,7 +381,7 @@ public class PhoneCallDetailsHelper CharSequence content = context.getString(R.string.voicemail_donation_promo_content); CharSequence learnMore = context.getString(R.string.voicemail_donation_promo_learn_more); String learnMoreUrl = context.getString(R.string.voicemail_donation_promo_learn_more_url); - SpannableString span = new SpannableString(content + "\n" + learnMore); + SpannableString span = new SpannableString(content + " " + learnMore); int end = span.length(); int start = end - learnMore.length(); span.setSpan(new URLSpan(learnMoreUrl), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); diff --git a/java/com/android/dialer/app/res/layout/call_log_list_item.xml b/java/com/android/dialer/app/res/layout/call_log_list_item.xml index 1b776b42c..acaa82085 100644 --- a/java/com/android/dialer/app/res/layout/call_log_list_item.xml +++ b/java/com/android/dialer/app/res/layout/call_log_list_item.xml @@ -202,6 +202,7 @@ android:id="@+id/voicemail_transcription_rating_good" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="@string/description_rating_good" android:gravity="end|center_vertical" android:focusable="true" android:src="@drawable/quantum_ic_thumb_up_grey600_24"/> @@ -211,6 +212,7 @@ android:id="@+id/voicemail_transcription_rating_bad" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="@string/description_rating_bad" android:gravity="end|center_vertical" android:focusable="true" android:src="@drawable/quantum_ic_thumb_down_grey600_24"/> diff --git a/java/com/android/dialer/app/res/values/strings.xml b/java/com/android/dialer/app/res/values/strings.xml index 5773a0cd7..7332c31e3 100644 --- a/java/com/android/dialer/app/res/values/strings.xml +++ b/java/com/android/dialer/app/res/values/strings.xml @@ -675,19 +675,15 @@ [CHAR LIMIT=64] --> <string name="voicemail_transcription_failed_no_speech">Transcript not available. No speech detected.</string> - <!-- Title of voicemail donation promo dialog, show after clicking a 'thumbs up' rating icon - [CHAR LIMIT=64] --> - <string name="voicemail_donation_promo_good_title">Thanks! Would you like to help us improve transcriptions?</string> - - <!-- Title of voicemail donation promo dialog, show after clicking a 'thumbs up' rating icon - [CHAR LIMIT=64] --> - <string name="voicemail_donation_promo_bad_title">Sorry. Would you like to help us improve transcriptions?</string> + <!-- Title of voicemail donation promo dialog + [CHAR LIMIT=64] --> + <string name="voicemail_donation_promo_title">Help improve transcription accuracy?</string> <!-- Content of voicemail donation promo dialog [CHAR LIMIT=NONE] --> <string name="voicemail_donation_promo_content"> - Let Google review your voicemail messages to improve transcription quality. - For voicemail transcription analysis, your voicemail messages are stored anonymously. + Let Google review this and future voicemail messages with transcripts. + They\'ll be stored anonymously. Change Settings any time. </string> <!-- Text for a 'learn more' link at the end of the voicemail donation promo dialog content --> @@ -710,6 +706,14 @@ <!-- Message displayed after user has rated a voicemail transcription [CHAR LIMIT=30] --> <string name="voicemail_transcription_rating_thanks">Thanks for your feedback</string> + <!-- Describes the thumbs up, 'good' transcription button. Read by TalkBack. + [CHAR LIMIT=NONE] --> + <string name="description_rating_good">Like</string> + + <!-- Describes the thumbs down, 'bad' transcription button. Read by TalkBack. + [CHAR LIMIT=NONE] --> + <string name="description_rating_bad">Dislike</string> + <!-- Button text to prompt a user to open an sms conversation [CHAR LIMIT=NONE] --> <string name="view_conversation">View</string> diff --git a/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogNotifier.java b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogNotifier.java index fd81568a8..58e1988fb 100644 --- a/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogNotifier.java +++ b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogNotifier.java @@ -20,7 +20,7 @@ import android.content.Context; import android.content.Intent; import android.support.v4.content.LocalBroadcastManager; import com.android.dialer.common.LogUtil; -import com.android.dialer.logging.ReportingLocation; +import com.android.dialer.protos.ProtoParsers; /** * Notifies that a dialog for blocking a number and/or marking it as spam/not spam should be shown. @@ -31,20 +31,9 @@ public final class ShowBlockReportSpamDialogNotifier { /** * Notifies that a dialog for blocking a number and optionally report it as spam should be shown. - * - * @param context Context - * @param normalizedNumber The number to be blocked/marked as spam - * @param countryIso The ISO 3166-1 two letters country code for the number - * @param callType Call type defined in {@link android.provider.CallLog.Calls} - * @param reportingLocation The location where the number is reported. See {@link - * ReportingLocation.Type}. */ public static void notifyShowDialogToBlockNumberAndOptionallyReportSpam( - Context context, - String normalizedNumber, - String countryIso, - int callType, - ReportingLocation.Type reportingLocation) { + Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo) { LogUtil.enterBlock( "ShowBlockReportSpamDialogNotifier.notifyShowDialogToBlockNumberAndOptionallyReportSpam"); @@ -52,40 +41,21 @@ public final class ShowBlockReportSpamDialogNotifier { intent.setAction( ShowBlockReportSpamDialogReceiver .ACTION_SHOW_DIALOG_TO_BLOCK_NUMBER_AND_OPTIONALLY_REPORT_SPAM); - - intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_NUMBER, normalizedNumber); - intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_COUNTRY_ISO, countryIso); - intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_CALL_TYPE, callType); - intent.putExtra( - ShowBlockReportSpamDialogReceiver.EXTRA_REPORTING_LOCATION, reportingLocation.getNumber()); + ProtoParsers.put( + intent, ShowBlockReportSpamDialogReceiver.EXTRA_DIALOG_INFO, blockReportSpamDialogInfo); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); } - /** - * Notifies that a dialog for reporting a number as not spam should be shown. - * - * @param context Context - * @param normalizedNumber The number to be reported as not spam - * @param countryIso The ISO 3166-1 two letters country code for the number - * @param callType Call type defined in {@link android.provider.CallLog.Calls} - * @param reportingLocation The location where the number is reported. See {@link - * ReportingLocation.Type}. - */ + /** Notifies that a dialog for reporting a number as not spam should be shown. */ public static void notifyShowDialogToReportNotSpam( - Context context, - String normalizedNumber, - String countryIso, - int callType, - ReportingLocation.Type reportingLocation) { + Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo) { LogUtil.enterBlock("ShowBlockReportSpamDialogNotifier.notifyShowDialogToReportNotSpam"); Intent intent = new Intent(); intent.setAction(ShowBlockReportSpamDialogReceiver.ACTION_SHOW_DIALOG_TO_REPORT_NOT_SPAM); - intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_NUMBER, normalizedNumber); - intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_COUNTRY_ISO, countryIso); - intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_CALL_TYPE, callType); - intent.putExtra(ShowBlockReportSpamDialogReceiver.EXTRA_REPORTING_LOCATION, reportingLocation); + ProtoParsers.put( + intent, ShowBlockReportSpamDialogReceiver.EXTRA_DIALOG_INFO, blockReportSpamDialogInfo); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); } diff --git a/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java index 75b624198..f24bb1c06 100644 --- a/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java +++ b/java/com/android/dialer/blockreportspam/ShowBlockReportSpamDialogReceiver.java @@ -26,10 +26,9 @@ import com.android.dialer.blockreportspam.BlockReportSpamDialogs.OnConfirmListen import com.android.dialer.blockreportspam.BlockReportSpamDialogs.OnSpamDialogClickListener; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.logging.ContactSource; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; -import com.android.dialer.logging.ReportingLocation; +import com.android.dialer.protos.ProtoParsers; import com.android.dialer.spam.Spam; import com.android.dialer.spam.SpamComponent; import java.util.Locale; @@ -43,10 +42,7 @@ public final class ShowBlockReportSpamDialogReceiver extends BroadcastReceiver { static final String ACTION_SHOW_DIALOG_TO_BLOCK_NUMBER_AND_OPTIONALLY_REPORT_SPAM = "show_dialog_to_block_number_and_optionally_report_spam"; static final String ACTION_SHOW_DIALOG_TO_REPORT_NOT_SPAM = "show_dialog_to_report_not_spam"; - static final String EXTRA_NUMBER = "number"; - static final String EXTRA_COUNTRY_ISO = "country_iso"; - static final String EXTRA_CALL_TYPE = "call_type"; - static final String EXTRA_REPORTING_LOCATION = "reporting_location"; + static final String EXTRA_DIALOG_INFO = "dialog_info"; /** {@link FragmentManager} needed to show a {@link android.app.DialogFragment}. */ private final FragmentManager fragmentManager; @@ -85,19 +81,10 @@ public final class ShowBlockReportSpamDialogReceiver extends BroadcastReceiver { LogUtil.enterBlock( "ShowBlockReportSpamDialogReceiver.showDialogToBlockNumberAndOptionallyReportSpam"); - Assert.checkArgument(intent.hasExtra(EXTRA_NUMBER)); - Assert.checkArgument(intent.hasExtra(EXTRA_COUNTRY_ISO)); - Assert.checkArgument(intent.hasExtra(EXTRA_CALL_TYPE)); - Assert.checkArgument(intent.hasExtra(EXTRA_REPORTING_LOCATION)); - - String normalizedNumber = intent.getStringExtra(EXTRA_NUMBER); - String countryIso = intent.getStringExtra(EXTRA_COUNTRY_ISO); - int callType = intent.getIntExtra(EXTRA_CALL_TYPE, 0); - ReportingLocation.Type reportingLocation = - ReportingLocation.Type.forNumber( - intent.getIntExtra( - EXTRA_REPORTING_LOCATION, - ReportingLocation.Type.UNKNOWN_REPORTING_LOCATION.getNumber())); + Assert.checkArgument(intent.hasExtra(EXTRA_DIALOG_INFO)); + BlockReportSpamDialogInfo dialogInfo = + ProtoParsers.getTrusted( + intent, EXTRA_DIALOG_INFO, BlockReportSpamDialogInfo.getDefaultInstance()); Spam spam = SpamComponent.get(context).spam(); @@ -117,24 +104,27 @@ public final class ShowBlockReportSpamDialogReceiver extends BroadcastReceiver { DialerImpression.Type .REPORT_CALL_AS_SPAM_VIA_CALL_LOG_BLOCK_REPORT_SPAM_SENT_VIA_BLOCK_NUMBER_DIALOG); spam.reportSpamFromCallHistory( - normalizedNumber, - countryIso, - callType, - reportingLocation, - ContactSource.Type.UNKNOWN_SOURCE_TYPE /* TODO(a bug): Fix. */); + dialogInfo.getNormalizedNumber(), + dialogInfo.getCountryIso(), + dialogInfo.getCallType(), + dialogInfo.getReportingLocation(), + dialogInfo.getContactSource()); } // TODO(a bug): Block the number. Toast.makeText( context, - String.format(Locale.ENGLISH, "TODO: " + "Block number %s.", normalizedNumber), + String.format( + Locale.ENGLISH, + "TODO: " + "Block number %s.", + dialogInfo.getNormalizedNumber()), Toast.LENGTH_SHORT) .show(); }; // Create and show the dialog. BlockReportSpamDialogs.BlockReportSpamDialogFragment.newInstance( - normalizedNumber, + dialogInfo.getNormalizedNumber(), spam.isDialogReportSpamCheckedByDefault(), onSpamDialogClickListener, /* dismissListener = */ null) @@ -144,19 +134,10 @@ public final class ShowBlockReportSpamDialogReceiver extends BroadcastReceiver { private void showDialogToReportNotSpam(Context context, Intent intent) { LogUtil.enterBlock("ShowBlockReportSpamDialogReceiver.showDialogToReportNotSpam"); - Assert.checkArgument(intent.hasExtra(EXTRA_NUMBER)); - Assert.checkArgument(intent.hasExtra(EXTRA_COUNTRY_ISO)); - Assert.checkArgument(intent.hasExtra(EXTRA_CALL_TYPE)); - Assert.checkArgument(intent.hasExtra(EXTRA_REPORTING_LOCATION)); - - String normalizedNumber = intent.getStringExtra(EXTRA_NUMBER); - String countryIso = intent.getStringExtra(EXTRA_COUNTRY_ISO); - int callType = intent.getIntExtra(EXTRA_CALL_TYPE, 0); - ReportingLocation.Type reportingLocation = - ReportingLocation.Type.forNumber( - intent.getIntExtra( - EXTRA_REPORTING_LOCATION, - ReportingLocation.Type.UNKNOWN_REPORTING_LOCATION.getNumber())); + Assert.checkArgument(intent.hasExtra(EXTRA_DIALOG_INFO)); + BlockReportSpamDialogInfo dialogInfo = + ProtoParsers.getTrusted( + intent, EXTRA_DIALOG_INFO, BlockReportSpamDialogInfo.getDefaultInstance()); // Set up the positive listener for the dialog. OnConfirmListener onConfirmListener = @@ -168,17 +149,17 @@ public final class ShowBlockReportSpamDialogReceiver extends BroadcastReceiver { Logger.get(context) .logImpression(DialerImpression.Type.DIALOG_ACTION_CONFIRM_NUMBER_NOT_SPAM); spam.reportNotSpamFromCallHistory( - normalizedNumber, - countryIso, - callType, - reportingLocation, - ContactSource.Type.UNKNOWN_SOURCE_TYPE /* TODO(a bug): Fix. */); + dialogInfo.getNormalizedNumber(), + dialogInfo.getCountryIso(), + dialogInfo.getCallType(), + dialogInfo.getReportingLocation(), + dialogInfo.getContactSource()); } }; // Create & show the dialog. BlockReportSpamDialogs.ReportNotSpamDialogFragment.newInstance( - normalizedNumber, onConfirmListener, /* dismissListener = */ null) + dialogInfo.getNormalizedNumber(), onConfirmListener, /* dismissListener = */ null) .show(fragmentManager, BlockReportSpamDialogs.NOT_SPAM_DIALOG_TAG); } } diff --git a/java/com/android/dialer/blockreportspam/block_report_spam_dialog_info.proto b/java/com/android/dialer/blockreportspam/block_report_spam_dialog_info.proto new file mode 100644 index 000000000..70872c7e0 --- /dev/null +++ b/java/com/android/dialer/blockreportspam/block_report_spam_dialog_info.proto @@ -0,0 +1,34 @@ +syntax = "proto2"; + +option java_package = "com.android.dialer.blockreportspam"; +option java_multiple_files = true; +option optimize_for = LITE_RUNTIME; + + +package com.android.dialer.blockreportspam; + +import "java/com/android/dialer/logging/contact_source.proto"; +import "java/com/android/dialer/logging/reporting_location.proto"; + +// Contains information needed in dialogs that allow a user to block a number +// and/or report it as spam/not spam. +// Next ID: 6 +message BlockReportSpamDialogInfo { + // A dialer-normalized version of the number used in the dialogs. + // See DialerPhoneNumber#normalized_number. + optional string normalized_number = 1; + + // The ISO 3166-1 two letters country code of the number. + optional string country_iso = 2; + + // Type of the call to/from the number, as defined in + // android.provider.CallLog.Calls + optional int32 call_type = 3; + + // The location where the number is reported. + optional com.android.dialer.logging.ReportingLocation.Type + reporting_location = 4; + + // The source where contact info is associated with the number. + optional com.android.dialer.logging.ContactSource.Type contact_source = 5; +}
\ No newline at end of file diff --git a/java/com/android/dialer/calllog/database/contract/number_attributes.proto b/java/com/android/dialer/calllog/database/contract/number_attributes.proto index 594e6764c..e24f393f7 100644 --- a/java/com/android/dialer/calllog/database/contract/number_attributes.proto +++ b/java/com/android/dialer/calllog/database/contract/number_attributes.proto @@ -21,8 +21,10 @@ option optimize_for = LITE_RUNTIME; package com.android.dialer; +import "java/com/android/dialer/logging/contact_source.proto"; + // Information related to the phone number of the call. -// Next ID: 12 +// Next ID: 13 message NumberAttributes { // The name (which may be a person's name or business name, but not a number) // formatted exactly as it should appear to the user. If the user's locale or @@ -65,4 +67,7 @@ message NumberAttributes { // Whether the number is spam. optional bool is_spam = 11; + + // Source of the contact associated with the number. + optional com.android.dialer.logging.ContactSource.Type contact_source = 12; }
\ No newline at end of file diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java index 147972710..184f7abf0 100644 --- a/java/com/android/dialer/calllog/ui/menu/Modules.java +++ b/java/com/android/dialer/calllog/ui/menu/Modules.java @@ -20,6 +20,7 @@ import android.content.Context; import android.provider.CallLog.Calls; import android.telecom.PhoneAccountHandle; import android.text.TextUtils; +import com.android.dialer.blockreportspam.BlockReportSpamDialogInfo; import com.android.dialer.calldetails.CallDetailsActivity; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.calllog.model.CoalescedRow; @@ -83,15 +84,20 @@ final class Modules { modules.add(moduleForAddingToContacts.get()); } + BlockReportSpamDialogInfo blockReportSpamDialogInfo = + BlockReportSpamDialogInfo.newBuilder() + .setNormalizedNumber(row.number().getNormalizedNumber()) + .setCountryIso(row.number().getCountryIso()) + .setCallType(row.callType()) + .setReportingLocation(ReportingLocation.Type.CALL_LOG_HISTORY) + .setContactSource(row.numberAttributes().getContactSource()) + .build(); modules.addAll( SharedModules.createModulesHandlingBlockedOrSpamNumber( context, - row.number().getNormalizedNumber(), - row.number().getCountryIso(), - row.callType(), + blockReportSpamDialogInfo, row.numberAttributes().getIsBlocked(), - row.numberAttributes().getIsSpam(), - ReportingLocation.Type.CALL_LOG_HISTORY)); + row.numberAttributes().getIsSpam())); Optional<HistoryItemActionModule> moduleForCopyingNumber = SharedModules.createModuleForCopyingNumber(context, normalizedNumber); diff --git a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java index ceb8d57ce..a9376bb98 100644 --- a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java +++ b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java @@ -56,6 +56,7 @@ public final class NumberAttributesConverter { .setIsBlocked(phoneLookupInfoConsolidator.isBlocked()) .setIsSpam(phoneLookupInfoConsolidator.isSpam()) .setCanReportAsInvalidNumber(phoneLookupInfoConsolidator.canReportAsInvalidNumber()) - .setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isDefaultCp2InfoIncomplete()); + .setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isDefaultCp2InfoIncomplete()) + .setContactSource(phoneLookupInfoConsolidator.getContactSource()); } } diff --git a/java/com/android/dialer/dialpadview/DialpadFragment.java b/java/com/android/dialer/dialpadview/DialpadFragment.java index 680159057..f09333280 100644 --- a/java/com/android/dialer/dialpadview/DialpadFragment.java +++ b/java/com/android/dialer/dialpadview/DialpadFragment.java @@ -1312,7 +1312,9 @@ public class DialpadFragment extends Fragment * or ringing or dialing, or on hold). */ private boolean isPhoneInUse() { - return getContext() != null && TelecomUtil.isInManagedCall(getContext()); + return getContext() != null + && TelecomUtil.isInManagedCall(getContext()) + && FragmentUtils.getParentUnsafe(this, HostInterface.class).shouldShowDialpadChooser(); } /** @return true if the phone is a CDMA phone type */ @@ -1584,6 +1586,9 @@ public class DialpadFragment extends Fragment * unless there happens to be content showing. */ boolean onDialpadSpacerTouchWithEmptyQuery(); + + /** Returns true if this fragment's parent want the dialpad to show the dialpad chooser. */ + boolean shouldShowDialpadChooser(); } /** diff --git a/java/com/android/dialer/historyitemactions/SharedModules.java b/java/com/android/dialer/historyitemactions/SharedModules.java index 7cfee37bb..c0460862b 100644 --- a/java/com/android/dialer/historyitemactions/SharedModules.java +++ b/java/com/android/dialer/historyitemactions/SharedModules.java @@ -24,9 +24,9 @@ import android.support.annotation.Nullable; import android.text.TextUtils; import android.widget.Toast; import com.android.dialer.DialerPhoneNumber; +import com.android.dialer.blockreportspam.BlockReportSpamDialogInfo; import com.android.dialer.blockreportspam.ShowBlockReportSpamDialogNotifier; import com.android.dialer.clipboard.ClipboardUtils; -import com.android.dialer.logging.ReportingLocation; import com.android.dialer.util.IntentUtil; import com.android.dialer.util.UriUtils; import com.google.common.base.Optional; @@ -114,63 +114,42 @@ public class SharedModules { } /** - * Add modules related to blocking/unblocking a number and/or reporting it as spam/not spam. - * - * @param normalizedNumber The number to be blocked / unblocked / marked as spam/not spam - * @param countryIso The ISO 3166-1 two letters country code for the number - * @param callType Call type defined in {@link android.provider.CallLog.Calls} - * @param reportingLocation The location where the number is reported. See {@link - * ReportingLocation.Type}. + * Create modules related to blocking/unblocking a number and/or reporting it as spam/not spam. */ public static List<HistoryItemActionModule> createModulesHandlingBlockedOrSpamNumber( Context context, - String normalizedNumber, - String countryIso, - int callType, + BlockReportSpamDialogInfo blockReportSpamDialogInfo, boolean isBlocked, - boolean isSpam, - ReportingLocation.Type reportingLocation) { + boolean isSpam) { List<HistoryItemActionModule> modules = new ArrayList<>(); // For a spam number, add two options: // (1) "Not spam" and "Block", or // (2) "Not spam" and "Unblock". if (isSpam) { + modules.add(createModuleForMarkingNumberAsNonSpam(context, blockReportSpamDialogInfo)); modules.add( - createModuleForMarkingNumberAsNonSpam( - context, normalizedNumber, countryIso, callType, reportingLocation)); - modules.add(createModuleForBlockingOrUnblockingNumber(context, normalizedNumber, isBlocked)); + createModuleForBlockingOrUnblockingNumber(context, blockReportSpamDialogInfo, isBlocked)); return modules; } // For a blocked non-spam number, add "Unblock" option. if (isBlocked) { - modules.add(createModuleForBlockingOrUnblockingNumber(context, normalizedNumber, isBlocked)); + modules.add( + createModuleForBlockingOrUnblockingNumber(context, blockReportSpamDialogInfo, isBlocked)); return modules; } // For a number that is neither a spam number nor blocked, add "Block/Report spam" option. modules.add( createModuleForBlockingNumberAndOptionallyReportingSpam( - context, normalizedNumber, countryIso, callType, reportingLocation)); + context, blockReportSpamDialogInfo)); return modules; } - /** - * Add "Not spam" module. - * - * @param normalizedNumber The number to be marked as not spam - * @param countryIso The ISO 3166-1 two letters country code for the number - * @param callType Call type defined in {@link android.provider.CallLog.Calls} - * @param reportingLocation The location where the number is reported. See {@link - * ReportingLocation.Type}. - */ + /** Create "Not spam" module. */ private static HistoryItemActionModule createModuleForMarkingNumberAsNonSpam( - Context context, - String normalizedNumber, - String countryIso, - int callType, - ReportingLocation.Type reportingLocation) { + Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo) { return new HistoryItemActionModule() { @Override public int getStringId() { @@ -185,14 +164,14 @@ public class SharedModules { @Override public boolean onClick() { ShowBlockReportSpamDialogNotifier.notifyShowDialogToReportNotSpam( - context, normalizedNumber, countryIso, callType, reportingLocation); + context, blockReportSpamDialogInfo); return true; // Close the bottom sheet. } }; } private static HistoryItemActionModule createModuleForBlockingOrUnblockingNumber( - Context context, String normalizedNumber, boolean isBlocked) { + Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo, boolean isBlocked) { return new HistoryItemActionModule() { @Override public int getStringId() { @@ -214,7 +193,7 @@ public class SharedModules { String.format( Locale.ENGLISH, "TODO: " + (isBlocked ? "Unblock " : "Block ") + " number %s.", - normalizedNumber), + blockReportSpamDialogInfo.getNormalizedNumber()), Toast.LENGTH_SHORT) .show(); return true; // Close the bottom sheet. @@ -222,21 +201,9 @@ public class SharedModules { }; } - /** - * Add "Block/Report spam" module - * - * @param normalizedNumber The number to be blocked / unblocked / marked as spam/not spam - * @param countryIso The ISO 3166-1 two letters country code for the number - * @param callType Call type defined in {@link android.provider.CallLog.Calls} - * @param reportingLocation The location where the number is reported. See {@link - * ReportingLocation.Type}. - */ + /** Create "Block/Report spam" module */ private static HistoryItemActionModule createModuleForBlockingNumberAndOptionallyReportingSpam( - Context context, - String normalizedNumber, - String countryIso, - int callType, - ReportingLocation.Type reportingLocation) { + Context context, BlockReportSpamDialogInfo blockReportSpamDialogInfo) { return new HistoryItemActionModule() { @Override public int getStringId() { @@ -251,7 +218,7 @@ public class SharedModules { @Override public boolean onClick() { ShowBlockReportSpamDialogNotifier.notifyShowDialogToBlockNumberAndOptionallyReportSpam( - context, normalizedNumber, countryIso, callType, reportingLocation); + context, blockReportSpamDialogInfo); return true; // Close the bottom sheet. } }; diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index a05ef6d16..293ec9563 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -23,11 +23,14 @@ import android.app.KeyguardManager; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.os.Handler; import android.provider.CallLog.Calls; import android.provider.ContactsContract.QuickContact; +import android.provider.VoicemailContract; import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; @@ -91,9 +94,15 @@ import com.android.dialer.smartdial.util.SmartDialPrefix; import com.android.dialer.storage.StorageComponent; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.DialerUtils; +import com.android.dialer.util.PermissionsUtil; import com.android.dialer.util.TransactionSafeActivity; +import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler; +import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler.Source; +import com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker; +import com.android.dialer.voicemailstatus.VoicemailStatusHelper; import com.android.voicemail.VoicemailComponent; import com.google.common.util.concurrent.ListenableFuture; +import java.util.Locale; import java.util.concurrent.TimeUnit; /** @@ -273,7 +282,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen if (VoicemailComponent.get(context) .getVoicemailClient() .isVoicemailEnabled(context, defaultUserSelectedAccount)) { - LogUtil.i("OldMainActivityPeer.canVoicemailTabBeShown", "Voicemail is not enabled"); + LogUtil.i("OldMainActivityPeer.canVoicemailTabBeShown", "Voicemail is enabled"); return true; } LogUtil.i("OldMainActivityPeer.canVoicemailTabBeShown", "returning false"); @@ -642,6 +651,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen // No-op, just let the clicks fall through to the search list return false; } + + @Override + public boolean shouldShowDialpadChooser() { + // Never show the dialpad chooser. Ever. + return false; + } } /** @see CallLogAdapter.OnActionModeStateChangedListener */ @@ -706,7 +721,6 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen * <li>Marking missed calls as read when appropriate. See {@link * #markMissedCallsAsReadAndRemoveNotification()} * <li>TODO(calderwoodra): multiselect - * <li>TODO(calderwoodra): voicemail status * </ul> * * @see CallLogFragmentListener @@ -727,6 +741,15 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private long timeSelected = -1; private boolean activityIsAlive; + private final ContentObserver voicemailStatusObserver = + new ContentObserver(new Handler()) { + @Override + public void onChange(boolean selfChange) { + super.onChange(selfChange); + callLogQueryHandler.fetchVoicemailStatus(); + } + }; + MainCallLogFragmentListener( Context context, ContentResolver contentResolver, @@ -738,6 +761,21 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen this.toolbar = toolbar; } + private void registerVoicemailStatusContentObserver(Context context) { + + if (PermissionsUtil.hasReadVoicemailPermissions(context) + && PermissionsUtil.hasAddVoicemailPermissions(context)) { + context + .getContentResolver() + .registerContentObserver( + VoicemailContract.Status.CONTENT_URI, true, voicemailStatusObserver); + } else { + LogUtil.w( + "MainCallLogFragmentListener.registerVoicemailStatusContentObserver", + "no voicemail read/add permissions"); + } + } + @Override public void updateTabUnreadCounts() { callLogQueryHandler.fetchMissedCallsUnreadCount(); @@ -752,7 +790,42 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onVoicemailStatusFetched(Cursor statusCursor) { - // TODO(calderwoodra): handle this when voicemail is implemented + LogUtil.i("OldMainActivityPeer.MainCallLogFragmentListener", "onVoicemailStatusFetched"); + VoicemailStatusCorruptionHandler.maybeFixVoicemailStatus( + context, statusCursor, Source.Activity); + + // Update hasActiveVoicemailProvider, which controls the number of tabs displayed. + int numberOfActiveVoicemailSources = + VoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor); + + boolean hasActiveVoicemailProvider = numberOfActiveVoicemailSources > 0; + LogUtil.i( + "OldMainActivityPeer.onVoicemailStatusFetched", + String.format( + Locale.US, + "hasActiveVoicemailProvider:%b, number of active voicemail sources:%d", + hasActiveVoicemailProvider, + numberOfActiveVoicemailSources)); + + if (hasActiveVoicemailProvider) { + // TODO(yueg): Use new logging for VVM_TAB_VISIBLE + // Logger.get(context).logImpression(DialerImpression.Type.VVM_TAB_VISIBLE); + bottomNavBar.showVoicemail(true); + callLogQueryHandler.fetchVoicemailUnreadCount(); + } else { + bottomNavBar.showVoicemail(false); + } + + StorageComponent.get(context) + .unencryptedSharedPrefs() + .edit() + .putBoolean( + VisualVoicemailEnabledChecker.PREF_KEY_HAS_ACTIVE_VOICEMAIL_PROVIDER, + hasActiveVoicemailProvider) + .apply(); + + // TODO(uabdullah): Check if we need to force move to the VM tab (e.g in the event of + // clicking a vm notification and a status wasn't yet fetched). } @Override @@ -812,6 +885,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen public void onActivityResume() { activityIsAlive = true; + registerVoicemailStatusContentObserver(context); callLogQueryHandler.fetchVoicemailStatus(); callLogQueryHandler.fetchMissedCallsUnreadCount(); // Reset the tab on resume to restart the timer @@ -820,6 +894,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen /** Should be called when {@link Activity#onStop()} is called. */ public void onActivityStop(boolean changingConfigurations, boolean keyguardLocked) { + context.getContentResolver().unregisterContentObserver(voicemailStatusObserver); activityIsAlive = false; if (viewedCallLogTabPastTimeThreshold() && !changingConfigurations && !keyguardLocked) { markMissedCallsAsReadAndRemoveNotification(); @@ -1002,6 +1077,18 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen this.context = context; this.fragmentManager = fragmentManager; this.fab = fab; + preloadCallLogFragment(); + } + + private void preloadCallLogFragment() { + if (ConfigProviderBindings.get(context).getBoolean("nui_preload_call_log", true)) { + CallLogFragment fragment = new CallLogFragment(); + fragmentManager + .beginTransaction() + .add(R.id.fragment_container, fragment, CALL_LOG_TAG) + .hide(fragment) + .commit(); + } } @Override diff --git a/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java b/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java index d9a446f84..5ee33fc71 100644 --- a/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java +++ b/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java @@ -23,6 +23,7 @@ import android.util.AttributeSet; import android.view.View; import android.widget.LinearLayout; import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; @@ -123,8 +124,25 @@ public final class BottomNavBar extends LinearLayout { } } + /** + * Displays or hides the voicemail tab. + * + * <p>In the event that the voicemail tab was earlier visible but is now no longer visible, we + * move to the speed dial tab. + * + * @param showTab whether to hide or show the voicemail + */ public void showVoicemail(boolean showTab) { + LogUtil.i("OldMainActivityPeer.showVoicemail", "showing Tab:%b", showTab); + int voicemailpreviousVisibility = voicemail.getVisibility(); voicemail.setVisibility(showTab ? View.VISIBLE : View.GONE); + int voicemailcurrentVisibility = voicemail.getVisibility(); + + if (voicemailpreviousVisibility != voicemailcurrentVisibility + && voicemailpreviousVisibility == View.VISIBLE) { + LogUtil.i("OldMainActivityPeer.showVoicemail", "hid VM tab and moved to speed dial tab"); + selectTab(TabIndex.SPEED_DIAL); + } } public void setNotificationCount(@TabIndex int tab, int count) { diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java index fc4bd0312..2f36717c9 100644 --- a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java +++ b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java @@ -19,6 +19,7 @@ package com.android.dialer.main.impl.toolbar; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.content.Context; +import android.support.annotation.NonNull; import android.support.annotation.StringRes; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; @@ -66,9 +67,9 @@ public final class MainToolbar extends Toolbar implements PopupMenu.OnMenuItemCl return listener.onMenuItemClicked(menuItem); } - public void setSearchBarListener(SearchBarListener listener) { - this.listener = listener; - ((SearchBarView) findViewById(R.id.search_view_container)).setSearchBarListener(listener); + public void setSearchBarListener(@NonNull SearchBarListener listener) { + this.listener = Assert.isNotNull(listener); + searchBar.setSearchBarListener(listener); } /** Slides the toolbar up and off the screen. */ diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java index 78cabf733..299985057 100644 --- a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java +++ b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java @@ -32,6 +32,7 @@ import android.widget.EditText; import android.widget.FrameLayout; import android.widget.TextView; import com.android.dialer.animation.AnimUtils; +import com.android.dialer.common.Assert; import com.android.dialer.common.UiUtil; import com.android.dialer.util.DialerUtils; import com.google.common.base.Optional; @@ -188,8 +189,8 @@ final class SearchBarView extends FrameLayout { requestLayout(); } - /* package-private */ void setSearchBarListener(SearchBarListener listener) { - this.listener = listener; + /* package-private */ void setSearchBarListener(@NonNull SearchBarListener listener) { + this.listener = Assert.isNotNull(listener); } public String getQuery() { @@ -236,7 +237,15 @@ final class SearchBarView extends FrameLayout { return; } - listener.onSearchQueryUpdated(s.toString()); + // afterTextChanged is called each time the device is rotated (or the activity is recreated). + // That means that this method could potentially be called before the listener is set and + // we should check if it's null. In the case that it is null, assert that the query is empty + // because the listener must be notified of non-empty queries. + if (listener != null) { + listener.onSearchQueryUpdated(s.toString()); + } else { + Assert.checkArgument(TextUtils.isEmpty(s.toString())); + } } } } diff --git a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java index 3a48fd538..6e867560d 100644 --- a/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java +++ b/java/com/android/dialer/phonelookup/consolidator/PhoneLookupInfoConsolidator.java @@ -18,6 +18,7 @@ package com.android.dialer.phonelookup.consolidator; import android.support.annotation.IntDef; import android.support.annotation.Nullable; import com.android.dialer.common.Assert; +import com.android.dialer.logging.ContactSource; import com.android.dialer.phonelookup.PhoneLookup; import com.android.dialer.phonelookup.PhoneLookupInfo; import com.android.dialer.phonelookup.PhoneLookupInfo.BlockedState; @@ -91,6 +92,39 @@ public final class PhoneLookupInfoConsolidator { } /** + * Returns a {@link com.android.dialer.logging.ContactSource.Type} representing the source from + * which info is used to display contact info in the UI. + */ + public ContactSource.Type getContactSource() { + switch (nameSource) { + case NameSource.CP2_DEFAULT_DIRECTORY: + return ContactSource.Type.SOURCE_TYPE_DIRECTORY; + case NameSource.CP2_EXTENDED_DIRECTORY: + return ContactSource.Type.SOURCE_TYPE_EXTENDED; + case NameSource.PEOPLE_API: + return getRefinedPeopleApiSource(); + case NameSource.NONE: + return ContactSource.Type.UNKNOWN_SOURCE_TYPE; + default: + throw Assert.createUnsupportedOperationFailException( + String.format("Unsupported name source: %s", nameSource)); + } + } + + private ContactSource.Type getRefinedPeopleApiSource() { + Assert.checkState(nameSource == NameSource.PEOPLE_API); + + switch (phoneLookupInfo.getPeopleApiInfo().getInfoType()) { + case CONTACT: + return ContactSource.Type.SOURCE_TYPE_PROFILE; + case NEARBY_BUSINESS: + return ContactSource.Type.SOURCE_TYPE_PLACES; + default: + return ContactSource.Type.SOURCE_TYPE_REMOTE_OTHER; + } + } + + /** * The {@link PhoneLookupInfo} passed to the constructor is associated with a number. This method * returns the name associated with that number. * diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java b/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java index 9296d04e7..6d71dade9 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java @@ -30,6 +30,7 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.FrameLayout; import com.android.dialer.calllog.CallLogComponent; import com.android.dialer.calllog.RefreshAnnotatedCallLogReceiver; import com.android.dialer.common.LogUtil; @@ -38,6 +39,7 @@ import com.android.dialer.common.concurrent.UiListener; import com.android.dialer.glidephotomanager.GlidePhotoManagerComponent; import com.android.dialer.voicemail.listui.error.VoicemailStatus; import com.android.dialer.voicemailstatus.VoicemailStatusQuery; +import com.android.dialer.widget.EmptyContentView; import com.android.voicemail.VoicemailComponent; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.ListenableFuture; @@ -52,6 +54,11 @@ public final class NewVoicemailFragment extends Fragment implements LoaderCallba private RefreshAnnotatedCallLogReceiver refreshAnnotatedCallLogReceiver; private UiListener<ImmutableList<VoicemailStatus>> queryVoicemailStatusTableListener; + // View required to show/hide recycler and empty views + FrameLayout fragmentRootFrameLayout; + + private EmptyContentView emptyContentView; + public NewVoicemailFragment() { LogUtil.enterBlock("NewVoicemailFragment.NewVoicemailFragment"); } @@ -147,10 +154,14 @@ public final class NewVoicemailFragment extends Fragment implements LoaderCallba public View onCreateView( LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { LogUtil.enterBlock("NewVoicemailFragment.onCreateView"); - View view = inflater.inflate(R.layout.new_voicemail_call_log_fragment, container, false); - recyclerView = view.findViewById(R.id.new_voicemail_call_log_recycler_view); + + fragmentRootFrameLayout = + (FrameLayout) inflater.inflate(R.layout.new_voicemail_call_log_fragment, container, false); + recyclerView = fragmentRootFrameLayout.findViewById(R.id.new_voicemail_call_log_recycler_view); + + emptyContentView = fragmentRootFrameLayout.findViewById(R.id.empty_content_view); getLoaderManager().restartLoader(0, null, this); - return view; + return fragmentRootFrameLayout; } @Override @@ -162,6 +173,12 @@ public final class NewVoicemailFragment extends Fragment implements LoaderCallba @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { LogUtil.i("NewVoicemailFragment.onLoadFinished", "cursor size is %d", data.getCount()); + if (data.getCount() == 0) { + showEmptyVoicemailFragmentView(); + return; + } + showView(recyclerView); + if (recyclerView.getAdapter() == null) { recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // TODO(uabdullah): Replace getActivity().getFragmentManager() with getChildFragment() @@ -182,9 +199,24 @@ public final class NewVoicemailFragment extends Fragment implements LoaderCallba recyclerView.getAdapter()); ((NewVoicemailAdapter) recyclerView.getAdapter()).updateCursor(data); ((NewVoicemailAdapter) recyclerView.getAdapter()).checkAndPlayVoicemail(); + queryAndUpdateVoicemailStatusAlert(); } + } + + /** Shows the view when there are no voicemails to be displayed * */ + private void showEmptyVoicemailFragmentView() { + LogUtil.enterBlock("NewVoicemailFragmentListener.showEmptyVoicemailFragmentView"); + + showView(emptyContentView); + + emptyContentView.setDescription((R.string.empty_voicemail_tab_text)); + emptyContentView.setImage(R.drawable.quantum_ic_schedule_vd_theme_24); + } - queryAndUpdateVoicemailStatusAlert(); + private void showView(View view) { + LogUtil.i("NewVoicemailFragmentListener.showView", "Showing view: " + view); + emptyContentView.setVisibility(view == emptyContentView ? View.VISIBLE : View.GONE); + recyclerView.setVisibility(view == recyclerView ? View.VISIBLE : View.GONE); } private void registerRefreshAnnotatedCallLogReceiver() { diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java index 519a0dfbd..efa1060ed 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java @@ -17,6 +17,7 @@ package com.android.dialer.voicemail.listui; import android.content.Context; +import android.media.AudioManager; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; import android.media.MediaPlayer.OnErrorListener; @@ -63,6 +64,7 @@ public class NewVoicemailMediaPlayer { () -> { try { mediaPlayer.setDataSource(context, uri); + setAudioManagerToNonSpeakerMode(context); } catch (IOException e) { LogUtil.i( "NewVoicemailMediaPlayer", @@ -86,6 +88,13 @@ public class NewVoicemailMediaPlayer { } } + /** We should never start playing voicemails from the speaker mode */ + private void setAudioManagerToNonSpeakerMode(Context context) { + AudioManager audioManager = context.getSystemService(AudioManager.class); + audioManager.setMode(AudioManager.STREAM_MUSIC); + audioManager.setSpeakerphoneOn(false); + } + private void verifyListenersNotNull() { Assert.isNotNull( newVoicemailMediaPlayerOnErrorListener, diff --git a/java/com/android/dialer/voicemail/listui/menu/Modules.java b/java/com/android/dialer/voicemail/listui/menu/Modules.java index 9473b80e1..c3c883ceb 100644 --- a/java/com/android/dialer/voicemail/listui/menu/Modules.java +++ b/java/com/android/dialer/voicemail/listui/menu/Modules.java @@ -17,6 +17,7 @@ package com.android.dialer.voicemail.listui.menu; import android.content.Context; +import com.android.dialer.blockreportspam.BlockReportSpamDialogInfo; import com.android.dialer.historyitemactions.DividerModule; import com.android.dialer.historyitemactions.HistoryItemActionModule; import com.android.dialer.historyitemactions.SharedModules; @@ -64,15 +65,20 @@ final class Modules { modules.add(new DividerModule()); } + BlockReportSpamDialogInfo blockReportSpamDialogInfo = + BlockReportSpamDialogInfo.newBuilder() + .setNormalizedNumber(voicemailEntry.number().getNormalizedNumber()) + .setCountryIso(voicemailEntry.number().getCountryIso()) + .setCallType(voicemailEntry.callType()) + .setReportingLocation(ReportingLocation.Type.VOICEMAIL_HISTORY) + .setContactSource(voicemailEntry.numberAttributes().getContactSource()) + .build(); modules.addAll( SharedModules.createModulesHandlingBlockedOrSpamNumber( context, - voicemailEntry.number().getNormalizedNumber(), - voicemailEntry.number().getCountryIso(), - voicemailEntry.callType(), + blockReportSpamDialogInfo, voicemailEntry.numberAttributes().getIsBlocked(), - voicemailEntry.numberAttributes().getIsSpam(), - ReportingLocation.Type.VOICEMAIL_HISTORY)); + voicemailEntry.numberAttributes().getIsSpam())); // TODO(zachh): Module for CallComposer. Optional<HistoryItemActionModule> moduleForCopyingNumber = diff --git a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_call_log_fragment.xml b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_call_log_fragment.xml index 9daa3e114..fd9e0f2d2 100644 --- a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_call_log_fragment.xml +++ b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_call_log_fragment.xml @@ -15,21 +15,35 @@ ~ limitations under the License --> - <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/fragment_my_frame_layout" - android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:id="@+id/new_voicemail_frame_layout" + android:layout_width="match_parent" + android:layout_height="match_parent" android:orientation="vertical"> - <include layout="@layout/voicemail_tos_fragment"/> <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/new_voicemail_call_log_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/background_dialer_light" android:paddingBottom="@dimen/floating_action_button_list_bottom_padding" - android:clipToPadding="false"/> + android:background="@color/background_dialer_light" + android:clipToPadding="false" + android:visibility="gone" + /> + + + <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <com.android.dialer.widget.EmptyContentView + android:id="@+id/empty_content_view" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:visibility="gone"/> + + </FrameLayout> </FrameLayout> diff --git a/java/com/android/dialer/voicemail/listui/res/values/strings.xml b/java/com/android/dialer/voicemail/listui/res/values/strings.xml index db33c1909..d12a71ee6 100644 --- a/java/com/android/dialer/voicemail/listui/res/values/strings.xml +++ b/java/com/android/dialer/voicemail/listui/res/values/strings.xml @@ -57,4 +57,7 @@ If you do not accept all of these terms and conditions, do not use Visual Voice <!-- Label indicating who provided the voicemail transcription [CHAR LIMIT=64] --> <string name="voicemail_transcription_branding_text">Transcribed by Google</string> + <!-- Text displayed when the list of voicemails is empty [CHAR LIMIT=NONE] --> + <string name="empty_voicemail_tab_text">Your voicemail inbox is empty.</string> + </resources> diff --git a/java/com/android/dialer/voicemail/settings/res/values/strings.xml b/java/com/android/dialer/voicemail/settings/res/values/strings.xml index 47228b70b..3056ef6b2 100644 --- a/java/com/android/dialer/voicemail/settings/res/values/strings.xml +++ b/java/com/android/dialer/voicemail/settings/res/values/strings.xml @@ -116,7 +116,7 @@ [CHAR LIMIT=NONE] --> <string name="voicemail_donate_preference_summary_not_activated">Visual voicemail is not activated yet, please try again later</string> <!-- Summary information for visual voicemail donation setting [CHAR LIMIT=NONE] --> - <string name="voicemail_donate_preference_summary_info">Let Google review your voicemail messages to improve transcription quality</string> + <string name="voicemail_donate_preference_summary_info">Let Google review your voicemail messages to improve transcription accuracy</string> <!-- Title for disable visual voicemail confirmation dialog [CHAR LIMIT=40] --> <string name="confirm_disable_voicemail_dialog_title">Turn off visual voicemail</string> diff --git a/java/com/android/dialer/widget/res/layout/empty_content_view.xml b/java/com/android/dialer/widget/res/layout/empty_content_view.xml index 177744385..9aac6f48f 100644 --- a/java/com/android/dialer/widget/res/layout/empty_content_view.xml +++ b/java/com/android/dialer/widget/res/layout/empty_content_view.xml @@ -18,7 +18,7 @@ <ImageView android:id="@+id/empty_list_view_image" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="108dp" android:gravity="center_horizontal"/> <TextView diff --git a/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml index ef3c1f91a..d85075106 100644 --- a/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml +++ b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml @@ -16,8 +16,7 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@color/dialer_theme_color"> + android:layout_height="match_parent"> <include layout="@layout/rtt_banner"/> |