Skip to content

Commit

Permalink
Merge pull request #889 from nextcloud/backport/886/stable-2.10
Browse files Browse the repository at this point in the history
[stable-2.10] OCCapability: restore nullability of optional strings
  • Loading branch information
AlvaroBrey authored May 6, 2022
2 parents 1b97363 + 0545b72 commit 7b5c368
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ class OCCapability {
var versionEdition: String? = null

// Theming
var serverName = ""
var serverSlogan = ""
var serverColor = ""
var serverTextColor = ""
var serverElementColor = ""
var serverElementColorBright = ""
var serverElementColorDark = ""
var serverLogo = ""
var serverBackground = ""
var serverName: String? = ""
var serverSlogan: String? = ""
var serverColor: String? = ""
var serverTextColor: String? = ""
var serverElementColor: String? = ""
var serverElementColorBright: String? = ""
var serverElementColorDark: String? = ""
var serverLogo: String? = ""
var serverBackground: String? = ""
var serverBackgroundDefault = CapabilityBooleanType.UNKNOWN
var serverBackgroundPlain = CapabilityBooleanType.UNKNOWN

Expand Down Expand Up @@ -100,7 +100,7 @@ class OCCapability {
var extendedSupport = CapabilityBooleanType.UNKNOWN

// DirectEditing
var directEditingEtag: String = ""
var directEditingEtag: String? = ""

// user status
var userStatus = CapabilityBooleanType.UNKNOWN
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Nextcloud Android Library is available under MIT license
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package com.owncloud.android.lib.resources.status

import org.junit.Test

class OCCapabilityTest {

/**
* This won't compile if the fields below are not nullable. This is sort of redundant,
* but it's meant to prevent a crash in client apps when trying to assign null from Java.
*/
@Test
fun testFieldNullability() {
OCCapability().apply {
serverName = null
serverSlogan = null
serverColor = null
serverTextColor = null
serverElementColor = null
serverElementColorBright = null
serverElementColorDark = null
serverLogo = null
serverBackground = null
directEditingEtag = null
}
}
}

0 comments on commit 7b5c368

Please sign in to comment.