diff options
| author | Daniel Sandler <dsandler@android.com> | 2012-05-22 08:17:29 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-22 08:17:29 -0700 |
| commit | c40a7fe00257d5742bd10bc611cd11d1600f469f (patch) | |
| tree | 5aca78592a34143443479e438471d758b002080b | |
| parent | 1957fd271f4e76c471d483df98cf23abf3e92360 (diff) | |
| parent | 9f7936a30bc097c31962891945802507cb4aeb82 (diff) | |
| download | frameworks_base-c40a7fe00257d5742bd10bc611cd11d1600f469f.zip frameworks_base-c40a7fe00257d5742bd10bc611cd11d1600f469f.tar.gz frameworks_base-c40a7fe00257d5742bd10bc611cd11d1600f469f.tar.bz2 | |
Merge "Fix three-line notifications." into jb-dev
| -rw-r--r-- | core/java/android/app/Notification.java | 52 | ||||
| -rw-r--r-- | core/res/res/layout/notification_template_base.xml | 27 | ||||
| -rw-r--r-- | core/res/res/layout/notification_template_big_base.xml | 13 | ||||
| -rw-r--r-- | core/res/res/layout/notification_template_big_picture.xml | 7 | ||||
| -rw-r--r-- | core/res/res/layout/notification_template_big_text.xml | 32 | ||||
| -rw-r--r-- | core/res/res/layout/notification_template_inbox.xml | 29 | ||||
| -rw-r--r-- | core/res/res/values/dimens.xml | 7 | ||||
| -rw-r--r-- | core/res/res/values/public.xml | 3 | ||||
| -rw-r--r-- | core/res/res/values/styles.xml | 10 |
9 files changed, 105 insertions, 75 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index c7afd2b..618f1f8 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -20,6 +20,7 @@ import com.android.internal.R; import android.content.Context; import android.content.Intent; +import android.content.res.Resources; import android.graphics.Bitmap; import android.media.AudioManager; import android.net.Uri; @@ -31,6 +32,8 @@ import android.os.SystemClock; import android.text.TextUtils; import android.util.IntProperty; import android.util.Log; +import android.util.Slog; +import android.util.TypedValue; import android.view.View; import android.widget.ProgressBar; import android.widget.RemoteViews; @@ -1378,8 +1381,8 @@ public class Notification implements Parcelable private RemoteViews applyStandardTemplate(int resId) { RemoteViews contentView = new RemoteViews(mContext.getPackageName(), resId); - boolean hasLine3 = false; - boolean hasLine2 = false; + boolean showLine3 = false; + boolean showLine2 = false; int smallIconImageViewId = R.id.icon; if (mLargeIcon != null) { contentView.setImageViewBitmap(R.id.icon, mLargeIcon); @@ -1401,15 +1404,13 @@ public class Notification implements Parcelable contentView.setTextViewText(R.id.title, mContentTitle); } if (mContentText != null) { - contentView.setTextViewText( - (mSubText != null) ? R.id.text2 : R.id.text, - mContentText); - hasLine3 = true; + contentView.setTextViewText(R.id.text, mContentText); + showLine3 = true; } if (mContentInfo != null) { contentView.setTextViewText(R.id.info, mContentInfo); contentView.setViewVisibility(R.id.info, View.VISIBLE); - hasLine3 = true; + showLine3 = true; } else if (mNumber > 0) { final int tooBig = mContext.getResources().getInteger( R.integer.status_bar_notification_info_maxnum); @@ -1421,25 +1422,42 @@ public class Notification implements Parcelable contentView.setTextViewText(R.id.info, f.format(mNumber)); } contentView.setViewVisibility(R.id.info, View.VISIBLE); - hasLine3 = true; + showLine3 = true; } else { contentView.setViewVisibility(R.id.info, View.GONE); } + // Need to show three lines? if (mSubText != null) { contentView.setTextViewText(R.id.text, mSubText); - contentView.setViewVisibility(R.id.text2, - mContentText != null ? View.VISIBLE : View.GONE); + if (mContentText != null) { + contentView.setTextViewText(R.id.text2, mContentText); + // need to shrink all the type to make sure everything fits + contentView.setViewVisibility(R.id.text2, View.VISIBLE); + showLine2 = true; + } else { + contentView.setViewVisibility(R.id.text2, View.GONE); + } } else { contentView.setViewVisibility(R.id.text2, View.GONE); if (mProgressMax != 0 || mProgressIndeterminate) { contentView.setProgressBar( R.id.progress, mProgressMax, mProgress, mProgressIndeterminate); contentView.setViewVisibility(R.id.progress, View.VISIBLE); + showLine2 = true; } else { contentView.setViewVisibility(R.id.progress, View.GONE); } } + if (showLine2) { + final Resources res = mContext.getResources(); + final float subTextSize = res.getDimensionPixelSize( + R.dimen.notification_subtext_size); + contentView.setTextViewTextSize(R.id.text, TypedValue.COMPLEX_UNIT_PX, subTextSize); + // vertical centering + contentView.setViewPadding(R.id.line1, 0, 0, 0, 0); + } + if (mWhen != 0) { if (mUseChronometer) { contentView.setViewVisibility(R.id.chronometer, View.VISIBLE); @@ -1451,7 +1469,7 @@ public class Notification implements Parcelable contentView.setLong(R.id.time, "setTime", mWhen); } } - contentView.setViewVisibility(R.id.line3, hasLine3 ? View.VISIBLE : View.GONE); + contentView.setViewVisibility(R.id.line3, showLine3 ? View.VISIBLE : View.GONE); return contentView; } @@ -1629,18 +1647,8 @@ public class Notification implements Parcelable mBuilder.setContentTitle(mBigContentTitle); } - if (mBuilder.mSubText == null) { - mBuilder.setContentText(null); - } - RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(layoutId); - if (mBuilder.mSubText == null) { - contentView.setViewVisibility(R.id.line3, View.GONE); - } else { - contentView.setViewVisibility(R.id.line3, View.VISIBLE); - } - if (mBigContentTitle != null && mBigContentTitle.equals("")) { contentView.setViewVisibility(R.id.line1, View.GONE); } else { @@ -1650,8 +1658,10 @@ public class Notification implements Parcelable if (mSummaryText != null && !mSummaryText.equals("")) { contentView.setViewVisibility(R.id.overflow_title, View.VISIBLE); contentView.setTextViewText(R.id.overflow_title, mSummaryText); + contentView.setViewVisibility(R.id.line3, View.GONE); } else { contentView.setViewVisibility(R.id.overflow_title, View.GONE); + contentView.setViewVisibility(R.id.line3, View.VISIBLE); } return contentView; diff --git a/core/res/res/layout/notification_template_base.xml b/core/res/res/layout/notification_template_base.xml index 3692a4d..ed680a9 100644 --- a/core/res/res/layout/notification_template_base.xml +++ b/core/res/res/layout/notification_template_base.xml @@ -38,14 +38,15 @@ android:orientation="vertical" android:paddingLeft="12dp" android:paddingRight="12dp" - android:paddingTop="4dp" - android:paddingBottom="4dp" - android:gravity="center_vertical" + android:paddingTop="2dp" + android:paddingBottom="2dp" + android:gravity="top" > <LinearLayout android:id="@+id/line1" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingTop="6dp" android:orientation="horizontal" > <TextView android:id="@+id/title" @@ -85,8 +86,15 @@ android:ellipsize="marquee" android:visibility="gone" /> + <ProgressBar + android:id="@android:id/progress" + android:layout_width="match_parent" + android:layout_height="12dp" + android:visibility="gone" + style="?android:attr/progressBarStyleHorizontal" + /> <TextView android:id="@+id/overflow_title" - android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" @@ -123,21 +131,14 @@ /> <ImageView android:id="@+id/right_icon" android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:layout_gravity="center" android:layout_weight="0" - android:scaleType="center" + android:scaleType="centerInside" android:paddingLeft="8dp" android:visibility="gone" android:drawableAlpha="180" /> </LinearLayout> - <ProgressBar - android:id="@android:id/progress" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" - style="?android:attr/progressBarStyleHorizontal" - /> </LinearLayout> </FrameLayout> diff --git a/core/res/res/layout/notification_template_big_base.xml b/core/res/res/layout/notification_template_big_base.xml index d50b792..f2c204f 100644 --- a/core/res/res/layout/notification_template_big_base.xml +++ b/core/res/res/layout/notification_template_big_base.xml @@ -38,9 +38,9 @@ android:orientation="vertical" android:paddingLeft="12dp" android:paddingRight="12dp" - android:paddingTop="4dp" - android:paddingBottom="4dp" - android:gravity="center_vertical" + android:paddingTop="2dp" + android:paddingBottom="2dp" + android:gravity="top" > <LinearLayout android:layout_width="match_parent" @@ -52,6 +52,7 @@ android:id="@+id/line1" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingTop="6dp" android:orientation="horizontal" > <TextView android:id="@+id/title" @@ -126,10 +127,10 @@ /> <ImageView android:id="@+id/right_icon" android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:layout_gravity="center" android:layout_weight="0" - android:scaleType="center" + android:scaleType="centerInside" android:paddingLeft="8dp" android:visibility="gone" android:drawableAlpha="180" @@ -138,7 +139,7 @@ <ProgressBar android:id="@android:id/progress" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="12dp" android:visibility="gone" style="?android:attr/progressBarStyleHorizontal" /> diff --git a/core/res/res/layout/notification_template_big_picture.xml b/core/res/res/layout/notification_template_big_picture.xml index f98970a..9b896a4 100644 --- a/core/res/res/layout/notification_template_big_picture.xml +++ b/core/res/res/layout/notification_template_big_picture.xml @@ -31,6 +31,13 @@ android:layout_gravity="bottom" android:scaleType="centerCrop" /> + <ImageView + android:layout_width="match_parent" + android:layout_height="6dp" + android:layout_marginTop="64dp" + android:scaleType="fitXY" + android:src="@drawable/title_bar_shadow" + /> <include layout="@layout/notification_template_base" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/core/res/res/layout/notification_template_big_text.xml b/core/res/res/layout/notification_template_big_text.xml index 210bc13..304f2b5 100644 --- a/core/res/res/layout/notification_template_big_text.xml +++ b/core/res/res/layout/notification_template_big_text.xml @@ -36,9 +36,9 @@ android:orientation="vertical" android:paddingLeft="12dp" android:paddingRight="12dp" - android:paddingTop="4dp" - android:paddingBottom="4dp" - android:gravity="center_vertical" + android:paddingTop="2dp" + android:paddingBottom="2dp" + android:gravity="top" > <LinearLayout android:layout_width="match_parent" @@ -50,6 +50,7 @@ android:id="@+id/line1" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingTop="6dp" android:orientation="horizontal" android:layout_gravity="top" android:layout_weight="0" @@ -92,11 +93,18 @@ android:layout_weight="0" android:visibility="gone" /> + <ProgressBar + android:id="@android:id/progress" + android:layout_width="match_parent" + android:layout_height="12dp" + android:visibility="gone" + android:layout_weight="0" + style="?android:attr/progressBarStyleHorizontal" + /> <TextView android:id="@+id/big_text" android:textAppearance="@style/TextAppearance.StatusBar.EventContent" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_marginTop="2dp" android:layout_marginBottom="2dp" android:singleLine="false" android:visibility="gone" @@ -113,7 +121,7 @@ android:layout_weight="1" /> <TextView android:id="@+id/overflow_title" - android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" @@ -127,7 +135,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:layout_weight="1" + android:layout_weight="0" > <TextView android:id="@+id/text" android:textAppearance="@style/TextAppearance.StatusBar.EventContent" @@ -151,22 +159,14 @@ /> <ImageView android:id="@+id/right_icon" android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:layout_gravity="center" android:layout_weight="0" - android:scaleType="center" + android:scaleType="centerInside" android:paddingLeft="8dp" android:visibility="gone" android:drawableAlpha="180" /> </LinearLayout> - <ProgressBar - android:id="@android:id/progress" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" - android:layout_weight="0" - style="?android:attr/progressBarStyleHorizontal" - /> </LinearLayout> </FrameLayout> diff --git a/core/res/res/layout/notification_template_inbox.xml b/core/res/res/layout/notification_template_inbox.xml index 3b00feb..121a81c 100644 --- a/core/res/res/layout/notification_template_inbox.xml +++ b/core/res/res/layout/notification_template_inbox.xml @@ -38,14 +38,15 @@ android:orientation="vertical" android:paddingLeft="12dp" android:paddingRight="12dp" - android:paddingTop="4dp" - android:paddingBottom="4dp" - android:gravity="center_vertical" + android:paddingTop="2dp" + android:paddingBottom="2dp" + android:gravity="top" > <LinearLayout android:id="@+id/line1" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingTop="6dp" android:orientation="horizontal" android:layout_weight="0" > @@ -87,6 +88,14 @@ android:visibility="gone" android:layout_weight="0" /> + <ProgressBar + android:id="@android:id/progress" + android:layout_width="match_parent" + android:layout_height="12dp" + android:visibility="gone" + android:layout_weight="0" + style="?android:attr/progressBarStyleHorizontal" + /> <TextView android:id="@+id/inbox_text0" android:textAppearance="@style/TextAppearance.StatusBar.EventContent" android:layout_width="match_parent" @@ -168,7 +177,7 @@ android:layout_weight="0" /> <TextView android:id="@+id/overflow_title" - android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" @@ -206,22 +215,14 @@ /> <ImageView android:id="@+id/right_icon" android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:layout_gravity="center" android:layout_weight="0" - android:scaleType="center" + android:scaleType="centerInside" android:paddingLeft="8dp" android:visibility="gone" android:drawableAlpha="180" /> </LinearLayout> - <ProgressBar - android:id="@android:id/progress" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" - android:layout_weight="0" - style="?android:attr/progressBarStyleHorizontal" - /> </LinearLayout> </FrameLayout> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 734151b..d549644 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -227,4 +227,11 @@ action bar tabs from becoming too wide on a wide screen when only a few are present. --> <dimen name="action_bar_stacked_tab_max_width">180dp</dimen> + + <!-- Size of notification text (see TextAppearance.StatusBar.EventContent) --> + <dimen name="notification_text_size">14dp</dimen> + <!-- Size of notification text titles (see TextAppearance.StatusBar.EventContent.Title) --> + <dimen name="notification_title_text_size">18dp</dimen> + <!-- Size of smaller notification text (see TextAppearance.StatusBar.EventContent.Line2, Info, Time) --> + <dimen name="notification_subtext_size">12dp</dimen> </resources> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index bbb2e8e..f1f67eb 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -297,6 +297,9 @@ <java-symbol type="dimen" name="volume_panel_top" /> <java-symbol type="dimen" name="action_bar_stacked_max_height" /> <java-symbol type="dimen" name="action_bar_stacked_tab_max_width" /> + <java-symbol type="dimen" name="notification_text_size" /> + <java-symbol type="dimen" name="notification_title_text_size" /> + <java-symbol type="dimen" name="notification_subtext_size" /> <java-symbol type="string" name="addToDictionary" /> <java-symbol type="string" name="action_bar_home_description" /> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index a90dab8..a54cdf1 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -240,23 +240,23 @@ please see styles_device_defaults.xml. <!-- Notification content styles --> <style name="TextAppearance.StatusBar.EventContent"> <item name="android:textColor">#808080</item> - <item name="android:textSize">14dp</item> + <item name="android:textSize">@dimen/notification_text_size</item> </style> <style name="TextAppearance.StatusBar.EventContent.Title"> <item name="android:textColor">#ffffff</item> <item name="android:fontFamily">sans-serif-light</item> - <item name="android:textSize">18dp</item> + <item name="android:textSize">@dimen/notification_title_text_size</item> <item name="android:textStyle">bold</item> </style> <style name="TextAppearance.StatusBar.EventContent.Line2"> - <!-- inherit all --> + <item name="android:textSize">@dimen/notification_subtext_size</item> </style> <style name="TextAppearance.StatusBar.EventContent.Info"> - <item name="android:textSize">12sp</item> + <item name="android:textSize">@dimen/notification_subtext_size</item> <item name="android:textColor">#666666</item> </style> <style name="TextAppearance.StatusBar.EventContent.Time"> - <item name="android:textSize">12sp</item> + <item name="android:textSize">@dimen/notification_subtext_size</item> <item name="android:textColor">#666666</item> </style> |
