| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.internal.widget; |
| 18 |
|
| 19 |
import android.compat.annotation.UnsupportedAppUsage; |
| 20 |
import android.content.Context; |
| 21 |
import android.content.res.TypedArray; |
| 22 |
import android.text.Layout; |
| 23 |
import android.util.AttributeSet; |
| 24 |
import android.util.TypedValue; |
| 25 |
import android.widget.TextView; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class DialogTitle extends TextView { |
| 32 |
|
| 33 |
public DialogTitle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
| 34 |
super(context, attrs, defStyleAttr, defStyleRes); |
| 35 |
} |
| 36 |
|
| 37 |
public DialogTitle(Context context, AttributeSet attrs, int defStyleAttr) { |
| 38 |
super(context, attrs, defStyleAttr); |
| 39 |
} |
| 40 |
|
| 41 |
@UnsupportedAppUsage |
| 42 |
public DialogTitle(Context context, AttributeSet attrs) { |
| 43 |
super(context, attrs); |
| 44 |
} |
| 45 |
|
| 46 |
public DialogTitle(Context context) { |
| 47 |
super(context); |
| 48 |
} |
| 49 |
|
| 50 |
@Override |
| 51 |
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 52 |
super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 53 |
|
| 54 |
final Layout layout = getLayout(); |
| 55 |
if (layout != null) { |
| 56 |
final int lineCount = layout.getLineCount(); |
| 57 |
if (lineCount > 0) { |
| 58 |
final int ellipsisCount = layout.getEllipsisCount(lineCount - 1); |
| 59 |
if (ellipsisCount > 0) { |
| 60 |
setSingleLine(false); |
| 61 |
setMaxLines(2); |
| 62 |
|
| 63 |
final TypedArray a = mContext.obtainStyledAttributes(null, |
| 64 |
android.R.styleable.TextAppearance, android.R.attr.textAppearanceMedium, |
| 65 |
android.R.style.TextAppearance_Medium); |
| 66 |
final int textSize = a.getDimensionPixelSize( |
| 67 |
android.R.styleable.TextAppearance_textSize, 0); |
| 68 |
if (textSize != 0) { |
| 69 |
|
| 70 |
setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
| 71 |
} |
| 72 |
a.recycle(); |
| 73 |
|
| 74 |
super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
} |