From b6bce2b2ec9a9b89f449648e627dfc1cd783ec7a Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 9 Oct 2019 10:42:18 +0200 Subject: [PATCH] fixing a crash related to Shared Theme navigation bar color fetching --- build.gradle | 2 +- .../kotlin/com/simplemobiletools/commons/extensions/Context.kt | 2 +- .../kotlin/com/simplemobiletools/commons/extensions/Cursor.kt | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 02ba7a42d..37a86fe0e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { propMinSdkVersion = 21 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 - propVersionName = '5.18.6' + propVersionName = '5.18.7' kotlin_version = '1.3.50' } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt index a4fb51e6d..fbc00f39c 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt @@ -373,7 +373,7 @@ fun Context.getSharedThemeSync(cursorLoader: CursorLoader): SharedTheme? { val backgroundColor = cursor.getIntValue(COL_BACKGROUND_COLOR) val primaryColor = cursor.getIntValue(COL_PRIMARY_COLOR) val appIconColor = cursor.getIntValue(COL_APP_ICON_COLOR) - val navigationBarColor = cursor.getIntValue(COL_NAVIGATION_BAR_COLOR) + val navigationBarColor = cursor.getIntValueOrNull(COL_NAVIGATION_BAR_COLOR) ?: INVALID_NAVIGATION_BAR_COLOR val lastUpdatedTS = cursor.getIntValue(COL_LAST_UPDATED_TS) return SharedTheme(textColor, backgroundColor, primaryColor, appIconColor, navigationBarColor, lastUpdatedTS) } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Cursor.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Cursor.kt index 8af687b9b..01f65c5f0 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Cursor.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Cursor.kt @@ -1,11 +1,14 @@ package com.simplemobiletools.commons.extensions import android.database.Cursor +import androidx.core.database.getIntOrNull fun Cursor.getStringValue(key: String) = getString(getColumnIndex(key)) fun Cursor.getIntValue(key: String) = getInt(getColumnIndex(key)) +fun Cursor.getIntValueOrNull(key: String) = getIntOrNull(getColumnIndex(key)) + fun Cursor.getLongValue(key: String) = getLong(getColumnIndex(key)) fun Cursor.getBlobValue(key: String) = getBlob(getColumnIndex(key))