summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/app
diff options
context:
space:
mode:
authoruabdullah <uabdullah@google.com>2018-03-16 17:32:54 -0700
committerCopybara-Service <copybara-piper@google.com>2018-03-16 17:39:34 -0700
commita7530f84656f1060957b14a4c946fd02cf88f7cd (patch)
tree6131ce961e48b0c971abb8c9ef5977cbb0d588f0 /java/com/android/dialer/app
parentfce3a793a925791b6ed22d8132db55cd6d7d3f15 (diff)
Refactor VM Settings and add support for voicemail transcription
This CL refactors the existing voicemail settings fragment and adds UI support for voicemail transcription. It mainly deals with the following: - ensuring that when the VVM toggle is turned off, transcription and donations are gone. - when transcription is off, donation preference is gone. - donation is only available when transcription is available and enabled - as part of the refactor, fixes existing logging bugs - breaks preferences and its associated methods into helper methods when possible - groups relevant preferences together when possible Bug: 74033229 Test: Unit tests PiperOrigin-RevId: 189418217 Change-Id: I3442cb5752a235cfca643ba55df3fb75171e3fe4
Diffstat (limited to 'java/com/android/dialer/app')
-rw-r--r--java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java93
1 files changed, 47 insertions, 46 deletions
diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
index 937f0419b..b88a959ed 100644
--- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
+++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
@@ -94,6 +94,49 @@ public class PhoneCallDetailsHelper
calendar = Calendar.getInstance();
}
+ static boolean shouldShowVoicemailDonationPromo(
+ Context context, PhoneAccountHandle accountHandle) {
+ VoicemailClient client = VoicemailComponent.get(context).getVoicemailClient();
+ return client.isVoicemailDonationAvailable(context, accountHandle)
+ && !hasSeenVoicemailDonationPromo(context);
+ }
+
+ static boolean hasSeenVoicemailDonationPromo(Context context) {
+ return StorageComponent.get(context.getApplicationContext())
+ .unencryptedSharedPrefs()
+ .getBoolean(PREF_VOICEMAIL_DONATION_PROMO_SHOWN_KEY, false);
+ }
+
+ private static int dpsToPixels(Context context, int dps) {
+ return (int)
+ (TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_DIP, dps, context.getResources().getDisplayMetrics()));
+ }
+
+ private static void recordPromoShown(Context context) {
+ StorageComponent.get(context.getApplicationContext())
+ .unencryptedSharedPrefs()
+ .edit()
+ .putBoolean(PREF_VOICEMAIL_DONATION_PROMO_SHOWN_KEY, true)
+ .apply();
+ }
+
+ /** Returns true if primary name is empty or the data is from Cequint Caller ID. */
+ private static boolean shouldShowLocation(PhoneCallDetails details) {
+ if (TextUtils.isEmpty(details.geocode)) {
+ return false;
+ }
+ // For caller ID provided by Cequint we want to show the geo location.
+ if (details.sourceType == ContactSource.Type.SOURCE_TYPE_CEQUINT_CALLER_ID) {
+ return true;
+ }
+ // Don't bother showing geo location for contacts.
+ if (!TextUtils.isEmpty(details.namePrimary)) {
+ return false;
+ }
+ return true;
+ }
+
/** Fills the call details views with content. */
public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details) {
// Display up to a given number of icons.
@@ -250,9 +293,10 @@ public class PhoneCallDetailsHelper
return true;
}
- // Also show the rating option if voicemail transcription is available (but not enabled)
+ // Also show the rating option if voicemail donation is available (but not enabled)
// and the donation promo has not yet been shown.
- if (client.isVoicemailDonationAvailable(context) && !hasSeenVoicemailDonationPromo(context)) {
+ if (client.isVoicemailDonationAvailable(context, account)
+ && !hasSeenVoicemailDonationPromo(context)) {
return true;
}
@@ -263,7 +307,7 @@ public class PhoneCallDetailsHelper
TranscriptionRatingValue ratingValue, PhoneCallDetails details, View ratingView) {
LogUtil.enterBlock("PhoneCallDetailsHelper.recordTranscriptionRating");
- if (shouldShowVoicemailDonationPromo(context)) {
+ if (shouldShowVoicemailDonationPromo(context, details.accountHandle)) {
showVoicemailDonationPromo(ratingValue, details, ratingView);
} else {
TranscriptionRatingHelper.sendRating(
@@ -275,19 +319,6 @@ public class PhoneCallDetailsHelper
}
}
- static boolean shouldShowVoicemailDonationPromo(Context context) {
- VoicemailClient client = VoicemailComponent.get(context).getVoicemailClient();
- return client.isVoicemailTranscriptionAvailable(context)
- && client.isVoicemailDonationAvailable(context)
- && !hasSeenVoicemailDonationPromo(context);
- }
-
- static boolean hasSeenVoicemailDonationPromo(Context context) {
- return StorageComponent.get(context.getApplicationContext())
- .unencryptedSharedPrefs()
- .getBoolean(PREF_VOICEMAIL_DONATION_PROMO_SHOWN_KEY, false);
- }
-
private void showVoicemailDonationPromo(
TranscriptionRatingValue ratingValue, PhoneCallDetails details, View ratingView) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
@@ -360,20 +391,6 @@ public class PhoneCallDetailsHelper
}
}
- private static int dpsToPixels(Context context, int dps) {
- return (int)
- (TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP, dps, context.getResources().getDisplayMetrics()));
- }
-
- private static void recordPromoShown(Context context) {
- StorageComponent.get(context.getApplicationContext())
- .unencryptedSharedPrefs()
- .edit()
- .putBoolean(PREF_VOICEMAIL_DONATION_PROMO_SHOWN_KEY, true)
- .apply();
- }
-
private SpannableString getVoicemailDonationPromoContent() {
return new ContentWithLearnMoreSpanner(context)
.create(
@@ -462,22 +479,6 @@ public class PhoneCallDetailsHelper
return numberFormattedLabel;
}
- /** Returns true if primary name is empty or the data is from Cequint Caller ID. */
- private static boolean shouldShowLocation(PhoneCallDetails details) {
- if (TextUtils.isEmpty(details.geocode)) {
- return false;
- }
- // For caller ID provided by Cequint we want to show the geo location.
- if (details.sourceType == ContactSource.Type.SOURCE_TYPE_CEQUINT_CALLER_ID) {
- return true;
- }
- // Don't bother showing geo location for contacts.
- if (!TextUtils.isEmpty(details.namePrimary)) {
- return false;
- }
- return true;
- }
-
public void setPhoneTypeLabelForTest(CharSequence phoneTypeLabel) {
this.phoneTypeLabelForTest = phoneTypeLabel;
}