diff --git a/android/src/main/kotlin/com/ionic/plugin/android/core/utils/BundleUtils.kt b/android/src/main/kotlin/com/ionic/plugin/android/core/utils/BundleUtils.kt new file mode 100644 index 0000000..11757e5 --- /dev/null +++ b/android/src/main/kotlin/com/ionic/plugin/android/core/utils/BundleUtils.kt @@ -0,0 +1,30 @@ +package com.ionic.plugin.android.core.utils + +import android.os.Bundle + +fun Bundle.optStringSafely(key: String): String? { + if (!containsKey(key)) return null + return getString(key) +} + +fun Bundle.getStringSafely(key: String): String { + return optStringSafely(key) ?: throw IllegalArgumentException("String with '$key' not found in the bundle") +} + +fun Bundle.optIntSafely(key: String): Int? { + if (!containsKey(key)) return null + return getInt(key) +} + +fun Bundle.getIntSafely(key: String): Int { + return optIntSafely(key) ?: throw IllegalArgumentException("Int with '$key' not found in the bundle") +} + +fun Bundle.optBooleanSafely(key: String): Boolean? { + if (!containsKey(key)) return null + return getBoolean(key) +} + +fun Bundle.getBooleanSafely(key: String): Boolean { + return optBooleanSafely(key) ?: throw IllegalArgumentException("Boolean with '$key' not found in the bundle") +} diff --git a/build.gradle.kts b/build.gradle.kts index 994fb23..88b5c9a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ buildscript { classpath(kotlin("gradle-plugin", version = kotlinVersion)) classpath(kotlin("serialization", version = kotlinVersion)) - classpath("com.android.tools.build:gradle:7.2.2") + classpath("com.android.tools.build:gradle:7.4.2") } } @@ -21,9 +21,9 @@ allprojects { extra.apply { set("kotlinxCoroutinesCoreVersion", "1.7.3") - set("kotlinxSerializationJsonVersion", "1.6.1") - set("kotlinxAtomicfuVersion", "0.23.1") + set("kotlinxSerializationJsonVersion", "1.6.2") + set("kotlinxAtomicfuVersion", "0.23.2") set("androidxAppcompatVersion", "1.6.1") set("mavenGroup", "com.github.SpryRocks.ionic-plugin-core") - set("mavenVersion", "0.1.13-alpha.0") + set("mavenVersion", "0.1.14-alpha.3") }