Skip to content

Commit

Permalink
First Version
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaiserdragon2 committed Dec 20, 2024
1 parent 902328e commit fa805fc
Show file tree
Hide file tree
Showing 57 changed files with 941 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties

# Gradle files
.gradle/
build/
Expand Down Expand Up @@ -30,4 +46,4 @@ render.experimental.xml
google-services.json

# Android Profiling
*.hprof
*.hprof
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
63 changes: 63 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
}

android {
namespace = "de.kaiserdragon.frigatewrapper"
compileSdk = 35

defaultConfig {
applicationId = "de.kaiserdragon.frigatewrapper"
minSdk = 24
targetSdk = 35
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
dependenciesInfo {
// Disables dependency metadata when building APKs.
includeInApk = false
// Disables dependency metadata when building Android App Bundles.
includeInBundle = false
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
debug {
}
androidComponents {
onVariants { variant ->
variant.outputs.forEach { output ->
if (output is com.android.build.api.variant.impl.VariantOutputImpl) {
output.outputFileName = "FrigateWrapper_${defaultConfig.versionName}.apk"
}
}
}
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Binary file not shown.
Binary file not shown.
37 changes: 37 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "de.kaiserdragon.frigatewrapper",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "FrigateWrapper_1.0.apk"
}
],
"elementType": "File",
"baselineProfiles": [
{
"minApi": 28,
"maxApi": 30,
"baselineProfiles": [
"baselineProfiles/1/FrigateWrapper_1.0.dm"
]
},
{
"minApi": 31,
"maxApi": 2147483647,
"baselineProfiles": [
"baselineProfiles/0/FrigateWrapper_1.0.dm"
]
}
],
"minSdkVersionForDexing": 24
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.kaiserdragon.frigatewrapper

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("de.kaiserdragon.frigatewrapper", appContext.packageName)
}
}
33 changes: 33 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.FrigateWrapper"
android:usesCleartextTraffic="true"
tools:targetApi="31" >
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SetupActivity"
android:exported="true">
</activity>

</application>

</manifest>
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
150 changes: 150 additions & 0 deletions app/src/main/java/de/kaiserdragon/frigatewrapper/Wrapper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
@file:Suppress("OVERRIDE_DEPRECATION")

package de.kaiserdragon.frigatewrapper

import android.annotation.SuppressLint
import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.webkit.WebView
import android.view.Window
import android.webkit.WebViewClient
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {

private lateinit var browserView: WebView
private lateinit var sharedPreferences: SharedPreferences

@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Remove the title bar
requestWindowFeature(Window.FEATURE_NO_TITLE)

// Initialize SharedPreferences
sharedPreferences = getSharedPreferences("FrigateApp", MODE_PRIVATE)

// Check if the URL is already set in SharedPreferences
val url = sharedPreferences.getString("url", null)

if (url == null) {
// If URL is not set, start SetupActivity to get the URL
val setupIntent = Intent(this, SetupActivity::class.java)
startActivity(setupIntent)
finish() // Close MainActivity, since we are redirecting to SetupActivity
} else {
// If the URL is set, load it in the WebView
setContentView(R.layout.activity_wrapper)
browserView = findViewById(R.id.webkit)

// Enable JavaScript
browserView.settings.javaScriptEnabled = true
browserView.isVerticalScrollBarEnabled = false
browserView.isHorizontalScrollBarEnabled = false

// Load the URL into the WebView
browserView.loadUrl(url)
}
}

// Handle back button press to navigate within WebView history
override fun onBackPressed() {
if (browserView.canGoBack()) {
// If the WebView has a history, navigate back
browserView.goBack()
} else {
// Otherwise, perform the default back press behavior (exit the activity)
super.onBackPressed()
}
}
// Inflate the options menu to show action bar buttons
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
return true
}

// Handle the action bar button clicks
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.action_reload -> {
// Reload the WebView
browserView.reload()
true
}
R.id.action_settings -> {
// Open SetupActivity to change the URL
val setupIntent = Intent(this, SetupActivity::class.java)
startActivity(setupIntent)
true
}
else -> super.onOptionsItemSelected(item)
}
}
}

class SetupActivity : AppCompatActivity() {

private lateinit var urlInput: EditText
private lateinit var submitButton: Button
private lateinit var sharedPreferences: SharedPreferences
private lateinit var tempWebView: WebView

@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_setup)

// Initialize SharedPreferences
sharedPreferences = getSharedPreferences("FrigateApp", MODE_PRIVATE)

urlInput = findViewById(R.id.url_input)
submitButton = findViewById(R.id.submit_url_button)
urlInput.setText(sharedPreferences.getString("url", ""))
// Initialize the temporary WebView for title validation
tempWebView = WebView(this)
tempWebView.settings.javaScriptEnabled = true

submitButton.setOnClickListener {
val url = urlInput.text.toString().trim()
if (url.isNotEmpty()) {
// Load the URL in the temporary WebView to check the title
tempWebView.loadUrl(url)
tempWebView.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
// After the page loads, check the title
val pageTitle = tempWebView.title
if (pageTitle == "Frigate") {
// Title is valid, save the URL to SharedPreferences
val editor = sharedPreferences.edit()
editor.putString("url", url)
editor.apply()

// Start MainActivity and pass the URL to it
val intent = Intent(this@SetupActivity, MainActivity::class.java)
intent.putExtra("url", url)
startActivity(intent)

// Close the SetupActivity
finish()
} else {
// Show error message if the title is not "Frigate"
Toast.makeText(this@SetupActivity,R.string.invalid_url_message, Toast.LENGTH_LONG).show()
}
}
}
} else {
// Handle empty URL input
Toast.makeText(this, R.string.setup_url_error_message, Toast.LENGTH_SHORT).show()
}
}
}
}
14 changes: 14 additions & 0 deletions app/src/main/res/drawable-night/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="512"
android:viewportHeight="512">
<group android:scaleX="0.45"
android:scaleY="0.45"
android:translateX="140.8"
android:translateY="140.8">
<path
android:pathData="M130,446.5C131.6,459.3 145,468 137,470C129,472 94,406.5 86,378.5C78,350.5 73.5,319 75.5,301C77.5,283 181,255 181,247.5C181,240 147.5,247 146,241C144.5,235 171.3,238.6 178.5,229C189.75,214 204,216.5 213,208.5C222,200.5 233,170 235,157C237,144 215,129 209,119C203,109 222,102 268,83C314,64 460,22 462,27C464,32 414,53 379,66C344,79 287,104 287,111C287,118 290,123.5 288,139.5C286,155.5 285.76,162.97 282,173.5C279.5,180.5 277,197 282,212C286,224 299,233 305,235C310,235.33 323.8,235.8 339,235C358,234 385,236 385,241C385,246 344,243 344,250C344,257 386,249 385,256C384,263 350,260 332,260C317.6,260 296.33,259.33 287,256L285,263C281.67,263 274.7,265 267.5,265C258.5,265 258,268 241.5,268C225,268 230,267 215,266C200,265 144,308 134,322C124,336 130,370 130,385.5C130,399.43 128,430.5 130,446.5Z"
android:fillColor="#ffffff"/>
</group>
</vector>
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="512"
android:viewportHeight="512">
<group android:scaleX="0.45"
android:scaleY="0.45"
android:translateX="140.8"
android:translateY="140.8">
<path
android:pathData="M130,446.5C131.6,459.3 145,468 137,470C129,472 94,406.5 86,378.5C78,350.5 73.5,319 75.5,301C77.5,283 181,255 181,247.5C181,240 147.5,247 146,241C144.5,235 171.3,238.6 178.5,229C189.75,214 204,216.5 213,208.5C222,200.5 233,170 235,157C237,144 215,129 209,119C203,109 222,102 268,83C314,64 460,22 462,27C464,32 414,53 379,66C344,79 287,104 287,111C287,118 290,123.5 288,139.5C286,155.5 285.76,162.97 282,173.5C279.5,180.5 277,197 282,212C286,224 299,233 305,235C310,235.33 323.8,235.8 339,235C358,234 385,236 385,241C385,246 344,243 344,250C344,257 386,249 385,256C384,263 350,260 332,260C317.6,260 296.33,259.33 287,256L285,263C281.67,263 274.7,265 267.5,265C258.5,265 258,268 241.5,268C225,268 230,267 215,266C200,265 144,308 134,322C124,336 130,370 130,385.5C130,399.43 128,430.5 130,446.5Z"
android:fillColor="#000000"/>
</group>
</vector>
Loading

0 comments on commit fa805fc

Please sign in to comment.