Search in sources :

Example 81 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project BottomNavigation by Ashok-Varma.

the class BadgeItem method show.

/**
 * @param animate whether to animate the change
 * @return this, to allow builder pattern
 */
public T show(boolean animate) {
    mIsHidden = false;
    if (isWeakReferenceValid()) {
        TextView textView = mTextViewRef.get();
        if (animate) {
            textView.setScaleX(0);
            textView.setScaleY(0);
            textView.setVisibility(View.VISIBLE);
            ViewPropertyAnimatorCompat animatorCompat = ViewCompat.animate(textView);
            animatorCompat.cancel();
            animatorCompat.setDuration(mAnimationDuration);
            animatorCompat.scaleX(1).scaleY(1);
            animatorCompat.setListener(null);
            animatorCompat.start();
        } else {
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setVisibility(View.VISIBLE);
        }
    }
    return getSubInstance();
}
Also used : TextView(android.widget.TextView) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat)

Example 82 with Builder

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

the class NotificationManager method buildSingleMessageNotification.

/**
 * Builds the actual notification for the single message. This code can be called at different points in execution
 * depending on whether or not the MMS data has been downloaded
 */
private static void buildSingleMessageNotification(final Context context, ArrayList<MessageItem> messages, long threadId, final NotificationCompat.Builder builder, ConversationPrefsHelper conversationPrefs, final Integer privateNotifications) {
    MessageItem message = messages.get(0);
    Intent threadIntent = new Intent(context, MainActivity.class);
    threadIntent.putExtra(MessageListActivity.ARG_THREAD_ID, threadId);
    final PendingIntent threadPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 1), threadIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    Intent readIntent = new Intent(ACTION_MARK_READ);
    readIntent.putExtra("thread_id", threadId);
    final PendingIntent readPI = PendingIntent.getBroadcast(context, buildRequestCode(threadId, 2), readIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    Intent seenIntent = new Intent(ACTION_MARK_SEEN);
    final PendingIntent seenPI = PendingIntent.getBroadcast(context, buildRequestCode(threadId, 4), seenIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    int unreadMessageCount = SmsHelper.getUnreadMessageCount(context);
    String body;
    String title;
    NotificationCompat.Style nstyle = null;
    switch(privateNotifications) {
        case // Hide nothing
        0:
            body = message.mBody;
            title = message.mContact;
            nstyle = new NotificationCompat.BigTextStyle().bigText(message.mBody);
            break;
        case // Hide message
        1:
            body = sRes.getString(R.string.new_message);
            title = message.mContact;
            break;
        case // Hide sender & message
        2:
            body = sRes.getString(R.string.new_message);
            title = "QKSMS";
            break;
        default:
            body = message.mBody;
            title = message.mContact;
            nstyle = null;
    }
    builder.setContentTitle(title).setContentText(body).setLargeIcon(getLargeIcon(context, Contact.get(message.mAddress, false), privateNotifications)).setContentIntent(threadPI).setNumber(unreadMessageCount).setStyle(nstyle).setColor(ThemeManager.getColor()).addAction(R.drawable.ic_accept, sRes.getString(R.string.read), readPI).extend(RemoteMessagingReceiver.getConversationExtender(context, message.mContact, message.mAddress, threadId)).setDeleteIntent(seenPI);
    if (Build.VERSION.SDK_INT < 24) {
        Intent replyIntent = new Intent(context, QKReplyActivity.class);
        replyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        replyIntent.putExtra(QKReplyActivity.EXTRA_THREAD_ID, threadId);
        replyIntent.putExtra(QKReplyActivity.EXTRA_SHOW_KEYBOARD, true);
        PendingIntent replyPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 0), replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        builder.addAction(R.drawable.ic_reply, sRes.getString(R.string.reply), replyPI);
    } else {
        builder.addAction(RemoteMessagingReceiver.getReplyAction(context, message.mAddress, threadId));
    }
    if (conversationPrefs.getDimissedReadEnabled()) {
        builder.setDeleteIntent(readPI);
    }
    if (conversationPrefs.getCallButtonEnabled()) {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + message.mAddress));
        PendingIntent callPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 3), callIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        builder.addAction(R.drawable.ic_call, sRes.getString(R.string.call), callPI);
    }
    if (message.isMms()) {
        Log.d(TAG, "Message is MMS");
        SlideshowModel model = message.mSlideshow;
        if (model != null && model.isSimple() && model.get(0).getImage() != null) {
            Log.d(TAG, "MMS type: image");
            ImageModel imageModel = model.get(0).getImage();
            Bitmap image = imageModel.getBitmap(imageModel.getWidth(), imageModel.getHeight());
            NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle().setBigContentTitle(message.mContact).setSummaryText(message.mBody).bigLargeIcon(getLargeIcon(context, Contact.get(message.mAddress, false), privateNotifications)).bigPicture(image);
            if (privateNotifications == 0)
                builder.setStyle(style);
            else
                builder.setStyle(null);
        } else {
            Log.d(TAG, "MMS Type: not an image lol");
            if (privateNotifications == 0)
                builder.setStyle(new NotificationCompat.BigTextStyle().bigText(message.mBody));
            else
                builder.setStyle(null);
        }
    }
    NotificationManager.notify(context, (int) threadId, builder.build());
}
Also used : MessageItem(com.moez.QKSMS.ui.messagelist.MessageItem) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Bitmap(android.graphics.Bitmap) SlideshowModel(com.moez.QKSMS.model.SlideshowModel) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent) ImageModel(com.moez.QKSMS.model.ImageModel)

Example 83 with Builder

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

the class NotificationManager method initQuickCompose.

/**
 * Set up the QK Compose notification
 *
 * @param override       If true, then show the QK Compose notification regardless of the user's preference
 * @param overrideCancel If true, dismiss the notification no matter what
 */
public static void initQuickCompose(Context context, boolean override, boolean overrideCancel) {
    if (sPrefs == null) {
        init(context);
    }
    if (sPrefs.getBoolean(SettingsFragment.QUICKCOMPOSE, false) || override) {
        Intent composeIntent = new Intent(context, QKComposeActivity.class);
        PendingIntent composePI = PendingIntent.getActivity(context, 9, composeIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(sRes.getString(R.string.quickcompose)).setContentText(sRes.getString(R.string.quickcompose_detail)).setOngoing(true).setContentIntent(composePI).setSmallIcon(R.drawable.ic_compose).setPriority(NotificationCompat.PRIORITY_MIN).setColor(ThemeManager.getColor());
        NotificationManager.notify(context, NOTIFICATION_ID_QUICKCOMPOSE, builder.build());
    } else {
        dismiss(context, NOTIFICATION_ID_QUICKCOMPOSE);
    }
    if (overrideCancel) {
        dismiss(context, NOTIFICATION_ID_QUICKCOMPOSE);
    }
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 84 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project bitcoin-wallet by bitcoin-wallet.

the class ReportIssueDialogBuilder method startSend.

private void startSend(final String subject, final CharSequence text, final List<Uri> attachments) {
    final ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(activity);
    for (final Uri attachment : attachments) builder.addStream(attachment);
    builder.addEmailTo(Constants.REPORT_EMAIL);
    if (subject != null)
        builder.setSubject(subject);
    builder.setText(text);
    builder.setType("text/plain");
    builder.setChooserTitle(R.string.report_issue_dialog_mail_intent_chooser);
    builder.startChooser();
    log.info("invoked chooser for sending issue report");
}
Also used : ShareCompat(android.support.v4.app.ShareCompat) Uri(android.net.Uri)

Example 85 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project run-wallet-android by runplay.

the class AppService method ensureForegroundService.

private void ensureForegroundService() {
    Intent intent = new Intent(SERVICE, MainActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setTicker("TICKER").setContentTitle("Play Lock").setContentText("").setSmallIcon(R.mipmap.ic_launcher).setWhen(System.currentTimeMillis()).setAutoCancel(false).setOngoing(true).setPriority(Notification.PRIORITY_HIGH).setContentIntent(pendIntent);
    Notification notification = builder.build();
    notification.flags |= Notification.FLAG_NO_CLEAR;
    startForeground(FOREGROUND_ID, notification);
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Aggregations

NotificationCompat (android.support.v4.app.NotificationCompat)109 PendingIntent (android.app.PendingIntent)89 Intent (android.content.Intent)82 NotificationManager (android.app.NotificationManager)36 Notification (android.app.Notification)31 Builder (android.support.v4.app.NotificationCompat.Builder)19 Context (android.content.Context)18 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)15 Uri (android.net.Uri)14 Bundle (android.os.Bundle)13 View (android.view.View)13 TextView (android.widget.TextView)11 Bitmap (android.graphics.Bitmap)10 IOException (java.io.IOException)10 RemoteViews (android.widget.RemoteViews)9 ArrayList (java.util.ArrayList)9 AlertDialog (android.app.AlertDialog)8 DialogInterface (android.content.DialogInterface)7 Dialog (android.app.Dialog)6 Paint (android.graphics.Paint)6