google preperation 1
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("kotlin-android")
|
||||
@@ -5,8 +8,15 @@ plugins {
|
||||
id("dev.flutter.flutter-gradle-plugin")
|
||||
}
|
||||
|
||||
// Upload key for Google Play. android/key.properties is gitignored — never commit it.
|
||||
val keystoreProperties = Properties()
|
||||
val keystorePropertiesFile = rootProject.file("key.properties")
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.example.shooter_app"
|
||||
namespace = "si.sdkkovinar.app"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
|
||||
ndkVersion = "27.0.12077973" // ✅ Keep only this line
|
||||
@@ -22,16 +32,32 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.example.shooter_app"
|
||||
minSdk = 26
|
||||
targetSdk = 33
|
||||
applicationId = "si.sdkkovinar.app"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = flutter.versionCode
|
||||
versionName = flutter.versionName
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keyAlias = keystoreProperties["keyAlias"] as String
|
||||
keyPassword = keystoreProperties["keyPassword"] as String
|
||||
storeFile = file(keystoreProperties["storeFile"] as String)
|
||||
storePassword = keystoreProperties["storePassword"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
// Falls back to debug key only when key.properties is missing (local testing).
|
||||
signingConfig = if (keystorePropertiesFile.exists()) {
|
||||
signingConfigs.getByName("release")
|
||||
} else {
|
||||
signingConfigs.getByName("debug")
|
||||
}
|
||||
isMinifyEnabled = false
|
||||
isShrinkResources = false
|
||||
}
|
||||
|
||||
@@ -11,14 +11,13 @@
|
||||
|
||||
|
||||
<application
|
||||
android:label="SDK Muta"
|
||||
android:label="SDK Kovinar"
|
||||
android:name="${applicationName}"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:preserveLegacyExternalStorage="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config">
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:localeConfig="@xml/locales_config">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.example.shooter_app
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity : FlutterActivity()
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.example.test1
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity : FlutterActivity()
|
||||
@@ -0,0 +1,75 @@
|
||||
package si.sdkkovinar.app
|
||||
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.net.NetworkCapabilities
|
||||
import android.net.NetworkRequest
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
|
||||
class MainActivity : FlutterActivity() {
|
||||
private val connectivity by lazy {
|
||||
getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
}
|
||||
private var wifiCallback: ConnectivityManager.NetworkCallback? = null
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "si.sdkkovinar.app/network")
|
||||
.setMethodCallHandler { call, result ->
|
||||
when (call.method) {
|
||||
"bindToWifi" -> result.success(bindToWifi())
|
||||
"unbind" -> {
|
||||
unbind()
|
||||
result.success(null)
|
||||
}
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The range Wi-Fi has no internet, so Android routes traffic over mobile data
|
||||
// and the cameras' local IPs become unreachable. Pin this app's traffic to
|
||||
// Wi-Fi (other apps keep using mobile data). Returns true if bound right away.
|
||||
private fun bindToWifi(): Boolean {
|
||||
if (wifiCallback == null) {
|
||||
val request = NetworkRequest.Builder()
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||
.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||
.build()
|
||||
val callback = object : ConnectivityManager.NetworkCallback() {
|
||||
override fun onAvailable(network: Network) {
|
||||
connectivity.bindProcessToNetwork(network)
|
||||
}
|
||||
|
||||
override fun onLost(network: Network) {
|
||||
if (connectivity.boundNetworkForProcess == network) {
|
||||
connectivity.bindProcessToNetwork(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
connectivity.registerNetworkCallback(request, callback)
|
||||
wifiCallback = callback
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val wifi = connectivity.allNetworks.firstOrNull {
|
||||
connectivity.getNetworkCapabilities(it)
|
||||
?.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) == true
|
||||
} ?: return false
|
||||
return connectivity.bindProcessToNetwork(wifi)
|
||||
}
|
||||
|
||||
private fun unbind() {
|
||||
wifiCallback?.let { connectivity.unregisterNetworkCallback(it) }
|
||||
wifiCallback = null
|
||||
connectivity.bindProcessToNetwork(null)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
unbind()
|
||||
super.onDestroy()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Languages offered in Android 13+ Settings > Apps > SDK Kovinar > Language -->
|
||||
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<locale android:name="sl"/>
|
||||
<locale android:name="en"/>
|
||||
</locale-config>
|
||||
Reference in New Issue
Block a user