100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Updated to use new ConsoleAppConfig
Michael Rademaker4f57cb0e2edb
diff --git a/console/android/GenericApp/app/build.gradle b/console/android/GenericApp/app/build.gradleindex 3f732a32b..b29c649bf 100644--- a/console/android/GenericApp/app/build.gradle+++ b/console/android/GenericApp/app/build.gradle@@ -10,8 +10,8 @@ android {applicationId "io.openremote.app"minSdkVersion 25targetSdkVersion 31- versionCode 25- versionName "1.0.5"+ versionCode 27+ versionName "1.0.6"testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/ProjectActivity.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/ProjectActivity.ktindex eb7727e1f..4f3224613 100644--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/ProjectActivity.kt+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/ProjectActivity.kt@@ -6,6 +6,7 @@ import android.content.SharedPreferencesimport android.os.Bundleimport android.view.Viewimport android.view.inputmethod.EditorInfo+import android.webkit.URLUtilimport android.widget.Toastimport androidx.preference.PreferenceManagerimport com.fasterxml.jackson.module.kotlin.jacksonObjectMapper@@ -18,7 +19,7 @@ class ProjectActivity : Activity() {private lateinit var binding: ActivityProjectBindingvar sharedPreferences: SharedPreferences? = null-+ var host: String? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)@@ -48,11 +49,13 @@ class ProjectActivity : Activity() {private fun requestAppConfig(project: String, realm: String) {binding.progressBar.visibility = View.VISIBLE- val apiManager = ApiManager("https://${project}.openremote.io/api/${realm}")- apiManager.getAppConfig { statusCode, appConfig, error ->+ host = if (URLUtil.isValidUrl(project)) project else "https://${project}.openremote.io/"+ val url = if (URLUtil.isValidUrl(project)) project.plus("/api/${realm}") else "https://${project}.openremote.io/api/${realm}"+ val apiManager = ApiManager(url)+ apiManager.getAppConfig(realm) { statusCode, appConfig, error ->binding.progressBar.visibility = View.INVISIBLEif (statusCode in 200..299) {- sharedPreferences?.edit()?.putString("project", project)?.apply()+ sharedPreferences?.edit()?.putString("host", host)?.apply()sharedPreferences?.edit()?.putString("realm", realm)?.apply()val intent = Intent(this@ProjectActivity, OrMainActivity::class.java)intent.putExtra(OrMainActivity.APP_CONFIG_KEY, jacksonObjectMapper().writeValueAsString(appConfig))diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/SplashActivity.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/SplashActivity.ktindex ea0afeb5e..d52eeb51f 100644--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/SplashActivity.kt+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/SplashActivity.kt@@ -19,6 +19,7 @@ class SplashActivity : Activity() {private lateinit var binding: ActivitySplashBindingvar sharedPreferences: SharedPreferences? = null+ var host: String? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)@@ -39,12 +40,13 @@ class SplashActivity : Activity() {}private fun startNextActivity() {- val project = sharedPreferences!!.getString("project", null)+ val host = sharedPreferences!!.getString("hostt", null)val realm = sharedPreferences!!.getString("realm", null)- if (!project.isNullOrBlank() && !realm.isNullOrBlank()) {- val apiManager = ApiManager("https://${project}.openremote.io/api/$realm")- apiManager.getAppConfig { statusCode, appConfig, error ->+ if (!host.isNullOrBlank() && !realm.isNullOrBlank()) {+ val url = host.plus("/api/${realm}")+ val apiManager = ApiManager(url)+ apiManager.getAppConfig(realm) { statusCode, appConfig, error ->if (statusCode in 200..299) {val intent = Intent(this@SplashActivity, OrMainActivity::class.java)intent.putExtra(diff --git a/console/android/GenericApp/build.gradle b/console/android/GenericApp/build.gradleindex 92e850c78..12a12f33c 100644--- a/console/android/GenericApp/build.gradle+++ b/console/android/GenericApp/build.gradle@@ -6,7 +6,7 @@ buildscript {jcenter()}dependencies {- classpath 'com.android.tools.build:gradle:7.0.4'+ classpath 'com.android.tools.build:gradle:7.1.1'classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"classpath 'com.google.gms:google-services:4.3.10'// NOTE: Do not place your application dependencies here; they belongdiff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/network/ApiManager.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/network/ApiManager.ktindex 01a98c1b6..a77f31f6e 100644--- a/console/android/ORLib/src/main/java/io/openremote/orlib/network/ApiManager.kt+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/network/ApiManager.kt@@ -19,8 +19,16 @@ class ApiManager(private val baseUrl: String) {PUT,}- fun getAppConfig(callback: ResponseBlock<ORAppConfig>?) {- get(arrayOf("app", "config"), callback)+ fun getAppConfig(realm: String, callback: ResponseBlock<ORAppConfig>?) {+ val uri = Uri.parse(baseUrl)+ val url = URL("${uri.scheme}://${uri.host}/consoleappconfig/${realm}.json")+ with(url.openConnection() as HttpURLConnection) {+ requestMethod = HttpMethod.GET.toString()+ setRequestProperty("Accept", "application/json")+ thread(start = true) {+ parseResponse(this, callback)+ }+ }}/*********************************Private functions*******************************/diff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.ktindex b6ed489e6..70344f555 100644--- a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt@@ -129,7 +129,7 @@ open class OrMainActivity : Activity() {if (!project.isNullOrBlank() && !realm.isNullOrBlank()) {val apiManager = ApiManager("https://${project}.openremote.io/api/$realm")- apiManager.getAppConfig { statusCode, appConfig, error ->+ apiManager.getAppConfig(realm) { statusCode, appConfig, error ->if (statusCode in 200..299) {this.appConfig = appConfigprocessAppConfig()diff --git a/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxproj b/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxprojindex 108376b51..df0bceba2 100644--- a/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxproj+++ b/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxproj@@ -524,7 +524,7 @@ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;CODE_SIGN_ENTITLEMENTS = GenericApp/OpenRemote.entitlements;CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 28;+ CURRENT_PROJECT_VERSION = 29;DEVELOPMENT_ASSET_PATHS = "";DEVELOPMENT_TEAM = 4AC88KZHJZ;ENABLE_PREVIEWS = YES;@@ -550,7 +550,7 @@ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;CODE_SIGN_ENTITLEMENTS = GenericApp/OpenRemote.entitlements;CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 28;+ CURRENT_PROJECT_VERSION = 29;DEVELOPMENT_ASSET_PATHS = "";DEVELOPMENT_TEAM = 4AC88KZHJZ;ENABLE_PREVIEWS = YES;@@ -575,7 +575,7 @@APPLICATION_EXTENSION_API_ONLY = YES;CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements;CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 28;+ CURRENT_PROJECT_VERSION = 29;DEVELOPMENT_TEAM = 4AC88KZHJZ;FRAMEWORK_SEARCH_PATHS = ("$(inherited)",@@ -619,7 +619,7 @@APPLICATION_EXTENSION_API_ONLY = YES;CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements;CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 28;+ CURRENT_PROJECT_VERSION = 29;DEVELOPMENT_TEAM = 4AC88KZHJZ;FRAMEWORK_SEARCH_PATHS = ("$(inherited)",diff --git a/console/iOS/GenericApp/GenericApp/Info.plist b/console/iOS/GenericApp/GenericApp/Info.plistindex 52c085a24..fd47d2164 100644--- a/console/iOS/GenericApp/GenericApp/Info.plist+++ b/console/iOS/GenericApp/GenericApp/Info.plist@@ -4,6 +4,8 @@<dict><key>CFBundleDevelopmentRegion</key><string>$(DEVELOPMENT_LANGUAGE)</string>+ <key>CFBundleDisplayName</key>+ <string></string><key>CFBundleExecutable</key><string>$(EXECUTABLE_NAME)</string><key>CFBundleIdentifier</key>@@ -24,14 +26,16 @@<string></string><key>LSRequiresIPhoneOS</key><true/>+ <key>NSCameraUsageDescription</key>+ <string>The camera is needed in order to send area information</string><key>NSLocationAlwaysAndWhenInUseUsageDescription</key>- <string>Location is needed in order to get updates on surveys</string>+ <string>Location is needed in order to get notifications based on your location</string><key>NSLocationAlwaysUsageDescription</key>- <string>Location is needed in order to get updates on surveys</string>+ <string>Location is needed in order to get notifications based on your location</string><key>NSLocationUsageDescription</key>- <string>Location is needed in order to get updates on surveys</string>+ <string>Location is needed in order to get notifications based on your location</string><key>NSLocationWhenInUseUsageDescription</key>- <string>Location is needed in order to get updates on surveys</string>+ <string>Location is needed in order to get notifications based on your location</string><key>UIApplicationShortcutItems</key><array><dict>