Loading res/layout/captioning_preview.xml +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ android:orientation="vertical" > <FrameLayout android:id="@+id/preview_viewport" android:layout_width="match_parent" android:layout_height="@dimen/captioning_preview_height" > Loading res/values/arrays.xml +6 −0 Original line number Diff line number Diff line Loading @@ -736,6 +736,7 @@ <!-- Titles for captioning character edge type preference. [CHAR LIMIT=35] --> <string-array name="captioning_edge_type_selector_titles"> <item>Default</item> <item>None</item> <item>Outline</item> <item>Drop shadow</item> Loading @@ -745,6 +746,7 @@ <!-- Values for captioning character edge type preference. --> <integer-array name="captioning_edge_type_selector_values" translatable="false" > <item>-1</item> <item>0</item> <item>1</item> <item>2</item> Loading @@ -754,6 +756,7 @@ <!-- Titles for captioning color preference. --> <string-array name="captioning_color_selector_titles" translatable="false" > <item>@string/color_unspecified</item> <item>@string/color_white</item> <item>@string/color_black</item> <item>@string/color_red</item> Loading @@ -766,6 +769,7 @@ <!-- Values for captioning color preference. --> <integer-array name="captioning_color_selector_values" translatable="false" > <item>0x00000100</item> <item>0xFFFFFFFF</item> <item>0xFF000000</item> <item>0xFFFF0000</item> Loading Loading @@ -850,6 +854,7 @@ <!-- Titles for captioning text style preset preference. [CHAR LIMIT=35] --> <string-array name="captioning_preset_selector_titles" > <item>Use app defaults</item> <item>White on black</item> <item>Black on white</item> <item>Yellow on black</item> Loading @@ -859,6 +864,7 @@ <!-- Values for captioning text style preset preference. --> <integer-array name="captioning_preset_selector_values" translatable="false" > <item>4</item> <item>0</item> <item>1</item> <item>2</item> Loading res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -122,4 +122,6 @@ <!-- Search title (recent / results) padding start --> <dimen name="search_title_padding_start">12dp</dimen> <!-- Default text size for caption preview samples. Uses dp rather than sp because captions are not scaled. --> <dimen name="caption_preview_text_size">48dp</dimen> </resources> res/values/strings.xml +3 −1 Original line number Diff line number Diff line Loading @@ -3369,7 +3369,9 @@ <!-- Label for the default device locale. [CHAR LIMIT=35] --> <string name="locale_default">Default</string> <!-- Label for no color. [CHAR LIMIT=35] --> <!-- Label for default color. This lets the app pick the color. [CHAR LIMIT=35] --> <string name="color_unspecified">Default</string> <!-- Label for no color (transparent). [CHAR LIMIT=35] --> <string name="color_none">None</string> <!-- Label for the color white. [CHAR LIMIT=35] --> <string name="color_white">White</string> Loading src/com/android/settings/accessibility/CaptionPropertiesFragment.java +31 −9 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.preference.Preference.OnPreferenceChangeListener; import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnLayoutChangeListener; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.accessibility.CaptioningManager; Loading Loading @@ -64,11 +65,13 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment private static final String PREF_PRESET = "captioning_preset"; private static final String PREF_CUSTOM = "custom"; private static final float DEFAULT_FONT_SIZE = 48f; /** WebVtt specifies line height as 5.3% of the viewport height. */ private static final float LINE_HEIGHT_RATIO = 0.0533f; private CaptioningManager mCaptioningManager; private SubtitleView mPreviewText; private View mPreviewWindow; private View mPreviewViewport; private SwitchBar mSwitchBar; private ToggleSwitch mToggleSwitch; Loading Loading @@ -130,13 +133,21 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment mPreviewText = (SubtitleView) view.findViewById(R.id.preview_text); mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); mPreviewWindow = view.findViewById(R.id.preview_window); mPreviewViewport = view.findViewById(R.id.preview_viewport); mPreviewViewport.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { refreshPreviewText(); } }); SettingsActivity activity = (SettingsActivity) getActivity(); mSwitchBar = activity.getSwitchBar(); mToggleSwitch = mSwitchBar.getSwitch(); mToggleSwitch.setCheckedInternal(enabled); mPreviewWindow = view.findViewById(R.id.preview_window); getPreferenceScreen().setEnabled(enabled); refreshPreviewText(); Loading Loading @@ -164,7 +175,7 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment final SubtitleView preview = mPreviewText; if (preview != null) { final int styleId = mCaptioningManager.getRawUserStyle(); applyCaptionProperties(mCaptioningManager, preview, styleId); applyCaptionProperties(mCaptioningManager, preview, mPreviewViewport, styleId); final Locale locale = mCaptioningManager.getLocale(); if (locale != null) { Loading @@ -176,18 +187,29 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment } final CaptionStyle style = mCaptioningManager.getUserStyle(); if (style.hasWindowColor()) { mPreviewWindow.setBackgroundColor(style.windowColor); } else { final CaptionStyle defStyle = CaptionStyle.DEFAULT; mPreviewWindow.setBackgroundColor(defStyle.windowColor); } } } public static void applyCaptionProperties( CaptioningManager manager, SubtitleView previewText, int styleId) { public static void applyCaptionProperties(CaptioningManager manager, SubtitleView previewText, View previewWindow, int styleId) { previewText.setStyle(styleId); final Context context = previewText.getContext(); final ContentResolver cr = context.getContentResolver(); final float fontScale = manager.getFontScale(); previewText.setTextSize(fontScale * DEFAULT_FONT_SIZE); if (previewWindow != null) { previewText.setTextSize(previewWindow.getHeight() * LINE_HEIGHT_RATIO * fontScale); } else { final float textSize = context.getResources().getDimension( R.dimen.caption_preview_text_size); previewText.setTextSize(textSize * fontScale); } final Locale locale = manager.getLocale(); if (locale != null) { Loading Loading @@ -341,7 +363,7 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment final int opacityValue = opacity.getValue(); final int value; if (Color.alpha(colorValue) == 0) { value = Color.alpha(opacityValue); value = colorValue & 0x00FFFF00 | Color.alpha(opacityValue); } else { value = colorValue & 0x00FFFFFF | opacityValue & 0xFF000000; } Loading Loading
res/layout/captioning_preview.xml +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ android:orientation="vertical" > <FrameLayout android:id="@+id/preview_viewport" android:layout_width="match_parent" android:layout_height="@dimen/captioning_preview_height" > Loading
res/values/arrays.xml +6 −0 Original line number Diff line number Diff line Loading @@ -736,6 +736,7 @@ <!-- Titles for captioning character edge type preference. [CHAR LIMIT=35] --> <string-array name="captioning_edge_type_selector_titles"> <item>Default</item> <item>None</item> <item>Outline</item> <item>Drop shadow</item> Loading @@ -745,6 +746,7 @@ <!-- Values for captioning character edge type preference. --> <integer-array name="captioning_edge_type_selector_values" translatable="false" > <item>-1</item> <item>0</item> <item>1</item> <item>2</item> Loading @@ -754,6 +756,7 @@ <!-- Titles for captioning color preference. --> <string-array name="captioning_color_selector_titles" translatable="false" > <item>@string/color_unspecified</item> <item>@string/color_white</item> <item>@string/color_black</item> <item>@string/color_red</item> Loading @@ -766,6 +769,7 @@ <!-- Values for captioning color preference. --> <integer-array name="captioning_color_selector_values" translatable="false" > <item>0x00000100</item> <item>0xFFFFFFFF</item> <item>0xFF000000</item> <item>0xFFFF0000</item> Loading Loading @@ -850,6 +854,7 @@ <!-- Titles for captioning text style preset preference. [CHAR LIMIT=35] --> <string-array name="captioning_preset_selector_titles" > <item>Use app defaults</item> <item>White on black</item> <item>Black on white</item> <item>Yellow on black</item> Loading @@ -859,6 +864,7 @@ <!-- Values for captioning text style preset preference. --> <integer-array name="captioning_preset_selector_values" translatable="false" > <item>4</item> <item>0</item> <item>1</item> <item>2</item> Loading
res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -122,4 +122,6 @@ <!-- Search title (recent / results) padding start --> <dimen name="search_title_padding_start">12dp</dimen> <!-- Default text size for caption preview samples. Uses dp rather than sp because captions are not scaled. --> <dimen name="caption_preview_text_size">48dp</dimen> </resources>
res/values/strings.xml +3 −1 Original line number Diff line number Diff line Loading @@ -3369,7 +3369,9 @@ <!-- Label for the default device locale. [CHAR LIMIT=35] --> <string name="locale_default">Default</string> <!-- Label for no color. [CHAR LIMIT=35] --> <!-- Label for default color. This lets the app pick the color. [CHAR LIMIT=35] --> <string name="color_unspecified">Default</string> <!-- Label for no color (transparent). [CHAR LIMIT=35] --> <string name="color_none">None</string> <!-- Label for the color white. [CHAR LIMIT=35] --> <string name="color_white">White</string> Loading
src/com/android/settings/accessibility/CaptionPropertiesFragment.java +31 −9 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.preference.Preference.OnPreferenceChangeListener; import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnLayoutChangeListener; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.accessibility.CaptioningManager; Loading Loading @@ -64,11 +65,13 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment private static final String PREF_PRESET = "captioning_preset"; private static final String PREF_CUSTOM = "custom"; private static final float DEFAULT_FONT_SIZE = 48f; /** WebVtt specifies line height as 5.3% of the viewport height. */ private static final float LINE_HEIGHT_RATIO = 0.0533f; private CaptioningManager mCaptioningManager; private SubtitleView mPreviewText; private View mPreviewWindow; private View mPreviewViewport; private SwitchBar mSwitchBar; private ToggleSwitch mToggleSwitch; Loading Loading @@ -130,13 +133,21 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment mPreviewText = (SubtitleView) view.findViewById(R.id.preview_text); mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); mPreviewWindow = view.findViewById(R.id.preview_window); mPreviewViewport = view.findViewById(R.id.preview_viewport); mPreviewViewport.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { refreshPreviewText(); } }); SettingsActivity activity = (SettingsActivity) getActivity(); mSwitchBar = activity.getSwitchBar(); mToggleSwitch = mSwitchBar.getSwitch(); mToggleSwitch.setCheckedInternal(enabled); mPreviewWindow = view.findViewById(R.id.preview_window); getPreferenceScreen().setEnabled(enabled); refreshPreviewText(); Loading Loading @@ -164,7 +175,7 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment final SubtitleView preview = mPreviewText; if (preview != null) { final int styleId = mCaptioningManager.getRawUserStyle(); applyCaptionProperties(mCaptioningManager, preview, styleId); applyCaptionProperties(mCaptioningManager, preview, mPreviewViewport, styleId); final Locale locale = mCaptioningManager.getLocale(); if (locale != null) { Loading @@ -176,18 +187,29 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment } final CaptionStyle style = mCaptioningManager.getUserStyle(); if (style.hasWindowColor()) { mPreviewWindow.setBackgroundColor(style.windowColor); } else { final CaptionStyle defStyle = CaptionStyle.DEFAULT; mPreviewWindow.setBackgroundColor(defStyle.windowColor); } } } public static void applyCaptionProperties( CaptioningManager manager, SubtitleView previewText, int styleId) { public static void applyCaptionProperties(CaptioningManager manager, SubtitleView previewText, View previewWindow, int styleId) { previewText.setStyle(styleId); final Context context = previewText.getContext(); final ContentResolver cr = context.getContentResolver(); final float fontScale = manager.getFontScale(); previewText.setTextSize(fontScale * DEFAULT_FONT_SIZE); if (previewWindow != null) { previewText.setTextSize(previewWindow.getHeight() * LINE_HEIGHT_RATIO * fontScale); } else { final float textSize = context.getResources().getDimension( R.dimen.caption_preview_text_size); previewText.setTextSize(textSize * fontScale); } final Locale locale = manager.getLocale(); if (locale != null) { Loading Loading @@ -341,7 +363,7 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment final int opacityValue = opacity.getValue(); final int value; if (Color.alpha(colorValue) == 0) { value = Color.alpha(opacityValue); value = colorValue & 0x00FFFF00 | Color.alpha(opacityValue); } else { value = colorValue & 0x00FFFFFF | opacityValue & 0xFF000000; } Loading