diff options
| author | 2011-12-06 13:36:03 -0500 | |
|---|---|---|
| committer | 2011-12-07 15:53:00 -0500 | |
| commit | a3850b68399ab49032e1fc2a2eab129fe3a7e69e (patch) | |
| tree | 2d7f5433154f0c6843a289d803dc22c589ebb0df | |
| parent | f352491aad71b5c0a30238707bdb83c9dc34fd9e (diff) | |
Improve handling of small largeIcons in tablet ticker.
The tablet system bar is too short for a full notification
row, but it will show the largeIcon of a new notification in
its full frame, intruding into the main application content
rectangle a bit. This is a good thing---the notifications
really pop out at you---but it looks a little odd if the
largeIcon is actually *small*: the icon is vertically
centered in the larger (invisible) rectangle, making it look
poorly centered on the system bar.
This change will detect short largeIcons and center them in
the system bar's height instead. Additionally, it applies
the same ticker background all the way to the left
underneath largeIcons that are not full-frame (and therefore
have transparent regions).
Bug: 5708907
Bug: 5560485
Change-Id: I32af45632df164c58fb960110063dbaa08b5536c
4 files changed, 40 insertions, 8 deletions
diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_ticker_panel.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_ticker_panel.xml index 6cd8899b3415..d51f9c839f54 100644 --- a/packages/SystemUI/res/layout-sw600dp/status_bar_ticker_panel.xml +++ b/packages/SystemUI/res/layout-sw600dp/status_bar_ticker_panel.xml @@ -15,20 +15,29 @@ * limitations under the License. --> -<LinearLayout +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="horizontal" - android:gravity="bottom" > + <View + android:layout_height="@*android:dimen/status_bar_height" + android:layout_width="match_parent" + android:background="@drawable/status_bar_ticker_background" + android:layout_alignParentLeft="true" + android:layout_alignParentBottom="true" + android:clickable="false" + /> + <ImageView android:id="@+id/large_icon" android:layout_width="@android:dimen/notification_large_icon_height" android:layout_height="@android:dimen/notification_large_icon_width" android:scaleType="center" android:visibility="gone" + android:layout_alignParentLeft="true" + android:layout_alignParentBottom="true" /> <FrameLayout @@ -36,6 +45,8 @@ android:layout_weight="1" android:layout_height="@*android:dimen/status_bar_height" android:layout_width="match_parent" - android:background="@drawable/status_bar_ticker_background" + android:layout_toRightOf="@id/large_icon" + android:layout_alignParentBottom="true" + android:layout_alignWithParentIfMissing="true" /> -</LinearLayout> +</RelativeLayout> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java index 6045e31d3ad7..e93a32bc1689 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java @@ -73,6 +73,8 @@ public class TabletTicker private StatusBarNotification[] mQueue = new StatusBarNotification[QUEUE_LENGTH]; private int mQueuePos; + private final int mLargeIconHeight; + private TabletStatusBar mBar; private LayoutTransition mLayoutTransition; @@ -81,6 +83,9 @@ public class TabletTicker public TabletTicker(TabletStatusBar bar) { mBar = bar; mContext = bar.getContext(); + final Resources res = mContext.getResources(); + mLargeIconHeight = res.getDimensionPixelSize( + android.R.dimen.notification_large_icon_height); } public void add(IBinder key, StatusBarNotification notification) { @@ -209,8 +214,6 @@ public class TabletTicker final Resources res = mContext.getResources(); final FrameLayout view = new FrameLayout(mContext); final int width = res.getDimensionPixelSize(R.dimen.notification_ticker_width); - final int height = res.getDimensionPixelSize( - android.R.dimen.notification_large_icon_height); int windowFlags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; @@ -219,7 +222,7 @@ public class TabletTicker } else { windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; } - WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, height, + WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, mLargeIconHeight, WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, windowFlags, PixelFormat.TRANSLUCENT); lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; @@ -297,6 +300,16 @@ public class TabletTicker if (n.largeIcon != null) { largeIcon.setImageBitmap(n.largeIcon); largeIcon.setVisibility(View.VISIBLE); + final ViewGroup.LayoutParams lp = largeIcon.getLayoutParams(); + final int statusBarHeight = mBar.getStatusBarHeight(); + if (n.largeIcon.getHeight() <= statusBarHeight) { + // for smallish largeIcons, it looks a little odd to have them floating halfway up + // the ticker, so we vertically center them in the status bar area instead + lp.height = statusBarHeight; + } else { + lp.height = mLargeIconHeight; + } + largeIcon.setLayoutParams(lp); } if (CLICKABLE_TICKER) { diff --git a/tests/StatusBar/res/layout/notification_builder_test.xml b/tests/StatusBar/res/layout/notification_builder_test.xml index e1199c75761e..6c384f70ff7e 100644 --- a/tests/StatusBar/res/layout/notification_builder_test.xml +++ b/tests/StatusBar/res/layout/notification_builder_test.xml @@ -605,6 +605,11 @@ style="@style/FieldContents" android:text="pineapple2" /> + <RadioButton + android:id="@+id/large_icon_small" + style="@style/FieldContents" + android:text="small" + /> </RadioGroup> diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java index 5a2ebacefa44..fefd89050ae9 100644 --- a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java +++ b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java @@ -287,6 +287,9 @@ public class NotificationBuilderTest extends Activity case R.id.large_icon_pineapple2: b.setLargeIcon(loadBitmap(R.drawable.pineapple2)); break; + case R.id.large_icon_small: + b.setLargeIcon(loadBitmap(R.drawable.icon2)); + break; } // sound TODO |