FreeRDP
Loading...
Searching...
No Matches
com.freerdp.freerdpcore.presentation.PrintNotificationHelper Class Reference

Static Public Member Functions

static void ensureChannel (Context ctx)
 
static void notify (Context ctx, File pdfFile)
 

Detailed Description

Definition at line 29 of file PrintNotificationHelper.java.

Member Function Documentation

◆ ensureChannel()

static void com.freerdp.freerdpcore.presentation.PrintNotificationHelper.ensureChannel ( Context  ctx)
inlinestatic

Definition at line 35 of file PrintNotificationHelper.java.

36 {
37 NotificationManager nm = ctx.getSystemService(NotificationManager.class);
38 if (nm.getNotificationChannel(CHANNEL_ID) != null)
39 return;
40 NotificationChannel ch =
41 new NotificationChannel(CHANNEL_ID, ctx.getString(R.string.print_notif_channel),
42 NotificationManager.IMPORTANCE_HIGH);
43 nm.createNotificationChannel(ch);
44 }

◆ notify()

static void com.freerdp.freerdpcore.presentation.PrintNotificationHelper.notify ( Context  ctx,
File  pdfFile 
)
inlinestatic

Definition at line 46 of file PrintNotificationHelper.java.

47 {
48 ensureChannel(ctx);
49
50 Uri uri = FileProvider.getUriForFile(ctx, AUTHORITY, pdfFile);
51
52 PendingIntent openIntent = PendingIntent.getActivity(
53 ctx, notifId.get(),
54 new Intent(Intent.ACTION_VIEW)
55 .setDataAndType(uri, "application/pdf")
56 .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION),
57 PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
58
59 Intent printLaunch = new Intent(ctx, PrintProxyActivity.class);
60 printLaunch.setData(uri);
61 printLaunch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
62 PendingIntent printIntent = PendingIntent.getActivity(
63 ctx, notifId.get() + 1, printLaunch,
64 PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
65
66 Notification notif = new NotificationCompat.Builder(ctx, CHANNEL_ID)
67 .setSmallIcon(android.R.drawable.ic_dialog_info)
68 .setContentTitle(ctx.getString(R.string.print_notif_title))
69 .setContentText(pdfFile.getName())
70 .setContentIntent(openIntent)
71 .addAction(android.R.drawable.ic_menu_view,
72 ctx.getString(R.string.print_notif_open), openIntent)
73 .addAction(android.R.drawable.ic_menu_send,
74 ctx.getString(R.string.print_notif_print), printIntent)
75 .setAutoCancel(true)
76 .build();
77
78 NotificationManager nm =
79 (NotificationManager)ctx.getSystemService(Context.NOTIFICATION_SERVICE);
80 nm.notify(notifId.getAndIncrement(), notif);
81 }

The documentation for this class was generated from the following file: