Java Code Examples for android.support.v4.app.NotificationCompat.BigPictureStyle

The following are top voted examples for showing how to use android.support.v4.app.NotificationCompat.BigPictureStyle. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: cusnews   File: MyGcmListenerService.java   View source code 6 votes vote down vote up
private void notify( long id, String title, String desc, String image, PendingIntent contentIntent, Picasso picasso, PendingIntent sharePi,
					 PendingIntent facebookPi
) throws IOException, OutOfMemoryError {

	Bitmap bitmap = picasso.load( Utils.uriStr2URI( image ).toASCIIString() ).get();
	mNotifyBuilder = new NotificationCompat.Builder( this ).setWhen( id ).setSmallIcon( R.drawable.ic_push_notify ).setTicker( title )
			.setContentTitle( title ).setContentText( desc ).setStyle( new BigPictureStyle().bigPicture( bitmap ).setBigContentTitle( title ) )
			.setAutoCancel( true ).setLargeIcon( bitmap ).addAction(
					R.drawable.ic_action_social_share, getString( R.string.action_share ), sharePi ).addAction(
					R.drawable.ic_stat_f, getString( R.string.action_fb ), facebookPi );
	mNotifyBuilder.setContentIntent( contentIntent );


	AudioManager audioManager = (AudioManager) getSystemService( Context.AUDIO_SERVICE );
	if( audioManager.getRingerMode() != AudioManager.RINGER_MODE_SILENT ) {
		mNotifyBuilder.setVibrate( new long[] { 1000 , 1000 , 1000 , 1000 } );
		mNotifyBuilder.setSound( Uri.parse( String.format( "android.resource://%s/%s", getPackageName(), R.raw.signal ) ) );
	}
	mNotifyBuilder.setLights( getResources().getColor( R.color.primary_color ), 1000, 1000 );
	mNotificationManager.notify( Utils.randInt( 1, 9999 ), mNotifyBuilder.build() );
}
 
Example 2
Project: txtr   File: NotificationService.java   View source code 6 votes vote down vote up
private void modifyForImage(final Builder builder, final Message message,
		final ArrayList<Message> messages, final boolean notify) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
			.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getDownloadable() == null) {
				tmp.add(msg);
					}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			bigPictureStyle.setSummaryText(getMergedBodies(tmp));
			builder.setContentText(getReadableBody(tmp.get(0)));
		} else {
			builder.setContentText(mXmppConnectionService.getString(R.string.image_file));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, messages, notify);
	}
}
 
Example 3
Project: TenguChat   File: NotificationService.java   View source code 5 votes vote down vote up
private void modifyForImage(final Builder builder, final UnreadConversation.Builder uBuilder,
							final Message message, final ArrayList<Message> messages) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
				.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getTransferable() == null) {
				tmp.add(msg);
			}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			CharSequence text = getMergedBodies(tmp);
			bigPictureStyle.setSummaryText(text);
			builder.setContentText(text);
		} else {
			builder.setContentText(mXmppConnectionService.getString(
					R.string.received_x_file,
					UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, uBuilder, messages);
	}
}
 
Example 4
Project: messengerxmpp   File: NotificationService.java   View source code 5 votes vote down vote up
private void modifyForImage(final Builder builder, final Message message,
							final ArrayList<Message> messages, final boolean notify) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
				.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getTransferable() == null) {
				tmp.add(msg);
			}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			bigPictureStyle.setSummaryText(getMergedBodies(tmp));
			builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, tmp.get(0)).first);
		} else {
			builder.setContentText(mXmppConnectionService.getString(
					R.string.received_x_file,
					UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, messages, notify);
	}
}
 
Example 5
Project: intellij-ce-playground   File: NotificationGenerator.java   View source code 5 votes vote down vote up
private static void generateStyle(NotificationCompat.Builder builder) {
    Integer styleValue = STYLE.getValueInt();

    if (STYLE_BIG_PICTURE.equals(styleValue)) {
        BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle();
        if (PICTURE.hasValue())
            bigPicture.bigPicture(PICTURE.getValueBitmap());
        if (BIG_CONTENT_TITLE.hasValue())
            bigPicture.setBigContentTitle(BIG_CONTENT_TITLE.getValueString());
        if (SUMMARY_TEXT.hasValue())
            bigPicture.setSummaryText(SUMMARY_TEXT.getValueString());
        builder.setStyle(bigPicture);
    } else if (STYLE_BIG_TEXT.equals(styleValue)) {
        BigTextStyle bigText = new NotificationCompat.BigTextStyle();
        if (BIG_TEXT.hasValue())
            bigText.bigText(BIG_TEXT.getValueString());
        if (BIG_CONTENT_TITLE.hasValue())
            bigText.setBigContentTitle(BIG_CONTENT_TITLE.getValueString());
        if (SUMMARY_TEXT.hasValue())
            bigText.setSummaryText(SUMMARY_TEXT.getValueString());
        builder.setStyle(bigText);
    } else if (STYLE_INBOX.equals(styleValue)) {
        InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        if (LINES.hasValue()) {
            for (String line : LINES.getValueString().split("\\n")) {
                inboxStyle.addLine(line);
            }
        }
        if (BIG_CONTENT_TITLE.hasValue())
            inboxStyle.setBigContentTitle(BIG_CONTENT_TITLE.getValueString());
        if (SUMMARY_TEXT.hasValue())
            inboxStyle.setSummaryText(SUMMARY_TEXT.getValueString());
        builder.setStyle(inboxStyle);
    }
}
 
Example 6
Project: Pix-Art-Messenger   File: NotificationService.java   View source code 5 votes vote down vote up
private void modifyForImage(final Builder builder, final UnreadConversation.Builder uBuilder,
                            final Message message, final ArrayList<Message> messages) {
    try {
        final Bitmap bitmap = mXmppConnectionService.getFileBackend()
                .getThumbnail(message, getPixel(288), false);
        final ArrayList<Message> tmp = new ArrayList<>();
        for (final Message msg : messages) {
            if (msg.getType() == Message.TYPE_TEXT
                    && msg.getTransferable() == null) {
                tmp.add(msg);
            }
        }
        final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
        bigPictureStyle.bigPicture(bitmap);
        if (tmp.size() > 0) {
            CharSequence text = getMergedBodies(tmp);
            bigPictureStyle.setSummaryText(text);
            builder.setContentText(text);
        } else {
            builder.setContentText(mXmppConnectionService.getString(
                    R.string.received_x_file,
                    UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
        }
        builder.setStyle(bigPictureStyle);
    } catch (final FileNotFoundException e) {
        modifyForTextOnly(builder, uBuilder, messages);
    }
}
 
Example 7
Project: Ti.NotificationFactory   File: BigPictureStyleProxy.java   View source code 5 votes vote down vote up
@Kroll.method @Kroll.setProperty
public void setBigPicture(Object picture)
{
	TiDrawableReference source = makeImageSource(picture);

	// Check for decodeRetries
	if (hasProperty(TiC.PROPERTY_DECODE_RETRIES)) {
		source.setDecodeRetries(TiConvert.toInt(getProperty(TiC.PROPERTY_DECODE_RETRIES), TiDrawableReference.DEFAULT_DECODE_RETRIES));
	}

	((BigPictureStyle)style).bigPicture(source.getBitmap());

	setProperty(NotificationfactoryModule.PROPERTY_BIG_PICTURE, picture);
}
 
Example 8
Project: Conversations   File: NotificationService.java   View source code 5 votes vote down vote up
private void modifyForImage(final Builder builder, final UnreadConversation.Builder uBuilder,
							final Message message, final ArrayList<Message> messages) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
				.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getTransferable() == null) {
				tmp.add(msg);
			}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			CharSequence text = getMergedBodies(tmp);
			bigPictureStyle.setSummaryText(text);
			builder.setContentText(text);
		} else {
			builder.setContentText(mXmppConnectionService.getString(
					R.string.received_x_file,
					UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, uBuilder, messages);
	}
}
 
Example 9
Project: frozenchat   File: NotificationService.java   View source code 5 votes vote down vote up
private void modifyForImage(final Builder builder, final Message message,
							final ArrayList<Message> messages, final boolean notify) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
				.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getTransferable() == null) {
				tmp.add(msg);
			}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			bigPictureStyle.setSummaryText(getMergedBodies(tmp));
			builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, tmp.get(0)).first);
		} else {
			builder.setContentText(mXmppConnectionService.getString(
					R.string.received_x_file,
					UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, messages, notify);
	}
}
 
Example 10
Project: Ti.NotificationFactory   File: BigPictureStyleProxy.java   View source code 4 votes vote down vote up
public BigPictureStyleProxy() {
	super();
	style = new BigPictureStyle();
}
 
Example 11
Project: Ti.NotificationFactory   File: BigPictureStyleProxy.java   View source code 4 votes vote down vote up
@Kroll.method @Kroll.setProperty
public void setBigContentTitle(String title) {		
	((BigPictureStyle)style).setBigContentTitle(title);	
	setProperty(NotificationfactoryModule.PROPERTY_BIG_CONTENT_TITLE, title);
}
 
Example 12
Project: Ti.NotificationFactory   File: BigPictureStyleProxy.java   View source code 4 votes vote down vote up
@Kroll.method @Kroll.setProperty
public void setSummaryText(String cs) {	
	((BigPictureStyle)style).setSummaryText(cs);
	setProperty(NotificationfactoryModule.PROPERTY_SUMMARY_TEXT, cs);
}