Skip to content

Commit c07191c

Browse files
committed
fix(crash): display utils show snackbar
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent 36dd404 commit c07191c

4 files changed

Lines changed: 19 additions & 36 deletions

File tree

app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,7 @@ private void fetchSharees() {
186186
return Unit.INSTANCE;
187187
}, () -> {
188188
showShareContainer();
189-
final var view = getView();
190-
if (view != null) {
191-
DisplayUtils.showSnackMessage(view, R.string.error_fetching_sharees);
192-
}
189+
DisplayUtils.showSnackMessage(this, R.string.error_fetching_sharees);
193190
return Unit.INSTANCE;
194191
});
195192
}
@@ -414,10 +411,7 @@ public void copyInternalLink() {
414411
OwnCloudAccount account = accountManager.getCurrentOwnCloudAccount();
415412

416413
if (account == null) {
417-
final var view = getView();
418-
if (view != null) {
419-
DisplayUtils.showSnackMessage(view, getString(R.string.could_not_retrieve_url));
420-
}
414+
DisplayUtils.showSnackMessage(this, R.string.could_not_retrieve_url);
421415
return;
422416
}
423417

@@ -581,10 +575,7 @@ public void refreshSharesFromDB() {
581575
}
582576

583577
if (internalShareeListAdapter == null) {
584-
final var view = getView();
585-
if (view != null) {
586-
DisplayUtils.showSnackMessage(view, getString(R.string.could_not_retrieve_shares));
587-
}
578+
DisplayUtils.showSnackMessage(this, R.string.could_not_retrieve_shares);
588579
return;
589580
}
590581

@@ -642,7 +633,7 @@ private void pickContactEmail() {
642633
if (intent.resolveActivity(requireContext().getPackageManager()) != null) {
643634
onContactSelectionResultLauncher.launch(intent);
644635
} else {
645-
DisplayUtils.showSnackMessage(requireActivity(), getString(R.string.file_detail_sharing_fragment_no_contact_app_message));
636+
DisplayUtils.showSnackMessage(this, R.string.file_detail_sharing_fragment_no_contact_app_message);
646637
}
647638
}
648639

@@ -665,16 +656,16 @@ private void handleContactResult(@NonNull Uri contactUri) {
665656
binding.searchView.requestFocus();
666657
});
667658
} else {
668-
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
659+
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed);
669660
Log_OC.e(FileDetailSharingFragment.class.getSimpleName(), "Failed to pick email address.");
670661
}
671662
} else {
672-
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
663+
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed);
673664
Log_OC.e(FileDetailSharingFragment.class.getSimpleName(), "Failed to pick email address as no Email found.");
674665
}
675666
cursor.close();
676667
} else {
677-
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
668+
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed);
678669
Log_OC.e(FileDetailSharingFragment.class.getSimpleName(), "Failed to pick email address as Cursor is null.");
679670
}
680671
}
@@ -737,10 +728,7 @@ public void unShare(OCShare share) {
737728
fileDataStorageManager.updateFileEntity(entity);
738729
}
739730
} else {
740-
final var view = getView();
741-
if (view != null) {
742-
DisplayUtils.showSnackMessage(view, getString(R.string.failed_update_ui));
743-
}
731+
DisplayUtils.showSnackMessage(this, R.string.failed_update_ui);
744732
}
745733
}
746734

@@ -778,7 +766,7 @@ public void openShareDetailWithCustomPermissions(OCShare share) {
778766
if (isGranted) {
779767
pickContactEmail();
780768
} else {
781-
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.contact_no_permission);
769+
DisplayUtils.showSnackMessage(this, R.string.contact_no_permission);
782770
}
783771
});
784772

@@ -789,13 +777,13 @@ public void openShareDetailWithCustomPermissions(OCShare share) {
789777
if (result.getResultCode() == Activity.RESULT_OK) {
790778
Intent intent = result.getData();
791779
if (intent == null) {
792-
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
780+
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed);
793781
return;
794782
}
795783

796784
Uri contactUri = intent.getData();
797785
if (contactUri == null) {
798-
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
786+
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed);
799787
return;
800788
}
801789

app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -752,14 +752,14 @@ class FileDetailsSharingProcessFragment :
752752
@Suppress("ReturnCount")
753753
private fun validateShareProcessFirst() {
754754
if (permission == OCShare.NO_PERMISSION) {
755-
DisplayUtils.showSnackMessage(binding.root, R.string.no_share_permission_selected)
755+
DisplayUtils.showSnackMessage(this, R.string.no_share_permission_selected)
756756
return
757757
}
758758

759759
if (binding.shareProcessSetPasswordSwitch.isChecked &&
760760
binding.shareProcessEnterPassword.text?.isBlank() == true
761761
) {
762-
DisplayUtils.showSnackMessage(binding.root, R.string.share_link_empty_password)
762+
DisplayUtils.showSnackMessage(this, R.string.share_link_empty_password)
763763
return
764764
}
765765

@@ -773,7 +773,7 @@ class FileDetailsSharingProcessFragment :
773773
if (binding.shareProcessChangeNameSwitch.isChecked &&
774774
binding.shareProcessChangeName.text?.isBlank() == true
775775
) {
776-
DisplayUtils.showSnackMessage(binding.root, R.string.label_empty)
776+
DisplayUtils.showSnackMessage(this, R.string.label_empty)
777777
return
778778
}
779779

@@ -790,13 +790,13 @@ class FileDetailsSharingProcessFragment :
790790
@Suppress("ReturnCount")
791791
private fun createShareOrUpdateNoteShare() {
792792
if (!isAnySharePermissionChecked()) {
793-
DisplayUtils.showSnackMessage(requireActivity(), R.string.share_option_required)
793+
DisplayUtils.showSnackMessage(this, R.string.share_option_required)
794794
return
795795
}
796796

797797
val noteText = binding.noteText.text.toString().trim()
798798
if (file == null && (share != null && share?.note == noteText)) {
799-
DisplayUtils.showSnackMessage(requireActivity(), R.string.share_cannot_update_empty_note)
799+
DisplayUtils.showSnackMessage(this, R.string.share_cannot_update_empty_note)
800800
return
801801
}
802802

@@ -807,7 +807,7 @@ class FileDetailsSharingProcessFragment :
807807
}
808808

809809
file == null -> {
810-
DisplayUtils.showSnackMessage(requireActivity(), R.string.file_not_found_cannot_share)
810+
DisplayUtils.showSnackMessage(this, R.string.file_not_found_cannot_share)
811811
return
812812
}
813813

app/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/BackupListFragment.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
462462
}
463463

464464
private void showPermissionErrorMessage() {
465-
final var view = getView();
466-
if (view != null) {
467-
DisplayUtils.showSnackMessage(view, R.string.contactlist_no_permission);
468-
} else {
469-
DisplayUtils.showSnackMessage(this, R.string.contactlist_no_permission);
470-
}
465+
DisplayUtils.showSnackMessage(this, R.string.contactlist_no_permission);
471466
}
472467

473468
private Unit onDownloadUpdate(Transfer download) {

app/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private void showFileActions(OCFile file) {
289289
private void onFileActionChosen(final int itemId) {
290290
if (itemId == R.id.action_send_share_file) {
291291
if (getFile().isSharedWithMe() && !getFile().canReshare()) {
292-
DisplayUtils.showSnackMessage(getView(), R.string.resharing_is_not_allowed);
292+
DisplayUtils.showSnackMessage(this, R.string.resharing_is_not_allowed);
293293
} else {
294294
containerActivity.getFileOperationsHelper().sendShareFile(getFile());
295295
}

0 commit comments

Comments
 (0)