2013-02-08 19:57:54 +00:00
|
|
|
package org.thoughtcrime.securesms.notifications;
|
|
|
|
|
|
|
|
import android.app.PendingIntent;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.text.SpannableStringBuilder;
|
|
|
|
|
2013-02-17 19:42:30 +00:00
|
|
|
import org.thoughtcrime.securesms.RoutingActivity;
|
2013-04-26 01:59:49 +00:00
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
2013-02-08 19:57:54 +00:00
|
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
|
|
|
|
|
|
|
public class NotificationItem {
|
|
|
|
|
|
|
|
private final Recipients recipients;
|
2013-04-26 01:59:49 +00:00
|
|
|
private final Recipient individualRecipient;
|
2013-02-08 19:57:54 +00:00
|
|
|
private final long threadId;
|
|
|
|
private final CharSequence text;
|
|
|
|
private final Uri image;
|
|
|
|
|
2013-04-26 01:59:49 +00:00
|
|
|
public NotificationItem(Recipient individualRecipient, Recipients recipients, long threadId,
|
|
|
|
CharSequence text, Uri image)
|
|
|
|
{
|
|
|
|
this.individualRecipient = individualRecipient;
|
|
|
|
this.recipients = recipients;
|
|
|
|
this.text = text;
|
|
|
|
this.image = image;
|
|
|
|
this.threadId = threadId;
|
2013-02-08 19:57:54 +00:00
|
|
|
}
|
|
|
|
|
2013-04-26 01:59:49 +00:00
|
|
|
public Recipient getIndividualRecipient() {
|
|
|
|
return individualRecipient;
|
2013-02-08 19:57:54 +00:00
|
|
|
}
|
|
|
|
|
2013-04-26 01:59:49 +00:00
|
|
|
public String getIndividualRecipientName() {
|
|
|
|
return individualRecipient.toShortString();
|
2013-02-08 19:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public CharSequence getText() {
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Uri getImage() {
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasImage() {
|
|
|
|
return image != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getThreadId() {
|
|
|
|
return threadId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public CharSequence getBigStyleSummary() {
|
|
|
|
return (text == null) ? "" : text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public CharSequence getTickerText() {
|
|
|
|
SpannableStringBuilder builder = new SpannableStringBuilder();
|
2013-04-26 01:59:49 +00:00
|
|
|
builder.append(Util.getBoldedString(getIndividualRecipientName()));
|
2013-02-08 19:57:54 +00:00
|
|
|
builder.append(": ");
|
|
|
|
builder.append(getText());
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PendingIntent getPendingIntent(Context context) {
|
2013-02-17 19:42:30 +00:00
|
|
|
Intent intent = new Intent(context, RoutingActivity.class);
|
2013-02-08 19:57:54 +00:00
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
|
|
2013-04-26 01:59:49 +00:00
|
|
|
if (recipients != null) {
|
2013-02-08 19:57:54 +00:00
|
|
|
intent.putExtra("recipients", recipients);
|
|
|
|
intent.putExtra("thread_id", threadId);
|
|
|
|
}
|
|
|
|
|
|
|
|
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
|
|
|
|
|
|
|
return PendingIntent.getActivity(context, 0, intent, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|