Merge changes If0b865ac,Ie0c61300 into jb-dev

* changes:
  Move BigPicture's header to the top of its large view.
  Action button improvements:
This commit is contained in:
Daniel Sandler
2012-05-16 06:19:15 -07:00
committed by Android (Google) Code Review
9 changed files with 73 additions and 53 deletions

View File

@@ -907,6 +907,8 @@ public class Notification implements Parcelable
* </pre>
*/
public static class Builder {
private static final int MAX_ACTION_BUTTONS = 2;
private Context mContext;
private long mWhen;
@@ -938,7 +940,7 @@ public class Notification implements Parcelable
private ArrayList<String> mKindList = new ArrayList<String>(1);
private Bundle mExtras;
private int mPriority;
private ArrayList<Action> mActions = new ArrayList<Action>(3);
private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS);
private boolean mUseChronometer;
private Style mStyle;
@@ -1460,7 +1462,7 @@ public class Notification implements Parcelable
if (N > 0) {
// Log.d("Notification", "has actions: " + mContentText);
big.setViewVisibility(R.id.actions, View.VISIBLE);
if (N>3) N=3;
if (N>MAX_ACTION_BUTTONS) N=MAX_ACTION_BUTTONS;
big.removeAllViews(R.id.actions);
for (int i=0; i<N; i++) {
final RemoteViews button = generateActionButton(mActions.get(i));
@@ -1500,18 +1502,14 @@ public class Notification implements Parcelable
}
private RemoteViews generateActionButton(Action action) {
RemoteViews button = new RemoteViews(mContext.getPackageName(), R.layout.notification_action);
final boolean tombstone = (action.actionIntent == null);
RemoteViews button = new RemoteViews(mContext.getPackageName(),
tombstone ? R.layout.notification_action_tombstone
: R.layout.notification_action);
button.setTextViewCompoundDrawables(R.id.action0, action.icon, 0, 0, 0);
button.setTextViewText(R.id.action0, action.title);
if (action.actionIntent != null) {
if (!tombstone) {
button.setOnClickPendingIntent(R.id.action0, action.actionIntent);
//button.setBoolean(R.id.action0, "setEnabled", true);
button.setFloat(R.id.button0, "setAlpha", 1.0f);
button.setBoolean(R.id.button0, "setClickable", true);
} else {
//button.setBoolean(R.id.action0, "setEnabled", false);
button.setFloat(R.id.button0, "setAlpha", 0.5f);
button.setBoolean(R.id.button0, "setClickable", false);
}
button.setContentDescription(R.id.action0, action.title);
return button;

View File

@@ -17,8 +17,9 @@
<Button xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/borderlessButtonStyle"
android:id="@+id/action0"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:gravity="left|center_vertical"
android:drawablePadding="8dp"
android:paddingLeft="8dp"

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone"
android:showDividers="middle"
android:divider="?android:attr/listDivider"
>
<!-- actions will be added here -->
</LinearLayout>

View File

@@ -15,12 +15,16 @@
-->
<Button xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/borderlessButtonStyle"
android:id="@+id/action0"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:gravity="left|center_vertical"
android:drawablePadding="8dp"
android:paddingLeft="8dp"
android:textColor="#666"
android:textColor="#ccc"
android:textSize="14dp"
android:alpha="0.5"
android:enabled="false"
/>

View File

@@ -143,14 +143,11 @@
style="?android:attr/progressBarStyleHorizontal"
/>
</LinearLayout>
<LinearLayout
<include
layout="@layout/notification_action_list"
android:id="@+id/actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
>
<!-- actions will be added here -->
</LinearLayout>
/>
</LinearLayout>
</FrameLayout>

View File

@@ -27,11 +27,12 @@
android:id="@+id/big_picture"
android:layout_width="match_parent"
android:layout_height="192dp"
android:layout_marginTop="64dp"
android:layout_gravity="bottom"
android:scaleType="centerCrop"
/>
<include layout="@layout/notification_template_base"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="192dp"
/>
</FrameLayout>

View File

@@ -105,16 +105,13 @@
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/actions"
<include
layout="@layout/notification_action_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:visibility="gone"
android:layout_weight="1"
>
<!-- actions will be added here -->
</LinearLayout>
/>
<TextView android:id="@+id/overflow_title"
android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"
android:layout_width="match_parent"

View File

@@ -142,16 +142,13 @@
android:visibility="gone"
android:layout_weight="1"
/>
<LinearLayout
<include
layout="@layout/notification_action_list"
android:id="@+id/actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0"
android:visibility="gone"
>
<!-- actions will be added here -->
</LinearLayout>
/>
<TextView android:id="@+id/overflow_title"
android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"
android:layout_width="match_parent"

View File

@@ -531,30 +531,27 @@ public abstract class BaseStatusBar extends SystemUI implements
}
}
catch (RuntimeException e) {
exception = e;
}
if (expandedOneU == null && expandedLarge == null) {
final String ident = sbn.pkg + "/0x" + Integer.toHexString(sbn.id);
Slog.e(TAG, "couldn't inflate view for notification " + ident, exception);
Slog.e(TAG, "couldn't inflate view for notification " + ident, e);
return false;
} else {
if (expandedOneU != null) {
SizeAdaptiveLayout.LayoutParams params =
new SizeAdaptiveLayout.LayoutParams(expandedOneU.getLayoutParams());
params.minHeight = minHeight;
params.maxHeight = minHeight;
adaptive.addView(expandedOneU, params);
}
if (expandedLarge != null) {
SizeAdaptiveLayout.LayoutParams params =
new SizeAdaptiveLayout.LayoutParams(expandedLarge.getLayoutParams());
params.minHeight = minHeight+1;
params.maxHeight = maxHeight;
adaptive.addView(expandedLarge, params);
}
row.setDrawingCacheEnabled(true);
}
if (expandedOneU != null) {
SizeAdaptiveLayout.LayoutParams params =
new SizeAdaptiveLayout.LayoutParams(expandedOneU.getLayoutParams());
params.minHeight = minHeight;
params.maxHeight = minHeight;
adaptive.addView(expandedOneU, params);
}
if (expandedLarge != null) {
SizeAdaptiveLayout.LayoutParams params =
new SizeAdaptiveLayout.LayoutParams(expandedLarge.getLayoutParams());
params.minHeight = minHeight+1;
params.maxHeight = maxHeight;
adaptive.addView(expandedLarge, params);
}
row.setDrawingCacheEnabled(true);
applyLegacyRowBackground(sbn, content);
row.setTag(R.id.expandable_tag, Boolean.valueOf(large != null));