diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-03-28 01:34:37 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-03-28 01:34:37 +0000 |
commit | dc5935b31560e90eb402de7319ae27f068d963d5 (patch) | |
tree | 8a6fab91b5b01cfc936501e5e7d57b7a9a22f864 /java/com | |
parent | 0aac99095d8a8776d9e6e87175b0cd861c53b503 (diff) | |
parent | bb4c1be2923ea7bfc9152e3cef9d0c12cb6664bd (diff) |
Merge changes Ic084d903,I9cb063a9,I8c0abf9f
* changes:
Use CallLogConfig for enabling new peer.
Turn on transcription when existing dialer user accepts ToS and transcription is available.
Turn off transcription when user declines tos (existing dialer user)
Diffstat (limited to 'java/com')
5 files changed, 37 insertions, 31 deletions
diff --git a/java/com/android/dialer/configprovider/SharedPrefConfigProvider.java b/java/com/android/dialer/configprovider/SharedPrefConfigProvider.java index d700fb676..ce95c5700 100644 --- a/java/com/android/dialer/configprovider/SharedPrefConfigProvider.java +++ b/java/com/android/dialer/configprovider/SharedPrefConfigProvider.java @@ -23,8 +23,8 @@ import android.content.SharedPreferences.Editor; import android.support.annotation.Nullable; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.inject.ApplicationContext; import com.android.dialer.storage.StorageComponent; +import com.android.dialer.storage.Unencrypted; import com.android.dialer.strictmode.StrictModeUtils; import javax.inject.Inject; @@ -49,14 +49,14 @@ import javax.inject.Inject; * /data/user_de/0/com.android.dialer/shared_prefs/com.android.dialer_preferences.xml * </pre> */ -class SharedPrefConfigProvider implements ConfigProvider { +public class SharedPrefConfigProvider implements ConfigProvider { private static final String PREF_PREFIX = "config_provider_prefs_"; - private final Context appContext; + private final SharedPreferences sharedPreferences; @Inject - SharedPrefConfigProvider(@ApplicationContext Context appContext) { - this.appContext = appContext; + SharedPrefConfigProvider(@Unencrypted SharedPreferences sharedPreferences) { + this.sharedPreferences = sharedPreferences; } /** Service to write values into {@link SharedPrefConfigProvider} using adb. */ @@ -93,25 +93,29 @@ class SharedPrefConfigProvider implements ConfigProvider { } } + /** Set a boolean config value. */ + public void putBoolean(String key, boolean value) { + sharedPreferences.edit().putBoolean(PREF_PREFIX + key, value).apply(); + } + @Override public String getString(String key, String defaultValue) { // Reading shared prefs on the main thread is generally safe since a single instance is cached. return StrictModeUtils.bypass( - () -> getSharedPrefs(appContext).getString(PREF_PREFIX + key, defaultValue)); + () -> sharedPreferences.getString(PREF_PREFIX + key, defaultValue)); } @Override public long getLong(String key, long defaultValue) { // Reading shared prefs on the main thread is generally safe since a single instance is cached. - return StrictModeUtils.bypass( - () -> getSharedPrefs(appContext).getLong(PREF_PREFIX + key, defaultValue)); + return StrictModeUtils.bypass(() -> sharedPreferences.getLong(PREF_PREFIX + key, defaultValue)); } @Override public boolean getBoolean(String key, boolean defaultValue) { // Reading shared prefs on the main thread is generally safe since a single instance is cached. return StrictModeUtils.bypass( - () -> getSharedPrefs(appContext).getBoolean(PREF_PREFIX + key, defaultValue)); + () -> sharedPreferences.getBoolean(PREF_PREFIX + key, defaultValue)); } private static SharedPreferences getSharedPrefs(Context appContext) { diff --git a/java/com/android/dialer/configprovider/SharedPrefConfigProviderModule.java b/java/com/android/dialer/configprovider/SharedPrefConfigProviderModule.java index fe1c90816..4af8bfe17 100644 --- a/java/com/android/dialer/configprovider/SharedPrefConfigProviderModule.java +++ b/java/com/android/dialer/configprovider/SharedPrefConfigProviderModule.java @@ -16,14 +16,17 @@ package com.android.dialer.configprovider; +import com.android.dialer.storage.StorageModule; import dagger.Binds; import dagger.Module; import javax.inject.Singleton; /** Dagger module providing {@link ConfigProvider} based on shared preferences. */ -@Module +@Module(includes = StorageModule.class) public abstract class SharedPrefConfigProviderModule { + private SharedPrefConfigProviderModule() {} + @Binds @Singleton abstract ConfigProvider to(SharedPrefConfigProvider impl); diff --git a/java/com/android/dialer/main/impl/MainActivity.java b/java/com/android/dialer/main/impl/MainActivity.java index 1d705f06c..2046b048f 100644 --- a/java/com/android/dialer/main/impl/MainActivity.java +++ b/java/com/android/dialer/main/impl/MainActivity.java @@ -21,9 +21,9 @@ import android.content.Intent; import android.os.Bundle; import android.support.v4.content.LocalBroadcastManager; import com.android.dialer.blockreportspam.ShowBlockReportSpamDialogReceiver; +import com.android.dialer.calllog.config.CallLogConfigComponent; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.interactions.PhoneNumberInteraction.DisambigDialogDismissedListener; import com.android.dialer.interactions.PhoneNumberInteraction.InteractionErrorCode; import com.android.dialer.interactions.PhoneNumberInteraction.InteractionErrorListener; @@ -53,7 +53,7 @@ public class MainActivity extends TransactionSafeActivity /** Returns intent that will open MainActivity to the specified tab. */ public static Intent getShowTabIntent(Context context, @TabIndex int tabIndex) { - if (ConfigProviderBindings.get(context).getBoolean("nui_peer_enabled", false)) { + if (CallLogConfigComponent.get(context).callLogConfig().isNewPeerEnabled()) { // TODO(calderwoodra): implement this in NewMainActivityPeer return null; } @@ -82,7 +82,7 @@ public class MainActivity extends TransactionSafeActivity } protected MainActivityPeer getNewPeer() { - if (ConfigProviderBindings.get(this).getBoolean("nui_peer_enabled", false)) { + if (CallLogConfigComponent.get(this).callLogConfig().isNewPeerEnabled()) { return new NewMainActivityPeer(this); } else { return new OldMainActivityPeer(this); diff --git a/java/com/android/dialer/voicemail/listui/error/VoicemailTosMessageCreator.java b/java/com/android/dialer/voicemail/listui/error/VoicemailTosMessageCreator.java index ec1a95a1a..382118fca 100644 --- a/java/com/android/dialer/voicemail/listui/error/VoicemailTosMessageCreator.java +++ b/java/com/android/dialer/voicemail/listui/error/VoicemailTosMessageCreator.java @@ -22,8 +22,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; -import android.net.Uri; -import android.os.Build; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.telecom.PhoneAccountHandle; @@ -40,11 +38,9 @@ import android.view.View.OnClickListener; import com.android.dialer.common.LogUtil; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.configprovider.ConfigProviderBindings; -import com.android.dialer.constants.Constants; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.voicemail.listui.error.VoicemailErrorMessage.Action; -import com.android.dialer.voicemail.settings.VoicemailSettingsFragment; import com.android.voicemail.VisualVoicemailTypeExtensions; import com.android.voicemail.VoicemailClient; import com.android.voicemail.VoicemailComponent; @@ -129,19 +125,16 @@ public class VoicemailTosMessageCreator { getExistingUserTosTitle(), getExistingUserTosMessageText(), new Action( - context.getString(R.string.dialer_terms_and_conditions_existing_user_setings), + context.getString(R.string.dialer_terms_and_conditions_existing_user_decline), new OnClickListener() { @Override public void onClick(View v) { - LogUtil.i("VoicemailTosMessageCreator.getPromoMessage", "open settings"); - Intent intent = - new Intent(Intent.ACTION_VIEW) - .setComponent( - new ComponentName(context, Constants.get().getSettingsActivity())) - .setData( - Uri.fromParts( - "header", VoicemailSettingsFragment.class.getName(), null)); - context.startActivity(intent); + LogUtil.i( + "VoicemailTosMessageCreator.getPromoMessage", "declined transcription"); + VoicemailClient voicemailClient = + VoicemailComponent.get(context).getVoicemailClient(); + voicemailClient.setVoicemailTranscriptionEnabled( + context, status.getPhoneAccountHandle(), false); } }), new Action( @@ -150,6 +143,12 @@ public class VoicemailTosMessageCreator { @Override public void onClick(View v) { LogUtil.i("VoicemailTosMessageCreator.getPromoMessage", "acknowledge clicked"); + if (isVoicemailTranscriptionAvailable()) { + VoicemailComponent.get(context) + .getVoicemailClient() + .setVoicemailTranscriptionEnabled( + context, status.getPhoneAccountHandle(), true); + } // Feature acknowledgement also means accepting TOS recordTosAcceptance(); recordFeatureAcknowledgement(); @@ -228,9 +227,9 @@ public class VoicemailTosMessageCreator { } private boolean isVoicemailTranscriptionAvailable() { - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && ConfigProviderBindings.get(context) - .getBoolean("voicemail_transcription_available", false); + return VoicemailComponent.get(context) + .getVoicemailClient() + .isVoicemailTranscriptionAvailable(context, status.getPhoneAccountHandle()); } private void showDeclineTosDialog(final PhoneAccountHandle handle) { diff --git a/java/com/android/dialer/voicemail/listui/error/res/values/strings.xml b/java/com/android/dialer/voicemail/listui/error/res/values/strings.xml index b222d9c01..4306063d9 100644 --- a/java/com/android/dialer/voicemail/listui/error/res/values/strings.xml +++ b/java/com/android/dialer/voicemail/listui/error/res/values/strings.xml @@ -199,7 +199,7 @@ Si no acepta todos estos términos y condiciones, no use el buzón de voz visual <string name="dialer_terms_and_conditions_decline_spanish" translatable="false">Rechazar</string> <string name="dialer_terms_and_conditions_existing_user_ack">Ok, got it</string> - <string name="dialer_terms_and_conditions_existing_user_setings">Settings</string> + <string name="dialer_terms_and_conditions_existing_user_decline">No Thanks</string> <string name="terms_and_conditions_decline_dialog_title">Disable visual voicemail?</string> |