Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Device.java
Show First 20 Lines • Show All 384 Lines • ▼ Show 20 Line(s) | 364 | public void displayPairingNotification() { | |||
---|---|---|---|---|---|
385 | rejectIntent.setAction("action "+System.currentTimeMillis()); | 385 | rejectIntent.setAction("action "+System.currentTimeMillis()); | ||
386 | rejectIntent.putExtra(MaterialActivity.PAIR_REQUEST_STATUS, MaterialActivity.PAIRING_REJECTED); | 386 | rejectIntent.putExtra(MaterialActivity.PAIR_REQUEST_STATUS, MaterialActivity.PAIRING_REJECTED); | ||
387 | 387 | | |||
388 | PendingIntent acceptedPendingIntent = PendingIntent.getActivity(getContext(), 2, acceptIntent, PendingIntent.FLAG_ONE_SHOT); | 388 | PendingIntent acceptedPendingIntent = PendingIntent.getActivity(getContext(), 2, acceptIntent, PendingIntent.FLAG_ONE_SHOT); | ||
389 | PendingIntent rejectedPendingIntent = PendingIntent.getActivity(getContext(), 4, rejectIntent, PendingIntent.FLAG_ONE_SHOT); | 389 | PendingIntent rejectedPendingIntent = PendingIntent.getActivity(getContext(), 4, rejectIntent, PendingIntent.FLAG_ONE_SHOT); | ||
390 | 390 | | |||
391 | Resources res = getContext().getResources(); | 391 | Resources res = getContext().getResources(); | ||
392 | 392 | | |||
393 | Notification noti = new NotificationCompat.Builder(getContext()) | 393 | final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); | ||
394 | | ||||
395 | Notification noti = new NotificationCompat.Builder(getContext(), NotificationHelper.getDefaultChannelId(notificationManager)) | ||||
394 | .setContentTitle(res.getString(R.string.pairing_request_from, getName())) | 396 | .setContentTitle(res.getString(R.string.pairing_request_from, getName())) | ||
395 | .setContentText(res.getString(R.string.tap_to_answer)) | 397 | .setContentText(res.getString(R.string.tap_to_answer)) | ||
396 | .setContentIntent(pendingIntent) | 398 | .setContentIntent(pendingIntent) | ||
397 | .setTicker(res.getString(R.string.pair_requested)) | 399 | .setTicker(res.getString(R.string.pair_requested)) | ||
398 | .setSmallIcon(R.drawable.ic_notification) | 400 | .setSmallIcon(R.drawable.ic_notification) | ||
399 | .addAction(R.drawable.ic_accept_pairing, res.getString(R.string.pairing_accept), acceptedPendingIntent) | 401 | .addAction(R.drawable.ic_accept_pairing, res.getString(R.string.pairing_accept), acceptedPendingIntent) | ||
400 | .addAction(R.drawable.ic_reject_pairing, res.getString(R.string.pairing_reject), rejectedPendingIntent) | 402 | .addAction(R.drawable.ic_reject_pairing, res.getString(R.string.pairing_reject), rejectedPendingIntent) | ||
401 | .setAutoCancel(true) | 403 | .setAutoCancel(true) | ||
402 | .setDefaults(Notification.DEFAULT_ALL) | 404 | .setDefaults(Notification.DEFAULT_ALL) | ||
403 | .build(); | 405 | .build(); | ||
404 | 406 | | |||
405 | final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); | | |||
406 | NotificationHelper.notifyCompat(notificationManager, notificationId, noti); | 407 | NotificationHelper.notifyCompat(notificationManager, notificationId, noti); | ||
407 | 408 | | |||
408 | BackgroundService.addGuiInUseCounter(context); | 409 | BackgroundService.addGuiInUseCounter(context); | ||
409 | } | 410 | } | ||
410 | 411 | | |||
411 | public void hidePairingNotification() { | 412 | public void hidePairingNotification() { | ||
412 | final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); | 413 | final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); | ||
413 | notificationManager.cancel(notificationId); | 414 | notificationManager.cancel(notificationId); | ||
▲ Show 20 Lines • Show All 480 Lines • Show Last 20 Lines |