am d213524d: Merge "Add an alternate title that can be used in the overflow of a InboxStyle. Always hide contentText for BigTextStyle and InboxStyle. Style cannot be used without specialization, it should be abstract." into jb-dev

* commit 'd213524d8fad57462a87d5f9bc874e09effdef7d':
  Add an alternate title that can be used in the overflow of a InboxStyle. Always hide contentText for BigTextStyle and InboxStyle. Style cannot be used without specialization, it should be abstract.
This commit is contained in:
Chris Wren
2012-05-04 12:58:00 -07:00
committed by Android Git Automerger
7 changed files with 191 additions and 46 deletions

View File

@@ -3770,12 +3770,18 @@ package android.app {
ctor public Notification.BigPictureStyle();
ctor public Notification.BigPictureStyle(android.app.Notification.Builder);
method public android.app.Notification.BigPictureStyle bigPicture(android.graphics.Bitmap);
method public android.app.Notification build();
method public android.app.Notification.BigPictureStyle setBigContentTitle(java.lang.CharSequence);
method public android.app.Notification.BigPictureStyle setSummaryText(java.lang.CharSequence);
}
public static class Notification.BigTextStyle extends android.app.Notification.Style {
ctor public Notification.BigTextStyle();
ctor public Notification.BigTextStyle(android.app.Notification.Builder);
method public android.app.Notification.BigTextStyle bigText(java.lang.CharSequence);
method public android.app.Notification build();
method public android.app.Notification.BigTextStyle setBigContentTitle(java.lang.CharSequence);
method public android.app.Notification.BigTextStyle setSummaryText(java.lang.CharSequence);
}
public static class Notification.Builder {
@@ -3817,11 +3823,18 @@ package android.app {
ctor public Notification.InboxStyle();
ctor public Notification.InboxStyle(android.app.Notification.Builder);
method public android.app.Notification.InboxStyle addLine(java.lang.CharSequence);
method public android.app.Notification build();
method public android.app.Notification.InboxStyle setBigContentTitle(java.lang.CharSequence);
method public android.app.Notification.InboxStyle setSummaryText(java.lang.CharSequence);
}
public static class Notification.Style {
public static abstract class Notification.Style {
ctor public Notification.Style();
method public android.app.Notification build();
method public abstract android.app.Notification build();
method protected void checkBuilder();
method protected android.widget.RemoteViews getStandardView(int);
method protected void internalSetBigContentTitle(java.lang.CharSequence);
method protected void internalSetSummaryText(java.lang.CharSequence);
method public void setBuilder(android.app.Notification.Builder);
field protected android.app.Notification.Builder mBuilder;
}

View File

@@ -1397,7 +1397,8 @@ public class Notification implements Parcelable
if (mSubText != null) {
contentView.setTextViewText(R.id.text, mSubText);
contentView.setViewVisibility(R.id.text2, View.VISIBLE);
contentView.setViewVisibility(R.id.text2,
mContentText != null ? View.VISIBLE : View.GONE);
} else {
contentView.setViewVisibility(R.id.text2, View.GONE);
if (mProgressMax != 0 || mProgressIndeterminate) {
@@ -1428,12 +1429,12 @@ public class Notification implements Parcelable
int N = mActions.size();
if (N > 0) {
Log.d("Notification", "has actions: " + mContentText);
// 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);
//Log.d("Notification", "adding action " + i + ": " + mActions.get(i).title);
big.addView(R.id.actions, button);
}
}
@@ -1549,9 +1550,28 @@ public class Notification implements Parcelable
* An object that can apply a rich notification style to a {@link Notification.Builder}
* object.
*/
public static class Style {
public static abstract class Style
{
private CharSequence mBigContentTitle;
private CharSequence mSummaryText = null;
protected Builder mBuilder;
/**
* Overrides ContentTitle in the big form of the template.
* This defaults to the value passed to setContentTitle().
*/
protected void internalSetBigContentTitle(CharSequence title) {
mBigContentTitle = title;
}
/**
* Set the first line of text after the detail section in the big form of the template.
*/
protected void internalSetSummaryText(CharSequence cs) {
mSummaryText = cs;
}
public void setBuilder(Builder builder) {
if (mBuilder != builder) {
mBuilder = builder;
@@ -1559,12 +1579,42 @@ public class Notification implements Parcelable
}
}
public Notification build() {
protected void checkBuilder() {
if (mBuilder == null) {
throw new IllegalArgumentException("Style requires a valid Builder object");
}
return mBuilder.buildUnstyled();
}
protected RemoteViews getStandardView(int layoutId) {
checkBuilder();
if (mBigContentTitle != null) {
mBuilder.setContentTitle(mBigContentTitle);
}
if (mBuilder.mSubText == null) {
mBuilder.setContentText(null);
}
RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(layoutId);
if (mBuilder.mSubText == null) {
contentView.setViewVisibility(R.id.line3, View.GONE);
}
if (mBigContentTitle != null && mBigContentTitle.equals("")) {
contentView.setViewVisibility(R.id.line1, View.GONE);
}
if (mSummaryText != null && !mSummaryText.equals("")) {
contentView.setViewVisibility(R.id.overflow_title, View.VISIBLE);
contentView.setTextViewText(R.id.overflow_title, mSummaryText);
}
return contentView;
}
public abstract Notification build();
}
/**
@@ -1594,13 +1644,30 @@ public class Notification implements Parcelable
setBuilder(builder);
}
/**
* Overrides ContentTitle in the big form of the template.
* This defaults to the value passed to setContentTitle().
*/
public BigPictureStyle setBigContentTitle(CharSequence title) {
internalSetBigContentTitle(title);
return this;
}
/**
* Set the first line of text after the detail section in the big form of the template.
*/
public BigPictureStyle setSummaryText(CharSequence cs) {
internalSetSummaryText(cs);
return this;
}
public BigPictureStyle bigPicture(Bitmap b) {
mPicture = b;
return this;
}
private RemoteViews makeBigContentView() {
RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(R.layout.notification_template_big_picture);
RemoteViews contentView = getStandardView(R.layout.notification_template_big_picture);
contentView.setImageViewBitmap(R.id.big_picture, mPicture);
@@ -1609,9 +1676,7 @@ public class Notification implements Parcelable
@Override
public Notification build() {
if (mBuilder == null) {
throw new IllegalArgumentException("Style requires a valid Builder object");
}
checkBuilder();
Notification wip = mBuilder.buildUnstyled();
wip.bigContentView = makeBigContentView();
return wip;
@@ -1645,26 +1710,39 @@ public class Notification implements Parcelable
setBuilder(builder);
}
/**
* Overrides ContentTitle in the big form of the template.
* This defaults to the value passed to setContentTitle().
*/
public BigTextStyle setBigContentTitle(CharSequence title) {
internalSetBigContentTitle(title);
return this;
}
/**
* Set the first line of text after the detail section in the big form of the template.
*/
public BigTextStyle setSummaryText(CharSequence cs) {
internalSetSummaryText(cs);
return this;
}
public BigTextStyle bigText(CharSequence cs) {
mBigText = cs;
return this;
}
private RemoteViews makeBigContentView() {
int bigTextId = R.layout.notification_template_big_text;
RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(bigTextId);
RemoteViews contentView = getStandardView(R.layout.notification_template_big_text);
contentView.setTextViewText(R.id.big_text, mBigText);
contentView.setViewVisibility(R.id.big_text, View.VISIBLE);
contentView.setViewVisibility(R.id.text2, View.GONE);
return contentView;
}
@Override
public Notification build() {
if (mBuilder == null) {
throw new IllegalArgumentException("Style requires a valid Builder object");
}
checkBuilder();
Notification wip = mBuilder.buildUnstyled();
wip.bigContentView = makeBigContentView();
return wip;
@@ -1678,12 +1756,14 @@ public class Notification implements Parcelable
* <pre class="prettyprint">
* Notification noti = new Notification.InboxStyle(
* new Notification.Builder()
* .setContentTitle(&quot;New mail from &quot; + sender.toString())
* .setContentTitle(&quot;5 New mails from &quot; + sender.toString())
* .setContentText(subject)
* .setSmallIcon(R.drawable.new_mail)
* .setLargeIcon(aBitmap))
* .addLine(str1)
* .addLine(str2)
* .setContentTitle("")
* .setSummaryText(&quot;+3 more&quot;)
* .build();
* </pre>
*
@@ -1699,16 +1779,35 @@ public class Notification implements Parcelable
setBuilder(builder);
}
/**
* Overrides ContentTitle in the big form of the template.
* This defaults to the value passed to setContentTitle().
*/
public InboxStyle setBigContentTitle(CharSequence title) {
internalSetBigContentTitle(title);
return this;
}
/**
* Set the first line of text after the detail section in the big form of the template.
*/
public InboxStyle setSummaryText(CharSequence cs) {
internalSetSummaryText(cs);
return this;
}
public InboxStyle addLine(CharSequence cs) {
mTexts.add(cs);
return this;
}
private RemoteViews makeBigContentView() {
RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(R.layout.notification_template_inbox);
RemoteViews contentView = getStandardView(R.layout.notification_template_inbox);
contentView.setViewVisibility(R.id.text2, View.GONE);
int[] rowIds = {R.id.inbox_text0, R.id.inbox_text1, R.id.inbox_text2, R.id.inbox_text3,
R.id.inbox_text4};
int[] rowIds = {R.id.inbox_text0, R.id.inbox_text1, R.id.inbox_text2, R.id.inbox_text3, R.id.inbox_text4};
int i=0;
while (i < mTexts.size() && i < rowIds.length) {
CharSequence str = mTexts.get(i);
@@ -1724,9 +1823,7 @@ public class Notification implements Parcelable
@Override
public Notification build() {
if (mBuilder == null) {
throw new IllegalArgumentException("Style requires a valid Builder object");
}
checkBuilder();
Notification wip = mBuilder.buildUnstyled();
wip.bigContentView = makeBigContentView();
return wip;

View File

@@ -85,6 +85,16 @@
android:ellipsize="marquee"
android:visibility="gone"
/>
<TextView android:id="@+id/overflow_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:visibility="gone"
android:layout_weight="1"
/>
<LinearLayout
android:id="@+id/line3"
android:layout_width="match_parent"
@@ -129,14 +139,5 @@
android:visibility="gone"
style="?android:attr/progressBarStyleHorizontal"
/>
<LinearLayout
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

@@ -137,12 +137,13 @@
style="?android:attr/progressBarStyleHorizontal"
/>
<LinearLayout
android:id="@+id/actions"
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 -->
>
<!-- actions will be added here -->
</LinearLayout>
</LinearLayout>
</FrameLayout>

View File

@@ -100,7 +100,7 @@
/>
</LinearLayout>
<LinearLayout
android:id="@+id/actions"
android:id="@+id/actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@@ -108,6 +108,16 @@
>
<!-- actions will be added here -->
</LinearLayout>
<TextView android:id="@+id/overflow_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:visibility="gone"
android:layout_weight="1"
/>
<LinearLayout
android:id="@+id/line3"
android:layout_width="match_parent"

View File

@@ -87,6 +87,8 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:visibility="gone"
/>
<TextView android:id="@+id/inbox_text1"
@@ -95,6 +97,8 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:visibility="gone"
/>
<TextView android:id="@+id/inbox_text2"
@@ -103,6 +107,8 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:visibility="gone"
/>
<TextView android:id="@+id/inbox_text3"
@@ -111,6 +117,8 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:visibility="gone"
/>
<TextView android:id="@+id/inbox_text4"
@@ -119,8 +127,29 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:visibility="gone"
/>
<LinearLayout
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>
<TextView android:id="@+id/overflow_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:visibility="gone"
android:layout_weight="1"
/>
<LinearLayout
android:id="@+id/line3"
android:layout_width="match_parent"
@@ -165,13 +194,5 @@
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>

View File

@@ -99,6 +99,7 @@
<java-symbol type="id" name="issued_on" />
<java-symbol type="id" name="left_icon" />
<java-symbol type="id" name="leftSpacer" />
<java-symbol type="id" name="line1" />
<java-symbol type="id" name="line3" />
<java-symbol type="id" name="list_footer" />
<java-symbol type="id" name="list_item" />
@@ -121,6 +122,7 @@
<java-symbol type="id" name="old_app_action" />
<java-symbol type="id" name="old_app_description" />
<java-symbol type="id" name="old_app_icon" />
<java-symbol type="id" name="overflow_title" />
<java-symbol type="id" name="package_label" />
<java-symbol type="id" name="packages_list" />
<java-symbol type="id" name="pause" />