Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2022-01-17 12:24:09 +0300
committerStefan Niedermann <info@niedermann.it>2022-01-17 12:24:09 +0300
commit580df2b026f95c61d73f87979de5f1b9f40bc342 (patch)
tree9266aa74a61b6b44872ce9848299cfc54d6838b9 /app/src/main/java/it/niedermann/nextcloud/deck/ui/card
parent5c206db37a4dc4ea6f5fdd5734e8f31f0fee30bb (diff)
Remove legacy code
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/card')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java18
1 files changed, 3 insertions, 15 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java
index 48fbc3ea7..182d7d9fa 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java
@@ -4,8 +4,6 @@ import static android.Manifest.permission.CAMERA;
import static android.Manifest.permission.READ_CONTACTS;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.app.Activity.RESULT_OK;
-import static android.os.Build.VERSION.SDK_INT;
-import static android.os.Build.VERSION_CODES.M;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static androidx.core.content.PermissionChecker.PERMISSION_GRANTED;
@@ -252,7 +250,7 @@ public class CardAttachmentsFragment extends Fragment implements AttachmentDelet
private void showGalleryPicker() {
if (!(pickerAdapter instanceof GalleryAdapter)) {
- if (isPermissionRequestNeeded(READ_EXTERNAL_STORAGE) || isPermissionRequestNeeded(CAMERA)) {
+ if (checkSelfPermission(requireActivity(), READ_EXTERNAL_STORAGE) != PERMISSION_GRANTED || checkSelfPermission(requireActivity(), CAMERA) != PERMISSION_GRANTED) {
requestPermissions(new String[]{READ_EXTERNAL_STORAGE, CAMERA}, REQUEST_CODE_PICK_GALLERY_PERMISSION);
} else {
unbindPickerAdapter();
@@ -276,7 +274,7 @@ public class CardAttachmentsFragment extends Fragment implements AttachmentDelet
private void showContactPicker() {
if (!(pickerAdapter instanceof ContactAdapter)) {
- if (isPermissionRequestNeeded(READ_CONTACTS)) {
+ if (checkSelfPermission(requireActivity(), READ_CONTACTS) != PERMISSION_GRANTED) {
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_CODE_PICK_CONTACT_PICKER_PERMISSION);
} else {
unbindPickerAdapter();
@@ -298,7 +296,7 @@ public class CardAttachmentsFragment extends Fragment implements AttachmentDelet
private void showFilePicker() {
if (!(pickerAdapter instanceof FileAdapter)) {
- if (isPermissionRequestNeeded(READ_EXTERNAL_STORAGE)) {
+ if (checkSelfPermission(requireActivity(), READ_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
requestPermissions(new String[]{READ_EXTERNAL_STORAGE}, REQUEST_CODE_PICK_FILE_PERMISSION);
} else {
openNativeFilePicker();
@@ -336,16 +334,6 @@ public class CardAttachmentsFragment extends Fragment implements AttachmentDelet
.setType("*/*"), REQUEST_CODE_PICK_FILE);
}
- /**
- * Checks the current Android version and whether the permission has already been granted.
- *
- * @param permission see {@link android.Manifest.permission}
- * @return whether or not requesting permission is needed
- */
- private boolean isPermissionRequestNeeded(@NonNull String permission) {
- return SDK_INT >= M && checkSelfPermission(requireActivity(), permission) != PERMISSION_GRANTED;
- }
-
private void unbindPickerAdapter() {
if (pickerAdapter != null) {
pickerAdapter.onDestroy();