feat: Implement update checker and dialog for available app updates with localization support

This commit is contained in:
Janez T
2025-10-26 17:47:37 +01:00
parent 0eae963efc
commit 0f9974c1e9
26 changed files with 727 additions and 12 deletions

View File

@@ -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 {

View File

@@ -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()
}
}
}
}

View File

@@ -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())
}
}