mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-12 00:40:28 +00:00
feat: Implement update checker and dialog for available app updates with localization support
This commit is contained in:
@@ -10,6 +10,11 @@ android {
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
ndkVersion = flutter.ndkVersion
|
||||
|
||||
// Enable BuildConfig generation
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
@@ -31,6 +36,11 @@ android {
|
||||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode = flutter.versionCode
|
||||
versionName = flutter.versionName
|
||||
|
||||
// Inject commit hash from environment variable (set by GitHub Actions)
|
||||
// Falls back to "dev" for local development builds
|
||||
val commitHash = System.getenv("COMMIT_HASH") ?: "dev"
|
||||
buildConfigField("String", "COMMIT_HASH", "\"$commitHash\"")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.meshcore.sar.meshcore_sar_app
|
||||
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||
import io.flutter.plugin.common.MethodChannel.Result
|
||||
|
||||
/**
|
||||
* Platform channel for exposing build information to Flutter
|
||||
* Provides access to BuildConfig values that are injected at build time
|
||||
*/
|
||||
class BuildInfoChannel : MethodCallHandler {
|
||||
companion object {
|
||||
const val CHANNEL_NAME = "com.meshcore.sar/build_info"
|
||||
const val METHOD_GET_COMMIT_HASH = "getCommitHash"
|
||||
}
|
||||
|
||||
override fun onMethodCall(call: MethodCall, result: Result) {
|
||||
when (call.method) {
|
||||
METHOD_GET_COMMIT_HASH -> {
|
||||
try {
|
||||
// Get commit hash from BuildConfig
|
||||
// This value is injected by gradle at build time
|
||||
val commitHash = BuildConfig.COMMIT_HASH
|
||||
result.success(commitHash)
|
||||
} catch (e: Exception) {
|
||||
result.error("BUILD_INFO_ERROR", "Failed to get commit hash: ${e.message}", null)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
result.notImplemented()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,17 @@
|
||||
package com.meshcore.sar.meshcore_sar_app
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
|
||||
class MainActivity : FlutterActivity()
|
||||
class MainActivity : FlutterActivity() {
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
|
||||
// Register BuildInfoChannel to expose build information to Flutter
|
||||
MethodChannel(
|
||||
flutterEngine.dartExecutor.binaryMessenger,
|
||||
BuildInfoChannel.CHANNEL_NAME
|
||||
).setMethodCallHandler(BuildInfoChannel())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user