Merge changes from topic "rtt-settings-change-cp"
am: 668300083e
Change-Id: If05a3f29730cede46254f38280065c465e9da613
diff --git a/res/layout/text_view_preference.xml b/res/layout/text_view_preference.xml
new file mode 100644
index 0000000..3677b3b
--- /dev/null
+++ b/res/layout/text_view_preference.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2018 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
+ -->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:fontFamily="sans-serif"
+ android:linksClickable="true"
+ android:singleLine="false"/>
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1bdd342..e7e2571 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1184,8 +1184,14 @@
<!-- RTT settings: used to turn on/off Real-Time Text, an accessibility feature similar to
TTY that allows users to send text over a phone call. -->
- <string name="rtt_mode_title">RTT</string>
- <string name="rtt_mode_summary">Turn RTT on or off</string>
+ <string name="rtt_mode_title">Real-time text (RTT) call</string>
+ <string name="rtt_mode_summary">Allow messaging within a voice call</string>
+ <string name="rtt_mode_more_information">
+ RTT assists callers who are deaf, hard hearing, have a speech disability,
+ or need more than voice alone.<br>
+ <a href="<xliff:g example="http://www.google.com" id="url">http://support.google.com/mobile?p=telephony_rtt</xliff:g>">Learn more</a>
+ <br><br> - RTT calls are saved as a message transcript
+ <br> - RTT is not available for video calls</string>
<!-- Service option entries. -->
<string-array name="tty_mode_entries">
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index e674e74..ccc97c5 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -38,4 +38,8 @@
android:persistent="true"
android:summary="@string/rtt_mode_summary"/>
+ <com.android.phone.settings.TextViewPreference
+ android:key="button_rtt_more_information_key"
+ android:title="@string/rtt_mode_more_information"/>
+
</PreferenceScreen>
diff --git a/src/com/android/phone/settings/AccessibilitySettingsFragment.java b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
index 8ec747c..314d895 100644
--- a/src/com/android/phone/settings/AccessibilitySettingsFragment.java
+++ b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
@@ -44,6 +44,7 @@
private static final String BUTTON_TTY_KEY = "button_tty_mode_key";
private static final String BUTTON_HAC_KEY = "button_hac_key";
private static final String BUTTON_RTT_KEY = "button_rtt_key";
+ private static final String RTT_INFO_PREF = "button_rtt_more_information_key";
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
/**
@@ -110,6 +111,8 @@
mButtonRtt.setChecked(rttOn);
} else {
getPreferenceScreen().removePreference(mButtonRtt);
+ Preference rttInfoPref = findPreference(RTT_INFO_PREF);
+ getPreferenceScreen().removePreference(rttInfoPref);
mButtonRtt = null;
}
}
diff --git a/src/com/android/phone/settings/TextViewPreference.java b/src/com/android/phone/settings/TextViewPreference.java
new file mode 100644
index 0000000..3770bda
--- /dev/null
+++ b/src/com/android/phone/settings/TextViewPreference.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2018 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.phone.settings;
+
+import android.content.Context;
+import android.preference.Preference;
+import android.text.Html;
+import android.text.method.LinkMovementMethod;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.TextView;
+
+import com.android.phone.R;
+
+/**
+ * Provides a {@link TextView} inside a preference. Useful for displaying static text which may
+ * contain hyperlinks.
+ */
+public class TextViewPreference extends Preference {
+
+ /**
+ * The resource ID of the text to be populated in the {@link TextView} when a resource ID is
+ * used.
+ */
+ private int mTextResourceId = 0;
+
+ /** The text to be populated in the {@link TextView} when a {@link CharSequence} is used. */
+ private CharSequence mText;
+
+ /** The {@link TextView} containing the text. */
+ private TextView mTextView;
+
+ /**
+ * Instantiates the {@link TextViewPreference} instance.
+ *
+ * @param context The Context this is associated with, through which it can access the current
+ * theme, resources, etc.
+ * @param attrs The attributes of the XML tag that is inflating the preference.
+ * @param defStyleAttr An attribute in the current theme that contains a reference to a style
+ * resource that supplies default values for the view. Can be 0 to not look for defaults.
+ * @param defStyleRes A resource identifier of a style resource that supplies default values for
+ * the view, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to
+ * not look for defaults.
+ */
+ public TextViewPreference(
+ Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+
+ setLayoutResource(R.layout.text_view_preference);
+ }
+
+ /**
+ * Instantiates the {@link TextViewPreference} instance.
+ *
+ * @param context The Context this is associated with, through which it can access the current
+ * theme, resources, etc.
+ * @param attrs The attributes of the XML tag that is inflating the preference.
+ * @param defStyleAttr An attribute in the current theme that contains a reference to a style
+ * resource that supplies default values for the view. Can be 0 to not look for defaults.
+ */
+ public TextViewPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, 0);
+ }
+
+ /**
+ * Instantiates the {@link TextViewPreference} instance.
+ *
+ * @param context The Context this is associated with, through which it can access the current
+ * theme, resources, etc.
+ * @param attrs The attributes of the XML tag that is inflating the preference.
+ */
+ public TextViewPreference(Context context, AttributeSet attrs) {
+ this(context, attrs, android.R.attr.preferenceStyle, 0);
+ }
+
+ /**
+ * Instantiates the {@link TextViewPreference} instance.
+ *
+ * @param context The Context this is associated with, through which it can access the current
+ * theme, resources, etc.
+ */
+ public TextViewPreference(Context context) {
+ super(context, null);
+
+ setLayoutResource(R.layout.text_view_preference);
+ }
+
+ /**
+ * Handles binding the preference.
+ *
+ * @param view The view.
+ */
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ mTextView = (TextView) view.findViewById(R.id.text);
+ if (mTextResourceId != 0) {
+ setTitle(mTextResourceId);
+ } else if (mText != null) {
+ setTitle(mText);
+ } else if (getTitleRes() != 0) {
+ setTitle(getTitleRes());
+ }
+ }
+
+ /**
+ * Sets the preference title from a {@link CharSequence}.
+ *
+ * @param text The text.
+ */
+ @Override
+ public void setTitle(CharSequence text) {
+ mTextResourceId = 0;
+ mText = text;
+ if (mTextView == null) {
+ return;
+ }
+
+ mTextView.setMovementMethod(LinkMovementMethod.getInstance());
+ mTextView.setText(text);
+ }
+
+ /**
+ * Sets the preference title from a resource id.
+ *
+ * @param textResId The string resource Id.
+ */
+ @Override
+ public void setTitle(int textResId) {
+ mTextResourceId = textResId;
+ setTitle(Html.fromHtml(getContext().getString(textResId), Html.FROM_HTML_MODE_COMPACT));
+ }
+}
+