Skip to content

armgit / core

Public Imported from GitHub
0

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

Fixed remaining issues on Generic Native apps

Michael Rademaker0b89078ef7bc
diff --git a/console/android/GenericApp/app/build.gradle b/console/android/GenericApp/app/build.gradle
index 67debeeef..f115ff420 100644
--- a/console/android/GenericApp/app/build.gradle
+++ b/console/android/GenericApp/app/build.gradle
@@ -11,7 +11,7 @@ android {
applicationId "io.openremote.app"
minSdkVersion 25
targetSdkVersion 29
- versionCode 18
+ versionCode 19
versionName "1.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -39,11 +39,10 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
- implementation 'androidx.preference:preference:1.1.1'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
+ implementation 'androidx.preference:preference-ktx:1.1.1'
implementation "com.google.android.gms:play-services-location:17.1.0"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.8"
-
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.android.material:material:1.2.1'
diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/models/ORAlertAction.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/models/ORAlertAction.kt
index c99967be8..c81b950b6 100644
--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/models/ORAlertAction.kt
+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/models/ORAlertAction.kt
@@ -4,6 +4,6 @@ data class ORAlertAction(
val url: String,
val httpMethod: String = "GET",
val data: Map<String, Any>?,
- val isSilent: Boolean = false,
- val isOpenInBrowser: Boolean = false,
+ val silent: Boolean = false,
+ val openInBrowser: Boolean = false
)
\ No newline at end of file
diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/models/ORAlertButton.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/models/ORAlertButton.kt
index f6e833984..7d55c1f5c 100644
--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/models/ORAlertButton.kt
+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/models/ORAlertButton.kt
@@ -1,6 +1,6 @@
package io.openremote.app.models
data class ORAlertButton(
- val title: String?,
+ val title: String,
val action: ORAlertAction?
)
\ No newline at end of file
diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/network/ApiManager.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/network/ApiManager.kt
index f6831bdb5..468738bc0 100644
--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/network/ApiManager.kt
+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/network/ApiManager.kt
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import io.openremote.app.models.ORAppConfig
import java.net.HttpURLConnection
import java.net.URL
-import java.util.concurrent.Executors
+import kotlin.concurrent.thread
typealias ResponseBlock<T> = (statusCode: Int, model: T?, error: Throwable?) -> Unit
@@ -45,19 +45,19 @@ class ApiManager(private val baseUrl: String) {
)
}
- return URL(builder.build().toString())
- .openConnection()
- .let {
- it as HttpURLConnection
- }.apply {
- requestMethod = method.toString()
- setRequestProperty("Accept", "application/json")
-
- if (method == HttpMethod.POST || method == HttpMethod.PUT) {
- setRequestProperty("Content-Type", "application/json")
- doOutput = true
- }
+ val url = URL(builder.build().toString())
+ with(url.openConnection() as HttpURLConnection) {
+
+ requestMethod = method.toString()
+ setRequestProperty("Accept", "application/json")
+
+ if (method == HttpMethod.POST || method == HttpMethod.PUT) {
+ setRequestProperty("Content-Type", "application/json")
+ doOutput = true
}
+
+ return this
+ }
}
private inline fun <reified T : Any> get(
@@ -65,7 +65,7 @@ class ApiManager(private val baseUrl: String) {
noinline callback: ResponseBlock<T>?,
queryParameters: Map<String, Any>? = null
) {
- Executors.newCachedThreadPool().execute {
+ thread(start = true) {
val urlRequest = createUrlRequest(HttpMethod.GET, pathComponents, queryParameters)
parseResponse<T>(urlRequest, callback)
}
@@ -75,8 +75,7 @@ class ApiManager(private val baseUrl: String) {
private inline fun <reified T : Any> post(
pathComponents: Array<String>, item: Any, noinline callback: ResponseBlock<T>?
) {
- Executors.newCachedThreadPool().execute {
-
+ thread(start = true) {
val urlRequest = createUrlRequest(HttpMethod.POST, pathComponents)
urlRequest.apply {
writeBody(item)
@@ -89,8 +88,7 @@ class ApiManager(private val baseUrl: String) {
private inline fun <reified T : Any> put(
pathComponents: Array<String>, item: Any, noinline callback: ResponseBlock<T>?
) {
- Executors.newCachedThreadPool().execute {
-
+ thread(start = true) {
val urlRequest = createUrlRequest(HttpMethod.PUT, pathComponents)
urlRequest.apply {
writeBody(item)
@@ -104,35 +102,37 @@ class ApiManager(private val baseUrl: String) {
httpConnection: HttpURLConnection,
noinline callback: ResponseBlock<T>?
) {
- val model = if (httpConnection.responseCode == 200) {
- try {
- jacksonObjectMapper().readValue(
- httpConnection.inputStream.bufferedReader().readText(),
- T::class.java
- )
- } catch (e: Exception) {
- Log.e(this::class.simpleName, e.message, e)
+ with(httpConnection) {
+ val model = if (this.responseCode == 200) {
+ try {
+ jacksonObjectMapper().readValue(
+ this.inputStream.bufferedReader().readText(),
+ T::class.java
+ )
+ } catch (e: Exception) {
+ Log.e(this::class.simpleName, e.message, e)
+ null
+ }
+ } else {
null
}
- } else {
- null
- }
- val error = try {
+ val error = try {
- if (httpConnection.responseCode !in 200..299) {
- val errorResponse = httpConnection.errorStream.bufferedReader().readText()
- Throwable(errorResponse)
- } else {
- null
+ if (this.responseCode !in 200..299) {
+ val errorResponse = this.errorStream.bufferedReader().readText()
+ Throwable(errorResponse)
+ } else {
+ null
+ }
+ } catch (e: Exception) {
+ e
}
- } catch (e: Exception) {
- e
- }
- error?.let {
- Log.e(this::class.simpleName, it.message, it)
+ error?.let {
+ Log.e(this::class.simpleName, it.message, it)
+ }
+ callback?.invoke(this.responseCode, model, error)
+ this.disconnect()
}
- callback?.invoke(httpConnection.responseCode, model, error)
- httpConnection.disconnect()
}
private fun HttpURLConnection.writeBody(item: Any) {
diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/service/GeofenceProvider.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/service/GeofenceProvider.kt
index e2b462419..215b408e6 100644
--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/service/GeofenceProvider.kt
+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/service/GeofenceProvider.kt
@@ -11,8 +11,8 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.fasterxml.jackson.databind.ObjectMapper
import com.google.android.gms.location.*
-import io.openremote.app.ui.MainActivity
import io.openremote.app.R
+import io.openremote.app.ui.MainActivity
import java.net.URL
import java.util.*
import java.util.logging.Level
@@ -267,22 +267,20 @@ class GeofenceProvider(val context: Context) : ActivityCompat.OnRequestPermissio
// Remove previous fences that no longer exist
val oldFences = getGeofences(context)
- val remainingFences: ArrayList<GeofenceDefinition> = arrayListOf()
oldFences.forEach { oldFence ->
if (geofences.none { Objects.equals(it.id, oldFence.id) }) {
LOG.info("Geofence now obsolete: $oldFence")
removeGeofence(oldFence.id)
- } else {
- remainingFences.add(oldFence)
- LOG.info("Geofence unchanged: $oldFence")
}
}
geofences.forEach { geofence ->
- if (remainingFences.none { Objects.equals(it.id, geofence.id) }) {
- addGeofence(geofencingClient, getGeofencePendingIntent(context, getBaseUrl(context).orEmpty()), geofence)
- }
+ addGeofence(
+ geofencingClient,
+ getGeofencePendingIntent(context, getBaseUrl(context).orEmpty()),
+ geofence
+ )
}
sharedPreferences.edit()
diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/service/ORFirebaseMessagingService.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/service/ORFirebaseMessagingService.kt
index 4bb2baed8..f52aa196b 100644
--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/service/ORFirebaseMessagingService.kt
+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/service/ORFirebaseMessagingService.kt
@@ -1,6 +1,5 @@
package io.openremote.app.service
-import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
@@ -12,13 +11,12 @@ import android.os.Build
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.google.firebase.messaging.RemoteMessage
-import io.openremote.app.BuildConfig.APPLICATION_ID
-import io.openremote.app.ui.MainActivity
import io.openremote.app.R
import io.openremote.app.models.ORAlertAction
import io.openremote.app.models.ORAlertButton
-import java.util.*
+import io.openremote.app.ui.MainActivity
import java.util.logging.Level
import java.util.logging.Logger
@@ -60,11 +58,11 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
// TODO(developer): Handle FCM messages here.
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
- LOG.fine("Received message from: " + remoteMessage.from)
+ LOG.info("Received message from: " + remoteMessage.from)
// If the message contains a notification then we assume it has been shown to the user
if (remoteMessage.notification != null) {
- LOG.fine(
+ LOG.info(
"Message contains notification body: " + remoteMessage.notification!!.getBody()
)
} else if (remoteMessage.data.isNotEmpty()) {
@@ -105,9 +103,9 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
// Check for action (to be executed when notification is clicked)
if (messageData.containsKey("action")) {
val actionJson = messageData["action"]
- if (actionJson != null && !actionJson.isEmpty()) {
+ if (actionJson != null && actionJson.isNotEmpty()) {
try {
- actionOR = ObjectMapper().readValue(
+ actionOR = jacksonObjectMapper().readValue(
actionJson,
ORAlertAction::class.java
)
@@ -122,7 +120,7 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
val buttonsJson = messageData["buttons"]
if (buttonsJson != null && buttonsJson.isNotEmpty()) {
try {
- buttonORS = ObjectMapper().readValue(
+ buttonORS = jacksonObjectMapper().readValue(
buttonsJson,
Array<ORAlertButton>::class.java
)
@@ -147,7 +145,11 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
getString(R.string.NOTIFICATION_CHANNEL_ID),
channelName, NotificationManager.IMPORTANCE_HIGH
)
+ val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
channel.setShowBadge(false)
+ channel.setSound(defaultSoundUri, null)
+ channel.enableVibration(true)
+ channel.vibrationPattern = longArrayOf(100, 200, 300, 400, 500, 400, 300, 200, 400)
val service = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
service.createNotificationChannel(channel)
}
@@ -159,17 +161,15 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
actionOR: ORAlertAction?,
buttonORS: Array<ORAlertButton>?
) {
- val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
- val notificationBuilder = NotificationCompat.Builder(this, getString(R.string.NOTIFICATION_CHANNEL_ID))
+
+ val notificationBuilder = NotificationCompat.Builder(
+ this,
+ getString(R.string.NOTIFICATION_CHANNEL_ID)
+ )
.setContentTitle(title)
- .setWhen(Date().time)
- .setShowWhen(true)
.setStyle(NotificationCompat.BigTextStyle().bigText(body))
.setContentText(body)
.setSmallIcon(R.drawable.notification_icon)
- .setWhen(0)
- .setPriority(Notification.PRIORITY_MAX)
- .setSound(defaultSoundUri)
.setDeleteIntent(createActionIntent(notificationId, "\"CLOSED\"", null))
if (actionOR != null) {
notificationBuilder.setContentIntent(createActionIntent(notificationId, null, actionOR))
@@ -189,7 +189,7 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
)
}
}
- LOG.fine(
+ LOG.info(
"Showing notification id=$notificationId, title=$title, body=$body, action=$actionOR, buttons=" + (buttonORS?.size
?: 0)
)
@@ -210,8 +210,8 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
if (ORAlertAction?.url != null && ORAlertAction.url.isNotEmpty()) {
actionIntent.putExtra("appUrl", ORAlertAction.url)
actionIntent.putExtra("httpMethod", ORAlertAction.httpMethod)
- actionIntent.putExtra("silent", ORAlertAction.isSilent)
- actionIntent.putExtra("openInBrowser", ORAlertAction.isOpenInBrowser)
+ actionIntent.putExtra("silent", ORAlertAction.silent)
+ actionIntent.putExtra("openInBrowser", ORAlertAction.openInBrowser)
actionIntent.putExtra("data", ObjectMapper().writeValueAsString(ORAlertAction.data))
}
return PendingIntent.getService(this, 0, actionIntent, PendingIntent.FLAG_ONE_SHOT)
diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/MainActivity.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/MainActivity.kt
index 6a78d6214..2e58a29bf 100644
--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/MainActivity.kt
+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/MainActivity.kt
@@ -15,9 +15,7 @@ import android.net.ConnectivityManager
import android.net.Uri
import android.os.*
import android.text.TextUtils
-import android.view.KeyEvent
-import android.view.View
-import android.view.ViewGroup
+import android.view.*
import android.webkit.*
import android.webkit.ConsoleMessage.MessageLevel
import android.webkit.WebView.WebViewTransport
@@ -144,6 +142,14 @@ class MainActivity : Activity() {
private fun processAppConfig() {
if (appConfig != null) {
+ if (!appConfig!!.primaryColor.isNullOrBlank()) {
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
+ window.statusBarColor = Color.parseColor(appConfig!!.primaryColor!!)
+
+ progressBar?.progressTintList =
+ ColorStateList.valueOf(Color.parseColor(appConfig!!.primaryColor!!))
+ }
+
if (appConfig!!.menuEnabled && !appConfig!!.links.isNullOrEmpty()) {
val floatingActionButton = FloatingActionButton(this)
@@ -185,6 +191,12 @@ class MainActivity : Activity() {
floatingActionButton.backgroundTintList =
ColorStateList.valueOf(Color.parseColor(appConfig!!.primaryColor!!))
}
+ if (!appConfig!!.secondaryColor.isNullOrBlank()) {
+ floatingActionButton.imageTintList =
+ ColorStateList.valueOf(Color.parseColor(appConfig!!.secondaryColor!!))
+ } else {
+ floatingActionButton.imageTintList = ColorStateList.valueOf(Color.DKGRAY)
+ }
floatingActionButton.setOnClickListener {
// We are showing only toast message. However, you can do anything you need.
val popupMenu = PopupMenu(this@MainActivity, it)
diff --git a/console/android/GenericApp/app/src/main/res/layout/activity_project.xml b/console/android/GenericApp/app/src/main/res/layout/activity_project.xml
index d54f50c9e..04ab94f8d 100644
--- a/console/android/GenericApp/app/src/main/res/layout/activity_project.xml
+++ b/console/android/GenericApp/app/src/main/res/layout/activity_project.xml
@@ -46,6 +46,11 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
+ android:padding="5dp"
+ app:boxCornerRadiusBottomEnd="8dp"
+ app:boxCornerRadiusTopEnd="8dp"
+ app:boxCornerRadiusBottomStart="8dp"
+ app:boxCornerRadiusTopStart="8dp"
android:background="@color/bright_grey">
<com.google.android.material.textfield.TextInputEditText
@@ -67,6 +72,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/project_input_layout"
+ android:padding="5dp"
android:background="@color/bright_grey">
<com.google.android.material.textfield.TextInputEditText
diff --git a/console/android/GenericApp/app/src/main/res/layout/activity_splash.xml b/console/android/GenericApp/app/src/main/res/layout/activity_splash.xml
index a8fab9698..00c34e57b 100644
--- a/console/android/GenericApp/app/src/main/res/layout/activity_splash.xml
+++ b/console/android/GenericApp/app/src/main/res/layout/activity_splash.xml
@@ -7,23 +7,4 @@
android:background="@color/white"
android:padding="@dimen/box_inset_layout_padding"
tools:context=".ui.SplashActivity"
- tools:deviceIds="wear">
-
-
- <ImageView
- android:id="@+id/imageView"
- android:layout_width="240dp"
- android:layout_height="240dp"
- android:layout_marginStart="24dp"
- android:layout_marginTop="24dp"
- android:layout_marginEnd="24dp"
- android:layout_marginBottom="24dp"
- android:src="@drawable/or_splash"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
-
-
-
-</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
+ tools:deviceIds="wear"/>
\ No newline at end of file
diff --git a/console/android/GenericApp/build.gradle b/console/android/GenericApp/build.gradle
index eb61d111f..9907c9ad8 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:4.0.2"
+ classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'
// NOTE: Do not place your application dependencies here; they belong
diff --git a/console/android/GenericApp/gradle/wrapper/gradle-wrapper.properties b/console/android/GenericApp/gradle/wrapper/gradle-wrapper.properties
index dab9c1ef1..fb9f02261 100644
--- a/console/android/GenericApp/gradle/wrapper/gradle-wrapper.properties
+++ b/console/android/GenericApp/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Oct 27 09:27:21 CET 2020
+#Tue Nov 03 11:24:38 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
diff --git a/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxproj b/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxproj
index e9ca907ea..b19eb3833 100644
--- a/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxproj
+++ b/console/iOS/GenericApp/GenericApp.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ 4C1FF8B6255044210085B2D0 /* Window+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1FF8B5255044210085B2D0 /* Window+Utils.swift */; };
4C81AA642546B251006ED5DD /* ProjectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C81AA632546B251006ED5DD /* ProjectViewController.swift */; };
4C81AADD2546EB28006ED5DD /* ORTextInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C81AADC2546EB28006ED5DD /* ORTextInput.swift */; };
4C81AAE62547124D006ED5DD /* UIColor+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C81AAE52547124D006ED5DD /* UIColor+Utils.swift */; };
@@ -71,6 +72,7 @@
/* Begin PBXFileReference section */
3B0E05618605D241D5A82AA3 /* Pods-NotificationService.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationService.debug.xcconfig"; path = "Target Support Files/Pods-NotificationService/Pods-NotificationService.debug.xcconfig"; sourceTree = "<group>"; };
46FD90D41833A0E2C4C7DDA6 /* Pods-NotificationService.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationService.release.xcconfig"; path = "Target Support Files/Pods-NotificationService/Pods-NotificationService.release.xcconfig"; sourceTree = "<group>"; };
+ 4C1FF8B5255044210085B2D0 /* Window+Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Window+Utils.swift"; sourceTree = "<group>"; };
4C38E9C02548089A00E381C6 /* OpenRemote.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OpenRemote.entitlements; sourceTree = "<group>"; };
4C38E9C12548090200E381C6 /* NotificationService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NotificationService.entitlements; sourceTree = "<group>"; };
4C81AA632546B251006ED5DD /* ProjectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProjectViewController.swift; sourceTree = "<group>"; };
@@ -166,6 +168,7 @@
4CEDA29D254074A500C47E3B /* Constants.swift */,
4C81AAE52547124D006ED5DD /* UIColor+Utils.swift */,
4C81AB2C25472C7F006ED5DD /* String+Utils.swift */,
+ 4C1FF8B5255044210085B2D0 /* Window+Utils.swift */,
);
path = Utils;
sourceTree = "<group>";
@@ -444,6 +447,7 @@
4C81AADD2546EB28006ED5DD /* ORTextInput.swift in Sources */,
4CEDA2A4254074B900C47E3B /* ORViewController.swift in Sources */,
4C81AB2D25472C7F006ED5DD /* String+Utils.swift in Sources */,
+ 4C1FF8B6255044210085B2D0 /* Window+Utils.swift in Sources */,
4CEDA27E25406A4400C47E3B /* ORAppConfig.swift in Sources */,
4CEDA28B2540742900C47E3B /* ORPushNotificationButton.swift in Sources */,
4CEDA28C2540742900C47E3B /* ORPushNotificationAction.swift in Sources */,
@@ -614,11 +618,12 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = GenericApp/OpenRemote.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 21;
+ CURRENT_PROJECT_VERSION = 22;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4AC88KZHJZ;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = GenericApp/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -639,11 +644,12 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = GenericApp/OpenRemote.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 21;
+ CURRENT_PROJECT_VERSION = 22;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 4AC88KZHJZ;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = GenericApp/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -662,9 +668,10 @@
buildSettings = {
CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 21;
+ CURRENT_PROJECT_VERSION = 22;
DEVELOPMENT_TEAM = 4AC88KZHJZ;
INFOPLIST_FILE = NotificationService/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -685,9 +692,10 @@
buildSettings = {
CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 21;
+ CURRENT_PROJECT_VERSION = 22;
DEVELOPMENT_TEAM = 4AC88KZHJZ;
INFOPLIST_FILE = NotificationService/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
diff --git a/console/iOS/GenericApp/GenericApp/AppDelegate.swift b/console/iOS/GenericApp/GenericApp/AppDelegate.swift
index 7a1d9fa6c..ae6ec775b 100644
--- a/console/iOS/GenericApp/GenericApp/AppDelegate.swift
+++ b/console/iOS/GenericApp/GenericApp/AppDelegate.swift
@@ -135,7 +135,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, URLSessionDelegate {
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if let action = userInfo[DefaultsKey.actionKey] as? String {
if action == Actions.geofenceRefresh {
- if let controllerGeofenceProvider = (self.window?.rootViewController as! ORViewcontroller).geofenceProvider {
+ if let controllerGeofenceProvider = (self.window?.topController as? ORViewcontroller)?.geofenceProvider {
+
controllerGeofenceProvider.refreshGeofences()
} else if let delegateGeofenceProvider = geofenceProvider {
delegateGeofenceProvider.refreshGeofences()
@@ -146,7 +147,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, URLSessionDelegate {
} else if action == Actions.store {
if let data = userInfo[DefaultsKey.dataKey] as? [String: String] {
if let key = data["key"] {
- if let storageProvider = (self.window?.rootViewController as! ORViewcontroller).storageProvider {
+ if let storageProvider = (self.window?.topController as? ORViewcontroller)?.storageProvider {
+ storageProvider.store(key: key, data: data["value"])
+ } else {
+ let storageProvider = StorageProvider()
storageProvider.store(key: key, data: data["value"])
}
}
@@ -260,7 +264,7 @@ extension AppDelegate : UNUserNotificationCenterDelegate {
UIApplication.shared.open(url)
} else {
NSLog("%@", " in app: \(url)")
- (self.window?.rootViewController as! ORViewcontroller).loadURL(url:url)
+ (self.window?.topController as? ORViewcontroller)?.loadURL(url:url)
}
}
}
@@ -307,7 +311,7 @@ extension AppDelegate : UNUserNotificationCenterDelegate {
UIApplication.shared.open(url)
} else {
NSLog("%@", " in app: \(url)")
- (self.window?.rootViewController as! ORViewcontroller).loadURL(url:url)
+ (self.window?.topController as? ORViewcontroller)?.loadURL(url:url)
}
}
}
diff --git a/console/iOS/GenericApp/GenericApp/UI/ORViewController.swift b/console/iOS/GenericApp/GenericApp/UI/ORViewController.swift
index c9f6b02e0..1aaf57879 100644
--- a/console/iOS/GenericApp/GenericApp/UI/ORViewController.swift
+++ b/console/iOS/GenericApp/GenericApp/UI/ORViewController.swift
@@ -54,7 +54,7 @@ class ORViewcontroller : UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if let applicationConfig = appConfig {
- myWebView?.load(URLRequest(url: URL(string: applicationConfig.initialUrl.stringByURLEncoding()!)!))
+ loadURL(url: URL(string: applicationConfig.initialUrl.stringByURLEncoding()!)!)
}
}
@@ -119,6 +119,7 @@ class ORViewcontroller : UIViewController {
menuButton?.setImage(#imageLiteral(resourceName: "ic_menu"), for: .normal)
menuButton?.setImage(#imageLiteral(resourceName: "ic_menu"), for: .selected)
menuButton?.setImage(#imageLiteral(resourceName: "ic_menu"), for: .highlighted)
+ menuButton?.isHidden = true
view.addSubview(menuButton!)
view.bringSubviewToFront(menuButton!)
@@ -386,6 +387,12 @@ extension ORViewcontroller: WKNavigationDelegate {
decisionHandler(.cancel)
}
} else {
+ if let config = appConfig, let button = menuButton {
+ if config.url.stringByURLEncoding() == navigationAction.request.url?.absoluteString {
+ button.isHidden = false
+ }
+ }
+
decisionHandler(.allow)
}
}
diff --git a/console/iOS/GenericApp/GenericApp/Utils/Window+Utils.swift b/console/iOS/GenericApp/GenericApp/Utils/Window+Utils.swift
new file mode 100644
index 000000000..8cf6e4df6
--- /dev/null
+++ b/console/iOS/GenericApp/GenericApp/Utils/Window+Utils.swift
@@ -0,0 +1,28 @@
+//
+// Window+Utils.swift
+// GenericApp
+//
+// Created by Michael Rademaker on 02/11/2020.
+// Copyright © 2020 OpenRemote. All rights reserved.
+//
+
+import Foundation
+import UIKit
+
+extension UIWindow {
+
+ var topController : UIViewController? {
+
+ guard let rootViewController = self.rootViewController else {
+ return nil
+ }
+
+ var topController = rootViewController
+
+ while let newTopController = topController.presentedViewController {
+ topController = newTopController
+ }
+
+ return topController
+ }
+}