am 110ddbfe: Merge "Fix NullPointerException issue when user change"
* commit '110ddbfea0b6ba8702d3f7ba9d00c9f97c908dbb':
Fix NullPointerException issue when user change
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 48287c9..fd67ee5 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1014,7 +1014,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.accessibility.ToggleCaptioningPreferenceFragment" />
+ android:value="com.android.settings.accessibility.CaptionPropertiesFragment" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/accessibility_settings" />
</activity>
@@ -1359,13 +1359,6 @@
<!-- Development settings -->
- <activity android:name="DebugIntentSender" android:label="@string/debug_intent_sender_label">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
- </intent-filter>
- </activity>
-
<!-- DeviceInfo adds the user's requested build to stats upload. -->
<receiver android:name=".DeviceInfo$StatsReportReceiver">
<intent-filter>
diff --git a/res/layout/captioning_preview.xml b/res/layout/captioning_preview.xml
index 00d94a0..44563e4 100644
--- a/res/layout/captioning_preview.xml
+++ b/res/layout/captioning_preview.xml
@@ -40,9 +40,8 @@
android:text="@string/captioning_preview_text" />
</FrameLayout>
- <fragment
+ <FrameLayout
android:id="@+id/properties_fragment"
- android:name="com.android.settings.accessibility.CaptionPropertiesFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 586373c..22eb3e8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1134,7 +1134,7 @@
<!-- Bluetooth settings. Title of the advanced bluetooth settings screen [CHAR LIMIT=30]-->
<string name="bluetooth_advanced_titlebar">Advanced Bluetooth</string>
<!-- Bluetooth settings. Text displayed when Bluetooth is off and device list is empty [CHAR LIMIT=50]-->
- <string name="bluetooth_empty_list_bluetooth_off">To see devices, turn Bluetooth on.</string>
+ <string name="bluetooth_empty_list_bluetooth_off">When Bluetooth is turned on, your device can communicate with other nearby Bluetooth devices.</string>
<!-- Bluetooth settings. The title of the screen to pick which profiles to connect to on the device. For example, headphones may have both A2DP and headset, this allows the user to choose which one he wants to connect to. -->
@@ -2380,7 +2380,7 @@
<!-- SMS Application [CHAR LIMIT=35]-->
<string name="sms_application_title" translatable="true">Default SMS app</string>
<string name="sms_change_default_dialog_title" translatable="true">Change SMS app?</string>
- <string name="sms_change_default_dialog_text" translatable="true">Use <xliff:g id="new_app">%s</xliff:g> instead of <xliff:g id="current_app">%s</xliff:g> as your SMS app?</string>
+ <string name="sms_change_default_dialog_text" translatable="true">Use <xliff:g id="new_app">%1$s</xliff:g> instead of <xliff:g id="current_app">%2$s</xliff:g> as your SMS app?</string>
<string name="sms_change_default_no_previous_dialog_text" translatable="true">Use <xliff:g id="new_app">%s</xliff:g> as your SMS app?</string>
<!-- The SIM operator is not known [CHAR_ LIMIT=50]-->
@@ -3330,6 +3330,8 @@
<string name="captioning_background_opacity">Background opacity</string>
<!-- Title for the preference to change video caption text color. [CHAR LIMIT=35] -->
<string name="captioning_foreground_color">Text color</string>
+ <!-- Title for the preference to change video caption text opacity. [CHAR LIMIT=35] -->
+ <string name="captioning_foreground_opacity">Text opacity</string>
<!-- Title for the preference to change video caption edge color. [CHAR LIMIT=35] -->
<string name="captioning_edge_color">Edge color</string>
<!-- Title for the preference to change video caption edge type. [CHAR LIMIT=35] -->
@@ -4845,6 +4847,8 @@
<string name="help_url_security" translatable="false"></string>
<!-- Help URL, Tap & pay [DO NOT TRANSLATE] -->
<string name="help_url_nfc_payment" translatable="false"></string>
+ <!-- Help URL, Remote display [DO NOT TRANSLATE] -->
+ <string name="help_url_remote_display" translatable="false"></string>
<!-- User account title [CHAR LIMIT=30] -->
<string name="user_account_title">Account for content</string>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 7b599b8..ee49bbd 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -28,7 +28,7 @@
android:title="@string/accessibility_system_title">
<PreferenceScreen
- android:fragment="com.android.settings.accessibility.ToggleCaptioningPreferenceFragment"
+ android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
android:key="captioning_preference_screen"
android:title="@string/accessibility_captioning_title" />
diff --git a/res/xml/captioning_settings.xml b/res/xml/captioning_settings.xml
index 9773943..d14d352 100644
--- a/res/xml/captioning_settings.xml
+++ b/res/xml/captioning_settings.xml
@@ -17,7 +17,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
- android:fragment="com.android.settings.accessibility.ToggleCaptioningPreferenceFragment"
+ android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
android:key="captioning_preference_screen"
android:title="@string/accessibility_captioning_title" >
@@ -58,6 +58,10 @@
android:key="captioning_foreground_color"
android:persistent="false"
android:title="@string/captioning_foreground_color" />
+ <com.android.settings.accessibility.ColorPreference
+ android:key="captioning_foreground_opacity"
+ android:persistent="false"
+ android:title="@string/captioning_foreground_opacity" />
<com.android.settings.accessibility.EdgeTypePreference
android:key="captioning_edge_type"
diff --git a/src/com/android/settings/DebugIntentSender.java b/src/com/android/settings/DebugIntentSender.java
deleted file mode 100644
index 9fed947..0000000
--- a/src/com/android/settings/DebugIntentSender.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings;
-
-import android.app.Activity;
-import android.widget.EditText;
-import android.widget.Button;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.text.TextUtils;
-import android.text.Spannable;
-import android.text.Selection;
-import android.net.Uri;
-
-/**
- * A simple activity that provides a UI for sending intents
- */
-public class DebugIntentSender extends Activity {
- private EditText mIntentField;
- private EditText mDataField;
- private EditText mAccountField;
- private EditText mResourceField;
- private Button mSendBroadcastButton;
- private Button mStartActivityButton;
- private View.OnClickListener mClicked = new View.OnClickListener() {
- public void onClick(View v) {
- if ((v == mSendBroadcastButton) ||
- (v == mStartActivityButton)) {
- String intentAction = mIntentField.getText().toString();
- String intentData = mDataField.getText().toString();
- String account = mAccountField.getText().toString();
- String resource = mResourceField.getText().toString();
-
- Intent intent = new Intent(intentAction);
- if (!TextUtils.isEmpty(intentData)) {
- intent.setData(Uri.parse(intentData));
- }
- intent.putExtra("account", account);
- intent.putExtra("resource", resource);
- if (v == mSendBroadcastButton) {
- sendBroadcast(intent);
- } else {
- startActivity(intent);
- }
-
- setResult(RESULT_OK);
- finish();
- }
- }
- };
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.intent_sender);
-
- mIntentField = (EditText) findViewById(R.id.intent);
- mIntentField.setText(Intent.ACTION_SYNC);
- Selection.selectAll((Spannable) mIntentField.getText());
-
- mDataField = (EditText) findViewById(R.id.data);
- mDataField.setBackgroundResource(android.R.drawable.editbox_background);
-
- mAccountField = (EditText) findViewById(R.id.account);
- mResourceField = (EditText) findViewById(R.id.resource);
-
- mSendBroadcastButton = (Button) findViewById(R.id.sendbroadcast);
- mSendBroadcastButton.setOnClickListener(mClicked);
-
- mStartActivityButton = (Button) findViewById(R.id.startactivity);
- mStartActivityButton.setOnClickListener(mClicked);
- }
-}
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index db7eb2b..f6f49b8 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -61,8 +61,8 @@
import com.android.internal.util.ArrayUtils;
import com.android.settings.accessibility.AccessibilitySettings;
+import com.android.settings.accessibility.CaptionPropertiesFragment;
import com.android.settings.accessibility.ToggleAccessibilityServicePreferenceFragment;
-import com.android.settings.accessibility.ToggleCaptioningPreferenceFragment;
import com.android.settings.accounts.AccountSyncSettings;
import com.android.settings.accounts.AuthenticatorHelper;
import com.android.settings.accounts.ManageAccountsSettings;
@@ -326,13 +326,12 @@
ManageApplications.class.getName(),
ProcessStatsUi.class.getName(),
NotificationStation.class.getName(),
- AppOpsSummary.class.getName(),
LocationSettings.class.getName(),
SecuritySettings.class.getName(),
PrivacySettings.class.getName(),
DeviceAdminSettings.class.getName(),
AccessibilitySettings.class.getName(),
- ToggleCaptioningPreferenceFragment.class.getName(),
+ CaptionPropertiesFragment.class.getName(),
TextToSpeechSettings.class.getName(),
Memory.class.getName(),
DevelopmentSettings.class.getName(),
@@ -1081,7 +1080,15 @@
public static class DeviceInfoSettingsActivity extends Settings { /* empty */ }
public static class ApplicationSettingsActivity extends Settings { /* empty */ }
public static class ManageApplicationsActivity extends Settings { /* empty */ }
- public static class AppOpsSummaryActivity extends Settings { /* empty */ }
+ public static class AppOpsSummaryActivity extends Settings {
+ @Override
+ public boolean isValidFragment(String className) {
+ if (AppOpsSummary.class.getName().equals(className)) {
+ return true;
+ }
+ return super.isValidFragment(className);
+ }
+ }
public static class StorageUseActivity extends Settings { /* empty */ }
public static class DevelopmentSettingsActivity extends Settings { /* empty */ }
public static class AccessibilitySettingsActivity extends Settings { /* empty */ }
diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
index b010ca8..8a08d90 100644
--- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
+++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
@@ -16,6 +16,8 @@
package com.android.settings.accessibility;
+import android.app.ActionBar;
+import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
@@ -24,22 +26,46 @@
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
+import android.preference.PreferenceFrameLayout;
import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
import android.view.accessibility.CaptioningManager;
import android.view.accessibility.CaptioningManager.CaptionStyle;
+import com.android.internal.widget.SubtitleView;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
+import com.android.settings.accessibility.ToggleSwitch.OnBeforeCheckedChangeListener;
+
+import java.util.Locale;
/**
* Settings fragment containing captioning properties.
*/
public class CaptionPropertiesFragment extends SettingsPreferenceFragment
implements OnPreferenceChangeListener, OnValueChangedListener {
- private ToggleCaptioningPreferenceFragment mParent;
+ private static final String PREF_BACKGROUND_COLOR = "captioning_background_color";
+ private static final String PREF_BACKGROUND_OPACITY = "captioning_background_opacity";
+ private static final String PREF_FOREGROUND_COLOR = "captioning_foreground_color";
+ private static final String PREF_FOREGROUND_OPACITY = "captioning_foreground_opacity";
+ private static final String PREF_EDGE_COLOR = "captioning_edge_color";
+ private static final String PREF_EDGE_TYPE = "captioning_edge_type";
+ private static final String PREF_FONT_SIZE = "captioning_font_size";
+ private static final String PREF_TYPEFACE = "captioning_typeface";
+ private static final String PREF_LOCALE = "captioning_locale";
+ private static final String PREF_PRESET = "captioning_preset";
+ private static final String PREF_CUSTOM = "custom";
+
+ private static final float DEFAULT_FONT_SIZE = 48f;
+
private CaptioningManager mCaptioningManager;
+ private SubtitleView mPreviewText;
// Standard options.
private LocalePreference mLocale;
@@ -49,6 +75,7 @@
// Custom options.
private ListPreference mTypeface;
private ColorPreference mForegroundColor;
+ private ColorPreference mForegroundOpacity;
private EdgeTypePreference mEdgeType;
private ColorPreference mEdgeColor;
private ColorPreference mBackgroundColor;
@@ -70,35 +97,137 @@
installUpdateListeners();
}
- /**
- * Sets the parent fragment, which is used to update the live preview.
- *
- * @param parent the parent fragment
- */
- public void setParent(ToggleCaptioningPreferenceFragment parent) {
- mParent = parent;
+ @Override
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ final View rootView = inflater.inflate(R.layout.captioning_preview, container, false);
+
+ // We have to do this now because PreferenceFrameLayout looks at it
+ // only when the view is added.
+ if (container instanceof PreferenceFrameLayout) {
+ ((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
+ }
+
+ final View content = super.onCreateView(inflater, container, savedInstanceState);
+ ((ViewGroup) rootView.findViewById(R.id.properties_fragment)).addView(
+ content, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+
+ return rootView;
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ mPreviewText = (SubtitleView) view.findViewById(R.id.preview_text);
+
+ installActionBarToggleSwitch();
+ refreshPreviewText();
+ }
+
+ private void refreshPreviewText() {
+ final Context context = getActivity();
+ if (context == null) {
+ // We've been destroyed, abort!
+ return;
+ }
+
+ final SubtitleView preview = mPreviewText;
+ if (preview != null) {
+ final int styleId = mCaptioningManager.getRawUserStyle();
+ applyCaptionProperties(mCaptioningManager, preview, styleId);
+
+ final Locale locale = mCaptioningManager.getLocale();
+ if (locale != null) {
+ final CharSequence localizedText = AccessibilityUtils.getTextForLocale(
+ context, locale, R.string.captioning_preview_text);
+ preview.setText(localizedText);
+ } else {
+ preview.setText(R.string.captioning_preview_text);
+ }
+ }
+ }
+
+ public static void applyCaptionProperties(
+ CaptioningManager manager, SubtitleView previewText, 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);
+
+ final Locale locale = manager.getLocale();
+ if (locale != null) {
+ final CharSequence localizedText = AccessibilityUtils.getTextForLocale(
+ context, locale, R.string.captioning_preview_characters);
+ previewText.setText(localizedText);
+ } else {
+ previewText.setText(R.string.captioning_preview_characters);
+ }
+ }
+
+ private void installActionBarToggleSwitch() {
+ final Activity activity = getActivity();
+ final ToggleSwitch toggleSwitch = new ToggleSwitch(activity);
+
+ final int padding = getResources().getDimensionPixelSize(
+ R.dimen.action_bar_switch_padding);
+ toggleSwitch.setPaddingRelative(0, 0, padding, 0);
+
+ final ActionBar actionBar = activity.getActionBar();
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM);
+
+ final ActionBar.LayoutParams params = new ActionBar.LayoutParams(
+ ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT,
+ Gravity.CENTER_VERTICAL | Gravity.END);
+ actionBar.setCustomView(toggleSwitch, params);
+
+ final boolean enabled = mCaptioningManager.isEnabled();
+ getPreferenceScreen().setEnabled(enabled);
+ mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
+ toggleSwitch.setCheckedInternal(enabled);
+ toggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
+ @Override
+ public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
+ toggleSwitch.setCheckedInternal(checked);
+ Settings.Secure.putInt(getActivity().getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, checked ? 1 : 0);
+ getPreferenceScreen().setEnabled(checked);
+ mPreviewText.setVisibility(checked ? View.VISIBLE : View.INVISIBLE);
+ return false;
+ }
+ });
}
private void initializeAllPreferences() {
- mLocale = (LocalePreference) findPreference("captioning_locale");
- mFontSize = (ListPreference) findPreference("captioning_font_size");
+ mLocale = (LocalePreference) findPreference(PREF_LOCALE);
+ mFontSize = (ListPreference) findPreference(PREF_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);
- mPreset = (PresetPreference) findPreference("captioning_preset");
+ mPreset = (PresetPreference) findPreference(PREF_PRESET);
mPreset.setValues(presetValues);
mPreset.setTitles(presetTitles);
- mCustom = (PreferenceCategory) findPreference("custom");
+ mCustom = (PreferenceCategory) findPreference(PREF_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) mCustom.findPreference("captioning_foreground_color");
+ mForegroundColor = (ColorPreference) mCustom.findPreference(PREF_FOREGROUND_COLOR);
mForegroundColor.setTitles(colorTitles);
mForegroundColor.setValues(colorValues);
- mEdgeColor = (ColorPreference) mCustom.findPreference("captioning_edge_color");
+
+ final int[] opacityValues = res.getIntArray(R.array.captioning_opacity_selector_values);
+ final String[] opacityTitles = res.getStringArray(
+ R.array.captioning_opacity_selector_titles);
+ mForegroundOpacity = (ColorPreference) mCustom.findPreference(PREF_FOREGROUND_OPACITY);
+ mForegroundOpacity.setTitles(opacityTitles);
+ mForegroundOpacity.setValues(opacityValues);
+
+ mEdgeColor = (ColorPreference) mCustom.findPreference(PREF_EDGE_COLOR);
mEdgeColor.setTitles(colorTitles);
mEdgeColor.setValues(colorValues);
@@ -109,25 +238,22 @@
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 = (ColorPreference) mCustom.findPreference(PREF_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) mCustom.findPreference(
- "captioning_background_opacity");
+ mBackgroundOpacity = (ColorPreference) mCustom.findPreference(PREF_BACKGROUND_OPACITY);
mBackgroundOpacity.setTitles(opacityTitles);
mBackgroundOpacity.setValues(opacityValues);
- mEdgeType = (EdgeTypePreference) mCustom.findPreference("captioning_edge_type");
- mTypeface = (ListPreference) mCustom.findPreference("captioning_typeface");
+ mEdgeType = (EdgeTypePreference) mCustom.findPreference(PREF_EDGE_TYPE);
+ mTypeface = (ListPreference) mCustom.findPreference(PREF_TYPEFACE);
}
private void installUpdateListeners() {
mPreset.setOnValueChangedListener(this);
mForegroundColor.setOnValueChangedListener(this);
+ mForegroundOpacity.setOnValueChangedListener(this);
mEdgeColor.setOnValueChangedListener(this);
mBackgroundColor.setOnValueChangedListener(this);
mBackgroundOpacity.setOnValueChangedListener(this);
@@ -147,22 +273,11 @@
final ContentResolver cr = getContentResolver();
final CaptionStyle attrs = CaptionStyle.getCustomStyle(cr);
- mForegroundColor.setValue(attrs.foregroundColor);
mEdgeType.setValue(attrs.edgeType);
mEdgeColor.setValue(attrs.edgeColor);
- final int backgroundColor = attrs.backgroundColor;
- final int bgColor;
- final int bgAlpha;
- if (Color.alpha(backgroundColor) == 0) {
- bgColor = Color.TRANSPARENT;
- bgAlpha = (backgroundColor & 0xFF) << 24;
- } else {
- bgColor = backgroundColor | 0xFF000000;
- bgAlpha = backgroundColor & 0xFF000000;
- }
- mBackgroundColor.setValue(bgColor);
- mBackgroundOpacity.setValue(bgAlpha | 0xFFFFFF);
+ parseColorOpacity(mForegroundColor, mForegroundOpacity, attrs.foregroundColor);
+ parseColorOpacity(mBackgroundColor, mBackgroundOpacity, attrs.backgroundColor);
final String rawTypeface = attrs.mRawTypeface;
mTypeface.setValue(rawTypeface == null ? "" : rawTypeface);
@@ -171,10 +286,30 @@
mLocale.setValue(rawLocale == null ? "" : rawLocale);
}
- private void refreshPreviewText() {
- if (mParent != null) {
- mParent.refreshPreviewText();
+ private void parseColorOpacity(ColorPreference color, ColorPreference opacity, int value) {
+ final int colorValue;
+ final int opacityValue;
+ if (Color.alpha(value) == 0) {
+ colorValue = Color.TRANSPARENT;
+ opacityValue = (value & 0xFF) << 24;
+ } else {
+ colorValue = value | 0xFF000000;
+ opacityValue = value & 0xFF000000;
}
+ color.setValue(colorValue);
+ opacity.setValue(opacityValue | 0xFFFFFF);
+ }
+
+ private int mergeColorOpacity(ColorPreference color, ColorPreference opacity) {
+ final int colorValue = color.getValue();
+ final int opacityValue = opacity.getValue();
+ final int value;
+ if (Color.alpha(colorValue) == 0) {
+ value = Color.alpha(opacityValue);
+ } else {
+ value = colorValue & 0x00FFFFFF | opacityValue & 0xFF000000;
+ }
+ return value;
}
private void refreshShowingCustom() {
@@ -191,20 +326,14 @@
@Override
public void onValueChanged(ListDialogPreference preference, int value) {
final ContentResolver cr = getActivity().getContentResolver();
- if (mForegroundColor == preference) {
+ if (mForegroundColor == preference || mForegroundOpacity == preference) {
+ final int merged = mergeColorOpacity(mForegroundColor, mForegroundOpacity);
Settings.Secure.putInt(
- cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR, value);
+ cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR, merged);
} else if (mBackgroundColor == preference || mBackgroundOpacity == preference) {
- final int bgColor = mBackgroundColor.getValue();
- final int bgAlpha = mBackgroundOpacity.getValue();
- final int argb;
- if (Color.alpha(bgColor) == 0) {
- argb = Color.alpha(bgAlpha);
- } else {
- argb = bgColor & 0x00FFFFFF | bgAlpha & 0xFF000000;
- }
+ final int merged = mergeColorOpacity(mBackgroundColor, mBackgroundOpacity);
Settings.Secure.putInt(
- cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR, argb);
+ cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR, merged);
} else if (mEdgeColor == preference) {
Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_EDGE_COLOR, value);
} else if (mPreset == preference) {
diff --git a/src/com/android/settings/accessibility/PresetPreference.java b/src/com/android/settings/accessibility/PresetPreference.java
index c091f71..84aba6c 100644
--- a/src/com/android/settings/accessibility/PresetPreference.java
+++ b/src/com/android/settings/accessibility/PresetPreference.java
@@ -51,7 +51,7 @@
protected void onBindListItem(View view, int index) {
final SubtitleView previewText = (SubtitleView) view.findViewById(R.id.preview);
final int value = getValueAt(index);
- ToggleCaptioningPreferenceFragment.applyCaptionProperties(
+ CaptionPropertiesFragment.applyCaptionProperties(
mCaptioningManager, previewText, value);
previewText.setTextSize(DEFAULT_FONT_SIZE);
diff --git a/src/com/android/settings/accessibility/ToggleCaptioningPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleCaptioningPreferenceFragment.java
deleted file mode 100644
index f3c8b1c..0000000
--- a/src/com/android/settings/accessibility/ToggleCaptioningPreferenceFragment.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.accessibility;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.app.Fragment;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.os.Bundle;
-import android.preference.PreferenceFrameLayout;
-import android.provider.Settings;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.accessibility.CaptioningManager;
-
-import com.android.internal.widget.SubtitleView;
-import com.android.settings.R;
-import com.android.settings.accessibility.ToggleSwitch.OnBeforeCheckedChangeListener;
-
-import java.util.Locale;
-
-public class ToggleCaptioningPreferenceFragment extends Fragment {
- private static final float DEFAULT_FONT_SIZE = 48f;
-
- private CaptionPropertiesFragment mPropsFragment;
- private SubtitleView mPreviewText;
- private CaptioningManager mCaptioningManager;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- mCaptioningManager = (CaptioningManager) getActivity()
- .getSystemService(Context.CAPTIONING_SERVICE);
- }
-
- @Override
- public View onCreateView(
- LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final View rootView = inflater.inflate(R.layout.captioning_preview, container, false);
-
- // We have to do this now because PreferenceFrameLayout looks at it
- // only when the view is added.
- if (container instanceof PreferenceFrameLayout) {
- ((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
- }
-
- return rootView;
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- mPropsFragment = ((CaptionPropertiesFragment) getFragmentManager()
- .findFragmentById(R.id.properties_fragment));
- mPropsFragment.setParent(this);
-
- mPreviewText = (SubtitleView) view.findViewById(R.id.preview_text);
-
- installActionBarToggleSwitch();
- refreshPreviewText();
- }
-
- public void refreshPreviewText() {
- final SubtitleView preview = mPreviewText;
- if (preview != null) {
- final Activity activity = getActivity();
- final ContentResolver cr = activity.getContentResolver();
- final int styleId = mCaptioningManager.getRawUserStyle();
- applyCaptionProperties(mCaptioningManager, preview, styleId);
-
- final Locale locale = mCaptioningManager.getLocale();
- if (locale != null) {
- final CharSequence localizedText = AccessibilityUtils.getTextForLocale(
- activity, locale, R.string.captioning_preview_text);
- preview.setText(localizedText);
- } else {
- preview.setText(R.string.captioning_preview_text);
- }
- }
- }
-
- public static void applyCaptionProperties(
- CaptioningManager manager, SubtitleView previewText, 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);
-
- final Locale locale = manager.getLocale();
- if (locale != null) {
- final CharSequence localizedText = AccessibilityUtils.getTextForLocale(
- context, locale, R.string.captioning_preview_characters);
- previewText.setText(localizedText);
- } else {
- previewText.setText(R.string.captioning_preview_characters);
- }
- }
-
- private void installActionBarToggleSwitch() {
- final Activity activity = getActivity();
- final ToggleSwitch toggleSwitch = new ToggleSwitch(activity);
-
- final int padding = getResources().getDimensionPixelSize(
- R.dimen.action_bar_switch_padding);
- toggleSwitch.setPaddingRelative(0, 0, padding, 0);
-
- final ActionBar actionBar = activity.getActionBar();
- actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM);
-
- final ActionBar.LayoutParams params = new ActionBar.LayoutParams(
- ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.END);
- actionBar.setCustomView(toggleSwitch, params);
-
- final boolean enabled = mCaptioningManager.isEnabled();
- mPropsFragment.getPreferenceScreen().setEnabled(enabled);
- mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
- toggleSwitch.setCheckedInternal(enabled);
- toggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
- @Override
- public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
- toggleSwitch.setCheckedInternal(checked);
- Settings.Secure.putInt(getActivity().getContentResolver(),
- Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, checked ? 1 : 0);
- mPropsFragment.getPreferenceScreen().setEnabled(checked);
- mPreviewText.setVisibility(checked ? View.VISIBLE : View.INVISIBLE);
- return false;
- }
- });
- }
-}
diff --git a/src/com/android/settings/wfd/WifiDisplaySettings.java b/src/com/android/settings/wfd/WifiDisplaySettings.java
index d04f6f2..d7f4708 100755
--- a/src/com/android/settings/wfd/WifiDisplaySettings.java
+++ b/src/com/android/settings/wfd/WifiDisplaySettings.java
@@ -137,6 +137,11 @@
}
@Override
+ protected int getHelpResource() {
+ return R.string.help_url_remote_display;
+ }
+
+ @Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);