|
@@ -1,5 +1,7 @@
|
|
|
package chef.sundby.com.homecontroldisplay
|
|
|
|
|
|
+import android.content.Intent
|
|
|
+import android.graphics.Color
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
import android.os.Build
|
|
|
import android.os.Bundle
|
|
@@ -11,12 +13,11 @@ import android.view.WindowInsets
|
|
|
import android.widget.Button
|
|
|
import android.widget.TextView
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
+import androidx.core.view.WindowCompat
|
|
|
+import androidx.core.view.WindowInsetsCompat
|
|
|
+import androidx.core.view.WindowInsetsControllerCompat
|
|
|
import chef.sundby.com.homecontroldisplay.databinding.ActivityFullscreenBinding
|
|
|
|
|
|
-/**
|
|
|
- * An example full-screen activity that shows and hides the system UI (i.e.
|
|
|
- * status bar and navigation/system bar) with user interaction.
|
|
|
- */
|
|
|
class FullscreenActivity : AppCompatActivity() {
|
|
|
|
|
|
private lateinit var binding: ActivityFullscreenBinding
|
|
@@ -24,6 +25,8 @@ class FullscreenActivity : AppCompatActivity() {
|
|
|
private lateinit var aButton: Button
|
|
|
private val hideHandler = Handler(Looper.myLooper()!!)
|
|
|
|
|
|
+ private val updateHandler = Handler(Looper.myLooper()!!)
|
|
|
+ private lateinit var runnable : Runnable
|
|
|
|
|
|
private var isFullscreen: Boolean = false
|
|
|
|
|
@@ -45,7 +48,49 @@ class FullscreenActivity : AppCompatActivity() {
|
|
|
aButton = binding.buttonA
|
|
|
aButton.setOnClickListener { Log.i("THOMAS", "Click()"); }
|
|
|
|
|
|
+ supportActionBar?.hide()
|
|
|
hide();
|
|
|
+
|
|
|
+ Intent(this, DataFetchService::class.java).also { intent ->
|
|
|
+ startService(intent)
|
|
|
+ }
|
|
|
+
|
|
|
+ //updateHandler = Handler()
|
|
|
+ runnable = Runnable {
|
|
|
+ //updateDisplay() // some action(s)
|
|
|
+ }
|
|
|
+ updateHandler.postDelayed(runnable, 5000)
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private suspend fun getTemperature() {
|
|
|
+ Log.i("THOMAS","getTemperature()")
|
|
|
+ val url = "http://chef.sundby.com/info/curr_temp.php"
|
|
|
+
|
|
|
+ val queue = Volley.newRequestQueue(this)
|
|
|
+ val stringRequest = StringRequest(
|
|
|
+ Request.Method.GET,
|
|
|
+ url,
|
|
|
+ Response.Listener<String> { response ->
|
|
|
+ Log.i("SERVICE", "Response is: $response")
|
|
|
+ for (widgetId in allWidgetIds) {
|
|
|
+ remoteViews.setTextViewText(R.id.appwidget_text,"$response")
|
|
|
+ remoteViews.setTextColor(R.id.appwidget_text, Color.BLACK)
|
|
|
+ remoteViews.setViewVisibility(R.id.progressBar, View.INVISIBLE)
|
|
|
+ appWidgetManager.updateAppWidget(widgetId, remoteViews)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ Response.ErrorListener {
|
|
|
+ Log.i("SERVICE", "That didn't work!" )
|
|
|
+ for (widgetId in allWidgetIds) {
|
|
|
+ remoteViews.setTextViewText(R.id.appwidget_text,"Error")
|
|
|
+ appWidgetManager.updateAppWidget(widgetId, remoteViews)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ //updateHandler.postDelayed(runnable, 5000)
|
|
|
}
|
|
|
|
|
|
private fun toggle() {
|
|
@@ -61,38 +106,23 @@ class FullscreenActivity : AppCompatActivity() {
|
|
|
isFullscreen = false
|
|
|
|
|
|
// Schedule a runnable to remove the (Android System) status and navigation bar after a delay
|
|
|
- Log.i("THOMAS", "hide() B");
|
|
|
+ Log.i("THOMAS", "hide() SDK_INT: ${Build.VERSION.SDK_INT}");
|
|
|
|
|
|
hideHandler.postDelayed(Runnable {
|
|
|
// Delayed removal of status and navigation bar
|
|
|
Log.i("THOMAS", "Delayed removal of nav bar");
|
|
|
- if (Build.VERSION.SDK_INT >= 30) {
|
|
|
- fullscreenContent.windowInsetsController?.hide(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars())
|
|
|
- } else {
|
|
|
- // Note that some of these constants are new as of API 16 (Jelly Bean)
|
|
|
- // and API 19 (KitKat). It is safe to use them, as they are inlined
|
|
|
- // at compile-time and do nothing on earlier devices.
|
|
|
- fullscreenContent.systemUiVisibility =
|
|
|
- View.SYSTEM_UI_FLAG_LOW_PROFILE or
|
|
|
- View.SYSTEM_UI_FLAG_FULLSCREEN or
|
|
|
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
|
|
- View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
|
|
|
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
|
|
- View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
|
+ WindowCompat.setDecorFitsSystemWindows(window, false)
|
|
|
+ WindowInsetsControllerCompat(window, fullscreenContent).let { controller ->
|
|
|
+ controller.hide(WindowInsetsCompat.Type.systemBars())
|
|
|
+ controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
|
|
}
|
|
|
}, UI_ANIMATION_DELAY.toLong())
|
|
|
}
|
|
|
|
|
|
private fun show() {
|
|
|
Log.i("THOMAS", "show()");
|
|
|
- // Show the system bar
|
|
|
- if (Build.VERSION.SDK_INT >= 30) {
|
|
|
- fullscreenContent.windowInsetsController?.show(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars())
|
|
|
- } else {
|
|
|
- fullscreenContent.systemUiVisibility =
|
|
|
- View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
|
|
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
|
- }
|
|
|
+ WindowCompat.setDecorFitsSystemWindows(window, true)
|
|
|
+ WindowInsetsControllerCompat(window, fullscreenContent).show(WindowInsetsCompat.Type.systemBars())
|
|
|
isFullscreen = true
|
|
|
}
|
|
|
|