Skip to content

Commit

Permalink
Merge pull request #1615 from instructure/release/student-6.18.1-240
Browse files Browse the repository at this point in the history
Release Student 6.18.1 (240)
  • Loading branch information
tamaskozmer authored Jun 21, 2022
2 parents 4e1d5ab + 2a1fd24 commit 4a8fc3e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
4 changes: 2 additions & 2 deletions apps/student/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ android {
applicationId "com.instructure.candroid"
minSdkVersion Versions.MIN_SDK
targetSdkVersion Versions.TARGET_SDK
versionCode = 239
versionName = '6.18.0'
versionCode = 240
versionName = '6.18.1'

vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ open class DiscussionListFragment : ParentFragment(), Bookmarkable {
super.onCreate(savedInstanceState)
checkForPermission()
checkFeatureFlags()
retainInstance = true
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
Expand Down Expand Up @@ -235,6 +234,7 @@ open class DiscussionListFragment : ParentFragment(), Bookmarkable {
super.onDestroyView()
permissionJob?.cancel()
featureFlagsJob?.cancel()
groupsJob?.cancel()
recyclerAdapter.cancel()
}
//endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.instructure.pandautils.utils

import android.content.Context
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import androidx.annotation.ColorInt
Expand Down Expand Up @@ -135,11 +134,21 @@ object ColorKeeper : PrefManager(PREFERENCE_FILE_NAME) {
* @return The parsed color, or [defaultColor] if the string could not be parsed
*/
private fun parseColor(hexColor: String): Int = try {
ColorUtils.parseColor("#${hexColor.trimMargin("#")}", "")
val trimmedColorCode = getTrimmedColorCode(hexColor)
ColorUtils.parseColor(trimmedColorCode, defaultColor = defaultColor)
} catch (e: IllegalArgumentException) {
defaultColor
}

// There might be cases where the color code from the response contains whitespaces.
private fun getTrimmedColorCode(colorCode: String): String {
return if (colorCode.contains("#")) {
"#${colorCode.trimMargin("#")}"
} else {
colorCode
}
}

/**
* Generates a generic color based on the canvas context id, this will produce consistent colors for a given course
* @param canvasContext a valid canvas context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.instructure.pandautils.utils
import android.graphics.*
import android.graphics.drawable.Drawable
import android.widget.ImageView
import androidx.annotation.ColorInt
import androidx.core.graphics.drawable.DrawableCompat

object ColorUtils {
Expand Down Expand Up @@ -46,7 +47,7 @@ object ColorUtils {

@JvmStatic
@JvmOverloads
fun parseColor(colorCode: String?, defaultColorCode: String = ColorApiHelper.K5_DEFAULT_COLOR): Int {
fun parseColor(colorCode: String?, @ColorInt defaultColor: Int? = null): Int {
return try {
val fullColorCode = if (colorCode?.length == 4 && colorCode[0].toString() == "#") {
"#${colorCode[1]}${colorCode[1]}${colorCode[2]}${colorCode[2]}${colorCode[3]}${colorCode[3]}"
Expand All @@ -55,7 +56,11 @@ object ColorUtils {
}
Color.parseColor(fullColorCode)
} catch (e: Exception) {
Color.parseColor(defaultColorCode)
if (defaultColor != null) {
defaultColor
} else {
Color.parseColor(ColorApiHelper.K5_DEFAULT_COLOR)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,20 @@ object ThemePrefs : PrefManager("CanvasTheme") {

private fun parseColor(hexColor: String, defaultColor: Int): Int {
try {
return ColorUtils.parseColor("#${hexColor.trimMargin("#")}", "")
val trimmedColorCode = getTrimmedColorCode(hexColor)
return ColorUtils.parseColor(trimmedColorCode, defaultColor = defaultColor)
} catch (e: IllegalArgumentException) {
return defaultColor
}
}

// There might be cases where the color codes from the response contain whitespaces.
private fun getTrimmedColorCode(colorCode: String): String {
return if (colorCode.contains("#")) {
"#${colorCode.trimMargin("#")}"
} else {
colorCode
}
}

}

0 comments on commit 4a8fc3e

Please sign in to comment.