Search in sources :

Example 1 with BigTextStyle

use of android.support.v4.app.NotificationCompat.BigTextStyle in project k-9 by k9mail.

the class BaseNotificationsTest method testCreateBigTextStyleNotification.

@Test
public void testCreateBigTextStyleNotification() throws Exception {
    Account account = createFakeAccount();
    int notificationId = 23;
    NotificationHolder holder = createNotificationHolder(notificationId);
    Builder builder = notifications.createBigTextStyleNotification(account, holder, notificationId);
    verify(builder).setTicker(NOTIFICATION_SUMMARY);
    verify(builder).setGroup("newMailNotifications-" + ACCOUNT_NUMBER);
    verify(builder).setContentTitle(SENDER);
    verify(builder).setContentText(SUBJECT);
    verify(builder).setSubText(ACCOUNT_NAME);
    BigTextStyle bigTextStyle = notifications.bigTextStyle;
    verify(bigTextStyle).bigText(NOTIFICATION_PREVIEW);
    verify(builder).setStyle(bigTextStyle);
}
Also used : Account(com.fsck.k9.Account) BigTextStyle(android.support.v4.app.NotificationCompat.BigTextStyle) Builder(android.support.v4.app.NotificationCompat.Builder) Test(org.junit.Test)

Example 2 with BigTextStyle

use of android.support.v4.app.NotificationCompat.BigTextStyle in project AprilBeacon-Android-SDK by AprilBrother.

the class NotifyService method setBigTextStyleNotification.

/**
	 * Big Text Style Notification
	 * 
	 * @return Notification
	 * @see CreateNotification
	 */
private Notification setBigTextStyleNotification(String content) {
    Bitmap remote_picture = null;
    // Create the style object with BigTextStyle subclass.
    NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle();
    notiStyle.setBigContentTitle("Big Text Expanded");
    notiStyle.setSummaryText("Nice big text.");
    try {
        remote_picture = BitmapFactory.decodeStream((InputStream) new URL(sample_url).getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }
    // Add the big text to the style.
    CharSequence bigText = "This is an example of a large string to demo how much " + "text you can show in a 'Big Text Style' notification.";
    notiStyle.bigText(bigText);
    // Creates an explicit intent for an ResultActivity to receive.
    Intent resultIntent = new Intent(this, ResultActivity.class);
    // This ensures that the back button follows the recommended convention
    // for the back key.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself).
    stackBuilder.addParentStack(ResultActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack.
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    return new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true).setLargeIcon(remote_picture).setContentIntent(resultPendingIntent).addAction(R.drawable.ic_launcher, "One", resultPendingIntent).addAction(R.drawable.ic_launcher, "Two", resultPendingIntent).addAction(R.drawable.ic_launcher, "Three", resultPendingIntent).setContentTitle("Big Text Normal").setContentText(content).setStyle(notiStyle).build();
}
Also used : Bitmap(android.graphics.Bitmap) InputStream(java.io.InputStream) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) IOException(java.io.IOException) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) URL(java.net.URL)

Example 3 with BigTextStyle

use of android.support.v4.app.NotificationCompat.BigTextStyle in project AprilBeacon-Android-SDK by AprilBrother.

the class NotifyService method setBigTextStyleNotification.

/**
	 * Big Text Style Notification
	 * 
	 * @return Notification
	 * @see CreateNotification
	 */
private Notification setBigTextStyleNotification(String content) {
    Bitmap remote_picture = null;
    // Create the style object with BigTextStyle subclass.
    NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle();
    notiStyle.setBigContentTitle("Big Text Expanded");
    notiStyle.setSummaryText("Nice big text.");
    try {
        remote_picture = BitmapFactory.decodeStream((InputStream) new URL(sample_url).getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }
    // Add the big text to the style.
    CharSequence bigText = "This is an example of a large string to demo how much " + "text you can show in a 'Big Text Style' notification.";
    notiStyle.bigText(bigText);
    // Creates an explicit intent for an ResultActivity to receive.
    Intent resultIntent = new Intent(this, ResultActivity.class);
    // This ensures that the back button follows the recommended convention
    // for the back key.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself).
    stackBuilder.addParentStack(ResultActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack.
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    return new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true).setLargeIcon(remote_picture).setContentIntent(resultPendingIntent).addAction(R.drawable.ic_launcher, "One", resultPendingIntent).addAction(R.drawable.ic_launcher, "Two", resultPendingIntent).addAction(R.drawable.ic_launcher, "Three", resultPendingIntent).setContentTitle("Big Text Normal").setContentText(content).setStyle(notiStyle).build();
}
Also used : Bitmap(android.graphics.Bitmap) InputStream(java.io.InputStream) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) IOException(java.io.IOException) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) URL(java.net.URL)

Example 4 with BigTextStyle

use of android.support.v4.app.NotificationCompat.BigTextStyle in project k-9 by k9mail.

the class AuthenticationErrorNotifications method showAuthenticationErrorNotification.

public void showAuthenticationErrorNotification(Account account, boolean incoming) {
    int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming);
    Context context = controller.getContext();
    PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming);
    String title = context.getString(R.string.notification_authentication_error_title);
    String text = context.getString(R.string.notification_authentication_error_text, account.getDescription());
    NotificationCompat.Builder builder = controller.createNotificationBuilder().setSmallIcon(R.drawable.notification_icon_warning).setWhen(System.currentTimeMillis()).setAutoCancel(true).setTicker(title).setContentTitle(title).setContentText(text).setContentIntent(editServerSettingsPendingIntent).setStyle(new BigTextStyle().bigText(text)).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setCategory(NotificationCompat.CATEGORY_ERROR);
    controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true);
    getNotificationManager().notify(notificationId, builder.build());
}
Also used : Context(android.content.Context) BigTextStyle(android.support.v4.app.NotificationCompat.BigTextStyle) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 5 with BigTextStyle

use of android.support.v4.app.NotificationCompat.BigTextStyle in project qksms by moezbhatti.

the class RemoteMessagingReceiver method getConversationExtender.

public static WearableExtender getConversationExtender(Context context, String name, String address, long threadId) {
    WearableExtender wearableExtender = new WearableExtender();
    wearableExtender.setGravity(Gravity.BOTTOM);
    wearableExtender.setStartScrollBottom(true);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    Bitmap background = ContactHelper.getBitmap(context, ContactHelper.getId(context, address));
    if (background == null) {
        background = Bitmap.createBitmap(640, 400, Bitmap.Config.ARGB_8888);
        // We can't use ThemeManager here because it might not be initialized
        background.eraseColor(Integer.parseInt(prefs.getString(SettingsFragment.THEME, "" + ThemeManager.DEFAULT_COLOR)));
    }
    wearableExtender.setBackground(background);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        BigTextStyle chatPageStyle = new BigTextStyle();
        chatPageStyle.setBigContentTitle(name).setSummaryText(address).bigText(SmsHelper.getHistoryForWearable(context, name, threadId));
        Notification chatPage = new NotificationCompat.Builder(context).setStyle(chatPageStyle).extend(new NotificationCompat.WearableExtender().setStartScrollBottom(true)).build();
        wearableExtender.addPage(chatPage);
    }
    wearableExtender.addAction(getReplyAction(context, address, threadId));
    Intent readIntent = new Intent(NotificationManager.ACTION_MARK_READ);
    readIntent.putExtra(EXTRA_THREAD_ID, threadId);
    PendingIntent readPI = PendingIntent.getBroadcast(context, 2, readIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Action readAction = new NotificationCompat.Action.Builder(R.drawable.ic_accept, context.getString(R.string.mark_read), readPI).build();
    wearableExtender.addAction(readAction);
    return wearableExtender;
}
Also used : SharedPreferences(android.content.SharedPreferences) WearableExtender(android.support.v4.app.NotificationCompat.WearableExtender) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification) WearableExtender(android.support.v4.app.NotificationCompat.WearableExtender) Bitmap(android.graphics.Bitmap) BigTextStyle(android.support.v4.app.NotificationCompat.BigTextStyle) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Aggregations

PendingIntent (android.app.PendingIntent)4 NotificationCompat (android.support.v4.app.NotificationCompat)4 Intent (android.content.Intent)3 Bitmap (android.graphics.Bitmap)3 BigTextStyle (android.support.v4.app.NotificationCompat.BigTextStyle)3 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 Notification (android.app.Notification)1 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 Builder (android.support.v4.app.NotificationCompat.Builder)1 WearableExtender (android.support.v4.app.NotificationCompat.WearableExtender)1 Account (com.fsck.k9.Account)1 Test (org.junit.Test)1