Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Updated to use new ConsoleAppConfig

Michael Rademaker4f57cb0e2edb
diff --git a/console/android/GenericApp/app/build.gradle b/console/android/GenericApp/app/build.gradle
index 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 25
targetSdkVersion 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.kt
index 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.SharedPreferences
import android.os.Bundle
import android.view.View
import android.view.inputmethod.EditorInfo
+import android.webkit.URLUtil
import android.widget.Toast
import androidx.preference.PreferenceManager
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
@@ -18,7 +19,7 @@ class ProjectActivity : Activity() {
private lateinit var binding: ActivityProjectBinding
var sharedPreferences: SharedPreferences? = null
-
+ var host: String? = null
override 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.INVISIBLE
if (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.kt
index 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: ActivitySplashBinding
var sharedPreferences: SharedPreferences? = null
+ var host: String? = null
override 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.gradle
index 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 belong
diff --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.kt
index 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.kt
index 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 = appConfig
processAppConfig()
diff --git a/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxproj b/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxproj
index 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.plist
index 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>