From 163ec5049ad9675ed40df1046ae67fc688178c6a Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Mon, 25 Sep 2023 08:24:27 +0100 Subject: [PATCH 1/7] Avoiding crashes when it's null --- .../presentation/files/details/FileDetailsFragment.kt | 8 ++++---- .../presentation/files/filelist/MainFileListViewModel.kt | 2 +- .../android/data/files/repository/OCFileRepository.kt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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..bd4d9b5df34 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,7 +168,7 @@ class OCFileRepository( val personalSpace = localSpacesDataSource.getPersonalSpaceForAccount(owner) if (personalSpace == null) { val legacyRootFolder = localFileDataSource.getFileByRemotePath(remotePath = ROOT_PATH, owner = owner, spaceId = null) - return legacyRootFolder!! + return legacyRootFolder ?: throw IllegalStateException("LegacyRootFolder not found") } // 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) From 1f9fb8f38d3196b8eb591fbcf153f77ec6d2046f Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Wed, 27 Sep 2023 15:50:02 +0100 Subject: [PATCH 2/7] Added calens --- changelog/unreleased/4170 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog/unreleased/4170 diff --git a/changelog/unreleased/4170 b/changelog/unreleased/4170 new file mode 100644 index 00000000000..55d12671faa --- /dev/null +++ b/changelog/unreleased/4170 @@ -0,0 +1,6 @@ +Bugfix: Null pointer exception have been avoided + +in the detail screen as elsewhere 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 From b2d0941c0022d56ef7c12c7ec2b68d587e0ca892 Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Wed, 27 Sep 2023 14:50:39 +0000 Subject: [PATCH 3/7] Calens changelog updated --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b21361bd54..f6208cabf20 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 - Null pointer exception have been avoided: [#4158](https://github.com/owncloud/android/issues/4158) + +Details +------- + +* Bugfix - Null pointer exception have been avoided: [#4158](https://github.com/owncloud/android/issues/4158) + + In the detail screen as elsewhere 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 From 392221d003d42484ebad87bee7188176d8c303e5 Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Thu, 28 Sep 2023 08:28:08 +0100 Subject: [PATCH 4/7] Fix cr --- changelog/unreleased/4170 | 4 ++-- .../android/data/files/repository/OCFileRepository.kt | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/changelog/unreleased/4170 b/changelog/unreleased/4170 index 55d12671faa..e7ad28c99a7 100644 --- a/changelog/unreleased/4170 +++ b/changelog/unreleased/4170 @@ -1,6 +1,6 @@ -Bugfix: Null pointer exception have been avoided +Bugfix: Some Null Pointer Exceptions avoided -in the detail screen as elsewhere the app has been prevented from crashing when a null is found. +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/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 bd4d9b5df34..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 ?: throw IllegalStateException("LegacyRootFolder not found") + 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!! } From 8cab430889cda299ad448831608fdddaf69371f8 Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Thu, 28 Sep 2023 07:29:15 +0000 Subject: [PATCH 5/7] Calens changelog updated --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6208cabf20..a88252fe5f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,14 +8,15 @@ ownCloud admins and users. Summary ------- -* Bugfix - Null pointer exception have been avoided: [#4158](https://github.com/owncloud/android/issues/4158) +* Bugfix - Some Null Pointer Exceptions avoided: [#4158](https://github.com/owncloud/android/issues/4158) Details ------- -* Bugfix - Null pointer exception have been avoided: [#4158](https://github.com/owncloud/android/issues/4158) +* Bugfix - Some Null Pointer Exceptions avoided: [#4158](https://github.com/owncloud/android/issues/4158) - In the detail screen as elsewhere the app has been prevented from crashing when a null is found. + 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 From 6190a728c95b1f048eab35ff86015dec55b1e8f1 Mon Sep 17 00:00:00 2001 From: JuancaG05 Date: Wed, 4 Oct 2023 07:56:42 +0000 Subject: [PATCH 6/7] Calens changelog updated --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a88252fe5f0..aa53408acf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,6 @@ Details 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 From fbd9d1a0ecbfb84effd87fa8fe46438d92adb159 Mon Sep 17 00:00:00 2001 From: Juan Carlos Garrote Date: Wed, 4 Oct 2023 11:13:55 +0200 Subject: [PATCH 7/7] Fix for release notes UI tests --- owncloudApp/build.gradle | 5 +++ .../android/utils/ReleaseNotesList.kt | 40 +++++-------------- 2 files changed, 15 insertions(+), 30 deletions(-) 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 + ) )