summaryrefslogtreecommitdiff
path: root/java/com/android/voicemail/impl/settings
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/voicemail/impl/settings
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/voicemail/impl/settings')
-rw-r--r--java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java53
1 files changed, 37 insertions, 16 deletions
diff --git a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java
index e42d56938..3e006988e 100644
--- a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java
+++ b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java
@@ -33,6 +33,7 @@ public class VisualVoicemailSettingsUtil {
@VisibleForTesting public static final String IS_ENABLED_KEY = "is_enabled";
private static final String ARCHIVE_ENABLED_KEY = "archive_is_enabled";
+ private static final String TRANSCRIBE_VOICEMAILS_KEY = "transcribe_voicemails";
private static final String DONATE_VOICEMAILS_KEY = "donate_voicemails";
public static void setEnabled(
@@ -59,21 +60,6 @@ public class VisualVoicemailSettingsUtil {
}
}
- private static class VoicemailDeleteWorker implements Worker<Void, Void> {
- private final Context context;
-
- VoicemailDeleteWorker(Context context) {
- this.context = context;
- }
-
- @Override
- public Void doInBackground(Void unused) {
- int deleted = VoicemailDatabaseUtil.deleteAll(context);
- VvmLog.i("VisualVoicemailSettingsUtil.doInBackground", "deleted " + deleted + " voicemails");
- return null;
- }
- }
-
private static void onSuccess(Void unused) {
VvmLog.i("VisualVoicemailSettingsUtil.onSuccess", "delete voicemails");
}
@@ -92,12 +78,24 @@ public class VisualVoicemailSettingsUtil {
.apply();
}
+ public static void setVoicemailTranscriptionEnabled(
+ Context context, PhoneAccountHandle phoneAccount, boolean isEnabled) {
+ Assert.checkArgument(
+ VoicemailComponent.get(context)
+ .getVoicemailClient()
+ .isVoicemailTranscriptionAvailable(context, phoneAccount));
+ new VisualVoicemailPreferences(context, phoneAccount)
+ .edit()
+ .putBoolean(TRANSCRIBE_VOICEMAILS_KEY, isEnabled)
+ .apply();
+ }
+
public static void setVoicemailDonationEnabled(
Context context, PhoneAccountHandle phoneAccount, boolean isEnabled) {
Assert.checkArgument(
VoicemailComponent.get(context)
.getVoicemailClient()
- .isVoicemailTranscriptionAvailable(context));
+ .isVoicemailTranscriptionAvailable(context, phoneAccount));
new VisualVoicemailPreferences(context, phoneAccount)
.edit()
.putBoolean(DONATE_VOICEMAILS_KEY, isEnabled)
@@ -125,6 +123,14 @@ public class VisualVoicemailSettingsUtil {
return prefs.getBoolean(ARCHIVE_ENABLED_KEY, false);
}
+ public static boolean isVoicemailTranscriptionEnabled(
+ Context context, PhoneAccountHandle phoneAccount) {
+ Assert.isNotNull(phoneAccount);
+
+ VisualVoicemailPreferences prefs = new VisualVoicemailPreferences(context, phoneAccount);
+ return prefs.getBoolean(TRANSCRIBE_VOICEMAILS_KEY, false);
+ }
+
public static boolean isVoicemailDonationEnabled(
Context context, PhoneAccountHandle phoneAccount) {
Assert.isNotNull(phoneAccount);
@@ -146,4 +152,19 @@ public class VisualVoicemailSettingsUtil {
VisualVoicemailPreferences prefs = new VisualVoicemailPreferences(context, phoneAccount);
return prefs.contains(IS_ENABLED_KEY);
}
+
+ private static class VoicemailDeleteWorker implements Worker<Void, Void> {
+ private final Context context;
+
+ VoicemailDeleteWorker(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public Void doInBackground(Void unused) {
+ int deleted = VoicemailDatabaseUtil.deleteAll(context);
+ VvmLog.i("VisualVoicemailSettingsUtil.doInBackground", "deleted " + deleted + " voicemails");
+ return null;
+ }
+ }
}