2121import org .schabi .newpipe .settings .NewPipeSettings ;
2222
2323public final class PermissionHelper {
24+ public static final int POST_NOTIFICATIONS_REQUEST_CODE = 779 ;
2425 public static final int DOWNLOAD_DIALOG_REQUEST_CODE = 778 ;
2526 public static final int DOWNLOADS_REQUEST_CODE = 777 ;
2627
@@ -71,8 +72,7 @@ public static boolean checkWriteStoragePermissions(final Activity activity,
7172
7273 // No explanation needed, we can request the permission.
7374 ActivityCompat .requestPermissions (activity ,
74- new String []{Manifest .permission .WRITE_EXTERNAL_STORAGE },
75- requestCode );
75+ new String []{Manifest .permission .WRITE_EXTERNAL_STORAGE }, requestCode );
7676
7777 // PERMISSION_WRITE_STORAGE is an
7878 // app-defined int constant. The callback method gets the
@@ -83,6 +83,18 @@ public static boolean checkWriteStoragePermissions(final Activity activity,
8383 return true ;
8484 }
8585
86+ public static boolean checkPostNotificationsPermission (final Activity activity ,
87+ final int requestCode ) {
88+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU
89+ && ContextCompat .checkSelfPermission (activity ,
90+ Manifest .permission .POST_NOTIFICATIONS )
91+ != PackageManager .PERMISSION_GRANTED ) {
92+ ActivityCompat .requestPermissions (activity ,
93+ new String [] {Manifest .permission .POST_NOTIFICATIONS }, requestCode );
94+ return false ;
95+ }
96+ return true ;
97+ }
8698
8799 /**
88100 * In order to be able to draw over other apps,
0 commit comments