Skip to content

Commit

Permalink
Add support to check build variant
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnil-musale committed Apr 14, 2024
1 parent 5c2a3d0 commit b609f29
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions KDeviceInfo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ android {
defaultConfig {
minSdk = 21
}
buildFeatures {
buildConfig = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.os.Build
import android.provider.Settings
import androidx.core.app.LocaleManagerCompat
import androidx.core.content.pm.PackageInfoCompat
import com.devx.kdeviceinfo.BuildConfig
import com.devx.kdeviceinfo.initilizer.applicationContext
import com.devx.kdeviceinfo.model.android.AndroidInfo
import com.devx.kdeviceinfo.model.android.DisplayMetrics
Expand Down Expand Up @@ -111,6 +112,9 @@ internal class AndroidInfoImpl : AndroidInfo {
Settings.Secure.ANDROID_ID
)

override val isDebug: Boolean
get() = BuildConfig.DEBUG

private fun getIsPhysicalDevice(): Boolean {
return !((Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|| Build.FINGERPRINT.startsWith("generic")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ interface AndroidInfo {
val locale: Locale
val deviceOrientation: DeviceOrientation
val androidId: String
val isDebug: Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ interface IosInfo {
val appVersion: String
val appShortVersion: String
val locale: Locale
val isDebug: Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import platform.Foundation.currentLocale
import platform.Foundation.languageCode
import platform.Foundation.regionCode
import platform.UIKit.UIDevice
import kotlin.experimental.ExperimentalNativeApi

internal class IosInfoImpl : IosInfo {

Expand Down Expand Up @@ -51,4 +52,8 @@ internal class IosInfoImpl : IosInfo {
languageCode = NSLocale.currentLocale.languageCode,
region = NSLocale.currentLocale.regionCode.orEmpty()
)

@OptIn(ExperimentalNativeApi::class)
override val isDebug: Boolean
get() = Platform.isDebugBinary
}
5 changes: 5 additions & 0 deletions sampleApp/composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ android {
versionCode = 1
versionName = "1.0.0"
}
buildTypes {
getByName("release") {
signingConfig = signingConfigs.getByName("debug")
}
}
sourceSets["main"].apply {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
res.srcDirs("src/androidMain/resources")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private fun ShowAndroidDeviceInfo(androidInfo: AndroidInfo) {
Text(text = "Version Code : ${androidInfo.versionCode}")
Text(text = "Version Name : ${androidInfo.versionName}")
Text(text = "Package Name : ${androidInfo.packageName}")
Text(text = "Debug App : ${androidInfo.isDebug}")
Spacer(modifier = Modifier.fillMaxWidth().height(height = 20.dp))

// Device Info
Expand Down Expand Up @@ -97,6 +98,7 @@ private fun ShowIosDeviceInfo(iosInfo: IosInfo) {
Text(text = "App Version : ${iosInfo.appVersion}")
Text(text = "App Short Version : ${iosInfo.appShortVersion}")
Text(text = "Bundle Id : ${iosInfo.bundleId}")
Text(text = "Debug App : ${iosInfo.isDebug}")
Spacer(modifier = Modifier.fillMaxWidth().height(height = 20.dp))

// Device Info
Expand Down

0 comments on commit b609f29

Please sign in to comment.