Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] NPEs in FileDetailsFragment (Play Store) #4178

Merged
merged 7 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/4170
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions owncloudApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ android {
}

testOptions {
packagingOptions {
jniLibs {
useLegacyPackaging = true
}
}
unitTests.returnDefaultValues = true
animationsDisabled = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -309,23 +309,23 @@ 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!!)
}
}

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!!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class MainFileListViewModel(
TODO()
}

updateFolderToDisplay(parentDir!!)
parentDir?.let { updateFolderToDisplay(it) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!!
}

Expand Down