mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 17:08:34 +03:00
harden theming calculations to handle null values
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
d4c07f1278
commit
eb967fbf7d
3 changed files with 10 additions and 10 deletions
|
@ -27,7 +27,7 @@ import android.content.Context
|
|||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.models.json.capabilities.ThemingCapability
|
||||
|
||||
internal class ServerThemeImpl(context: Context, themingCapability: ThemingCapability) :
|
||||
internal class ServerThemeImpl(context: Context, themingCapability: ThemingCapability?) :
|
||||
ServerTheme {
|
||||
|
||||
override val primaryColor: Int
|
||||
|
@ -37,12 +37,12 @@ internal class ServerThemeImpl(context: Context, themingCapability: ThemingCapab
|
|||
override val colorText: Int
|
||||
|
||||
init {
|
||||
primaryColor = ColorUtil.getPrimaryColor(context, themingCapability.color, R.color.colorPrimary)
|
||||
primaryColor = ColorUtil.getPrimaryColor(context, themingCapability?.color, R.color.colorPrimary)
|
||||
|
||||
colorElement = ColorUtil.getNullsafeColor(themingCapability.colorElement, primaryColor)
|
||||
colorElementBright = ColorUtil.getNullsafeColor(themingCapability.colorElementBright, primaryColor)
|
||||
colorElementDark = ColorUtil.getNullsafeColor(themingCapability.colorElementDark, primaryColor)
|
||||
colorElement = ColorUtil.getNullsafeColor(themingCapability?.colorElement, primaryColor)
|
||||
colorElementBright = ColorUtil.getNullsafeColor(themingCapability?.colorElementBright, primaryColor)
|
||||
colorElementDark = ColorUtil.getNullsafeColor(themingCapability?.colorElementDark, primaryColor)
|
||||
|
||||
colorText = ColorUtil.getTextColor(context, themingCapability.colorText, primaryColor)
|
||||
colorText = ColorUtil.getTextColor(context, themingCapability?.colorText, primaryColor)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ import com.nextcloud.talk.models.json.capabilities.Capabilities
|
|||
|
||||
interface ServerThemeProvider {
|
||||
fun getServerThemeForUser(user: User): ServerTheme
|
||||
fun getServerThemeForCapabilities(capabilities: Capabilities): ServerTheme
|
||||
fun getServerThemeForCapabilities(capabilities: Capabilities?): ServerTheme
|
||||
fun getServerThemeForCurrentUser(): ServerTheme
|
||||
}
|
||||
|
|
|
@ -55,14 +55,14 @@ internal class ServerThemeProviderImpl @Inject constructor(
|
|||
}
|
||||
|
||||
override fun getServerThemeForUser(user: User): ServerTheme {
|
||||
return getServerThemeForCapabilities(user.capabilities!!)
|
||||
return getServerThemeForCapabilities(user.capabilities)
|
||||
}
|
||||
|
||||
override fun getServerThemeForCurrentUser(): ServerTheme {
|
||||
return getServerThemeForUser(currentUser)
|
||||
}
|
||||
|
||||
override fun getServerThemeForCapabilities(capabilities: Capabilities): ServerTheme {
|
||||
return ServerThemeImpl(context, capabilities.themingCapability!!)
|
||||
override fun getServerThemeForCapabilities(capabilities: Capabilities?): ServerTheme {
|
||||
return ServerThemeImpl(context, capabilities?.themingCapability)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue