Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to check build variant #40

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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