File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
app/src/main/java/com/wmods/wppenhacer/preference Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -92,21 +92,23 @@ public boolean onPreferenceClick(@NonNull Preference preference) {
9292 return true ;
9393 }
9494
95+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
96+ if (ContextCompat .checkSelfPermission (getContext (), Manifest .permission .READ_MEDIA_IMAGES ) != PackageManager .PERMISSION_GRANTED ) {
97+ ((Activity ) getContext ()).requestPermissions (new String []{Manifest .permission .READ_MEDIA_IMAGES }, 1 );
98+ return true ;
99+ }
100+ } else if (ContextCompat .checkSelfPermission (getContext (), Manifest .permission .READ_EXTERNAL_STORAGE ) != PackageManager .PERMISSION_GRANTED ) {
101+ ((Activity ) getContext ()).requestPermissions (new String []{Manifest .permission .READ_EXTERNAL_STORAGE }, 1 );
102+ return true ;
103+ }
104+
95105 FilePicker .setOnFilePickedListener (this );
96106 if (selectDirectory ) {
97107 showSelectDirectoryDialog ();
98108 return true ;
99109 }
110+
100111 if (mineTypes .length == 1 && mineTypes [0 ].contains ("image" )) {
101- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
102- if (ContextCompat .checkSelfPermission (getContext (), Manifest .permission .READ_MEDIA_IMAGES ) != PackageManager .PERMISSION_GRANTED ) {
103- ((Activity ) getContext ()).requestPermissions (new String []{Manifest .permission .READ_MEDIA_IMAGES }, 1 );
104- return true ;
105- }
106- } else if (ContextCompat .checkSelfPermission (getContext (), Manifest .permission .READ_EXTERNAL_STORAGE ) != PackageManager .PERMISSION_GRANTED ) {
107- ((Activity ) getContext ()).requestPermissions (new String []{Manifest .permission .READ_EXTERNAL_STORAGE }, 1 );
108- return true ;
109- }
110112 FilePicker .setOnUriPickedListener (this );
111113 FilePicker .imageCapture .launch (new PickVisualMediaRequest .Builder ().setMediaType (new ActivityResultContracts .PickVisualMedia .SingleMimeType (mineTypes [0 ])).build ());
112114 return true ;
You can’t perform that action at this time.
0 commit comments