simplify Compatibility.hasStoragePermission and no sdk <=23 anymore

This commit is contained in:
Arne 2023-10-24 14:57:35 +02:00
parent 4f674bf434
commit 6374259024
2 changed files with 7 additions and 14 deletions

View file

@ -64,9 +64,7 @@ public class UriHandlerActivity extends AppCompatActivity {
}
public static void scan(final Activity activity, final boolean provisioning) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED) {
if (ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
final Intent intent = new Intent(activity, UriHandlerActivity.class);
intent.setAction(UriHandlerActivity.ACTION_SCAN_QR_CODE);
if (provisioning) {

View file

@ -42,17 +42,12 @@ public class Compatibility {
Collections.singletonList("message_notification_settings");
public static boolean hasStoragePermission(Context context) {
if (Compatibility.runsThirtyThree()) { return ContextCompat.checkSelfPermission(
context, Manifest.permission.READ_MEDIA_IMAGES)
== PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(
context, Manifest.permission.READ_MEDIA_AUDIO)
== PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(
context, Manifest.permission.READ_MEDIA_VIDEO)
== PackageManager.PERMISSION_GRANTED; } else { return
ContextCompat.checkSelfPermission(
context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED;
}
return ((Compatibility.runsThirtyThree()
&& ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_AUDIO) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_VIDEO) == PackageManager.PERMISSION_GRANTED)
|| (!Compatibility.runsThirtyThree() && ContextCompat.checkSelfPermission(context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED));
}
public static boolean s() {