Loading res/xml/captioning_more_options.xml +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ <com.android.settings.accessibility.LocalePreference android:key="captioning_locale" android:summary="%s" android:title="@string/captioning_locale" settings:controller="com.android.settings.accessibility.CaptionLocalePreferenceController"/> Loading src/com/android/settings/accessibility/CaptionCustomController.java +2 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ public class CaptionCustomController extends BasePreferenceController private Preference mCustom; private final CaptionHelper mCaptionHelper; private final ContentResolver mContentResolver; private final Handler mHandler = new Handler(Looper.getMainLooper()); @VisibleForTesting AccessibilitySettingsContentObserver mSettingsContentObserver; @VisibleForTesting Loading @@ -54,7 +53,8 @@ public class CaptionCustomController extends BasePreferenceController super(context, preferenceKey); mCaptionHelper = new CaptionHelper(context); mContentResolver = context.getContentResolver(); mSettingsContentObserver = new AccessibilitySettingsContentObserver(mHandler); mSettingsContentObserver = new AccessibilitySettingsContentObserver( new Handler(Looper.getMainLooper())); mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS, key -> refreshShowingCustom()); } Loading src/com/android/settings/accessibility/CaptionFontSizeController.java +4 −5 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ public class CaptionFontSizeController extends BasePreferenceController private final CaptioningManager mCaptioningManager; private final CaptionHelper mCaptionHelper; private ListPreference mPreference; public CaptionFontSizeController(Context context, String preferenceKey) { super(context, preferenceKey); Loading @@ -49,19 +48,19 @@ public class CaptionFontSizeController extends BasePreferenceController @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); mPreference = screen.findPreference(getPreferenceKey()); final ListPreference listPreference = screen.findPreference(getPreferenceKey()); final float fontSize = mCaptioningManager.getFontScale(); mPreference.setValue(Float.toString(fontSize)); listPreference.setValue(Float.toString(fontSize)); } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final ListPreference listPreference = (ListPreference) preference; final ContentResolver cr = mContext.getContentResolver(); Settings.Secure.putFloat( cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, Float.parseFloat((String) newValue)); mPreference.setValue((String) newValue); listPreference.setValue((String) newValue); mCaptionHelper.setEnabled(true); return false; } Loading src/com/android/settings/accessibility/CaptionHelper.java +13 −3 Original line number Diff line number Diff line Loading @@ -188,17 +188,27 @@ public class CaptionHelper { } /** * Sets the caption raw user style. * Sets the captioning raw user style. * * @param type The caption raw user style * @param type The captioning raw user style */ public void setRawUserStyle(int type) { Settings.Secure.putInt(mContentResolver, Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, type); } /** Returns the caption raw user style.*/ /** Returns the captioning raw preset number.*/ public int getRawUserStyle() { return mCaptioningManager.getRawUserStyle(); } /** Returns the captioning visual properties.*/ public CaptionStyle getUserStyle() { return mCaptioningManager.getUserStyle(); } /** Returns the captioning locale language.*/ public Locale getLocale() { return mCaptioningManager.getLocale(); } } src/com/android/settings/accessibility/CaptionLocalePreferenceController.java +4 −10 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ public class CaptionLocalePreferenceController extends BasePreferenceController implements Preference.OnPreferenceChangeListener { private final CaptioningManager mCaptioningManager; private LocalePreference mPreference; public CaptionLocalePreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); Loading @@ -45,22 +44,17 @@ public class CaptionLocalePreferenceController extends BasePreferenceController @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); mPreference = screen.findPreference(getPreferenceKey()); final LocalePreference localePreference = screen.findPreference(getPreferenceKey()); final String rawLocale = mCaptioningManager.getRawLocale(); mPreference.setValue(rawLocale == null ? "" : rawLocale); } @Override public CharSequence getSummary() { return mPreference.getEntry(); localePreference.setValue(rawLocale == null ? "" : rawLocale); } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final LocalePreference localePreference = (LocalePreference) preference; Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_LOCALE, (String) newValue); mPreference.setValue((String) newValue); mPreference.setSummary(mPreference.getEntry()); localePreference.setValue((String) newValue); return true; } } Loading
res/xml/captioning_more_options.xml +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ <com.android.settings.accessibility.LocalePreference android:key="captioning_locale" android:summary="%s" android:title="@string/captioning_locale" settings:controller="com.android.settings.accessibility.CaptionLocalePreferenceController"/> Loading
src/com/android/settings/accessibility/CaptionCustomController.java +2 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ public class CaptionCustomController extends BasePreferenceController private Preference mCustom; private final CaptionHelper mCaptionHelper; private final ContentResolver mContentResolver; private final Handler mHandler = new Handler(Looper.getMainLooper()); @VisibleForTesting AccessibilitySettingsContentObserver mSettingsContentObserver; @VisibleForTesting Loading @@ -54,7 +53,8 @@ public class CaptionCustomController extends BasePreferenceController super(context, preferenceKey); mCaptionHelper = new CaptionHelper(context); mContentResolver = context.getContentResolver(); mSettingsContentObserver = new AccessibilitySettingsContentObserver(mHandler); mSettingsContentObserver = new AccessibilitySettingsContentObserver( new Handler(Looper.getMainLooper())); mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS, key -> refreshShowingCustom()); } Loading
src/com/android/settings/accessibility/CaptionFontSizeController.java +4 −5 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ public class CaptionFontSizeController extends BasePreferenceController private final CaptioningManager mCaptioningManager; private final CaptionHelper mCaptionHelper; private ListPreference mPreference; public CaptionFontSizeController(Context context, String preferenceKey) { super(context, preferenceKey); Loading @@ -49,19 +48,19 @@ public class CaptionFontSizeController extends BasePreferenceController @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); mPreference = screen.findPreference(getPreferenceKey()); final ListPreference listPreference = screen.findPreference(getPreferenceKey()); final float fontSize = mCaptioningManager.getFontScale(); mPreference.setValue(Float.toString(fontSize)); listPreference.setValue(Float.toString(fontSize)); } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final ListPreference listPreference = (ListPreference) preference; final ContentResolver cr = mContext.getContentResolver(); Settings.Secure.putFloat( cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, Float.parseFloat((String) newValue)); mPreference.setValue((String) newValue); listPreference.setValue((String) newValue); mCaptionHelper.setEnabled(true); return false; } Loading
src/com/android/settings/accessibility/CaptionHelper.java +13 −3 Original line number Diff line number Diff line Loading @@ -188,17 +188,27 @@ public class CaptionHelper { } /** * Sets the caption raw user style. * Sets the captioning raw user style. * * @param type The caption raw user style * @param type The captioning raw user style */ public void setRawUserStyle(int type) { Settings.Secure.putInt(mContentResolver, Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, type); } /** Returns the caption raw user style.*/ /** Returns the captioning raw preset number.*/ public int getRawUserStyle() { return mCaptioningManager.getRawUserStyle(); } /** Returns the captioning visual properties.*/ public CaptionStyle getUserStyle() { return mCaptioningManager.getUserStyle(); } /** Returns the captioning locale language.*/ public Locale getLocale() { return mCaptioningManager.getLocale(); } }
src/com/android/settings/accessibility/CaptionLocalePreferenceController.java +4 −10 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ public class CaptionLocalePreferenceController extends BasePreferenceController implements Preference.OnPreferenceChangeListener { private final CaptioningManager mCaptioningManager; private LocalePreference mPreference; public CaptionLocalePreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); Loading @@ -45,22 +44,17 @@ public class CaptionLocalePreferenceController extends BasePreferenceController @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); mPreference = screen.findPreference(getPreferenceKey()); final LocalePreference localePreference = screen.findPreference(getPreferenceKey()); final String rawLocale = mCaptioningManager.getRawLocale(); mPreference.setValue(rawLocale == null ? "" : rawLocale); } @Override public CharSequence getSummary() { return mPreference.getEntry(); localePreference.setValue(rawLocale == null ? "" : rawLocale); } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final LocalePreference localePreference = (LocalePreference) preference; Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_LOCALE, (String) newValue); mPreference.setValue((String) newValue); mPreference.setSummary(mPreference.getEntry()); localePreference.setValue((String) newValue); return true; } }