diff --git a/WallPanelApp/build.gradle b/WallPanelApp/build.gradle index 39b21f1..6b699d1 100644 --- a/WallPanelApp/build.gradle +++ b/WallPanelApp/build.gradle @@ -29,7 +29,7 @@ repositories { def versionMajor = 0 def versionMinor = 8 def versionPatch = 4 -def versionBuild = 3 // bump for dog food builds, public betas, etc. +def versionBuild = 4 // bump for dog food builds, public betas, etc. android { kapt { diff --git a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/WallPanel.kt b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/WallPanel.kt index 38fda85..86c7678 100644 --- a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/WallPanel.kt +++ b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/WallPanel.kt @@ -37,6 +37,9 @@ class WallPanel : DaggerApplication() { super.onCreate() if (BuildConfig.DEBUG) { Timber.plant(Timber.DebugTree()) + Fabric.with(this, Crashlytics()) + Fabric.with(this, Answers()) + Timber.plant(CrashlyticsTree()) } else { Fabric.with(this, Crashlytics()) Fabric.with(this, Answers()) diff --git a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/network/WallPanelService.kt b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/network/WallPanelService.kt index 3b0e97a..fd69a8d 100644 --- a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/network/WallPanelService.kt +++ b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/network/WallPanelService.kt @@ -60,6 +60,7 @@ import com.thanksmister.iot.wallpanel.utils.NotificationUtils import dagger.android.AndroidInjection import org.json.JSONException import org.json.JSONObject +import timber.log.BuildConfig import timber.log.Timber import java.io.IOException import java.nio.ByteBuffer @@ -102,6 +103,7 @@ class WallPanelService : LifecycleService(), MQTTModule.MQTTListener { private var appLaunchUrl: String? = null private var localBroadCastManager: LocalBroadcastManager? = null private var mqttAlertMessageShown = false + private var mqttConnected = false inner class WallPanelServiceBinder : Binder() { val service: WallPanelService @@ -311,21 +313,23 @@ class WallPanelService : LifecycleService(), MQTTModule.MQTTListener { } } + //Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1 override fun onMQTTConnect() { Timber.w("onMQTTConnect") - if(mqttAlertMessageShown) { + if(!mqttConnected) { clearAlertMessage() // clear any dialogs - mqttAlertMessageShown = false + mqttConnected = true } publishMessage(COMMAND_STATE, state.toString()) clearFaceDetected() clearMotionDetected() } + //Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1 override fun onMQTTDisconnect() { Timber.e("onMQTTDisconnect") if(hasNetwork()) { - if(!mqttAlertMessageShown) { + if(!mqttAlertMessageShown && !mqttConnected) { mqttAlertMessageShown = true sendAlertMessage(getString(R.string.error_mqtt_connection)) } @@ -333,10 +337,11 @@ class WallPanelService : LifecycleService(), MQTTModule.MQTTListener { } } + //Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1 override fun onMQTTException(message: String) { Timber.e("onMQTTException: $message") if(hasNetwork()) { - if(!mqttAlertMessageShown) { + if(!mqttAlertMessageShown && !mqttConnected) { mqttAlertMessageShown = true sendAlertMessage(getString(R.string.error_mqtt_exception)) } diff --git a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivity.kt b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivity.kt index 61f072b..3bedde1 100644 --- a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivity.kt +++ b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivity.kt @@ -21,17 +21,14 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.content.pm.PackageManager import android.os.Build import android.os.Bundle -import android.support.v4.app.ActivityCompat import android.support.v4.content.LocalBroadcastManager import android.view.KeyEvent import android.view.View import android.view.ViewTreeObserver import android.view.WindowManager import android.widget.Toast -import com.thanksmister.iot.wallpanel.R import com.thanksmister.iot.wallpanel.network.WallPanelService import com.thanksmister.iot.wallpanel.network.WallPanelService.Companion.BROADCAST_ALERT_MESSAGE import com.thanksmister.iot.wallpanel.network.WallPanelService.Companion.BROADCAST_CLEAR_ALERT_MESSAGE @@ -70,13 +67,13 @@ abstract class BrowserActivity : DaggerAppCompatActivity() { } else if (BROADCAST_ACTION_RELOAD_PAGE == intent.action) { Timber.d("Browser page reloading.") reload() - } else if (BROADCAST_TOAST_MESSAGE == intent.action) { + } else if (BROADCAST_TOAST_MESSAGE == intent.action && !isFinishing) { val message = intent.getStringExtra(BROADCAST_TOAST_MESSAGE) Toast.makeText(applicationContext, message, Toast.LENGTH_SHORT).show() - } else if (BROADCAST_ALERT_MESSAGE == intent.action) { + } else if (BROADCAST_ALERT_MESSAGE == intent.action && !isFinishing) { val message = intent.getStringExtra(BROADCAST_ALERT_MESSAGE) dialogUtils.showAlertDialog(this@BrowserActivity, message) - } else if (BROADCAST_CLEAR_ALERT_MESSAGE == intent.action) { + } else if (BROADCAST_CLEAR_ALERT_MESSAGE == intent.action && !isFinishing) { dialogUtils.clearDialogs() } } @@ -96,7 +93,7 @@ abstract class BrowserActivity : DaggerAppCompatActivity() { decorView = window.decorView - if(configuration.cameraEnabled || configuration.hasCameraDetections()) { + if(configuration.cameraEnabled || configuration.hasCameraDetections() && Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { window.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) } @@ -105,6 +102,8 @@ abstract class BrowserActivity : DaggerAppCompatActivity() { } else { window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } + + lifecycle.addObserver(dialogUtils) } override fun onResume() { diff --git a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivityLegacy.kt b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivityLegacy.kt index b9c273c..aff88cf 100644 --- a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivityLegacy.kt +++ b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivityLegacy.kt @@ -17,33 +17,20 @@ package com.thanksmister.iot.wallpanel.ui.activities import android.annotation.SuppressLint -import android.content.Intent -import android.os.Build import android.os.Bundle import android.support.design.widget.Snackbar -import android.support.v7.preference.PreferenceManager +import android.support.v7.app.AlertDialog import android.text.TextUtils -import android.view.KeyEvent import android.view.MotionEvent import android.view.View -import android.webkit.WebSettings +import android.view.ViewTreeObserver +import android.widget.Toast import com.thanksmister.iot.wallpanel.R -import com.thanksmister.iot.wallpanel.persistence.Configuration - +import kotlinx.android.synthetic.main.activity_browser.* +import org.xwalk.core.XWalkCookieManager import org.xwalk.core.XWalkResourceClient import org.xwalk.core.XWalkView -import org.xwalk.core.XWalkCookieManager - import timber.log.Timber -import javax.inject.Inject -import android.content.DialogInterface -import android.net.http.SslError -import android.support.v7.app.AlertDialog -import android.view.ViewTreeObserver -import android.webkit.SslErrorHandler -import android.webkit.WebView -import android.widget.Toast -import kotlinx.android.synthetic.main.activity_browser.* class BrowserActivityLegacy : BrowserActivity() { @@ -55,6 +42,8 @@ class BrowserActivityLegacy : BrowserActivity() { super.onCreate(savedInstanceState) + Timber.i("BrowserActivityLegacy") + try { setContentView(R.layout.activity_browser) } catch (e: Exception) { diff --git a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivityNative.kt b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivityNative.kt index 0100534..aae2be7 100644 --- a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivityNative.kt +++ b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/BrowserActivityNative.kt @@ -21,18 +21,16 @@ import android.net.http.SslError import android.os.Build import android.os.Bundle import android.support.design.widget.Snackbar +import android.support.v7.app.AlertDialog import android.text.TextUtils import android.view.MotionEvent import android.view.View +import android.view.ViewTreeObserver import android.webkit.* +import android.widget.Toast import com.thanksmister.iot.wallpanel.R import kotlinx.android.synthetic.main.activity_browser.* import timber.log.Timber -import android.webkit.WebView -import android.widget.Toast -import android.content.DialogInterface -import android.support.v7.app.AlertDialog -import android.view.ViewTreeObserver class BrowserActivityNative : BrowserActivity() { @@ -42,7 +40,7 @@ class BrowserActivityNative : BrowserActivity() { @SuppressLint("SetJavaScriptEnabled", "ClickableViewAccessibility") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - + Timber.i("BrowserActivityNative") try { setContentView(R.layout.activity_browser) } catch (e: Exception) { diff --git a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/SettingsActivity.kt b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/SettingsActivity.kt index 48b5c49..9ef3729 100644 --- a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/SettingsActivity.kt +++ b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/SettingsActivity.kt @@ -160,25 +160,26 @@ class SettingsActivity : DaggerAppCompatActivity(), SettingsFragment.OnSettingsF override fun onBrowserButton() { val browserType = configuration.androidBrowserType + Timber.i("onBrowserButton browserType $browserType") val targetClass: Class<*> when (browserType) { Configuration.PREF_BROWSER_NATIVE -> { - Timber.d("Explicitly using native browser") + Timber.i("Explicitly using native browser") targetClass = BrowserActivityNative::class.java } Configuration.PREF_BROWSER_LEGACY -> { - Timber.d("Explicitly using legacy browser") + Timber.i("Explicitly using legacy browser") targetClass = BrowserActivityLegacy::class.java } Configuration.PREF_BROWSER_AUTO -> { - Timber.d("Auto-selecting dashboard browser") + Timber.i("Auto-selecting dashboard browser") targetClass = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) BrowserActivityNative::class.java else BrowserActivityLegacy::class.java } else -> { - Timber.d("Auto-selecting dashboard browser") + Timber.i("Auto-selecting dashboard browser") targetClass = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) BrowserActivityNative::class.java else diff --git a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/WelcomeActivity.kt b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/WelcomeActivity.kt index 1115285..f7ceeea 100644 --- a/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/WelcomeActivity.kt +++ b/WallPanelApp/src/main/java/com/thanksmister/iot/wallpanel/ui/activities/WelcomeActivity.kt @@ -56,19 +56,19 @@ class WelcomeActivity : DaggerAppCompatActivity() { } private fun startBrowserActivity() { - Timber.i("startBrowserActivity Called") val browserType = configuration.androidBrowserType + Timber.i("startBrowserActivity browserType $browserType") val targetClass: Class<*> when (browserType) { - "Native" -> { + Configuration.PREF_BROWSER_NATIVE -> { Timber.i( "Explicitly using native browser") targetClass = BrowserActivityNative::class.java } - "Legacy" -> { + Configuration.PREF_BROWSER_LEGACY -> { Timber.i("Explicitly using legacy browser") targetClass = BrowserActivityLegacy::class.java } - "Auto" -> { + Configuration.PREF_BROWSER_AUTO -> { Timber.i("Auto-selecting dashboard browser") targetClass = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) BrowserActivityNative::class.java diff --git a/WallPanelApp/src/main/res/values-v14/bools.xml b/WallPanelApp/src/main/res/values-v14/bools.xml new file mode 100644 index 0000000..4d0af39 --- /dev/null +++ b/WallPanelApp/src/main/res/values-v14/bools.xml @@ -0,0 +1,21 @@ + + + + + true + + diff --git a/WallPanelApp/src/main/res/values/bools.xml b/WallPanelApp/src/main/res/values/bools.xml new file mode 100644 index 0000000..f5b4f9d --- /dev/null +++ b/WallPanelApp/src/main/res/values/bools.xml @@ -0,0 +1,21 @@ + + + + + false + +