summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/tts
diff options
context:
space:
mode:
authorJoshua Imbriani <joshimbriani@google.com>2019-06-26 15:23:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-06-26 15:23:32 +0000
commit5d00bdbdc5ea9a7b2b931600446010bfa124e337 (patch)
tree063f8065c32dc4ba8c79d77e8990d162273975af /src/com/android/settings/tts
parenta1a0f7d7ea66779d1bda6e8c130799e6dfa5aaae (diff)
parent1f248705eb092b9b5ba81f70661b8efec716ef2c (diff)
downloadpackages_apps_Settings-5d00bdbdc5ea9a7b2b931600446010bfa124e337.tar.gz
packages_apps_Settings-5d00bdbdc5ea9a7b2b931600446010bfa124e337.tar.bz2
packages_apps_Settings-5d00bdbdc5ea9a7b2b931600446010bfa124e337.zip
Merge "Making changes to TTS pitch and rate also apply to work profiles"
Diffstat (limited to 'src/com/android/settings/tts')
-rw-r--r--src/com/android/settings/tts/TextToSpeechSettings.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index d4c7318002..325370ff44 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -26,7 +26,10 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
import android.provider.SearchIndexableResource;
+import android.provider.Settings.Secure;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.EngineInfo;
import android.speech.tts.TtsEngines;
@@ -44,6 +47,7 @@ import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
+import com.android.settings.Utils;
import com.android.settings.widget.GearPreference;
import com.android.settings.widget.SeekBarPreference;
import com.android.settingslib.search.SearchIndexable;
@@ -148,6 +152,11 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
*/
private final TextToSpeech.OnInitListener mInitListener = this::onInitEngine;
+ /**
+ * A UserManager used to set settings for both person and work profiles for a user
+ */
+ private UserManager mUserManager;
+
@Override
public int getMetricsCategory() {
return SettingsEnums.TTS_TEXT_TO_SPEECH;
@@ -176,6 +185,9 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
.setButton2OnClickListener(v -> resetTts())
.setButton1Enabled(true);
+ mUserManager = (UserManager) getActivity()
+ .getApplicationContext().getSystemService(Context.USER_SERVICE);
+
if (savedInstanceState == null) {
mLocalePreference.setEnabled(false);
mLocalePreference.setEntries(new CharSequence[0]);
@@ -670,8 +682,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
private void updateSpeechRate(int speechRateSeekBarProgress) {
mDefaultRate = getValueFromSeekBarProgress(KEY_DEFAULT_RATE, speechRateSeekBarProgress);
try {
- android.provider.Settings.Secure.putInt(
- getContentResolver(), TTS_DEFAULT_RATE, mDefaultRate);
+ updateTTSSetting(TTS_DEFAULT_RATE, mDefaultRate);
if (mTts != null) {
mTts.setSpeechRate(mDefaultRate / 100.0f);
}
@@ -685,8 +696,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
private void updateSpeechPitchValue(int speechPitchSeekBarProgress) {
mDefaultPitch = getValueFromSeekBarProgress(KEY_DEFAULT_PITCH, speechPitchSeekBarProgress);
try {
- android.provider.Settings.Secure.putInt(
- getContentResolver(), TTS_DEFAULT_PITCH, mDefaultPitch);
+ updateTTSSetting(TTS_DEFAULT_PITCH, mDefaultPitch);
if (mTts != null) {
mTts.setPitch(mDefaultPitch / 100.0f);
}
@@ -697,6 +707,16 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
return;
}
+ private void updateTTSSetting(String key, int value) {
+ Secure.putInt(
+ getContentResolver(), key, value);
+ final int managedProfileUserId =
+ Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
+ if (managedProfileUserId != UserHandle.USER_NULL) {
+ Secure.putIntForUser(getContentResolver(), key, value, managedProfileUserId);
+ }
+ }
+
private void updateWidgetState(boolean enable) {
getActivity().runOnUiThread(() -> {
mActionButtons.setButton1Enabled(enable);