Commit 04c0a348 authored by Natalie Chouinard's avatar Natalie Chouinard Committed by Commit Bot

Cleanup of TextMessagePreference

In the Support Library Preference's onBindViewHolder, visibility
toggling is handled for both title and summary empty TextViews, so
removing some now redundant logic.

There are no TextMessagePreferences which contain links in the title,
and the LinkMovementMethod was breaking DPad navigation on screens where
it was set, so removing that as well. See https://crbug.com/993368.

Bug: 993368
Change-Id: I702fc08e563e544e9ad774c2b05dcdd070a74678
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1757390Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Natalie Chouinard <chouinard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688204}
parent a4aeb242
......@@ -6,14 +6,12 @@ package org.chromium.chrome.browser.preferences;
import android.content.Context;
import android.support.v7.preference.PreferenceViewHolder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
/**
* A preference that displays informational text.
* A preference that displays informational text, and a summary which can contain a link.
*/
public class TextMessagePreference extends ChromeBasePreference {
/**
......@@ -22,24 +20,14 @@ public class TextMessagePreference extends ChromeBasePreference {
public TextMessagePreference(Context context, AttributeSet attrs) {
super(context, attrs);
setSelectable(false);
setSingleLineTitle(false);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
TextView titleView = (TextView) holder.findViewById(android.R.id.title);
if (!TextUtils.isEmpty(getTitle())) {
titleView.setVisibility(View.VISIBLE);
titleView.setSingleLine(false);
titleView.setMaxLines(Integer.MAX_VALUE);
titleView.setMovementMethod(LinkMovementMethod.getInstance());
} else {
titleView.setVisibility(View.GONE);
}
TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
// No need to manually toggle visibility for summary - it is done in super.onBindView.
summaryView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment