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 30 of file PrintNotificationHelper.java.

Member Function Documentation

◆ ensureChannel()

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

Definition at line 35 of file PrintNotificationHelper.java.

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

◆ notify()

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

Definition at line 48 of file PrintNotificationHelper.java.

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

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