dashPi: a self-hosted home dashboard, its sync server and phone app
The dashboard (Raspberry Pi 3.5" screen + web pages), the end-to-end encrypted sync mailbox (PHP + SQLite) and the Android companion app (Flutter), with docs, clean-install checks and screenshots made from demo data. Built mostly with an AI coding assistant; not yet reviewed line by line by a human (see README and SECURITY.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
fb3c01cdd7
333 changed files with 45151 additions and 0 deletions
9
app/packages/gb_export/android/.gitignore
vendored
Normal file
9
app/packages/gb_export/android/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.cxx
|
||||
75
app/packages/gb_export/android/build.gradle.kts
Normal file
75
app/packages/gb_export/android/build.gradle.kts
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
group = "dev.bashynx.gb_export"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
buildscript {
|
||||
val kotlinVersion = "2.3.20"
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:9.0.1")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "dev.bashynx.gb_export"
|
||||
|
||||
compileSdk = 36
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
getByName("main") {
|
||||
java.srcDirs("src/main/kotlin")
|
||||
}
|
||||
getByName("test") {
|
||||
java.srcDirs("src/test/kotlin")
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 24
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests {
|
||||
isIncludeAndroidResources = true
|
||||
all {
|
||||
it.useJUnitPlatform()
|
||||
|
||||
it.outputs.upToDateWhen { false }
|
||||
|
||||
it.testLogging {
|
||||
events("passed", "skipped", "failed", "standardOut", "standardError")
|
||||
showStandardStreams = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
}
|
||||
1
app/packages/gb_export/android/settings.gradle.kts
Normal file
1
app/packages/gb_export/android/settings.gradle.kts
Normal file
|
|
@ -0,0 +1 @@
|
|||
rootProject.name = "gb_export"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="dev.bashynx.gb_export">
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package dev.bashynx.gb_export
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.DocumentsContract
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.PluginRegistry
|
||||
import java.io.File
|
||||
|
||||
// "dash/gbexport": pick() → uri or null (needs the activity) · info(uri) → {size, modified} or null ·
|
||||
// copy(uri, path) → true when copied · timeZone() → the phone's zone ("Europe/Bucharest").
|
||||
// info / copy / timeZone work without an activity (background tasks).
|
||||
class GbExportPlugin : FlutterPlugin, ActivityAware, PluginRegistry.ActivityResultListener {
|
||||
private val pickCode = 4711
|
||||
private lateinit var channel: MethodChannel
|
||||
private lateinit var context: Context
|
||||
private var activity: ActivityPluginBinding? = null
|
||||
private var pending: MethodChannel.Result? = null
|
||||
|
||||
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
context = binding.applicationContext
|
||||
channel = MethodChannel(binding.binaryMessenger, "dash/gbexport")
|
||||
channel.setMethodCallHandler { call, result ->
|
||||
when (call.method) {
|
||||
"pick" -> {
|
||||
val a = activity?.activity
|
||||
if (a == null) {
|
||||
result.error("no_activity", "the picker needs the app on screen", null)
|
||||
} else {
|
||||
pending = result
|
||||
val i = Intent(Intent.ACTION_OPEN_DOCUMENT).addCategory(Intent.CATEGORY_OPENABLE).setType("*/*")
|
||||
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
|
||||
a.startActivityForResult(i, pickCode)
|
||||
}
|
||||
}
|
||||
"info" -> result.success(info(Uri.parse(call.argument<String>("uri"))))
|
||||
"timeZone" -> result.success(java.util.TimeZone.getDefault().id)
|
||||
"copy" -> result.success(try {
|
||||
context.contentResolver.openInputStream(Uri.parse(call.argument<String>("uri")))!!.use { inp ->
|
||||
File(call.argument<String>("path")!!).outputStream().use { inp.copyTo(it) }
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
})
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) = channel.setMethodCallHandler(null)
|
||||
|
||||
private fun info(uri: Uri): Map<String, Long>? = try {
|
||||
context.contentResolver.query(uri, arrayOf(DocumentsContract.Document.COLUMN_SIZE,
|
||||
DocumentsContract.Document.COLUMN_LAST_MODIFIED), null, null, null)?.use { c ->
|
||||
if (c.moveToFirst()) mapOf("size" to c.getLong(0), "modified" to (if (c.isNull(1)) 0L else c.getLong(1))) else null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
|
||||
if (requestCode != pickCode) return false
|
||||
val uri = if (resultCode == Activity.RESULT_OK) data?.data else null
|
||||
if (uri != null) {
|
||||
try {
|
||||
context.contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
} catch (e: SecurityException) {
|
||||
}
|
||||
}
|
||||
pending?.success(uri?.toString())
|
||||
pending = null
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
||||
activity = binding
|
||||
binding.addActivityResultListener(this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromActivityForConfigChanges() = onDetachedFromActivity()
|
||||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) = onAttachedToActivity(binding)
|
||||
override fun onDetachedFromActivity() {
|
||||
activity?.removeActivityResultListener(this)
|
||||
activity = null
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue