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 Original line Diff line number Diff line
@@ -22,6 +22,7 @@


    <com.android.settings.accessibility.LocalePreference
    <com.android.settings.accessibility.LocalePreference
        android:key="captioning_locale"
        android:key="captioning_locale"
        android:summary="%s"
        android:title="@string/captioning_locale"
        android:title="@string/captioning_locale"
        settings:controller="com.android.settings.accessibility.CaptionLocalePreferenceController"/>
        settings:controller="com.android.settings.accessibility.CaptionLocalePreferenceController"/>


+2 −2
Original line number Original line Diff line number Diff line
@@ -42,7 +42,6 @@ public class CaptionCustomController extends BasePreferenceController
    private Preference mCustom;
    private Preference mCustom;
    private final CaptionHelper mCaptionHelper;
    private final CaptionHelper mCaptionHelper;
    private final ContentResolver mContentResolver;
    private final ContentResolver mContentResolver;
    private final Handler mHandler = new Handler(Looper.getMainLooper());
    @VisibleForTesting
    @VisibleForTesting
    AccessibilitySettingsContentObserver mSettingsContentObserver;
    AccessibilitySettingsContentObserver mSettingsContentObserver;
    @VisibleForTesting
    @VisibleForTesting
@@ -54,7 +53,8 @@ public class CaptionCustomController extends BasePreferenceController
        super(context, preferenceKey);
        super(context, preferenceKey);
        mCaptionHelper = new CaptionHelper(context);
        mCaptionHelper = new CaptionHelper(context);
        mContentResolver = context.getContentResolver();
        mContentResolver = context.getContentResolver();
        mSettingsContentObserver = new AccessibilitySettingsContentObserver(mHandler);
        mSettingsContentObserver = new AccessibilitySettingsContentObserver(
                new Handler(Looper.getMainLooper()));
        mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS,
        mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS,
                key -> refreshShowingCustom());
                key -> refreshShowingCustom());
    }
    }
+4 −5
Original line number Original line Diff line number Diff line
@@ -33,7 +33,6 @@ public class CaptionFontSizeController extends BasePreferenceController


    private final CaptioningManager mCaptioningManager;
    private final CaptioningManager mCaptioningManager;
    private final CaptionHelper mCaptionHelper;
    private final CaptionHelper mCaptionHelper;
    private ListPreference mPreference;


    public CaptionFontSizeController(Context context, String preferenceKey) {
    public CaptionFontSizeController(Context context, String preferenceKey) {
        super(context, preferenceKey);
        super(context, preferenceKey);
@@ -49,19 +48,19 @@ public class CaptionFontSizeController extends BasePreferenceController
    @Override
    @Override
    public void displayPreference(PreferenceScreen screen) {
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        super.displayPreference(screen);
        mPreference = screen.findPreference(getPreferenceKey());
        final ListPreference listPreference = screen.findPreference(getPreferenceKey());

        final float fontSize = mCaptioningManager.getFontScale();
        final float fontSize = mCaptioningManager.getFontScale();
        mPreference.setValue(Float.toString(fontSize));
        listPreference.setValue(Float.toString(fontSize));
    }
    }


    @Override
    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        final ListPreference listPreference = (ListPreference) preference;
        final ContentResolver cr = mContext.getContentResolver();
        final ContentResolver cr = mContext.getContentResolver();
        Settings.Secure.putFloat(
        Settings.Secure.putFloat(
                cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE,
                cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE,
                Float.parseFloat((String) newValue));
                Float.parseFloat((String) newValue));
        mPreference.setValue((String) newValue);
        listPreference.setValue((String) newValue);
        mCaptionHelper.setEnabled(true);
        mCaptionHelper.setEnabled(true);
        return false;
        return false;
    }
    }
+13 −3
Original line number Original line 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) {
    public void setRawUserStyle(int type) {
        Settings.Secure.putInt(mContentResolver,
        Settings.Secure.putInt(mContentResolver,
                Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, type);
                Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, type);
    }
    }


    /** Returns the caption raw user style.*/
    /** Returns the captioning raw preset number.*/
    public int getRawUserStyle() {
    public int getRawUserStyle() {
        return mCaptioningManager.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 Original line Diff line number Diff line
@@ -30,7 +30,6 @@ public class CaptionLocalePreferenceController extends BasePreferenceController
        implements Preference.OnPreferenceChangeListener {
        implements Preference.OnPreferenceChangeListener {


    private final CaptioningManager mCaptioningManager;
    private final CaptioningManager mCaptioningManager;
    private LocalePreference mPreference;


    public CaptionLocalePreferenceController(Context context, String preferenceKey) {
    public CaptionLocalePreferenceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
        super(context, preferenceKey);
@@ -45,22 +44,17 @@ public class CaptionLocalePreferenceController extends BasePreferenceController
    @Override
    @Override
    public void displayPreference(PreferenceScreen screen) {
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        super.displayPreference(screen);
        mPreference = screen.findPreference(getPreferenceKey());
        final LocalePreference localePreference = screen.findPreference(getPreferenceKey());
        final String rawLocale = mCaptioningManager.getRawLocale();
        final String rawLocale = mCaptioningManager.getRawLocale();
        mPreference.setValue(rawLocale == null ? "" : rawLocale);
        localePreference.setValue(rawLocale == null ? "" : rawLocale);
    }

    @Override
    public CharSequence getSummary() {
        return mPreference.getEntry();
    }
    }


    @Override
    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        final LocalePreference localePreference = (LocalePreference) preference;
        Settings.Secure.putString(mContext.getContentResolver(),
        Settings.Secure.putString(mContext.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_CAPTIONING_LOCALE, (String) newValue);
                Settings.Secure.ACCESSIBILITY_CAPTIONING_LOCALE, (String) newValue);
        mPreference.setValue((String) newValue);
        localePreference.setValue((String) newValue);
        mPreference.setSummary(mPreference.getEntry());
        return true;
        return true;
    }
    }
}
}
Loading