Skip to content

Commit

Permalink
Make flag non-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mscwilson committed Apr 15, 2024
1 parent e380657 commit 6b60b21
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,12 @@ class Subject(context: Context, config: SubjectConfigurationInterface?) {
standardPairs[Parameters.COLOR_DEPTH] = depth.toString()
}

var useContextResourcesScreenResolution: Boolean? = false
/**
* Whether to get the size from the context resources or not.
* By default this is false, the size is obtained from WindowManager.
*
* @param useContextResourcesScreenResolution
*/
set(useContextResourcesScreenResolution) {
if (useContextResourcesScreenResolution == null) {
return
}

field = useContextResourcesScreenResolution
}
/**
* Whether to get the size from the context resources or not.
* By default this is false, the size is obtained from WindowManager.
*/
var useContextResourcesScreenResolution: Boolean = false


init {
setDefaultTimezone()
setDefaultLanguage()
Expand All @@ -212,7 +202,6 @@ class Subject(context: Context, config: SubjectConfigurationInterface?) {
config.screenResolution?.let { screenResolution = it }
config.screenViewPort?.let { screenViewPort = it }
config.colorDepth?.let { colorDepth = it }
config.useContextResourcesScreenResolution?.let { useContextResourcesScreenResolution = it }
}
v(TAG, "Subject created successfully.")
}
Expand Down Expand Up @@ -240,8 +229,8 @@ class Subject(context: Context, config: SubjectConfigurationInterface?) {
* @param context the Android context
* @param useContextResourcesScreenResolution whether to get the size from the context resources or not
*/
private fun setDefaultScreenResolution(context: Context, useContextResourcesScreenResolution: Boolean?) {
if (useContextResourcesScreenResolution == true) {
private fun setDefaultScreenResolution(context: Context, useContextResourcesScreenResolution: Boolean) {
if (useContextResourcesScreenResolution) {
val width = context.resources.displayMetrics.widthPixels
val height = context.resources.displayMetrics.heightPixels
screenResolution = Size(width, height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ interface SubjectConfigurationInterface {
var screenResolution: Size?
var screenViewPort: Size?
var colorDepth: Int?
var useContextResourcesScreenResolution: Boolean?
var useContextResourcesScreenResolution: Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class SubjectControllerImpl // Constructors
subject.colorDepth = colorDepth
}

override var useContextResourcesScreenResolution: Boolean?
override var useContextResourcesScreenResolution: Boolean
get() = subject.useContextResourcesScreenResolution
set(useContextResourcesScreenResolution) {
dirtyConfig.useContextResourcesScreenResolution = useContextResourcesScreenResolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ open class SubjectConfiguration() : Configuration, SubjectConfigurationInterface
set(value) { _colorDepth = value }

private var _useContextResourcesScreenResolution: Boolean? = null
override var useContextResourcesScreenResolution: Boolean?
get() = _useContextResourcesScreenResolution ?: sourceConfig?.useContextResourcesScreenResolution
override var useContextResourcesScreenResolution: Boolean
get() = _useContextResourcesScreenResolution ?: sourceConfig?.useContextResourcesScreenResolution ?: false
set(value) { _useContextResourcesScreenResolution = value }

// Builder methods
Expand Down Expand Up @@ -179,7 +179,7 @@ open class SubjectConfiguration() : Configuration, SubjectConfigurationInterface
* NB: the height value will be smaller using Resources as it doesn't include the menu bar.
* Defaults to false.
*/
fun useContextResourcesScreenResolution(useContextResourcesScreenResolution: Boolean?): SubjectConfiguration {
fun useContextResourcesScreenResolution(useContextResourcesScreenResolution: Boolean): SubjectConfiguration {
this.useContextResourcesScreenResolution = useContextResourcesScreenResolution
return this
}
Expand Down

0 comments on commit 6b60b21

Please sign in to comment.