Fix Wifi off state UI
- Apply footerPreferenceStyle to reduce the text size and text color - Add "info" icon Bug: 80087791 Test: visual, RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi Change-Id: I19d4f67c5a9f2fc2b542f40e051c1469ab40e7db
This commit is contained in:
@@ -23,12 +23,14 @@ import android.text.style.TextAppearanceSpan;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.LinkifyUtils;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.content.res.TypedArrayUtils;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
|
import com.android.settings.LinkifyUtils;
|
||||||
|
import com.android.settingslib.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A preference with a title that can have linkable content on click.
|
* A preference with a title that can have linkable content on click.
|
||||||
*/
|
*/
|
||||||
@@ -38,19 +40,20 @@ public class LinkablePreference extends Preference {
|
|||||||
private CharSequence mContentTitle;
|
private CharSequence mContentTitle;
|
||||||
private CharSequence mContentDescription;
|
private CharSequence mContentDescription;
|
||||||
|
|
||||||
|
|
||||||
public LinkablePreference(Context ctx, AttributeSet attrs, int defStyle) {
|
public LinkablePreference(Context ctx, AttributeSet attrs, int defStyle) {
|
||||||
super(ctx, attrs, defStyle);
|
super(ctx, attrs, defStyle);
|
||||||
|
setIcon(R.drawable.ic_info_outline_24dp);
|
||||||
setSelectable(false);
|
setSelectable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkablePreference(Context ctx, AttributeSet attrs) {
|
public LinkablePreference(Context ctx, AttributeSet attrs) {
|
||||||
super(ctx, attrs);
|
this(ctx, attrs, TypedArrayUtils.getAttr(
|
||||||
setSelectable(false);
|
ctx, R.attr.footerPreferenceStyle, android.R.attr.preferenceStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkablePreference(Context ctx) {
|
public LinkablePreference(Context ctx) {
|
||||||
super(ctx);
|
this(ctx, null);
|
||||||
setSelectable(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,21 +78,20 @@ public class LinkablePreference extends Preference {
|
|||||||
|
|
||||||
boolean linked = LinkifyUtils.linkify(textView, contentBuilder, mClickListener);
|
boolean linked = LinkifyUtils.linkify(textView, contentBuilder, mClickListener);
|
||||||
if (linked && mContentTitle != null) {
|
if (linked && mContentTitle != null) {
|
||||||
// Embolden and enlarge the title.
|
Spannable spannableContent = (Spannable) textView.getText();
|
||||||
Spannable boldSpan = (Spannable) textView.getText();
|
spannableContent.setSpan(
|
||||||
boldSpan.setSpan(
|
new TextAppearanceSpan(getContext(), android.R.style.TextAppearance_Small),
|
||||||
new TextAppearanceSpan(
|
|
||||||
getContext(), android.R.style.TextAppearance_Medium),
|
|
||||||
0,
|
0,
|
||||||
mContentTitle.length(),
|
mContentTitle.length(),
|
||||||
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
textView.setText(boldSpan);
|
textView.setText(spannableContent);
|
||||||
textView.setMovementMethod(new LinkMovementMethod());
|
textView.setMovementMethod(new LinkMovementMethod());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the linkable text for the Preference title.
|
* Sets the linkable text for the Preference title.
|
||||||
|
*
|
||||||
* @param contentTitle text to set the Preference title.
|
* @param contentTitle text to set the Preference title.
|
||||||
* @param contentDescription description text to append underneath title, can be null.
|
* @param contentDescription description text to append underneath title, can be null.
|
||||||
* @param clickListener OnClickListener for the link portion of the text.
|
* @param clickListener OnClickListener for the link portion of the text.
|
||||||
|
Reference in New Issue
Block a user