Skip to content

Commit a3850b6

Browse files
committed
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
1 parent f352491 commit a3850b6

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

packages/SystemUI/res/layout-sw600dp/status_bar_ticker_panel.xml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,38 @@
1515
* limitations under the License.
1616
-->
1717

18-
<LinearLayout
18+
<RelativeLayout
1919
xmlns:android="http://schemas.android.com/apk/res/android"
2020
android:layout_width="match_parent"
2121
android:layout_height="match_parent"
22-
android:orientation="horizontal"
23-
android:gravity="bottom"
2422
>
2523

24+
<View
25+
android:layout_height="@*android:dimen/status_bar_height"
26+
android:layout_width="match_parent"
27+
android:background="@drawable/status_bar_ticker_background"
28+
android:layout_alignParentLeft="true"
29+
android:layout_alignParentBottom="true"
30+
android:clickable="false"
31+
/>
32+
2633
<ImageView
2734
android:id="@+id/large_icon"
2835
android:layout_width="@android:dimen/notification_large_icon_height"
2936
android:layout_height="@android:dimen/notification_large_icon_width"
3037
android:scaleType="center"
3138
android:visibility="gone"
39+
android:layout_alignParentLeft="true"
40+
android:layout_alignParentBottom="true"
3241
/>
3342

3443
<FrameLayout
3544
android:id="@+id/ticker_expanded"
3645
android:layout_weight="1"
3746
android:layout_height="@*android:dimen/status_bar_height"
3847
android:layout_width="match_parent"
39-
android:background="@drawable/status_bar_ticker_background"
48+
android:layout_toRightOf="@id/large_icon"
49+
android:layout_alignParentBottom="true"
50+
android:layout_alignWithParentIfMissing="true"
4051
/>
41-
</LinearLayout>
52+
</RelativeLayout>

packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public class TabletTicker
7373
private StatusBarNotification[] mQueue = new StatusBarNotification[QUEUE_LENGTH];
7474
private int mQueuePos;
7575

76+
private final int mLargeIconHeight;
77+
7678
private TabletStatusBar mBar;
7779

7880
private LayoutTransition mLayoutTransition;
@@ -81,6 +83,9 @@ public class TabletTicker
8183
public TabletTicker(TabletStatusBar bar) {
8284
mBar = bar;
8385
mContext = bar.getContext();
86+
final Resources res = mContext.getResources();
87+
mLargeIconHeight = res.getDimensionPixelSize(
88+
android.R.dimen.notification_large_icon_height);
8489
}
8590

8691
public void add(IBinder key, StatusBarNotification notification) {
@@ -209,8 +214,6 @@ private ViewGroup makeWindow() {
209214
final Resources res = mContext.getResources();
210215
final FrameLayout view = new FrameLayout(mContext);
211216
final int width = res.getDimensionPixelSize(R.dimen.notification_ticker_width);
212-
final int height = res.getDimensionPixelSize(
213-
android.R.dimen.notification_large_icon_height);
214217
int windowFlags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
215218
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
216219
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
@@ -219,7 +222,7 @@ private ViewGroup makeWindow() {
219222
} else {
220223
windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
221224
}
222-
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, height,
225+
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, mLargeIconHeight,
223226
WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, windowFlags,
224227
PixelFormat.TRANSLUCENT);
225228
lp.gravity = Gravity.BOTTOM | Gravity.RIGHT;
@@ -297,6 +300,16 @@ private View makeTickerView(StatusBarNotification notification) {
297300
if (n.largeIcon != null) {
298301
largeIcon.setImageBitmap(n.largeIcon);
299302
largeIcon.setVisibility(View.VISIBLE);
303+
final ViewGroup.LayoutParams lp = largeIcon.getLayoutParams();
304+
final int statusBarHeight = mBar.getStatusBarHeight();
305+
if (n.largeIcon.getHeight() <= statusBarHeight) {
306+
// for smallish largeIcons, it looks a little odd to have them floating halfway up
307+
// the ticker, so we vertically center them in the status bar area instead
308+
lp.height = statusBarHeight;
309+
} else {
310+
lp.height = mLargeIconHeight;
311+
}
312+
largeIcon.setLayoutParams(lp);
300313
}
301314

302315
if (CLICKABLE_TICKER) {

tests/StatusBar/res/layout/notification_builder_test.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,11 @@
605605
style="@style/FieldContents"
606606
android:text="pineapple2"
607607
/>
608+
<RadioButton
609+
android:id="@+id/large_icon_small"
610+
style="@style/FieldContents"
611+
android:text="small"
612+
/>
608613
</RadioGroup>
609614

610615

tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ private Notification buildNotification(int id) {
287287
case R.id.large_icon_pineapple2:
288288
b.setLargeIcon(loadBitmap(R.drawable.pineapple2));
289289
break;
290+
case R.id.large_icon_small:
291+
b.setLargeIcon(loadBitmap(R.drawable.icon2));
292+
break;
290293
}
291294

292295
// sound TODO

0 commit comments

Comments
 (0)