Skip to content

Commit 70334ac

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge changes If0b865ac,Ie0c61300 into jb-dev
* changes: Move BigPicture's header to the top of its large view. Action button improvements:
2 parents 5ddb19e + 0749e8e commit 70334ac

File tree

9 files changed

+73
-53
lines changed

9 files changed

+73
-53
lines changed

core/java/android/app/Notification.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,8 @@ public String toString() {
907907
* </pre>
908908
*/
909909
public static class Builder {
910+
private static final int MAX_ACTION_BUTTONS = 2;
911+
910912
private Context mContext;
911913

912914
private long mWhen;
@@ -938,7 +940,7 @@ public static class Builder {
938940
private ArrayList<String> mKindList = new ArrayList<String>(1);
939941
private Bundle mExtras;
940942
private int mPriority;
941-
private ArrayList<Action> mActions = new ArrayList<Action>(3);
943+
private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS);
942944
private boolean mUseChronometer;
943945
private Style mStyle;
944946

@@ -1460,7 +1462,7 @@ private RemoteViews applyStandardTemplateWithActions(int layoutId) {
14601462
if (N > 0) {
14611463
// Log.d("Notification", "has actions: " + mContentText);
14621464
big.setViewVisibility(R.id.actions, View.VISIBLE);
1463-
if (N>3) N=3;
1465+
if (N>MAX_ACTION_BUTTONS) N=MAX_ACTION_BUTTONS;
14641466
big.removeAllViews(R.id.actions);
14651467
for (int i=0; i<N; i++) {
14661468
final RemoteViews button = generateActionButton(mActions.get(i));
@@ -1500,18 +1502,14 @@ private RemoteViews makeBigContentView() {
15001502
}
15011503

15021504
private RemoteViews generateActionButton(Action action) {
1503-
RemoteViews button = new RemoteViews(mContext.getPackageName(), R.layout.notification_action);
1505+
final boolean tombstone = (action.actionIntent == null);
1506+
RemoteViews button = new RemoteViews(mContext.getPackageName(),
1507+
tombstone ? R.layout.notification_action_tombstone
1508+
: R.layout.notification_action);
15041509
button.setTextViewCompoundDrawables(R.id.action0, action.icon, 0, 0, 0);
15051510
button.setTextViewText(R.id.action0, action.title);
1506-
if (action.actionIntent != null) {
1511+
if (!tombstone) {
15071512
button.setOnClickPendingIntent(R.id.action0, action.actionIntent);
1508-
//button.setBoolean(R.id.action0, "setEnabled", true);
1509-
button.setFloat(R.id.button0, "setAlpha", 1.0f);
1510-
button.setBoolean(R.id.button0, "setClickable", true);
1511-
} else {
1512-
//button.setBoolean(R.id.action0, "setEnabled", false);
1513-
button.setFloat(R.id.button0, "setAlpha", 0.5f);
1514-
button.setBoolean(R.id.button0, "setClickable", false);
15151513
}
15161514
button.setContentDescription(R.id.action0, action.title);
15171515
return button;

core/res/res/layout/notification_action.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
<Button xmlns:android="http://schemas.android.com/apk/res/android"
1818
style="?android:attr/borderlessButtonStyle"
1919
android:id="@+id/action0"
20-
android:layout_width="match_parent"
20+
android:layout_width="0dp"
2121
android:layout_height="48dp"
22+
android:layout_weight="1"
2223
android:gravity="left|center_vertical"
2324
android:drawablePadding="8dp"
2425
android:paddingLeft="8dp"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2012 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<LinearLayout
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:id="@+id/actions"
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:orientation="horizontal"
23+
android:visibility="gone"
24+
android:showDividers="middle"
25+
android:divider="?android:attr/listDivider"
26+
>
27+
<!-- actions will be added here -->
28+
</LinearLayout>

core/res/res/layout/notification_action_tombstone.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
-->
1616

1717
<Button xmlns:android="http://schemas.android.com/apk/res/android"
18+
style="?android:attr/borderlessButtonStyle"
1819
android:id="@+id/action0"
19-
android:layout_width="match_parent"
20+
android:layout_width="0dp"
2021
android:layout_height="48dp"
22+
android:layout_weight="1"
2123
android:gravity="left|center_vertical"
2224
android:drawablePadding="8dp"
2325
android:paddingLeft="8dp"
24-
android:textColor="#666"
26+
android:textColor="#ccc"
2527
android:textSize="14dp"
28+
android:alpha="0.5"
29+
android:enabled="false"
2630
/>

core/res/res/layout/notification_template_big_base.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,11 @@
143143
style="?android:attr/progressBarStyleHorizontal"
144144
/>
145145
</LinearLayout>
146-
<LinearLayout
146+
<include
147+
layout="@layout/notification_action_list"
147148
android:id="@+id/actions"
148149
android:layout_width="match_parent"
149150
android:layout_height="wrap_content"
150-
android:orientation="vertical"
151-
android:visibility="gone"
152-
>
153-
<!-- actions will be added here -->
154-
</LinearLayout>
151+
/>
155152
</LinearLayout>
156153
</FrameLayout>

core/res/res/layout/notification_template_big_picture.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
android:id="@+id/big_picture"
2828
android:layout_width="match_parent"
2929
android:layout_height="192dp"
30+
android:layout_marginTop="64dp"
31+
android:layout_gravity="bottom"
3032
android:scaleType="centerCrop"
3133
/>
3234
<include layout="@layout/notification_template_base"
3335
android:layout_width="match_parent"
3436
android:layout_height="wrap_content"
35-
android:layout_marginTop="192dp"
3637
/>
3738
</FrameLayout>

core/res/res/layout/notification_template_big_text.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,13 @@
105105
android:layout_weight="1"
106106
/>
107107
</LinearLayout>
108-
<LinearLayout
109-
android:id="@+id/actions"
108+
<include
109+
layout="@layout/notification_action_list"
110110
android:layout_width="match_parent"
111111
android:layout_height="0dp"
112-
android:orientation="vertical"
113112
android:visibility="gone"
114113
android:layout_weight="1"
115-
>
116-
<!-- actions will be added here -->
117-
</LinearLayout>
114+
/>
118115
<TextView android:id="@+id/overflow_title"
119116
android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"
120117
android:layout_width="match_parent"

core/res/res/layout/notification_template_inbox.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,13 @@
142142
android:visibility="gone"
143143
android:layout_weight="1"
144144
/>
145-
<LinearLayout
145+
<include
146+
layout="@layout/notification_action_list"
146147
android:id="@+id/actions"
147148
android:layout_width="match_parent"
148149
android:layout_height="wrap_content"
149-
android:orientation="vertical"
150150
android:layout_weight="0"
151-
android:visibility="gone"
152-
>
153-
<!-- actions will be added here -->
154-
</LinearLayout>
151+
/>
155152
<TextView android:id="@+id/overflow_title"
156153
android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"
157154
android:layout_width="match_parent"

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -531,30 +531,27 @@ protected boolean inflateViews(NotificationData.Entry entry, ViewGroup parent)
531531
}
532532
}
533533
catch (RuntimeException e) {
534-
exception = e;
535-
}
536-
if (expandedOneU == null && expandedLarge == null) {
537534
final String ident = sbn.pkg + "/0x" + Integer.toHexString(sbn.id);
538-
Slog.e(TAG, "couldn't inflate view for notification " + ident, exception);
535+
Slog.e(TAG, "couldn't inflate view for notification " + ident, e);
539536
return false;
540-
} else {
541-
if (expandedOneU != null) {
542-
SizeAdaptiveLayout.LayoutParams params =
543-
new SizeAdaptiveLayout.LayoutParams(expandedOneU.getLayoutParams());
544-
params.minHeight = minHeight;
545-
params.maxHeight = minHeight;
546-
adaptive.addView(expandedOneU, params);
547-
}
548-
if (expandedLarge != null) {
549-
SizeAdaptiveLayout.LayoutParams params =
550-
new SizeAdaptiveLayout.LayoutParams(expandedLarge.getLayoutParams());
551-
params.minHeight = minHeight+1;
552-
params.maxHeight = maxHeight;
553-
adaptive.addView(expandedLarge, params);
554-
}
555-
row.setDrawingCacheEnabled(true);
556537
}
557538

539+
if (expandedOneU != null) {
540+
SizeAdaptiveLayout.LayoutParams params =
541+
new SizeAdaptiveLayout.LayoutParams(expandedOneU.getLayoutParams());
542+
params.minHeight = minHeight;
543+
params.maxHeight = minHeight;
544+
adaptive.addView(expandedOneU, params);
545+
}
546+
if (expandedLarge != null) {
547+
SizeAdaptiveLayout.LayoutParams params =
548+
new SizeAdaptiveLayout.LayoutParams(expandedLarge.getLayoutParams());
549+
params.minHeight = minHeight+1;
550+
params.maxHeight = maxHeight;
551+
adaptive.addView(expandedLarge, params);
552+
}
553+
row.setDrawingCacheEnabled(true);
554+
558555
applyLegacyRowBackground(sbn, content);
559556

560557
row.setTag(R.id.expandable_tag, Boolean.valueOf(large != null));

0 commit comments

Comments
 (0)