Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0494c454 authored by Menghan Li's avatar Menghan Li Committed by Android (Google) Code Review
Browse files

Merge "Minor change for CaptionAppearanceFragment"

parents 9e6c889a b9194c4e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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"/>

+2 −2
Original line number Diff line number Diff line
@@ -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
@@ -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());
    }
+4 −5
Original line number Diff line number Diff line
@@ -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);
@@ -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;
    }
+13 −3
Original line number Diff line number Diff line
@@ -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();
    }
}
+4 −10
Original line number Diff line number Diff line
@@ -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);
@@ -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