2020
2121import android .content .Context ;
2222import android .content .Intent ;
23+ import android .content .res .Resources ;
2324import android .graphics .Bitmap ;
2425import android .media .AudioManager ;
2526import android .net .Uri ;
3132import android .text .TextUtils ;
3233import android .util .IntProperty ;
3334import android .util .Log ;
35+ import android .util .Slog ;
36+ import android .util .TypedValue ;
3437import android .view .View ;
3538import android .widget .ProgressBar ;
3639import android .widget .RemoteViews ;
@@ -1378,8 +1381,8 @@ private void setFlag(int mask, boolean value) {
13781381
13791382 private RemoteViews applyStandardTemplate (int resId ) {
13801383 RemoteViews contentView = new RemoteViews (mContext .getPackageName (), resId );
1381- boolean hasLine3 = false ;
1382- boolean hasLine2 = false ;
1384+ boolean showLine3 = false ;
1385+ boolean showLine2 = false ;
13831386 int smallIconImageViewId = R .id .icon ;
13841387 if (mLargeIcon != null ) {
13851388 contentView .setImageViewBitmap (R .id .icon , mLargeIcon );
@@ -1401,15 +1404,13 @@ private RemoteViews applyStandardTemplate(int resId) {
14011404 contentView .setTextViewText (R .id .title , mContentTitle );
14021405 }
14031406 if (mContentText != null ) {
1404- contentView .setTextViewText (
1405- (mSubText != null ) ? R .id .text2 : R .id .text ,
1406- mContentText );
1407- hasLine3 = true ;
1407+ contentView .setTextViewText (R .id .text , mContentText );
1408+ showLine3 = true ;
14081409 }
14091410 if (mContentInfo != null ) {
14101411 contentView .setTextViewText (R .id .info , mContentInfo );
14111412 contentView .setViewVisibility (R .id .info , View .VISIBLE );
1412- hasLine3 = true ;
1413+ showLine3 = true ;
14131414 } else if (mNumber > 0 ) {
14141415 final int tooBig = mContext .getResources ().getInteger (
14151416 R .integer .status_bar_notification_info_maxnum );
@@ -1421,25 +1422,42 @@ private RemoteViews applyStandardTemplate(int resId) {
14211422 contentView .setTextViewText (R .id .info , f .format (mNumber ));
14221423 }
14231424 contentView .setViewVisibility (R .id .info , View .VISIBLE );
1424- hasLine3 = true ;
1425+ showLine3 = true ;
14251426 } else {
14261427 contentView .setViewVisibility (R .id .info , View .GONE );
14271428 }
14281429
1430+ // Need to show three lines?
14291431 if (mSubText != null ) {
14301432 contentView .setTextViewText (R .id .text , mSubText );
1431- contentView .setViewVisibility (R .id .text2 ,
1432- mContentText != null ? View .VISIBLE : View .GONE );
1433+ if (mContentText != null ) {
1434+ contentView .setTextViewText (R .id .text2 , mContentText );
1435+ // need to shrink all the type to make sure everything fits
1436+ contentView .setViewVisibility (R .id .text2 , View .VISIBLE );
1437+ showLine2 = true ;
1438+ } else {
1439+ contentView .setViewVisibility (R .id .text2 , View .GONE );
1440+ }
14331441 } else {
14341442 contentView .setViewVisibility (R .id .text2 , View .GONE );
14351443 if (mProgressMax != 0 || mProgressIndeterminate ) {
14361444 contentView .setProgressBar (
14371445 R .id .progress , mProgressMax , mProgress , mProgressIndeterminate );
14381446 contentView .setViewVisibility (R .id .progress , View .VISIBLE );
1447+ showLine2 = true ;
14391448 } else {
14401449 contentView .setViewVisibility (R .id .progress , View .GONE );
14411450 }
14421451 }
1452+ if (showLine2 ) {
1453+ final Resources res = mContext .getResources ();
1454+ final float subTextSize = res .getDimensionPixelSize (
1455+ R .dimen .notification_subtext_size );
1456+ contentView .setTextViewTextSize (R .id .text , TypedValue .COMPLEX_UNIT_PX , subTextSize );
1457+ // vertical centering
1458+ contentView .setViewPadding (R .id .line1 , 0 , 0 , 0 , 0 );
1459+ }
1460+
14431461 if (mWhen != 0 ) {
14441462 if (mUseChronometer ) {
14451463 contentView .setViewVisibility (R .id .chronometer , View .VISIBLE );
@@ -1451,7 +1469,7 @@ private RemoteViews applyStandardTemplate(int resId) {
14511469 contentView .setLong (R .id .time , "setTime" , mWhen );
14521470 }
14531471 }
1454- contentView .setViewVisibility (R .id .line3 , hasLine3 ? View .VISIBLE : View .GONE );
1472+ contentView .setViewVisibility (R .id .line3 , showLine3 ? View .VISIBLE : View .GONE );
14551473 return contentView ;
14561474 }
14571475
@@ -1629,18 +1647,8 @@ protected RemoteViews getStandardView(int layoutId) {
16291647 mBuilder .setContentTitle (mBigContentTitle );
16301648 }
16311649
1632- if (mBuilder .mSubText == null ) {
1633- mBuilder .setContentText (null );
1634- }
1635-
16361650 RemoteViews contentView = mBuilder .applyStandardTemplateWithActions (layoutId );
16371651
1638- if (mBuilder .mSubText == null ) {
1639- contentView .setViewVisibility (R .id .line3 , View .GONE );
1640- } else {
1641- contentView .setViewVisibility (R .id .line3 , View .VISIBLE );
1642- }
1643-
16441652 if (mBigContentTitle != null && mBigContentTitle .equals ("" )) {
16451653 contentView .setViewVisibility (R .id .line1 , View .GONE );
16461654 } else {
@@ -1650,8 +1658,10 @@ protected RemoteViews getStandardView(int layoutId) {
16501658 if (mSummaryText != null && !mSummaryText .equals ("" )) {
16511659 contentView .setViewVisibility (R .id .overflow_title , View .VISIBLE );
16521660 contentView .setTextViewText (R .id .overflow_title , mSummaryText );
1661+ contentView .setViewVisibility (R .id .line3 , View .GONE );
16531662 } else {
16541663 contentView .setViewVisibility (R .id .overflow_title , View .GONE );
1664+ contentView .setViewVisibility (R .id .line3 , View .VISIBLE );
16551665 }
16561666
16571667 return contentView ;
0 commit comments