mirror of
https://github.com/jellyfin/jellyfin-android.git
synced 2025-12-23 23:37:53 -05:00
Setup web app, improve styling
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.jellyfin.android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".WebappActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
41
app/src/main/java/org/jellyfin/android/WebappActivity.kt
Normal file
41
app/src/main/java/org/jellyfin/android/WebappActivity.kt
Normal file
@@ -0,0 +1,41 @@
|
||||
package org.jellyfin.android
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.webkit.WebChromeClient
|
||||
import android.webkit.WebView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.jellyfin.android.utils.lazyView
|
||||
|
||||
class WebappActivity : AppCompatActivity() {
|
||||
|
||||
private val webView: WebView by lazyView<WebView>(R.id.web_view)
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_webapp)
|
||||
|
||||
webView.webChromeClient = WebChromeClient()
|
||||
webView.settings.apply {
|
||||
javaScriptEnabled = true
|
||||
domStorageEnabled = true
|
||||
allowUniversalAccessFromFileURLs = true
|
||||
}
|
||||
|
||||
webView.loadUrl("file:///android_asset/www/index.html")
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
val history = webView.copyBackForwardList()
|
||||
if (webView.canGoBack() && history.currentIndex > 1) {
|
||||
webView.goBack()
|
||||
} else super.onBackPressed()
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
if (BuildConfig.DEBUG) WebView.setWebContentsDebuggingEnabled(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
10
app/src/main/java/org/jellyfin/android/utils/ViewUtils.kt
Normal file
10
app/src/main/java/org/jellyfin/android/utils/ViewUtils.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
package org.jellyfin.android.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.webkit.WebView
|
||||
import androidx.annotation.IdRes
|
||||
|
||||
inline fun <T> Activity.lazyView(@IdRes id: Int) =
|
||||
lazy(LazyThreadSafetyMode.NONE) { findViewById<WebView>(id) }
|
||||
5
app/src/main/res/layout/activity_webapp.xml
Normal file
5
app/src/main/res/layout/activity_webapp.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/web_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#6200EE</color>
|
||||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
<color name="colorAccent">#03DAC5</color>
|
||||
<color name="colorPrimary">#202020</color>
|
||||
<color name="colorPrimaryDark">#1a1a1a</color>
|
||||
<color name="colorAccent">#00a4dc</color>
|
||||
</resources>
|
||||
@@ -1,10 +1,8 @@
|
||||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<!-- Application theme -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user