diff options
Diffstat (limited to 'core/src/main/kotlin')
3 files changed, 12 insertions, 7 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt b/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt index c94b06d..dbdcf09 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt @@ -69,9 +69,14 @@ class EmailBuilder(val email: String, val subject: String) { if (appInfo) { try { val appInfo = context.packageManager.getPackageInfo(context.packageName, 0) + val versionCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + appInfo.longVersionCode.toString() + } else { + appInfo.versionCode.toString() + } emailBuilder.append("\nApp: ").append(context.packageName) .append("\nApp Version Name: ").append(appInfo.versionName) - .append("\nApp Version Code: ").append(appInfo.longVersionCode).append("\n") + .append("\nApp Version Code: ").append(versionCode).append("\n") } catch (e: PackageManager.NameNotFoundException) { KL.e { "EmailBuilder packageInfo not found" } } diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt index 2630884..b80479e 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt @@ -21,8 +21,8 @@ fun KPref.kpref(key: String, fallback: Int, postSetter: (value: Int) -> Unit = { fun KPref.kpref(key: String, fallback: Long, postSetter: (value: Long) -> Unit = {}) = KPrefDelegate(key, fallback, this, KPrefLongTransaction, postSetter) -fun KPref.kpref(key: String, fallback: Set<String>?, postSetter: (value: Set<String>) -> Unit = {}) = - KPrefDelegate(key, fallback, this, KPrefSetTransaction) { postSetter(it ?: emptySet()) } +fun KPref.kpref(key: String, fallback: Set<String>, postSetter: (value: Set<String>) -> Unit = {}) = + KPrefDelegate(key, fallback, this, KPrefSetTransaction, postSetter) fun KPref.kpref(key: String, fallback: String, postSetter: (value: String) -> Unit = {}) = KPrefDelegate(key, fallback, this, KPrefStringTransaction, postSetter) diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefTransaction.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefTransaction.kt index d02cf06..773d208 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefTransaction.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefTransaction.kt @@ -52,11 +52,11 @@ internal object KPrefStringTransaction : KPrefTransaction<String> { } } -internal object KPrefSetTransaction : KPrefTransaction<Set<String>?> { - override fun get(prefs: SharedPreferences, key: String, fallback: Set<String>?) = - prefs.getStringSet(key, fallback) +internal object KPrefSetTransaction : KPrefTransaction<Set<String>> { + override fun get(prefs: SharedPreferences, key: String, fallback: Set<String>) = + prefs.getStringSet(key, fallback)!! - override fun set(editor: SharedPreferences.Editor, key: String, data: Set<String>?) { + override fun set(editor: SharedPreferences.Editor, key: String, data: Set<String>) { editor.putStringSet(key, data) } } |