diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b21361bd54..aa53408acf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +Changelog for ownCloud Android Client [unreleased] (UNRELEASED) +======================================= +The following sections list the changes in ownCloud Android Client unreleased relevant to +ownCloud admins and users. + +[unreleased]: https://github.com/owncloud/android/compare/v4.1.0...master + +Summary +------- + +* Bugfix - Some Null Pointer Exceptions avoided: [#4158](https://github.com/owncloud/android/issues/4158) + +Details +------- + +* Bugfix - Some Null Pointer Exceptions avoided: [#4158](https://github.com/owncloud/android/issues/4158) + + In the detail screen, in the main file list ViewModel and in the OCFile repository the app has + been prevented from crashing when a null is found. + + https://github.com/owncloud/android/issues/4158 + https://github.com/owncloud/android/pull/4170 + Changelog for ownCloud Android Client [4.1.0] (2023-08-23) ======================================= The following sections list the changes in ownCloud Android Client 4.1.0 relevant to diff --git a/changelog/unreleased/4170 b/changelog/unreleased/4170 new file mode 100644 index 00000000000..e7ad28c99a7 --- /dev/null +++ b/changelog/unreleased/4170 @@ -0,0 +1,6 @@ +Bugfix: Some Null Pointer Exceptions avoided + +in the detail screen, in the main file list ViewModel and in the OCFile repository the app has been prevented from crashing when a null is found. + +https://github.com/owncloud/android/issues/4158 +https://github.com/owncloud/android/pull/4170 diff --git a/owncloudApp/build.gradle b/owncloudApp/build.gradle index 3e61d9d2882..20f9b89e182 100644 --- a/owncloudApp/build.gradle +++ b/owncloudApp/build.gradle @@ -160,6 +160,11 @@ android { } testOptions { + packagingOptions { + jniLibs { + useLegacyPackaging = true + } + } unitTests.returnDefaultValues = true animationsDisabled = true } diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/ReleaseNotesList.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/ReleaseNotesList.kt index dec200fba1e..16a2cde32a7 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/ReleaseNotesList.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/ReleaseNotesList.kt @@ -25,38 +25,18 @@ import com.owncloud.android.presentation.releasenotes.ReleaseNoteType val releaseNotesList = listOf( ReleaseNote( - title = R.string.release_notes_4_1_title_1, - subtitle = R.string.release_notes_4_1_subtitle_1, - type = ReleaseNoteType.ENHANCEMENT, + title = R.string.release_notes_header, + subtitle = R.string.release_notes_footer, + type = ReleaseNoteType.BUGFIX ), ReleaseNote( - title = R.string.release_notes_4_1_title_2, - subtitle = R.string.release_notes_4_1_subtitle_2, - type = ReleaseNoteType.ENHANCEMENT, + title = R.string.release_notes_header, + subtitle = R.string.release_notes_footer, + type = ReleaseNoteType.BUGFIX ), ReleaseNote( - title = R.string.release_notes_4_1_title_3, - subtitle = R.string.release_notes_4_1_subtitle_3, - type = ReleaseNoteType.ENHANCEMENT, - ), - ReleaseNote( - title = R.string.release_notes_4_1_title_4, - subtitle = R.string.release_notes_4_1_subtitle_4, - type = ReleaseNoteType.BUGFIX, - ), - ReleaseNote( - title = R.string.release_notes_4_1_title_5, - subtitle = R.string.release_notes_4_1_subtitle_5, - type = ReleaseNoteType.ENHANCEMENT, - ), - ReleaseNote( - title = R.string.release_notes_4_1_title_6, - subtitle = R.string.release_notes_4_1_subtitle_6, - type = ReleaseNoteType.ENHANCEMENT, - ), - ReleaseNote( - title = R.string.release_notes_4_1_title_7, - subtitle = R.string.release_notes_4_1_subtitle_7, - type = ReleaseNoteType.BUGFIX, - ), + title = R.string.release_notes_header, + subtitle = R.string.release_notes_footer, + type = ReleaseNoteType.ENHANCEMENT + ) ) diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/details/FileDetailsFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/details/FileDetailsFragment.kt index 34ac35701bb..f1611f7aabb 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/details/FileDetailsFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/details/FileDetailsFragment.kt @@ -309,7 +309,7 @@ class FileDetailsFragment : FileFragment() { } private fun setLastSync(ocFile: OCFile) { - if (ocFile.lastSyncDateForData!! > ZERO_MILLISECOND_TIME) { + if (ocFile.lastSyncDateForData?.let { it > ZERO_MILLISECOND_TIME } == true) { binding.fdLastSync.visibility = View.VISIBLE binding.fdLastSyncLabel.visibility = View.VISIBLE binding.fdLastSync.text = DisplayUtils.unixTimeToHumanReadable(ocFile.lastSyncDateForData!!) @@ -317,15 +317,15 @@ class FileDetailsFragment : FileFragment() { } private fun setModified(ocFile: OCFile) { - if (ocFile.modificationTimestamp!! > ZERO_MILLISECOND_TIME) { + if (ocFile.modificationTimestamp?.let { it > ZERO_MILLISECOND_TIME } == true) { binding.fdModified.visibility = View.VISIBLE binding.fdModifiedLabel.visibility = View.VISIBLE - binding.fdModified.text = DisplayUtils.unixTimeToHumanReadable(ocFile.modificationTimestamp!!) + binding.fdModified.text = DisplayUtils.unixTimeToHumanReadable(ocFile.modificationTimestamp) } } private fun setCreated(ocFile: OCFile) { - if (ocFile.creationTimestamp!! > ZERO_MILLISECOND_TIME) { + if (ocFile.creationTimestamp?.let { it > ZERO_MILLISECOND_TIME } == true) { binding.fdCreated.visibility = View.VISIBLE binding.fdCreatedLabel.visibility = View.VISIBLE binding.fdCreated.text = DisplayUtils.unixTimeToHumanReadable(ocFile.creationTimestamp!!) diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListViewModel.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListViewModel.kt index 48de4b2ba71..a9dde92c8b8 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListViewModel.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListViewModel.kt @@ -256,7 +256,7 @@ class MainFileListViewModel( TODO() } - updateFolderToDisplay(parentDir!!) + parentDir?.let { updateFolderToDisplay(it) } } } diff --git a/owncloudData/src/main/java/com/owncloud/android/data/files/repository/OCFileRepository.kt b/owncloudData/src/main/java/com/owncloud/android/data/files/repository/OCFileRepository.kt index 45e694e4a6d..fbb94a734cb 100644 --- a/owncloudData/src/main/java/com/owncloud/android/data/files/repository/OCFileRepository.kt +++ b/owncloudData/src/main/java/com/owncloud/android/data/files/repository/OCFileRepository.kt @@ -168,10 +168,14 @@ class OCFileRepository( val personalSpace = localSpacesDataSource.getPersonalSpaceForAccount(owner) if (personalSpace == null) { val legacyRootFolder = localFileDataSource.getFileByRemotePath(remotePath = ROOT_PATH, owner = owner, spaceId = null) - return legacyRootFolder!! + try { + return legacyRootFolder ?: throw IllegalStateException("LegacyRootFolder not found") + } catch (e: IllegalStateException) { + Timber.i("There was an error: $e") + } } // TODO: Retrieving the root folders should return a non nullable. If they don't exist yet, they are created and returned. Remove nullability - val personalRootFolder = localFileDataSource.getFileByRemotePath(remotePath = ROOT_PATH, owner = owner, spaceId = personalSpace.root.id) + val personalRootFolder = localFileDataSource.getFileByRemotePath(remotePath = ROOT_PATH, owner = owner, spaceId = personalSpace?.root?.id) return personalRootFolder!! }