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

Commit 660223ff authored by Alan Viverette's avatar Alan Viverette
Browse files

Update captioning settings to match final design

BUG: 9926077
Change-Id: I058c05643f33aca89327f23bcdee53dd8afb3bbb
parent b14698ee
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -15,19 +15,12 @@
     limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <GridView
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/list"
    android:layout_width="match_parent"
        android:layout_height="400dp"
    android:layout_height="300dp"
    android:columnWidth="112dp"
    android:numColumns="auto_fit"
    android:paddingTop="16dp"
    android:stretchMode="spacingWidthUniform"
        android:verticalSpacing="16dp"
        android:paddingTop="16dp" />

</LinearLayout>
    android:verticalSpacing="16dp" />
+56 −30
Original line number Diff line number Diff line
@@ -759,7 +759,6 @@
    <!-- Titles for captioning color preference. -->
    <string-array name="captioning_color_selector_titles" translatable="false" >
        <item>@string/color_white</item>
        <item>@string/color_gray</item>
        <item>@string/color_black</item>
        <item>@string/color_red</item>
        <item>@string/color_yellow</item>
@@ -772,35 +771,6 @@
    <!-- Values for captioning color preference. -->
    <integer-array name="captioning_color_selector_values" translatable="false" >
        <item>0xFFFFFFFF</item>
        <item>0xFF808080</item>
        <item>0xFF000000</item>
        <item>0xFFFF0000</item>
        <item>0xFFFFFF00</item>
        <item>0xFF00FF00</item>
        <item>0xFF00FFFF</item>
        <item>0xFF0000FF</item>
        <item>0xFFFF00FF</item>
    </integer-array>

    <!-- Titles for captioning background color preference. -->
    <string-array name="captioning_background_color_selector_titles" translatable="false" >
        <item>@string/color_none</item>
        <item>@string/color_white</item>
        <item>@string/color_gray</item>
        <item>@string/color_black</item>
        <item>@string/color_red</item>
        <item>@string/color_yellow</item>
        <item>@string/color_green</item>
        <item>@string/color_cyan</item>
        <item>@string/color_blue</item>
        <item>@string/color_magenta</item>
    </string-array>

    <!-- Values for captioning background color preference. -->
    <integer-array name="captioning_background_color_selector_values" translatable="false" >
        <item>0x00000000</item>
        <item>0xFFFFFFFF</item>
        <item>0xFF808080</item>
        <item>0xFF000000</item>
        <item>0xFFFF0000</item>
        <item>0xFFFFFF00</item>
@@ -808,6 +778,62 @@
        <item>0xFF00FFFF</item>
        <item>0xFF0000FF</item>
        <item>0xFFFF00FF</item>
        <item>0xFF000055</item>
        <item>0xFF0000AA</item>
        <item>0xFF005500</item>
        <item>0xFF005555</item>
        <item>0xFF0055AA</item>
        <item>0xFF0055FF</item>
        <item>0xFF00AA00</item>
        <item>0xFF00AA55</item>
        <item>0xFF00AAAA</item>
        <item>0xFF00AAFF</item>
        <item>0xFF00FF55</item>
        <item>0xFF00FFAA</item>
        <item>0xFF550000</item>
        <item>0xFF550055</item>
        <item>0xFF5500AA</item>
        <item>0xFF5500FF</item>
        <item>0xFF555500</item>
        <item>0xFF555555</item>
        <item>0xFF5555AA</item>
        <item>0xFF5555FF</item>
        <item>0xFF55AA00</item>
        <item>0xFF55AA55</item>
        <item>0xFF55AAAA</item>
        <item>0xFF55AAFF</item>
        <item>0xFF55FF00</item>
        <item>0xFF55FF55</item>
        <item>0xFF55FFAA</item>
        <item>0xFF55FFFF</item>
        <item>0xFFAA0000</item>
        <item>0xFFAA0055</item>
        <item>0xFFAA00AA</item>
        <item>0xFFAA00FF</item>
        <item>0xFFAA5500</item>
        <item>0xFFAA5555</item>
        <item>0xFFAA55AA</item>
        <item>0xFFAA55FF</item>
        <item>0xFFAAAA00</item>
        <item>0xFFAAAA55</item>
        <item>0xFFAAAAAA</item>
        <item>0xFFAAAAFF</item>
        <item>0xFFAAFF00</item>
        <item>0xFFAAFF55</item>
        <item>0xFFAAFFAA</item>
        <item>0xFFAAFFFF</item>
        <item>0xFFFF0055</item>
        <item>0xFFFF00AA</item>
        <item>0xFFFF5500</item>
        <item>0xFFFF5555</item>
        <item>0xFFFF55AA</item>
        <item>0xFFFF55FF</item>
        <item>0xFFFFAA00</item>
        <item>0xFFFFAA55</item>
        <item>0xFFFFAAAA</item>
        <item>0xFFFFAAFF</item>
        <item>0xFFFFFF55</item>
        <item>0xFFFFFFAA</item>
    </integer-array>

    <!-- Titles for captioning opacity preference. [CHAR LIMIT=35] -->
+2 −0
Original line number Diff line number Diff line
@@ -3299,6 +3299,8 @@
    <string name="color_yellow">Yellow</string>
    <!-- Label for the color magenta. [CHAR LIMIT=35] -->
    <string name="color_magenta">Magenta</string>
    <!-- Label for custom colors, formats as a HTML color. -->
    <string name="color_custom" translatable="false">#%1$02X%2$02X%3$02X</string>

    <!-- Title for a warning about security implications of enabling an accessibility
         service. [CHAR LIMIT=NONE] -->
+0 −4
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@
        android:key="custom"
        android:title="@string/captioning_custom_options_title" >
        <ListPreference
            android:dependency="captioning_preset"
            android:entries="@array/captioning_typeface_selector_titles"
            android:entryValues="@array/captioning_typeface_selector_values"
            android:key="captioning_typeface"
@@ -56,13 +55,11 @@
            android:title="@string/captioning_typeface" />

        <com.android.settings.accessibility.ColorPreference
            android:dependency="captioning_preset"
            android:key="captioning_foreground_color"
            android:persistent="false"
            android:title="@string/captioning_foreground_color" />

        <com.android.settings.accessibility.EdgeTypePreference
            android:dependency="captioning_preset"
            android:key="captioning_edge_type"
            android:persistent="false"
            android:title="@string/captioning_edge_type" />
@@ -73,7 +70,6 @@
            android:persistent="false"
            android:title="@string/captioning_edge_color" />
        <com.android.settings.accessibility.ColorPreference
            android:dependency="captioning_preset"
            android:key="captioning_background_color"
            android:persistent="false"
            android:title="@string/captioning_background_color" />
+37 −12
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.graphics.Color;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings;
import android.view.accessibility.CaptioningManager;
@@ -50,6 +51,9 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
    private ColorPreference mEdgeColor;
    private ColorPreference mBackgroundColor;
    private ColorPreference mBackgroundOpacity;
    private PreferenceCategory mCustom;

    private boolean mShowingCustom;

    @Override
    public void onCreate(Bundle icicle) {
@@ -57,6 +61,7 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
        addPreferencesFromResource(R.xml.captioning_settings);
        initializeAllPreferences();
        updateAllPreferences();
        refreshShowingCustom();
        installUpdateListeners();
    }

@@ -70,6 +75,9 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
    }

    private void initializeAllPreferences() {
        mLocale = (LocalePreference) findPreference("captioning_locale");
        mFontSize = (ListPreference) findPreference("captioning_font_size");

        final Resources res = getResources();
        final int[] presetValues = res.getIntArray(R.array.captioning_preset_selector_values);
        final String[] presetTitles = res.getStringArray(R.array.captioning_preset_selector_titles);
@@ -77,34 +85,39 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
        mPreset.setValues(presetValues);
        mPreset.setTitles(presetTitles);

        mCustom = (PreferenceCategory) findPreference("custom");
        mShowingCustom = true;

        final int[] colorValues = res.getIntArray(R.array.captioning_color_selector_values);
        final String[] colorTitles = res.getStringArray(R.array.captioning_color_selector_titles);
        mForegroundColor = (ColorPreference) findPreference("captioning_foreground_color");
        mForegroundColor = (ColorPreference) mCustom.findPreference("captioning_foreground_color");
        mForegroundColor.setTitles(colorTitles);
        mForegroundColor.setValues(colorValues);
        mEdgeColor = (ColorPreference) findPreference("captioning_edge_color");
        mEdgeColor = (ColorPreference) mCustom.findPreference("captioning_edge_color");
        mEdgeColor.setTitles(colorTitles);
        mEdgeColor.setValues(colorValues);

        final int[] bgColorValues = res.getIntArray(
                R.array.captioning_background_color_selector_values);
        final String[] bgColorTitles = res.getStringArray(
                R.array.captioning_background_color_selector_titles);
        mBackgroundColor = (ColorPreference) findPreference("captioning_background_color");
        // Add "none" as an additional option for backgrounds.
        final int[] bgColorValues = new int[colorValues.length + 1];
        final String[] bgColorTitles = new String[colorTitles.length + 1];
        System.arraycopy(colorValues, 0, bgColorValues, 1, colorValues.length);
        System.arraycopy(colorTitles, 0, bgColorTitles, 1, colorTitles.length);
        bgColorValues[0] = Color.TRANSPARENT;
        bgColorTitles[0] = getString(R.string.color_none);
        mBackgroundColor = (ColorPreference) mCustom.findPreference("captioning_background_color");
        mBackgroundColor.setTitles(bgColorTitles);
        mBackgroundColor.setValues(bgColorValues);

        final int[] opacityValues = res.getIntArray(R.array.captioning_opacity_selector_values);
        final String[] opacityTitles = res.getStringArray(
                R.array.captioning_opacity_selector_titles);
        mBackgroundOpacity = (ColorPreference) findPreference("captioning_background_opacity");
        mBackgroundOpacity = (ColorPreference) mCustom.findPreference(
                "captioning_background_opacity");
        mBackgroundOpacity.setTitles(opacityTitles);
        mBackgroundOpacity.setValues(opacityValues);

        mEdgeType = (EdgeTypePreference) findPreference("captioning_edge_type");
        mTypeface = (ListPreference) findPreference("captioning_typeface");
        mFontSize = (ListPreference) findPreference("captioning_font_size");
        mLocale = (LocalePreference) findPreference("captioning_locale");
        mEdgeType = (EdgeTypePreference) mCustom.findPreference("captioning_edge_type");
        mTypeface = (ListPreference) mCustom.findPreference("captioning_typeface");
    }

    private void installUpdateListeners() {
@@ -159,6 +172,17 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
        }
    }

    private void refreshShowingCustom() {
        final boolean customPreset = mPreset.getValue() == CaptionStyle.PRESET_CUSTOM;
        if (!customPreset && mShowingCustom) {
            getPreferenceScreen().removePreference(mCustom);
            mShowingCustom = false;
        } else if (customPreset && !mShowingCustom) {
            getPreferenceScreen().addPreference(mCustom);
            mShowingCustom = true;
        }
    }

    @Override
    public void onValueChanged(ListDialogPreference preference, int value) {
        final ContentResolver cr = getActivity().getContentResolver();
@@ -180,6 +204,7 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
            Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_EDGE_COLOR, value);
        } else if (mPreset == preference) {
            Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, value);
            refreshShowingCustom();
        } else if (mEdgeType == preference) {
            Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_EDGE_TYPE, value);
        }
Loading