Merge "Update the rich content UI to meet the UX design version 2."

This commit is contained in:
PETER LIANG
2020-02-08 08:17:28 +00:00
committed by Android (Google) Code Review
5 changed files with 32 additions and 63 deletions

View File

@@ -34,7 +34,7 @@
android:paddingTop="16dp"
android:paddingBottom="4dp">
<ImageView
android:id="@+android:id/icon"
android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
@@ -45,11 +45,11 @@
android:paddingBottom="16dp"
android:paddingTop="16dp">
<TextView android:id="@+android:id/title"
<TextView android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+android:id/summary"
<TextView android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
@@ -57,9 +57,10 @@
android:textColor="?android:attr/textColorSecondary"/>
</RelativeLayout>
<LinearLayout android:id="@+android:id/widget_frame"
<LinearLayout android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" />
</LinearLayout>

View File

@@ -4806,7 +4806,7 @@
<!-- Summary for the accessibility magnification setting indicating both "Magnify with button" and "Magnify with triple-tap" are enabled [CHAR LIMIT=50] -->
<string name="accessibility_screen_magnification_state_navbar_gesture">Magnify with shortcut &amp; triple-tap</string>
<!-- Title for the footer text to explain what accessibility service does. [CHAR LIMIT=35] -->
<string name="accessibility_footer_title">About <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
<string name="accessibility_introduction_title">About <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
<!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
<string name="accessibility_screen_option">Options</string>
<!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->

View File

@@ -33,7 +33,6 @@ import com.android.settings.R;
*/
public class AnimatedImagePreference extends Preference {
private boolean mDividerAllowedAbove = false;
private Uri mImageUri;
AnimatedImagePreference(Context context) {
@@ -44,7 +43,6 @@ public class AnimatedImagePreference extends Preference {
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
holder.setDividerAllowedAbove(mDividerAllowedAbove);
final ImageView imageView = holder.itemView.findViewById(R.id.animated_img);
if (imageView != null && mImageUri != null) {
@@ -59,18 +57,6 @@ public class AnimatedImagePreference extends Preference {
}
}
/**
* Sets divider whether to show in preference above.
*
* @param allowed true will be drawn on above this item
*/
public void setDividerAllowedAbove(boolean allowed) {
if (allowed != mDividerAllowedAbove) {
mDividerAllowedAbove = allowed;
notifyChanged();
}
}
/**
* Set image uri to display image in {@link ImageView}
*

View File

@@ -32,7 +32,6 @@ import java.util.regex.Pattern;
*/
public final class HtmlTextPreference extends StaticTextPreference {
private boolean mDividerAllowedAbove = false;
private int mFlag = Html.FROM_HTML_MODE_COMPACT;
private Html.ImageGetter mImageGetter;
private Html.TagHandler mTagHandler;
@@ -45,7 +44,6 @@ public final class HtmlTextPreference extends StaticTextPreference {
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
holder.setDividerAllowedAbove(mDividerAllowedAbove);
final TextView summaryView = holder.itemView.findViewById(android.R.id.summary);
if (summaryView != null && !TextUtils.isEmpty(getSummary())) {
@@ -54,18 +52,6 @@ public final class HtmlTextPreference extends StaticTextPreference {
}
}
/**
* Sets divider whether to show in preference above.
*
* @param allowed true will be drawn on above this item
*/
public void setDividerAllowedAbove(boolean allowed) {
if (allowed != mDividerAllowedAbove) {
mDividerAllowedAbove = allowed;
notifyChanged();
}
}
/**
* Sets the flag to which text format to be applied.
*

View File

@@ -47,6 +47,7 @@ import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.widget.FooterPreference;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -75,7 +76,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
protected ComponentName mComponentName;
protected CharSequence mPackageName;
protected Uri mImageUri;
protected CharSequence mStaticDescription;
protected CharSequence mHtmlDescription;
private static final String ANCHOR_TAG = "a";
private static final String DRAWABLE_FOLDER = "drawable";
@@ -141,7 +141,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
final AnimatedImagePreference animatedImagePreference = new AnimatedImagePreference(
getPrefContext());
animatedImagePreference.setImageUri(mImageUri);
animatedImagePreference.setDividerAllowedAbove(true);
animatedImagePreference.setSelectable(false);
preferenceScreen.addPreference(animatedImagePreference);
}
@@ -172,34 +172,24 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
groupCategory.addPreference(mSettingsPreference);
}
if (mStaticDescription != null || mHtmlDescription != null) {
final PreferenceCategory footerCategory = new PreferenceCategory(getPrefContext());
final CharSequence title = getString(R.string.accessibility_footer_title, mPackageName);
footerCategory.setTitle(title);
preferenceScreen.addPreference(footerCategory);
if (mHtmlDescription != null) {
final PreferenceCategory introductionCategory = new PreferenceCategory(
getPrefContext());
final CharSequence title = getString(R.string.accessibility_introduction_title,
mPackageName);
introductionCategory.setTitle(title);
preferenceScreen.addPreference(introductionCategory);
if (mStaticDescription != null) {
final StaticTextPreference staticTextPreference = new StaticTextPreference(
getPrefContext());
staticTextPreference.setSummary(mStaticDescription);
staticTextPreference.setSelectable(/* selectable= */ false);
footerCategory.addPreference(staticTextPreference);
}
// For accessibility service, avoid malicious links made by third party developer.
final List<String> unsupportedTagList = new ArrayList<>();
unsupportedTagList.add(ANCHOR_TAG);
if (mHtmlDescription != null) {
// For accessibility service, avoid malicious links made by third party developer.
final List<String> unsupportedTagList = new ArrayList<>();
unsupportedTagList.add(ANCHOR_TAG);
final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(
getPrefContext());
htmlTextPreference.setSummary(mHtmlDescription);
htmlTextPreference.setImageGetter(mImageGetter);
htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
htmlTextPreference.setDividerAllowedAbove(true);
htmlTextPreference.setSelectable(/* selectable= */ false);
footerCategory.addPreference(htmlTextPreference);
}
final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(getPrefContext());
htmlTextPreference.setSummary(mHtmlDescription);
htmlTextPreference.setImageGetter(mImageGetter);
htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
htmlTextPreference.setSelectable(false);
introductionCategory.addPreference(htmlTextPreference);
}
}
@@ -362,11 +352,11 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
// Summary.
if (arguments.containsKey(AccessibilitySettings.EXTRA_SUMMARY_RES)) {
final int summary = arguments.getInt(AccessibilitySettings.EXTRA_SUMMARY_RES);
mStaticDescription = getText(summary);
createFooterPreference(getText(summary));
} else if (arguments.containsKey(AccessibilitySettings.EXTRA_SUMMARY)) {
final CharSequence summary = arguments.getCharSequence(
AccessibilitySettings.EXTRA_SUMMARY);
mStaticDescription = summary;
createFooterPreference(summary);
}
}
@@ -635,4 +625,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
public void onSettingsClicked(ShortcutPreference preference) {
mUserShortcutTypeCache = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
}
private void createFooterPreference(CharSequence title) {
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.addPreference(new FooterPreference.Builder(getActivity()).setTitle(
title).build());
}
}