Loading core/java/android/app/Notification.java +38 −4 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.util.IntProperty; import android.util.Log; import android.view.View; import android.widget.ProgressBar; import android.widget.RemoteViews; Loading Loading @@ -808,7 +809,7 @@ public class Notification implements Parcelable public void setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent) { RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.status_bar_latest_event_content); R.layout.notification_template_base); if (this.icon != 0) { contentView.setImageViewResource(R.id.icon, this.icon); } Loading Loading @@ -1439,11 +1440,28 @@ public class Notification implements Parcelable return contentView; } private RemoteViews applyStandardTemplateWithActions(int layoutId) { RemoteViews big = applyStandardTemplate(layoutId); int N = mActions.size(); if (N > 0) { Log.d("Notification", "has actions: " + mContentText); big.setViewVisibility(R.id.actions, View.VISIBLE); if (N>3) N=3; for (int i=0; i<N; i++) { final RemoteViews button = generateActionButton(mActions.get(i)); Log.d("Notification", "adding action " + i + ": " + mActions.get(i).title); big.addView(R.id.actions, button); } } return big; } private RemoteViews makeContentView() { if (mContentView != null) { return mContentView; } else { return applyStandardTemplate(R.layout.status_bar_latest_event_content); // no more special large_icon flavor return applyStandardTemplate(R.layout.notification_template_base); // no more special large_icon flavor } } Loading @@ -1461,6 +1479,12 @@ public class Notification implements Parcelable } } private RemoteViews makeBigContentView() { if (mActions.size() == 0) return null; return applyStandardTemplateWithActions(R.layout.notification_template_base); } private RemoteViews makeIntruderView(boolean showLabels) { RemoteViews intruderView = new RemoteViews(mContext.getPackageName(), R.layout.notification_intruder_content); Loading Loading @@ -1500,6 +1524,15 @@ public class Notification implements Parcelable return intruderView; } private RemoteViews generateActionButton(Action action) { RemoteViews button = new RemoteViews(mContext.getPackageName(), R.layout.notification_action); button.setTextViewCompoundDrawables(R.id.action0, action.icon, 0, 0, 0); button.setTextViewText(R.id.action0, action.title); button.setOnClickPendingIntent(R.id.action0, action.actionIntent); button.setContentDescription(R.id.action0, action.title); return button; } /** * Combine all of the options that have been set and return a new {@link Notification} * object. Loading Loading @@ -1528,6 +1561,7 @@ public class Notification implements Parcelable if (mCanHasIntruder) { n.intruderView = makeIntruderView(mIntruderActionsShowText); } n.bigContentView = makeBigContentView(); if (mLedOnMs != 0 && mLedOffMs != 0) { n.flags |= FLAG_SHOW_LIGHTS; } Loading Loading @@ -1583,7 +1617,7 @@ public class Notification implements Parcelable } private RemoteViews makeBigContentView() { RemoteViews contentView = mBuilder.applyStandardTemplate(R.layout.notification_template_big_picture); RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(R.layout.notification_template_big_picture); contentView.setImageViewBitmap(R.id.big_picture, mPicture); Loading Loading @@ -1630,7 +1664,7 @@ public class Notification implements Parcelable } private RemoteViews makeBigContentView() { RemoteViews contentView = mBuilder.applyStandardTemplate(R.layout.status_bar_latest_event_content); RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(R.layout.notification_template_base); contentView.setTextViewText(R.id.big_text, mBigText); contentView.setViewVisibility(R.id.big_text, View.VISIBLE); Loading core/res/res/layout/notification_action.xml 0 → 100644 +23 −0 Original line number Diff line number Diff line <?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. --> <Button xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/action0" android:layout_width="match_parent" android:layout_height="wrap_content" style="@android:style/Widget.Holo.Button.Small" android:gravity="left" /> No newline at end of file core/res/res/layout/notification_template_base.xml 0 → 100644 +137 −0 Original line number Diff line number Diff line <?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. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/status_bar_latest_event_content" android:layout_width="match_parent" android:layout_height="wrap_content" > <ImageView android:id="@+id/icon" android:layout_width="@dimen/notification_large_icon_width" android:layout_height="@dimen/notification_large_icon_height" android:background="@android:drawable/notify_panel_notification_icon_bg_tile" android:scaleType="center" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/notification_large_icon_width" android:minHeight="@dimen/notification_large_icon_height" android:orientation="vertical" android:paddingLeft="12dp" android:paddingRight="12dp" android:paddingTop="4dp" android:paddingBottom="4dp" > <LinearLayout android:id="@+id/line1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/title" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:fadingEdge="horizontal" android:layout_weight="1" /> <DateTimeView android:id="@+id/time" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:singleLine="true" android:gravity="center" android:paddingLeft="8dp" /> </LinearLayout> <TextView android:id="@+id/text2" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Line2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="-2dp" android:layout_marginBottom="-2dp" android:singleLine="true" android:fadingEdge="horizontal" android:ellipsize="marquee" android:visibility="gone" /> <TextView android:id="@+id/big_text" android:textAppearance="@style/TextAppearance.StatusBar.EventContent" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="false" android:visibility="gone" /> <LinearLayout android:id="@+id/line3" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/text" android:textAppearance="@style/TextAppearance.StatusBar.EventContent" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center" android:singleLine="true" android:ellipsize="marquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/info" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:singleLine="true" android:gravity="center" android:paddingLeft="8dp" /> <ImageView android:id="@+id/right_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:scaleType="center" 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 android:id="@+id/actions" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone" > <!-- actions will be added here --> </LinearLayout> </LinearLayout> </FrameLayout> core/res/res/layout/notification_template_big_picture.xml +18 −2 Original line number Diff line number Diff line <?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. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/status_bar_latest_event_content" android:layout_width="match_parent" Loading @@ -9,9 +25,9 @@ android:layout_height="192dp" android:scaleType="centerCrop" /> <include layout="@layout/status_bar_latest_event_content" <include layout="@layout/notification_template_base" android:layout_width="match_parent" android:layout_height="@dimen/notification_large_icon_height" android:layout_height="wrap_content" android:layout_marginTop="192dp" /> </FrameLayout> No newline at end of file core/res/res/layout/status_bar_latest_event_content.xml +22 −10 Original line number Diff line number Diff line <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <?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. --> <!-- Nobody should be using this file directly. If you do, you will get a purple background. Have fun with that. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/status_bar_latest_event_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#FFFF00FF" > <ImageView android:id="@+id/icon" android:layout_width="@dimen/notification_large_icon_width" android:layout_height="@dimen/notification_large_icon_height" android:background="@android:drawable/notify_panel_notification_icon_bg_tile" android:scaleType="center" /> <include layout="@layout/status_bar_latest_event_content_large_icon" <include layout="@layout/notification_template_base" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" /> </LinearLayout> </FrameLayout> Loading
core/java/android/app/Notification.java +38 −4 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.util.IntProperty; import android.util.Log; import android.view.View; import android.widget.ProgressBar; import android.widget.RemoteViews; Loading Loading @@ -808,7 +809,7 @@ public class Notification implements Parcelable public void setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent) { RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.status_bar_latest_event_content); R.layout.notification_template_base); if (this.icon != 0) { contentView.setImageViewResource(R.id.icon, this.icon); } Loading Loading @@ -1439,11 +1440,28 @@ public class Notification implements Parcelable return contentView; } private RemoteViews applyStandardTemplateWithActions(int layoutId) { RemoteViews big = applyStandardTemplate(layoutId); int N = mActions.size(); if (N > 0) { Log.d("Notification", "has actions: " + mContentText); big.setViewVisibility(R.id.actions, View.VISIBLE); if (N>3) N=3; for (int i=0; i<N; i++) { final RemoteViews button = generateActionButton(mActions.get(i)); Log.d("Notification", "adding action " + i + ": " + mActions.get(i).title); big.addView(R.id.actions, button); } } return big; } private RemoteViews makeContentView() { if (mContentView != null) { return mContentView; } else { return applyStandardTemplate(R.layout.status_bar_latest_event_content); // no more special large_icon flavor return applyStandardTemplate(R.layout.notification_template_base); // no more special large_icon flavor } } Loading @@ -1461,6 +1479,12 @@ public class Notification implements Parcelable } } private RemoteViews makeBigContentView() { if (mActions.size() == 0) return null; return applyStandardTemplateWithActions(R.layout.notification_template_base); } private RemoteViews makeIntruderView(boolean showLabels) { RemoteViews intruderView = new RemoteViews(mContext.getPackageName(), R.layout.notification_intruder_content); Loading Loading @@ -1500,6 +1524,15 @@ public class Notification implements Parcelable return intruderView; } private RemoteViews generateActionButton(Action action) { RemoteViews button = new RemoteViews(mContext.getPackageName(), R.layout.notification_action); button.setTextViewCompoundDrawables(R.id.action0, action.icon, 0, 0, 0); button.setTextViewText(R.id.action0, action.title); button.setOnClickPendingIntent(R.id.action0, action.actionIntent); button.setContentDescription(R.id.action0, action.title); return button; } /** * Combine all of the options that have been set and return a new {@link Notification} * object. Loading Loading @@ -1528,6 +1561,7 @@ public class Notification implements Parcelable if (mCanHasIntruder) { n.intruderView = makeIntruderView(mIntruderActionsShowText); } n.bigContentView = makeBigContentView(); if (mLedOnMs != 0 && mLedOffMs != 0) { n.flags |= FLAG_SHOW_LIGHTS; } Loading Loading @@ -1583,7 +1617,7 @@ public class Notification implements Parcelable } private RemoteViews makeBigContentView() { RemoteViews contentView = mBuilder.applyStandardTemplate(R.layout.notification_template_big_picture); RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(R.layout.notification_template_big_picture); contentView.setImageViewBitmap(R.id.big_picture, mPicture); Loading Loading @@ -1630,7 +1664,7 @@ public class Notification implements Parcelable } private RemoteViews makeBigContentView() { RemoteViews contentView = mBuilder.applyStandardTemplate(R.layout.status_bar_latest_event_content); RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(R.layout.notification_template_base); contentView.setTextViewText(R.id.big_text, mBigText); contentView.setViewVisibility(R.id.big_text, View.VISIBLE); Loading
core/res/res/layout/notification_action.xml 0 → 100644 +23 −0 Original line number Diff line number Diff line <?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. --> <Button xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/action0" android:layout_width="match_parent" android:layout_height="wrap_content" style="@android:style/Widget.Holo.Button.Small" android:gravity="left" /> No newline at end of file
core/res/res/layout/notification_template_base.xml 0 → 100644 +137 −0 Original line number Diff line number Diff line <?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. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/status_bar_latest_event_content" android:layout_width="match_parent" android:layout_height="wrap_content" > <ImageView android:id="@+id/icon" android:layout_width="@dimen/notification_large_icon_width" android:layout_height="@dimen/notification_large_icon_height" android:background="@android:drawable/notify_panel_notification_icon_bg_tile" android:scaleType="center" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/notification_large_icon_width" android:minHeight="@dimen/notification_large_icon_height" android:orientation="vertical" android:paddingLeft="12dp" android:paddingRight="12dp" android:paddingTop="4dp" android:paddingBottom="4dp" > <LinearLayout android:id="@+id/line1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/title" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:fadingEdge="horizontal" android:layout_weight="1" /> <DateTimeView android:id="@+id/time" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:singleLine="true" android:gravity="center" android:paddingLeft="8dp" /> </LinearLayout> <TextView android:id="@+id/text2" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Line2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="-2dp" android:layout_marginBottom="-2dp" android:singleLine="true" android:fadingEdge="horizontal" android:ellipsize="marquee" android:visibility="gone" /> <TextView android:id="@+id/big_text" android:textAppearance="@style/TextAppearance.StatusBar.EventContent" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="false" android:visibility="gone" /> <LinearLayout android:id="@+id/line3" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/text" android:textAppearance="@style/TextAppearance.StatusBar.EventContent" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center" android:singleLine="true" android:ellipsize="marquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/info" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:singleLine="true" android:gravity="center" android:paddingLeft="8dp" /> <ImageView android:id="@+id/right_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:scaleType="center" 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 android:id="@+id/actions" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone" > <!-- actions will be added here --> </LinearLayout> </LinearLayout> </FrameLayout>
core/res/res/layout/notification_template_big_picture.xml +18 −2 Original line number Diff line number Diff line <?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. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/status_bar_latest_event_content" android:layout_width="match_parent" Loading @@ -9,9 +25,9 @@ android:layout_height="192dp" android:scaleType="centerCrop" /> <include layout="@layout/status_bar_latest_event_content" <include layout="@layout/notification_template_base" android:layout_width="match_parent" android:layout_height="@dimen/notification_large_icon_height" android:layout_height="wrap_content" android:layout_marginTop="192dp" /> </FrameLayout> No newline at end of file
core/res/res/layout/status_bar_latest_event_content.xml +22 −10 Original line number Diff line number Diff line <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <?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. --> <!-- Nobody should be using this file directly. If you do, you will get a purple background. Have fun with that. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/status_bar_latest_event_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#FFFF00FF" > <ImageView android:id="@+id/icon" android:layout_width="@dimen/notification_large_icon_width" android:layout_height="@dimen/notification_large_icon_height" android:background="@android:drawable/notify_panel_notification_icon_bg_tile" android:scaleType="center" /> <include layout="@layout/status_bar_latest_event_content_large_icon" <include layout="@layout/notification_template_base" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" /> </LinearLayout> </FrameLayout>