WebViewAssetLoader

This commit is contained in:
2025-04-09 14:25:05 -04:00
parent 5713b6572e
commit f17a7fcaa2
7 changed files with 88 additions and 10 deletions

26
.idea/appInsightsSettings.xml generated Normal file
View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AppInsightsSettings">
<option name="tabSettings">
<map>
<entry key="Firebase Crashlytics">
<value>
<InsightsFilterSettings>
<option name="connection">
<ConnectionSetting>
<option name="appId" value="PLACEHOLDER" />
<option name="mobileSdkAppId" value="" />
<option name="projectId" value="" />
<option name="projectNumber" value="" />
</ConnectionSetting>
</option>
<option name="signal" value="SIGNAL_UNSPECIFIED" />
<option name="timeIntervalDays" value="THIRTY_DAYS" />
<option name="visibilityType" value="ALL" />
</InsightsFilterSettings>
</value>
</entry>
</map>
</option>
</component>
</project>

View File

@@ -4,10 +4,10 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-04-03T16:08:16.340902800Z"> <DropdownSelection timestamp="2025-04-09T17:43:14.816533500Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="Default" identifier="serial=192.168.11.180:37459;connection=024bbef4" /> <DeviceId pluginId="Default" identifier="serial=192.168.11.180:43825;connection=7831d20c" />
</handle> </handle>
</Target> </Target>
</DropdownSelection> </DropdownSelection>

View File

@@ -46,6 +46,7 @@ dependencies {
implementation(libs.androidx.activity.compose) implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom)) implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui) implementation(libs.androidx.ui)
implementation(libs.androidx.webkit)
implementation(libs.androidx.ui.graphics) implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3) implementation(libs.androidx.material3)

View File

@@ -111,6 +111,28 @@
} }
.calendar-day.today { .calendar-day.today {
background-color: #8d2b68; /* Highlight color */ background-color: #8d2b68; /* Highlight color */
}
#gotify-container {
position: relative;
top: -550px;
left: 1415px;
width: 500px;
height: 300px;
border: 1px solid #ccc;
overflow-y: auto;
padding: 10px;
color: #eee;
font-family: Arial, sans-serif;
border: 1px solid;
}
/* Style each notification block */
.notification {
border-bottom: 1px solid #eee;
padding: 5px 0;
margin-bottom: 5px;
}
.notification:last-child {
border-bottom: none;
} }
</style> </style>

View File

@@ -1,22 +1,26 @@
package com.zefie.zkiosk package com.zefie.zkiosk
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle
import android.graphics.Rect import android.graphics.Rect
import android.net.Uri
import android.os.Bundle
import android.os.PowerManager import android.os.PowerManager
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.floatingactionbutton.FloatingActionButton
import org.videolan.libvlc.util.VLCVideoLayout
import android.os.Build
import android.view.Gravity import android.view.Gravity
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import android.webkit.WebView import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import androidx.webkit.WebViewAssetLoader
import android.widget.PopupWindow import android.widget.PopupWindow
import android.widget.RelativeLayout import android.widget.RelativeLayout
import android.widget.SeekBar import android.widget.SeekBar
import android.widget.TextView import android.widget.TextView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import org.videolan.libvlc.util.VLCVideoLayout
import java.util.Locale import java.util.Locale
@@ -75,8 +79,31 @@ class MainActivity : AppCompatActivity() {
clockWebView.settings.displayZoomControls = false clockWebView.settings.displayZoomControls = false
clockWebView.settings.javaScriptEnabled = true clockWebView.settings.javaScriptEnabled = true
wxWebView.loadUrl("file:///android_asset/radar.html") val assetLoader = WebViewAssetLoader.Builder()
clockWebView.loadUrl("file:///android_asset/clock.html") .addPathHandler("/assets/", WebViewAssetLoader.AssetsPathHandler(this))
.addPathHandler("/res/", WebViewAssetLoader.ResourcesPathHandler(this))
.build()
wxWebView.webViewClient = object : WebViewClient() {
override fun shouldInterceptRequest(
view: WebView,
request: WebResourceRequest
): WebResourceResponse? {
return assetLoader.shouldInterceptRequest(request.url)
}
}
clockWebView.webViewClient = object : WebViewClient() {
override fun shouldInterceptRequest(
view: WebView,
request: WebResourceRequest
): WebResourceResponse? {
return assetLoader.shouldInterceptRequest(request.url)
}
}
wxWebView.loadUrl("https://appassets.androidplatform.net/assets/radar.html")
clockWebView.loadUrl("https://appassets.androidplatform.net/assets/clock.html")
startPlayer(1) startPlayer(1)
startPlayer(2) startPlayer(2)

View File

@@ -38,7 +38,7 @@ class VLCPlayer(private val context: Context, private val videoLayout: VLCVideoL
streamUrl = url streamUrl = url
val media = Media(libVLC, Uri.parse(url)) val media = Media(libVLC, Uri.parse(url))
media.setHWDecoderEnabled(true, false) media.setHWDecoderEnabled(true, false)
media.addOption(":network-caching=250") // Adjust caching to handle jitter media.addOption(":network-caching=500") // Adjust caching to handle jitter
mediaPlayer.media = media mediaPlayer.media = media
media.release() media.release()
mediaPlayer.play() mediaPlayer.play()

View File

@@ -11,10 +11,12 @@ lifecycleRuntimeKtx = "2.8.7"
activityCompose = "1.10.1" activityCompose = "1.10.1"
composeBom = "2025.03.01" composeBom = "2025.03.01"
material = "1.12.0" material = "1.12.0"
webkit = "1.13.0"
[libraries] [libraries]
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-webkit = { module = "androidx.webkit:webkit", version.ref = "webkit" }
junit = { group = "junit", name = "junit", version.ref = "junit" } junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }