Search in sources :

Example 1 with GROUP_ALERT_SUMMARY

use of android.support.v4.app.NotificationCompat.GROUP_ALERT_SUMMARY in project samourai-wallet-android by Samourai-Wallet.

the class WhirlpoolNotificationService method updateNotification.

void updateNotification() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this, WHIRLPOOL_CHANNEL).setGroupAlertBehavior(GROUP_ALERT_SUMMARY).setContentTitle("Samourai Whirlpool").setOngoing(true).setSound(null).setGroup("service").setOnlyAlertOnce(true).addAction(getStopAction()).setCategory(NotificationCompat.CATEGORY_PROGRESS).setGroupSummary(true).setSmallIcon(R.drawable.ic_whirlpool).setColor(getResources().getColor(R.color.blue));
    setMixState(builder);
    // .build();
    Notification notification = builder.build();
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(WHIRLPOOL_SERVICE_NOTIFICATION_ID, notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification)

Example 2 with GROUP_ALERT_SUMMARY

use of android.support.v4.app.NotificationCompat.GROUP_ALERT_SUMMARY in project samourai-wallet-android by Samourai-Wallet.

the class WhirlpoolNotificationService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    Notification notification = new NotificationCompat.Builder(this, WHIRLPOOL_CHANNEL).setContentTitle("Samourai Whirlpool").setContentText("Waiting...").setOngoing(true).setSound(null).setOnlyAlertOnce(true).setGroupAlertBehavior(GROUP_ALERT_SUMMARY).setGroup("service").setCategory(NotificationCompat.CATEGORY_PROGRESS).setGroupSummary(false).setSmallIcon(R.drawable.ic_whirlpool).build();
    startForeground(WHIRLPOOL_SERVICE_NOTIFICATION_ID, notification);
    listenService();
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification)

Example 3 with GROUP_ALERT_SUMMARY

use of android.support.v4.app.NotificationCompat.GROUP_ALERT_SUMMARY in project samourai-wallet-android by Samourai-Wallet.

the class TorService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    Notification notification = new NotificationCompat.Builder(this, TOR_CHANNEL_ID).setContentTitle(title).setContentText("Waiting...").setOngoing(true).setSound(null).setOnlyAlertOnce(true).setGroupAlertBehavior(GROUP_ALERT_SUMMARY).setGroup("Tor").setCategory(NotificationCompat.CATEGORY_PROGRESS).setGroupSummary(false).setSmallIcon(R.drawable.ic_samourai_and_tor_notif_icon).build();
    startForeground(TOR_SERVICE_NOTIFICATION_ID, notification);
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification)

Example 4 with GROUP_ALERT_SUMMARY

use of android.support.v4.app.NotificationCompat.GROUP_ALERT_SUMMARY in project samourai-wallet-android by Samourai-Wallet.

the class TorService method updateNotification.

private void updateNotification(String content) {
    // Log.i(TAG, "Tor Log: ".concat(content));
    if (content.isEmpty()) {
        content = "Bootstrapping...";
    }
    if (TorManager.getInstance(this).state == TorManager.CONNECTION_STATES.CONNECTED) {
        title = "Tor: Connected";
    }
    if (TorManager.getInstance(this).state == TorManager.CONNECTION_STATES.DISCONNECTED) {
        title = "Tor: Disconnected";
    }
    NotificationCompat.Builder notification = new NotificationCompat.Builder(this, TOR_CHANNEL_ID).setContentTitle(title).setContentText(content).setOngoing(true).setOnlyAlertOnce(true).setGroupAlertBehavior(GROUP_ALERT_SUMMARY).setGroup("Tor").setCategory(NotificationCompat.CATEGORY_PROGRESS).setGroupSummary(false).setSmallIcon(R.drawable.ic_samourai_and_tor_notif_icon);
    switch(TorManager.getInstance(getApplicationContext()).state) {
        case CONNECTED:
            {
                notification.setColorized(true);
                notification.addAction(getStopAction("Stop"));
                notification.addAction(getRestartAction());
                notification.setColor(ContextCompat.getColor(this, R.color.green_ui_2));
                break;
            }
        case CONNECTING:
            {
                break;
            }
        case DISCONNECTED:
            {
                notification.addAction(getStopAction("Stop"));
                notification.setColor(ContextCompat.getColor(this, R.color.red));
                break;
            }
    }
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    if (mNotificationManager != null) {
        mNotificationManager.notify(TOR_SERVICE_NOTIFICATION_ID, notification.build());
    }
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat)

Aggregations

NotificationCompat (android.support.v4.app.NotificationCompat)4 Notification (android.app.Notification)3 NotificationManager (android.app.NotificationManager)2