Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e11ce89b21 | |||
| d57fbe3ef1 | |||
|
|
ba10b8ef7b | ||
|
|
995f2e5ae0 | ||
|
|
a2d6d2a925 | ||
| f6a3cd6b5e | |||
| 23845391d4 | |||
|
|
6220238068 | ||
| 85a1f9dc8a | |||
| 755220d08a | |||
|
|
a757743161 | ||
| 5eff98a639 | |||
| 95f9be70bd | |||
|
|
75a7898c68 | ||
|
|
ee31e0ee7c | ||
| 43200dda05 | |||
| 2e194da4e3 | |||
|
|
b37e3db037 | ||
| dae5118354 | |||
| 3490849837 | |||
|
|
9905c4788f | ||
|
|
a478c95536 | ||
| 985bd3ed13 | |||
|
|
89f1b5275a |
106 changed files with 4947 additions and 115 deletions
138
.forgejo/workflows/release.yml
Normal file
138
.forgejo/workflows/release.yml
Normal file
|
|
@ -0,0 +1,138 @@
|
||||||
|
# What happens at every merge into main:
|
||||||
|
# 1. semantic-release reads the commits since the last release (Conventional Commits), works out the next version,
|
||||||
|
# writes CHANGELOG.md, makes the release on the forge and tags it. A merge with nothing to release (docs, tests, ci)
|
||||||
|
# makes none.
|
||||||
|
# 2. When there is a release, the image is built from the tag, for amd64 and for arm64, and pushed to
|
||||||
|
# git.kmalloc.org/squid/sonda as X.Y.Z-ARCH; then X.Y.Z, X.Y and latest are made to point at both.
|
||||||
|
# The runner has no Docker and cannot emulate another architecture, so the images are built with kaniko, which needs no
|
||||||
|
# daemon, and the Dockerfile crosses to arm64 without running anything for it.
|
||||||
|
# Secret needed: FORGEJO_TOKEN, a token of the owner with the scopes write:repository and write:package.
|
||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
# One release at a time: two merges close together must not make two versions at once.
|
||||||
|
concurrency:
|
||||||
|
group: release
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: docker
|
||||||
|
# The commit that the release makes (CHANGELOG.md) says [skip ci]; this is the belt for those braces.
|
||||||
|
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.version.outputs.version }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # the whole history: the next version depends on every commit since the last tag
|
||||||
|
token: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- name: Release
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
GITEA_URL: https://git.kmalloc.org
|
||||||
|
GIT_AUTHOR_NAME: sonda-release
|
||||||
|
GIT_AUTHOR_EMAIL: squid@kmalloc.org
|
||||||
|
GIT_COMMITTER_NAME: sonda-release
|
||||||
|
GIT_COMMITTER_EMAIL: squid@kmalloc.org
|
||||||
|
run: >
|
||||||
|
npx --yes
|
||||||
|
-p semantic-release@25
|
||||||
|
-p @semantic-release/commit-analyzer@13.0.1
|
||||||
|
-p @semantic-release/release-notes-generator@14.1.1
|
||||||
|
-p @semantic-release/changelog@7.0.0
|
||||||
|
-p @semantic-release/git@11.0.1
|
||||||
|
-p conventional-changelog-conventionalcommits@8.0.0
|
||||||
|
-p @saithodev/semantic-release-gitea@2.1.0
|
||||||
|
semantic-release
|
||||||
|
- name: Which version was made, if any
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
# The tag of a release points at the commit the release made, which is where the checkout now is.
|
||||||
|
tag="$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true)"
|
||||||
|
echo "version=${tag#v}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "released: ${tag:-nothing}"
|
||||||
|
|
||||||
|
# The Alpine of the arm64 image, by digest: kaniko, which has no emulation here, takes the base of every stage for the
|
||||||
|
# platform of the runner, so the last stage is told which one to use.
|
||||||
|
base:
|
||||||
|
needs: release
|
||||||
|
if: ${{ needs.release.outputs.version != '' }}
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: gcr.io/go-containerregistry/crane:debug
|
||||||
|
outputs:
|
||||||
|
arm64: ${{ steps.digest.outputs.arm64 }}
|
||||||
|
steps:
|
||||||
|
- id: digest
|
||||||
|
run: echo "arm64=alpine@$(crane digest --platform linux/arm64 alpine:3.22)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# One image for each architecture. The Go program crosses to the other one with no emulation, and the last stage of the
|
||||||
|
# Dockerfile runs no command (see the Dockerfile).
|
||||||
|
image:
|
||||||
|
needs: [release, base]
|
||||||
|
if: ${{ needs.release.outputs.version != '' }}
|
||||||
|
runs-on: docker
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
arch: [amd64, arm64]
|
||||||
|
container:
|
||||||
|
image: gcr.io/kaniko-project/executor:v1.23.2-debug
|
||||||
|
steps:
|
||||||
|
- name: Build the image from the tag and push it as X.Y.Z-ARCH
|
||||||
|
env:
|
||||||
|
VERSION: ${{ needs.release.outputs.version }}
|
||||||
|
ARCH: ${{ matrix.arch }}
|
||||||
|
ARM64_BASE: ${{ needs.base.outputs.arm64 }}
|
||||||
|
REGISTRY_USER: squid
|
||||||
|
REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
mkdir -p /kaniko/.docker
|
||||||
|
auth="$(printf '%s:%s' "$REGISTRY_USER" "$REGISTRY_TOKEN" | base64 | tr -d '\n')"
|
||||||
|
printf '{"auths":{"git.kmalloc.org":{"auth":"%s"}}}' "$auth" > /kaniko/.docker/config.json
|
||||||
|
base=alpine:3.22
|
||||||
|
if [ "$ARCH" = arm64 ]; then base="$ARM64_BASE"; fi
|
||||||
|
/kaniko/executor \
|
||||||
|
--dockerfile Dockerfile \
|
||||||
|
--context "git://git.kmalloc.org/squid/sonda.git#refs/tags/v${VERSION}" \
|
||||||
|
--build-arg "VERSION=${VERSION}" \
|
||||||
|
--build-arg "SONDA_ARCH=${ARCH}" \
|
||||||
|
--build-arg "RUNTIME_BASE=${base}" \
|
||||||
|
--label "org.opencontainers.image.version=${VERSION}" \
|
||||||
|
--destination "git.kmalloc.org/squid/sonda:${VERSION}-${ARCH}" \
|
||||||
|
--verbosity info
|
||||||
|
|
||||||
|
# The tags that people use (X.Y.Z, X.Y, latest) point at a list of the two images, so that each machine takes its own.
|
||||||
|
manifest:
|
||||||
|
needs: [release, image]
|
||||||
|
if: ${{ needs.release.outputs.version != '' }}
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: gcr.io/go-containerregistry/crane:debug
|
||||||
|
steps:
|
||||||
|
- name: Join the images under X.Y.Z, X.Y and latest
|
||||||
|
env:
|
||||||
|
VERSION: ${{ needs.release.outputs.version }}
|
||||||
|
REGISTRY_USER: squid
|
||||||
|
REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
image=git.kmalloc.org/squid/sonda
|
||||||
|
crane auth login git.kmalloc.org -u "$REGISTRY_USER" -p "$REGISTRY_TOKEN"
|
||||||
|
# Kaniko writes the architecture of the runner in both images: say the right one for each.
|
||||||
|
for arch in amd64 arm64; do
|
||||||
|
crane mutate "${image}:${VERSION}-${arch}" --set-platform "linux/${arch}" --tag "${image}:${VERSION}-${arch}"
|
||||||
|
done
|
||||||
|
crane index append \
|
||||||
|
--tag "${image}:${VERSION}" \
|
||||||
|
--manifest "${image}:${VERSION}-amd64" \
|
||||||
|
--manifest "${image}:${VERSION}-arm64"
|
||||||
|
crane tag "${image}:${VERSION}" "${VERSION%.*}"
|
||||||
|
crane tag "${image}:${VERSION}" latest
|
||||||
35
.releaserc.json
Normal file
35
.releaserc.json
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"branches": ["main"],
|
||||||
|
"tagFormat": "v${version}",
|
||||||
|
"plugins": [
|
||||||
|
["@semantic-release/commit-analyzer", { "preset": "conventionalcommits" }],
|
||||||
|
[
|
||||||
|
"@semantic-release/release-notes-generator",
|
||||||
|
{
|
||||||
|
"preset": "conventionalcommits",
|
||||||
|
"presetConfig": {
|
||||||
|
"types": [
|
||||||
|
{ "type": "feat", "section": "Features" },
|
||||||
|
{ "type": "fix", "section": "Bug fixes" },
|
||||||
|
{ "type": "perf", "section": "Performance" },
|
||||||
|
{ "type": "refactor", "section": "Refactoring" },
|
||||||
|
{ "type": "docs", "section": "Documentation" },
|
||||||
|
{ "type": "style", "hidden": true },
|
||||||
|
{ "type": "test", "hidden": true },
|
||||||
|
{ "type": "chore", "hidden": true },
|
||||||
|
{ "type": "ci", "hidden": true }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
["@semantic-release/changelog", { "changelogFile": "CHANGELOG.md", "changelogTitle": "# Changelog" }],
|
||||||
|
[
|
||||||
|
"@semantic-release/git",
|
||||||
|
{
|
||||||
|
"assets": ["CHANGELOG.md"],
|
||||||
|
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
["@saithodev/semantic-release-gitea", { "giteaUrl": "https://git.kmalloc.org" }]
|
||||||
|
]
|
||||||
|
}
|
||||||
46
CHANGELOG.md
Normal file
46
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [0.5.0](https://git.kmalloc.org/squid/sonda/compare/v0.4.2...v0.5.0) (2026-11-17)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **android:** add an Android app ([ba10b8e](https://git.kmalloc.org/squid/sonda/commit/ba10b8ef7bbcf4fe3735e7b931d1b687259cc044)), closes [#47](https://git.kmalloc.org/squid/sonda/issues/47)
|
||||||
|
* **web:** talk to the Android app ([995f2e5](https://git.kmalloc.org/squid/sonda/commit/995f2e5ae013897a56743b60eeedea909fe04db9))
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
* **web:** show a restored queue on the lock screen ([a2d6d2a](https://git.kmalloc.org/squid/sonda/commit/a2d6d2a925edf8de89a7a4df0afbfa82004ccf87))
|
||||||
|
|
||||||
|
## [0.4.2](https://git.kmalloc.org/squid/sonda/compare/v0.4.1...v0.4.2) (2026-11-17)
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
* **web:** make the seek bar fit the width of a phone ([6220238](https://git.kmalloc.org/squid/sonda/commit/6220238068c446a97d1726697601f7ba5e126028)), closes [#45](https://git.kmalloc.org/squid/sonda/issues/45)
|
||||||
|
|
||||||
|
## [0.4.1](https://git.kmalloc.org/squid/sonda/compare/v0.4.0...v0.4.1) (2026-11-17)
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
* **web:** keep the controls of the full-screen player on screen on a phone ([a757743](https://git.kmalloc.org/squid/sonda/commit/a757743161ac3f7a348884a9f7b2490ab09b99e1)), closes [#43](https://git.kmalloc.org/squid/sonda/issues/43)
|
||||||
|
|
||||||
|
## [0.4.0](https://git.kmalloc.org/squid/sonda/compare/v0.3.0...v0.4.0) (2026-11-16)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **web:** make Sonda feel like an app on a phone ([75a7898](https://git.kmalloc.org/squid/sonda/commit/75a7898c68ca65c8c4efa0f51b72d62ac9a4db6e))
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
* note that this repo moved to git.kmalloc.org ([ee31e0e](https://git.kmalloc.org/squid/sonda/commit/ee31e0ee7caf9e7510b7cfde1f4e096721966e90))
|
||||||
|
|
||||||
|
## [0.3.0](https://git.kmalloc.org/squid/sonda/compare/v0.2.0...v0.3.0) (2026-11-16)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* publish the Docker image for ARM as well ([b37e3db](https://git.kmalloc.org/squid/sonda/commit/b37e3db037a442af439c5183cf4937a9be630a14))
|
||||||
|
|
||||||
|
## [0.2.0](https://git.kmalloc.org/squid/sonda/compare/v0.1.0...v0.2.0) (2026-11-16)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* scan the libraries by themselves when their music changed ([89f1b52](https://git.kmalloc.org/squid/sonda/commit/89f1b5275a3f1d0115f1cdd22512daebebf964d2))
|
||||||
40
Dockerfile
40
Dockerfile
|
|
@ -1,8 +1,11 @@
|
||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# RUNTIME_BASE is alpine:3.22 unless the CI release asks for another architecture, with the digest of that one.
|
||||||
|
ARG RUNTIME_BASE=alpine:3.22
|
||||||
|
|
||||||
# The web app: built once here, written (by its Vite config) to /src/internal/webui/dist, where the Go
|
# The web app: built once here, written (by its Vite config) to /src/internal/webui/dist, where the Go
|
||||||
# build below embeds it. Nothing of Node reaches the final image.
|
# build below embeds it. Nothing of Node reaches the final image.
|
||||||
FROM node:24-alpine AS web
|
FROM --platform=$BUILDPLATFORM node:24-alpine AS web
|
||||||
WORKDIR /src/web
|
WORKDIR /src/web
|
||||||
COPY web/package.json web/package-lock.json ./
|
COPY web/package.json web/package-lock.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
@ -12,7 +15,13 @@ RUN npm run build
|
||||||
# Build: Sonda has no CGO (SQLite, PostgreSQL and the tag reader are pure Go), so the binary
|
# Build: Sonda has no CGO (SQLite, PostgreSQL and the tag reader are pure Go), so the binary
|
||||||
# is static and the final image needs nothing but it and the CA certificates. The web app is inside it
|
# is static and the final image needs nothing but it and the CA certificates. The web app is inside it
|
||||||
# (-tags webui), so sondad serves it on / and the API on /api.
|
# (-tags webui), so sondad serves it on / and the API on /api.
|
||||||
FROM golang:1.27-alpine AS build
|
FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS build
|
||||||
|
# Built on the machine that builds, for the machine that runs: Go crosses to another architecture with no emulation
|
||||||
|
# (TARGETOS and TARGETARCH come from the platform asked for).
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
# SONDA_ARCH is for a builder that cannot say TARGETARCH (the CI release, see .forgejo/workflows/release.yml).
|
||||||
|
ARG SONDA_ARCH
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
@ -20,19 +29,28 @@ COPY cmd ./cmd
|
||||||
COPY internal ./internal
|
COPY internal ./internal
|
||||||
COPY migrations ./migrations
|
COPY migrations ./migrations
|
||||||
COPY --from=web /src/internal/webui/dist ./internal/webui/dist
|
COPY --from=web /src/internal/webui/dist ./internal/webui/dist
|
||||||
RUN CGO_ENABLED=0 go build -tags webui -trimpath -ldflags="-s -w" -o /out/sondad ./cmd/sondad
|
# The version of the release (see .releaserc.json), as GET /version and the User-Agent of the providers say it.
|
||||||
|
ARG VERSION=dev
|
||||||
|
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${SONDA_ARCH:-${TARGETARCH:-amd64}} go build -tags webui -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /out/sondad ./cmd/sondad
|
||||||
|
|
||||||
FROM alpine:3.22
|
# What the image has besides the program (the zones of tzdata, the user, the folders) is made here, on the machine that
|
||||||
|
# builds. The last stage then runs no command, so it can be built for another architecture with no emulation.
|
||||||
|
FROM --platform=$BUILDPLATFORM alpine:3.22 AS rootfs
|
||||||
|
RUN apk add --no-cache tzdata \
|
||||||
|
&& addgroup -S -g 10001 sonda \
|
||||||
|
&& adduser -S -u 10001 -G sonda -h /data -H sonda \
|
||||||
|
&& mkdir -p /out/data /out/music
|
||||||
|
|
||||||
|
FROM ${RUNTIME_BASE}
|
||||||
LABEL org.opencontainers.image.title="Sonda" \
|
LABEL org.opencontainers.image.title="Sonda" \
|
||||||
org.opencontainers.image.description="A privacy-first, self-hosted music server" \
|
org.opencontainers.image.description="A privacy-first, self-hosted music server" \
|
||||||
org.opencontainers.image.source="https://git.kmalloc.org/squid/sonda"
|
org.opencontainers.image.source="https://git.kmalloc.org/squid/sonda"
|
||||||
# ca-certificates: the providers an admin may switch on are reached over https.
|
# The certificates of alpine (ca-certificates-bundle) are what the providers an admin may switch on are reached with,
|
||||||
# tzdata: log times in the zone the operator sets with TZ.
|
# over https. tzdata is for the log times in the zone the operator sets with TZ.
|
||||||
RUN apk add --no-cache ca-certificates tzdata \
|
COPY --from=rootfs /usr/share/zoneinfo /usr/share/zoneinfo
|
||||||
&& addgroup -S -g 10001 sonda \
|
COPY --from=rootfs /etc/passwd /etc/group /etc/shadow /etc/
|
||||||
&& adduser -S -u 10001 -G sonda -h /data -H sonda \
|
COPY --from=rootfs --chown=10001:10001 /out/data /data
|
||||||
&& mkdir -p /data /music \
|
COPY --from=rootfs /out/music /music
|
||||||
&& chown sonda:sonda /data
|
|
||||||
COPY --from=build /out/sondad /usr/local/bin/sondad
|
COPY --from=build /out/sondad /usr/local/bin/sondad
|
||||||
|
|
||||||
# Everything Sonda writes is under /data: the database and the files it makes (covers, pictures).
|
# Everything Sonda writes is under /data: the database and the files it makes (covers, pictures).
|
||||||
|
|
|
||||||
5
Makefile
5
Makefile
|
|
@ -8,8 +8,11 @@
|
||||||
|
|
||||||
.PHONY: build web test
|
.PHONY: build web test
|
||||||
|
|
||||||
|
# The version is the last release tag, and how far this checkout is from it (v1.2.3-4-gabcdef), or "dev" outside git.
|
||||||
|
VERSION ?= $(shell git describe --tags --always 2>/dev/null | sed 's/^v//' || echo dev)
|
||||||
|
|
||||||
build: web
|
build: web
|
||||||
CGO_ENABLED=0 go build -tags webui -trimpath -ldflags="-s -w" -o bin/sondad ./cmd/sondad
|
CGO_ENABLED=0 go build -tags webui -trimpath -ldflags="-s -w -X main.version=$(VERSION)" -o bin/sondad ./cmd/sondad
|
||||||
|
|
||||||
web:
|
web:
|
||||||
cd web && npm ci && npm run build
|
cd web && npm ci && npm run build
|
||||||
|
|
|
||||||
43
README.md
43
README.md
|
|
@ -1,5 +1,9 @@
|
||||||
# Sonda
|
# Sonda
|
||||||
|
|
||||||
|
**This repository has moved.** Development continues at
|
||||||
|
[git.kmalloc.org/squid/sonda](https://git.kmalloc.org/squid/sonda); this
|
||||||
|
Codeberg mirror is archived and read-only.
|
||||||
|
|
||||||
Sonda is a privacy-first, self-hosted music server written in Go. It streams the music you already own, from your own disks, and keeps everything it knows about you on your own machine.
|
Sonda is a privacy-first, self-hosted music server written in Go. It streams the music you already own, from your own disks, and keeps everything it knows about you on your own machine.
|
||||||
|
|
||||||
It is a single executable, one database (SQLite by default, PostgreSQL if you prefer) and the folders that hold your music. There is no Redis, no message broker and no cloud account.
|
It is a single executable, one database (SQLite by default, PostgreSQL if you prefer) and the folders that hold your music. There is no Redis, no message broker and no cloud account.
|
||||||
|
|
@ -10,7 +14,7 @@ It is a single executable, one database (SQLite by default, PostgreSQL if you pr
|
||||||
|
|
||||||
- **Accounts.** An account is an email address and a password. The first user to register becomes the admin and registration then closes; admins create the other users. The address only identifies the account: Sonda sends no mail, does not check that the address exists, and keeps it on your server. It is trimmed and lowercased, and unique. Accounts made before addresses were asked for keep the plain name they had as their login. Short-lived access tokens (JWT) plus rotating refresh tokens, so a stolen refresh token is detected.
|
- **Accounts.** An account is an email address and a password. The first user to register becomes the admin and registration then closes; admins create the other users. The address only identifies the account: Sonda sends no mail, does not check that the address exists, and keeps it on your server. It is trimmed and lowercased, and unique. Accounts made before addresses were asked for keep the plain name they had as their login. Short-lived access tokens (JWT) plus rotating refresh tokens, so a stolen refresh token is detected.
|
||||||
- **Libraries.** A library is a name and a folder, managed through the API. Sonda only reads your music folders: it never writes or renames a file, and it deletes one only when an admin asks to remove the extra copy of a song and you turned on `library.allow_delete` (see **Duplicates**), which is off by default.
|
- **Libraries.** A library is a name and a folder, managed through the API. Sonda only reads your music folders: it never writes or renames a file, and it deletes one only when an admin asks to remove the extra copy of a song and you turned on `library.allow_delete` (see **Duplicates**), which is off by default.
|
||||||
- **Scanner.** Reads MP3 and FLAC tags and audio properties with several workers in parallel. Rescans are incremental, renamed files keep their identity, vanished files are flagged (never deleted), and a library whose folder looks empty or unreadable (an unmounted NAS) is left alone instead of being wiped. Audio in other formats (m4a, ogg, opus, wav, wma and similar) is not read yet, but it is counted as `unsupported` in the scan result instead of disappearing silently. NAS housekeeping folders (`@Recycle`, `#recycle`, `@eaDir`, `.@__thumb`, `$RECYCLE.BIN`) are skipped.
|
- **Scanner.** Reads MP3 and FLAC tags and audio properties with several workers in parallel. Rescans are incremental, renamed files keep their identity, vanished files are flagged (never deleted), and a library whose folder looks empty or unreadable (an unmounted NAS) is left alone instead of being wiped. Audio in other formats (m4a, ogg, opus, wav, wma and similar) is not read yet, but it is counted as `unsupported` in the scan result instead of disappearing silently. NAS housekeeping folders (`@Recycle`, `#recycle`, `@eaDir`, `.@__thumb`, `$RECYCLE.BIN`) are skipped. **Scans by itself.** Every 15 minutes (`library.auto_scan_minutes`) Sonda looks at the folders of each library, which costs only the names of the files, and scans a library whose music changed: a song or a folder came, went or was renamed. A library is also scanned at least once a day, to find a song that was tagged again where it stands. It never scans while another scan runs, and a folder it cannot read (a NAS that is not mounted) is left alone.
|
||||||
- **Catalog.** Browse and search artists, albums and songs, with paging, by library, artist or album. Only songs you can actually play are listed.
|
- **Catalog.** Browse and search artists, albums and songs, with paging, by library, artist or album. Only songs you can actually play are listed.
|
||||||
- **Duplicates.** `GET /library/duplicates` (admin) lists the songs that are in more than one file: the same set of main artists, the same title and durations within 3 seconds, possibly on different albums. It is worked out from the index, touches no file, and returns no file path. Each group proposes the copy to keep (lossless first, then the higher bitrate, then the bigger file, then the oldest). A background job (`POST /library/duplicates/check`, like the other bulk jobs) reads the files of the groups and keeps their SHA-256, so a group can be called `identical` (byte for byte). `POST /library/duplicates/clean` **deletes the extra copies of one song from the disk**, and it is the one thing Sonda does that writes in your music folders, so it is off until you set `library.allow_delete` (or `SONDA_ALLOW_DELETE=true`) and mount the folders writable. It deletes only when an admin asks, never by itself, and the server checks again at that moment that no scan is running, that the songs are copies of one song, and that every file is still the one the last scan saw (same size and date, a regular file, not a link, inside its library): so the last copy of a song is never deleted, a file that changed is not deleted, and every file is checked before the first is deleted. The listens and the playlist items of a deleted copy move to the one that stays, so your taste and your playlists are not lost. Folders are never removed, and nothing is sent anywhere. The web app has a Duplicates section in Admin: a table of the copies of each song with the copy to keep already chosen (you can pick another), the check with its progress and a Stop button, **Delete the others** for one song and **Clean all suggestions** for all of them, each after a question that lists the files and the space it frees; with deleting off everything is visible and the delete buttons are disabled.
|
- **Duplicates.** `GET /library/duplicates` (admin) lists the songs that are in more than one file: the same set of main artists, the same title and durations within 3 seconds, possibly on different albums. It is worked out from the index, touches no file, and returns no file path. Each group proposes the copy to keep (lossless first, then the higher bitrate, then the bigger file, then the oldest). A background job (`POST /library/duplicates/check`, like the other bulk jobs) reads the files of the groups and keeps their SHA-256, so a group can be called `identical` (byte for byte). `POST /library/duplicates/clean` **deletes the extra copies of one song from the disk**, and it is the one thing Sonda does that writes in your music folders, so it is off until you set `library.allow_delete` (or `SONDA_ALLOW_DELETE=true`) and mount the folders writable. It deletes only when an admin asks, never by itself, and the server checks again at that moment that no scan is running, that the songs are copies of one song, and that every file is still the one the last scan saw (same size and date, a regular file, not a link, inside its library): so the last copy of a song is never deleted, a file that changed is not deleted, and every file is checked before the first is deleted. The listens and the playlist items of a deleted copy move to the one that stays, so your taste and your playlists are not lost. Folders are never removed, and nothing is sent anywhere. The web app has a Duplicates section in Admin: a table of the copies of each song with the copy to keep already chosen (you can pick another), the check with its progress and a Stop button, **Delete the others** for one song and **Clean all suggestions** for all of them, each after a question that lists the files and the space it frees; with deleting off everything is visible and the delete buttons are disabled.
|
||||||
- **Streaming.** `GET` and `HEAD` with `Range` support, so players can seek. Opening or prefetching a stream does not record a listen. `GET /tracks/{id}/peaks` gives the shape of a song for the seek bar: 120 levels from 0 to 255, how loud it is along its length. The server finds it by decoding the file (MP3 and FLAC, in pure Go: nothing else to install), which takes a few seconds, so the first request starts the work in the background and answers `202` with `Retry-After`; it is done once for each file, worked out again if the size or the date of the file change, and one song at a time, so a NAS is not kept busy. A file that cannot be decoded answers `waveform_unavailable`, and that is remembered too. A friend's song has no shape yet.
|
- **Streaming.** `GET` and `HEAD` with `Range` support, so players can seek. Opening or prefetching a stream does not record a listen. `GET /tracks/{id}/peaks` gives the shape of a song for the seek bar: 120 levels from 0 to 255, how loud it is along its length. The server finds it by decoding the file (MP3 and FLAC, in pure Go: nothing else to install), which takes a few seconds, so the first request starts the work in the background and answers `202` with `Retry-After`; it is done once for each file, worked out again if the size or the date of the file change, and one song at a time, so a NAS is not kept busy. A file that cannot be decoded answers `waveform_unavailable`, and that is remembered too. A friend's song has no shape yet.
|
||||||
|
|
@ -65,7 +69,7 @@ A plain `go build -o bin/sondad ./cmd/sondad` needs no Node and gives the API on
|
||||||
|
|
||||||
The image holds `sondad` with the web app inside, and nothing else: it builds the app itself, so you need no Node on your machine. It runs as an ordinary user, keeps the database and the files Sonda makes under `/data`, listens on port 8080 inside the container, and does not start without `SONDA_JWT_SECRET`.
|
The image holds `sondad` with the web app inside, and nothing else: it builds the app itself, so you need no Node on your machine. It runs as an ordinary user, keeps the database and the files Sonda makes under `/data`, listens on port 8080 inside the container, and does not start without `SONDA_JWT_SECRET`.
|
||||||
|
|
||||||
The image is published on the registry of git.kmalloc.org, so you do not have to build it: `git.kmalloc.org/squid/sonda:latest` is the last one, and `git.kmalloc.org/squid/sonda:<commit>` (the first seven characters of a commit of `main`) is one you can stay on. Anyone can pull it, with no login. To build it yourself instead, run `docker build -t sonda .` and use `sonda` where the commands below say `git.kmalloc.org/squid/sonda:latest`.
|
The image is published on the registry of git.kmalloc.org, so you do not have to build it: `git.kmalloc.org/squid/sonda:latest` is the last one, and `git.kmalloc.org/squid/sonda:0.3.0` (a version from [CHANGELOG.md](CHANGELOG.md)) is one you can stay on. It runs on amd64 and on arm64 (a Raspberry Pi, an ARM NAS): one tag gives each machine its own. Anyone can pull it, with no login. To build it yourself instead, run `docker build -t sonda .` and use `sonda` where the commands below say `git.kmalloc.org/squid/sonda:latest`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker pull git.kmalloc.org/squid/sonda:latest
|
docker pull git.kmalloc.org/squid/sonda:latest
|
||||||
|
|
@ -104,6 +108,7 @@ Precedence is: built-in defaults, then the file, then environment variables. An
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `server.listen` | `SONDA_LISTEN` | `127.0.0.1:8080` | Address to listen on. Localhost by default. |
|
| `server.listen` | `SONDA_LISTEN` | `127.0.0.1:8080` | Address to listen on. Localhost by default. |
|
||||||
| `library.scan_workers` | | `4` | Files whose tags are read in parallel during a scan. |
|
| `library.scan_workers` | | `4` | Files whose tags are read in parallel during a scan. |
|
||||||
|
| `library.auto_scan_minutes` | `SONDA_AUTO_SCAN_MINUTES` | `15` | How often, in minutes, Sonda looks at the folders of the libraries and scans the ones whose music changed (a song or a folder came, went or was renamed); `0` turns it off. Looking reads the names of the files and nothing else, so it is cheap for a NAS. A library is scanned at least once a day anyway, which finds a song that was tagged again where it stands. A folder that cannot be read (a NAS that is not mounted) is left alone. |
|
||||||
| `library.allow_delete` | `SONDA_ALLOW_DELETE` | `false` | Lets an admin delete the extra copy of a song from the music folders (see **Duplicates**). It is the one thing that makes Sonda write there, so it needs the folders mounted writable. A value that is not `true` or `false` is an error. |
|
| `library.allow_delete` | `SONDA_ALLOW_DELETE` | `false` | Lets an admin delete the extra copy of a song from the music folders (see **Duplicates**). It is the one thing that makes Sonda write there, so it needs the folders mounted writable. A value that is not `true` or `false` is an error. |
|
||||||
| `database.driver` | `SONDA_DB_DRIVER` | `sqlite` | `sqlite` or `postgres`. |
|
| `database.driver` | `SONDA_DB_DRIVER` | `sqlite` | `sqlite` or `postgres`. |
|
||||||
| `database.path` | `SONDA_DB_PATH` | `sonda.db` | SQLite file (driver `sqlite`). |
|
| `database.path` | `SONDA_DB_PATH` | `sonda.db` | SQLite file (driver `sqlite`). |
|
||||||
|
|
@ -389,7 +394,7 @@ Back up the database and `sonda.toml`. Your music stays wherever you keep it.
|
||||||
|
|
||||||
## Web app
|
## Web app
|
||||||
|
|
||||||
A web client lives in `web/` (React, Vite and shadcn/ui). It talks only to the Sonda server: no CDN, no external fonts, no analytics. With the app built into the binary (`make build`, or the Docker image) `sondad` serves it: open the address of the server, for example `http://127.0.0.1:8080`, and sign in. The page carries a strict Content-Security-Policy (only resources of the server itself, no inline scripts), cannot be framed and sends no referrer, and a link inside the app (`/admin/users`) works when you reload it. The player draws a live picture of what is playing, in the browser, from the sound itself (Web Audio). Settings has a choice for it, kept on the device: a spectrogram (the last seconds, low notes at the bottom, the default), the classic bars with falling caps, an oscilloscope, Milkdrop, or nothing. The bars, the oscilloscope and the spectrogram take the colour of this server or, for a friend's song, the colour of the friend. Milkdrop fills the background of the full-screen player with the pictures Winamp made famous, drawn on the device with [butterchurn](https://github.com/jberg/butterchurn) (MIT) and its presets, which are part of the app: nothing is fetched from outside. It is loaded only when chosen, and anyone who asked the system for less motion gets the spectrogram instead, because the pictures flash. The player listens to the sound and changes nothing of it, and draws only while something plays.
|
A web client lives in `web/` (React, Vite and shadcn/ui). It talks only to the Sonda server: no CDN, no external fonts, no analytics. With the app built into the binary (`make build`, or the Docker image) `sondad` serves it: open the address of the server, for example `http://127.0.0.1:8080`, and sign in. The page carries a strict Content-Security-Policy (only resources of the server itself, no inline scripts), cannot be framed and sends no referrer, and a link inside the app (`/admin/users`) works when you reload it. The player draws a live picture of what is playing, in the browser, from the sound itself (Web Audio). Settings has a choice for it, kept on the device: a spectrogram (the last seconds, low notes at the bottom, the default), the classic bars with falling caps, an oscilloscope, Milkdrop, or nothing. The bars, the oscilloscope and the spectrogram take the colour of this server or, for a friend's song, the colour of the friend. Milkdrop fills the background of the full-screen player with the pictures Winamp made famous, drawn on the device with [butterchurn](https://github.com/jberg/butterchurn) (MIT) and its presets, which are part of the app: nothing is fetched from outside. It is loaded only when chosen, and anyone who asked the system for less motion gets the spectrogram instead, because the pictures flash. The player listens to the sound and changes nothing of it, and draws only while something plays. On a phone the player is one row at the foot of the page (and is not there while nothing plays); a tap or a swipe up opens the full-screen player, a swipe down or the Back gesture closes it, and the lock screen shows the song with its seek bar and follows play and pause. The queue is kept in the browser, so a page that is reloaded, or a tab that Android throws away, comes back paused on the same song at the same second.
|
||||||
|
|
||||||
To work on the interface itself, run the Vite dev server next to a running `sondad` (set `SONDA_URL` to where it listens: the default is `http://127.0.0.1:8080`):
|
To work on the interface itself, run the Vite dev server next to a running `sondad` (set `SONDA_URL` to where it listens: the default is `http://127.0.0.1:8080`):
|
||||||
|
|
||||||
|
|
@ -403,6 +408,38 @@ What it does today: sign in (and create the first account of a new server), brow
|
||||||
|
|
||||||
More commands, all run in `web/`: `npm test`, `npm run build`, and `npm run gen:api`, which rebuilds `src/api/schema.d.ts` from the OpenAPI spec (it fetches the generator with `npx`, so it needs the network once). `npm run build` writes to `internal/webui/dist` (git-ignored), not to `web/dist`.
|
More commands, all run in `web/`: `npm test`, `npm run build`, and `npm run gen:api`, which rebuilds `src/api/schema.d.ts` from the OpenAPI spec (it fetches the generator with `npx`, so it needs the network once). `npm run build` writes to `internal/webui/dist` (git-ignored), not to `web/dist`.
|
||||||
|
|
||||||
|
## Android app
|
||||||
|
|
||||||
|
`android/` holds a small Android app: a Capacitor shell that opens a Sonda server in a WebView, with its own icon and no browser bars. It is for a phone whose browser cannot install a PWA. It has no copy of the web app: it shows the one of your server, so a new version of the server is a new version of the app.
|
||||||
|
|
||||||
|
- The first time it asks for the address of the server (`music.example.org`, or `http://192.168.1.5:8080`) and remembers it. Settings has Change server, shown only inside the app.
|
||||||
|
- It trusts the certificate authorities installed on the phone, so a server behind a private CA opens once the CA is installed (Settings, Security, Install a certificate). It also opens a server on plain `http`.
|
||||||
|
- A WebView has no Media Session API, so the app keeps its own: a notification with the song, its cover and the buttons, and the lock screen and headset buttons work. The music goes on with the screen off. From Android 13 it asks to show notifications; without a yes the music still plays and only the notification is hidden.
|
||||||
|
|
||||||
|
To build it you need Node, a JDK 21 and the Android SDK (platform 36 and its build tools; set `ANDROID_HOME`):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd android
|
||||||
|
npm ci
|
||||||
|
npm run apk # android/android/app/build/outputs/apk/debug/app-debug.apk
|
||||||
|
adb install -r android/app/build/outputs/apk/debug/app-debug.apk
|
||||||
|
```
|
||||||
|
|
||||||
|
The APK is signed with the debug key, which is fine for your own phone. It is not part of the release pipeline, because the runner has no Android SDK. `npm test` checks how an address typed by hand is read.
|
||||||
|
|
||||||
|
## Releases
|
||||||
|
|
||||||
|
Every merge into `main` can make a release, by itself (`.forgejo/workflows/release.yml`, [semantic-release](https://semantic-release.gitbook.io)). The next version comes from the messages of the commits since the last one, written as [Conventional Commits](https://www.conventionalcommits.org):
|
||||||
|
|
||||||
|
| Commit | Release |
|
||||||
|
|---|---|
|
||||||
|
| `fix: ...`, `perf: ...` | patch (0.2.0 to 0.2.1) |
|
||||||
|
| `feat: ...` | minor (0.2.0 to 0.3.0) |
|
||||||
|
| `feat!: ...`, or `BREAKING CHANGE:` in the body | major (0.2.0 to 1.0.0) |
|
||||||
|
| `docs:`, `test:`, `chore:`, `ci:`, `style:` | none by themselves |
|
||||||
|
|
||||||
|
A release adds its entry to [CHANGELOG.md](CHANGELOG.md), tags the commit (`v0.3.0`), makes the release on the forge, and the image is built from the tag and pushed to `git.kmalloc.org/squid/sonda` as `0.3.0`, `0.3` and `latest`. The version is inside the binary: `GET /version` and the User-Agent of the providers say it (a build that no release made says `dev`). The commit that writes `CHANGELOG.md` says `[skip ci]`. The image is made for amd64 and for arm64, and each tag points at both. The runner has no Docker and cannot emulate ARM, so the images are built with [kaniko](https://github.com/GoogleContainerTools/kaniko): the Go program is compiled for ARM with no emulation, the last stage of the Dockerfile runs no command, and a last job (with [crane](https://github.com/google/go-containerregistry)) says the architecture of each image and joins them. The workflow needs the secret `FORGEJO_TOKEN`: a token of the owner with the scopes `write:repository` and `write:package`.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
14
android/.gitignore
vendored
Normal file
14
android/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
node_modules/
|
||||||
|
# Build output and local settings of the Android project
|
||||||
|
android/.gradle/
|
||||||
|
android/build/
|
||||||
|
android/app/build/
|
||||||
|
android/local.properties
|
||||||
|
android/.idea/
|
||||||
|
android/captures/
|
||||||
|
android/app/src/main/assets/public/
|
||||||
|
android/app/src/main/assets/capacitor.config.json
|
||||||
|
android/app/src/main/assets/capacitor.plugins.json
|
||||||
|
android/capacitor-cordova-android-plugins/
|
||||||
|
*.keystore
|
||||||
|
*.jks
|
||||||
101
android/android/.gitignore
vendored
Normal file
101
android/android/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore
|
||||||
|
|
||||||
|
# Built application files
|
||||||
|
*.apk
|
||||||
|
*.aar
|
||||||
|
*.ap_
|
||||||
|
*.aab
|
||||||
|
|
||||||
|
# Files for the ART/Dalvik VM
|
||||||
|
*.dex
|
||||||
|
|
||||||
|
# Java class files
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
bin/
|
||||||
|
gen/
|
||||||
|
out/
|
||||||
|
# Uncomment the following line in case you need and you don't have the release build type files in your app
|
||||||
|
# release/
|
||||||
|
|
||||||
|
# Gradle files
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Local configuration file (sdk path, etc)
|
||||||
|
local.properties
|
||||||
|
|
||||||
|
# Proguard folder generated by Eclipse
|
||||||
|
proguard/
|
||||||
|
|
||||||
|
# Log Files
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Android Studio Navigation editor temp files
|
||||||
|
.navigation/
|
||||||
|
|
||||||
|
# Android Studio captures folder
|
||||||
|
captures/
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
*.iml
|
||||||
|
.idea/workspace.xml
|
||||||
|
.idea/tasks.xml
|
||||||
|
.idea/gradle.xml
|
||||||
|
.idea/assetWizardSettings.xml
|
||||||
|
.idea/dictionaries
|
||||||
|
.idea/libraries
|
||||||
|
# Android Studio 3 in .gitignore file.
|
||||||
|
.idea/caches
|
||||||
|
.idea/modules.xml
|
||||||
|
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
|
||||||
|
.idea/navEditor.xml
|
||||||
|
|
||||||
|
# Keystore files
|
||||||
|
# Uncomment the following lines if you do not want to check your keystore files in.
|
||||||
|
#*.jks
|
||||||
|
#*.keystore
|
||||||
|
|
||||||
|
# External native build folder generated in Android Studio 2.2 and later
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx/
|
||||||
|
|
||||||
|
# Google Services (e.g. APIs or Firebase)
|
||||||
|
# google-services.json
|
||||||
|
|
||||||
|
# Freeline
|
||||||
|
freeline.py
|
||||||
|
freeline/
|
||||||
|
freeline_project_description.json
|
||||||
|
|
||||||
|
# fastlane
|
||||||
|
fastlane/report.xml
|
||||||
|
fastlane/Preview.html
|
||||||
|
fastlane/screenshots
|
||||||
|
fastlane/test_output
|
||||||
|
fastlane/readme.md
|
||||||
|
|
||||||
|
# Version control
|
||||||
|
vcs.xml
|
||||||
|
|
||||||
|
# lint
|
||||||
|
lint/intermediates/
|
||||||
|
lint/generated/
|
||||||
|
lint/outputs/
|
||||||
|
lint/tmp/
|
||||||
|
# lint/reports/
|
||||||
|
|
||||||
|
# Android Profiling
|
||||||
|
*.hprof
|
||||||
|
|
||||||
|
# Cordova plugins for Capacitor
|
||||||
|
capacitor-cordova-android-plugins
|
||||||
|
|
||||||
|
# Copied web assets
|
||||||
|
app/src/main/assets/public
|
||||||
|
|
||||||
|
# Generated Config files
|
||||||
|
app/src/main/assets/capacitor.config.json
|
||||||
|
app/src/main/assets/capacitor.plugins.json
|
||||||
|
app/src/main/res/xml/config.xml
|
||||||
2
android/android/app/.gitignore
vendored
Normal file
2
android/android/app/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
/build/*
|
||||||
|
!/build/.npmkeep
|
||||||
55
android/android/app/build.gradle
Normal file
55
android/android/app/build.gradle
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "app.sonda"
|
||||||
|
compileSdk = rootProject.ext.compileSdkVersion
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "app.sonda"
|
||||||
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
aaptOptions {
|
||||||
|
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||||
|
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
|
||||||
|
ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
flatDir{
|
||||||
|
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
||||||
|
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
|
||||||
|
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
|
||||||
|
implementation "androidx.media:media:1.7.0"
|
||||||
|
implementation project(':capacitor-android')
|
||||||
|
testImplementation "junit:junit:$junitVersion"
|
||||||
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
||||||
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
||||||
|
implementation project(':capacitor-cordova-android-plugins')
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: 'capacitor.build.gradle'
|
||||||
|
|
||||||
|
try {
|
||||||
|
def servicesJSON = file('google-services.json')
|
||||||
|
if (servicesJSON.text) {
|
||||||
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
|
||||||
|
}
|
||||||
19
android/android/app/capacitor.build.gradle
Normal file
19
android/android/app/capacitor.build.gradle
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_21
|
||||||
|
targetCompatibility JavaVersion.VERSION_21
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
||||||
|
dependencies {
|
||||||
|
implementation project(':capacitor-app')
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (hasProperty('postBuildExtras')) {
|
||||||
|
postBuildExtras()
|
||||||
|
}
|
||||||
21
android/android/app/proguard-rules.pro
vendored
Normal file
21
android/android/app/proguard-rules.pro
vendored
Normal file
|
|
@ -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
|
||||||
50
android/android/app/src/main/AndroidManifest.xml
Normal file
50
android/android/app/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:label="@string/title_activity_main"
|
||||||
|
android:theme="@style/AppTheme.NoActionBarLaunch"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:exported="true">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".MediaService"
|
||||||
|
android:exported="false"
|
||||||
|
android:foregroundServiceType="mediaPlayback" />
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths"></meta-data>
|
||||||
|
</provider>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<!-- Permissions -->
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||||
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
</manifest>
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package app.sonda;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import com.getcapacitor.BridgeActivity;
|
||||||
|
|
||||||
|
public class MainActivity extends BridgeActivity {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
WebView web = getBridge().getWebView();
|
||||||
|
web.addJavascriptInterface(new SondaNative(this), "SondaNative");
|
||||||
|
// The buttons of the notification and of the lock screen go back to the page.
|
||||||
|
MediaService.listener = (name, ms) -> web.post(() -> web.evaluateJavascript(
|
||||||
|
"window.sondaNativeAction && window.sondaNativeAction('" + name + "'," + ms + ")", null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
MediaService.listener = null;
|
||||||
|
if (isFinishing()) MediaService.end(this);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
219
android/android/app/src/main/java/app/sonda/MediaService.java
Normal file
219
android/android/app/src/main/java/app/sonda/MediaService.java
Normal file
|
|
@ -0,0 +1,219 @@
|
||||||
|
package app.sonda;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ServiceInfo;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.support.v4.media.MediaMetadataCompat;
|
||||||
|
import android.support.v4.media.session.MediaSessionCompat;
|
||||||
|
import android.support.v4.media.session.PlaybackStateCompat;
|
||||||
|
import androidx.core.app.NotificationCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.media.app.NotificationCompat.MediaStyle;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the playback alive while the screen is off or another app is in front, and shows what plays with its
|
||||||
|
* controls in a notification and on the lock screen. The web app does the playing; this only mirrors it, and
|
||||||
|
* passes the buttons back through {@link #listener}.
|
||||||
|
*/
|
||||||
|
public class MediaService extends Service {
|
||||||
|
/** Where a press of a button goes: the name is play, pause, next, previous or seekto. */
|
||||||
|
interface Listener {
|
||||||
|
void onAction(String name, long ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
static volatile Listener listener;
|
||||||
|
|
||||||
|
private static final String CHANNEL = "playback";
|
||||||
|
private static final int NOTIFICATION_ID = 1;
|
||||||
|
private static final String PLAY = "app.sonda.PLAY";
|
||||||
|
private static final String PAUSE = "app.sonda.PAUSE";
|
||||||
|
private static final String NEXT = "app.sonda.NEXT";
|
||||||
|
private static final String PREVIOUS = "app.sonda.PREVIOUS";
|
||||||
|
|
||||||
|
// The latest word of the page, kept here because the service may start after it was said.
|
||||||
|
private static NowPlaying latest;
|
||||||
|
private static MediaService instance;
|
||||||
|
|
||||||
|
private MediaSessionCompat session;
|
||||||
|
private String artworkUrl = "";
|
||||||
|
private Bitmap artwork;
|
||||||
|
|
||||||
|
/** Shows what plays. The first time it starts the service; after that it only updates it. */
|
||||||
|
static void show(Context context, NowPlaying now) {
|
||||||
|
latest = now;
|
||||||
|
if (instance != null) {
|
||||||
|
instance.apply(now);
|
||||||
|
} else {
|
||||||
|
ContextCompat.startForegroundService(context, new Intent(context, MediaService.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Nothing plays any more: the notification goes. */
|
||||||
|
static void end(Context context) {
|
||||||
|
latest = null;
|
||||||
|
if (instance != null) instance.shutDown();
|
||||||
|
else context.stopService(new Intent(context, MediaService.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
instance = this;
|
||||||
|
createChannel();
|
||||||
|
session = new MediaSessionCompat(this, "Sonda");
|
||||||
|
session.setCallback(new MediaSessionCompat.Callback() {
|
||||||
|
@Override public void onPlay() { send("play", 0); }
|
||||||
|
@Override public void onPause() { send("pause", 0); }
|
||||||
|
@Override public void onSkipToNext() { send("next", 0); }
|
||||||
|
@Override public void onSkipToPrevious() { send("previous", 0); }
|
||||||
|
@Override public void onSeekTo(long pos) { send("seekto", pos); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
String action = intent == null ? null : intent.getAction();
|
||||||
|
if (PLAY.equals(action)) send("play", 0);
|
||||||
|
else if (PAUSE.equals(action)) send("pause", 0);
|
||||||
|
else if (NEXT.equals(action)) send("next", 0);
|
||||||
|
else if (PREVIOUS.equals(action)) send("previous", 0);
|
||||||
|
if (latest != null) {
|
||||||
|
apply(latest);
|
||||||
|
} else {
|
||||||
|
// Started with nothing to show, or after the app was killed: Android wants a notification anyway, then it goes.
|
||||||
|
startForeground(NOTIFICATION_ID, notification(null));
|
||||||
|
shutDown();
|
||||||
|
}
|
||||||
|
return START_NOT_STICKY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The person swiped the app away: the page is gone, so the music and its notification go too. */
|
||||||
|
@Override
|
||||||
|
public void onTaskRemoved(Intent rootIntent) {
|
||||||
|
latest = null;
|
||||||
|
shutDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
instance = null;
|
||||||
|
if (session != null) {
|
||||||
|
session.setActive(false);
|
||||||
|
session.release();
|
||||||
|
session = null;
|
||||||
|
}
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void send(String name, long ms) {
|
||||||
|
Listener l = listener;
|
||||||
|
if (l != null) l.onAction(name, ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shutDown() {
|
||||||
|
stopForeground(STOP_FOREGROUND_REMOVE);
|
||||||
|
stopSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void apply(NowPlaying now) {
|
||||||
|
session.setMetadata(
|
||||||
|
new MediaMetadataCompat.Builder()
|
||||||
|
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, now.title)
|
||||||
|
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, now.artist)
|
||||||
|
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, now.album)
|
||||||
|
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, now.durationMs)
|
||||||
|
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, now.artworkUrl.equals(artworkUrl) ? artwork : null)
|
||||||
|
.build());
|
||||||
|
long actions = PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE
|
||||||
|
| PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS | PlaybackStateCompat.ACTION_SEEK_TO;
|
||||||
|
session.setPlaybackState(
|
||||||
|
new PlaybackStateCompat.Builder()
|
||||||
|
.setActions(actions)
|
||||||
|
.setState(now.playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, now.positionNow(), now.playing ? 1f : 0f)
|
||||||
|
.build());
|
||||||
|
session.setActive(true);
|
||||||
|
|
||||||
|
Notification n = notification(now);
|
||||||
|
if (Build.VERSION.SDK_INT >= 29) {
|
||||||
|
startForeground(NOTIFICATION_ID, n, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
|
||||||
|
} else {
|
||||||
|
startForeground(NOTIFICATION_ID, n);
|
||||||
|
}
|
||||||
|
if (!now.artworkUrl.isEmpty() && !now.artworkUrl.equals(artworkUrl)) fetchArtwork(now.artworkUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Notification notification(NowPlaying now) {
|
||||||
|
NotificationCompat.Builder b = new NotificationCompat.Builder(this, CHANNEL)
|
||||||
|
.setSmallIcon(R.drawable.ic_stat_sonda)
|
||||||
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
|
.setOnlyAlertOnce(true)
|
||||||
|
.setShowWhen(false)
|
||||||
|
.setContentIntent(PendingIntent.getActivity(
|
||||||
|
this, 0, new Intent(this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT));
|
||||||
|
if (now == null) return b.setContentTitle("Sonda").build();
|
||||||
|
b.setContentTitle(now.title).setContentText(now.artist).setSubText(now.album);
|
||||||
|
if (now.artworkUrl.equals(artworkUrl) && artwork != null) b.setLargeIcon(artwork);
|
||||||
|
b.addAction(android.R.drawable.ic_media_previous, getString(R.string.previous), button(PREVIOUS));
|
||||||
|
if (now.playing) b.addAction(android.R.drawable.ic_media_pause, getString(R.string.pause), button(PAUSE));
|
||||||
|
else b.addAction(android.R.drawable.ic_media_play, getString(R.string.play), button(PLAY));
|
||||||
|
b.addAction(android.R.drawable.ic_media_next, getString(R.string.next), button(NEXT));
|
||||||
|
b.setStyle(new MediaStyle().setMediaSession(session.getSessionToken()).setShowActionsInCompactView(0, 1, 2));
|
||||||
|
return b.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private PendingIntent button(String action) {
|
||||||
|
return PendingIntent.getService(
|
||||||
|
this, action.hashCode(), new Intent(this, MediaService.class).setAction(action), PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createChannel() {
|
||||||
|
if (Build.VERSION.SDK_INT < 26) return;
|
||||||
|
NotificationChannel channel = new NotificationChannel(CHANNEL, getString(R.string.channel_playback), NotificationManager.IMPORTANCE_LOW);
|
||||||
|
channel.setShowBadge(false);
|
||||||
|
getSystemService(NotificationManager.class).createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The cover comes from the server with the token in its address; a cover that does not come leaves the notification without one. */
|
||||||
|
private void fetchArtwork(String url) {
|
||||||
|
artworkUrl = url;
|
||||||
|
artwork = null;
|
||||||
|
new Thread(() -> {
|
||||||
|
Bitmap bitmap = null;
|
||||||
|
try {
|
||||||
|
HttpURLConnection c = (HttpURLConnection) new URL(url).openConnection();
|
||||||
|
c.setConnectTimeout(8000);
|
||||||
|
c.setReadTimeout(8000);
|
||||||
|
try (InputStream in = c.getInputStream()) {
|
||||||
|
bitmap = BitmapFactory.decodeStream(in);
|
||||||
|
} finally {
|
||||||
|
c.disconnect();
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// No cover: the notification stays as it is.
|
||||||
|
}
|
||||||
|
final Bitmap result = bitmap;
|
||||||
|
ContextCompat.getMainExecutor(this).execute(() -> {
|
||||||
|
if (instance != this || !url.equals(artworkUrl) || result == null) return;
|
||||||
|
artwork = result;
|
||||||
|
if (latest != null) apply(latest);
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
51
android/android/app/src/main/java/app/sonda/NowPlaying.java
Normal file
51
android/android/app/src/main/java/app/sonda/NowPlaying.java
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
package app.sonda;
|
||||||
|
|
||||||
|
import android.os.SystemClock;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
/** What the web app says is playing: the song, whether it plays and where it is. */
|
||||||
|
final class NowPlaying {
|
||||||
|
final String title;
|
||||||
|
final String artist;
|
||||||
|
final String album;
|
||||||
|
final String artworkUrl;
|
||||||
|
final boolean playing;
|
||||||
|
final long durationMs;
|
||||||
|
private final long positionMs;
|
||||||
|
private final long receivedAt;
|
||||||
|
|
||||||
|
private NowPlaying(String title, String artist, String album, String artworkUrl, boolean playing, long positionMs, long durationMs) {
|
||||||
|
this.title = title;
|
||||||
|
this.artist = artist;
|
||||||
|
this.album = album;
|
||||||
|
this.artworkUrl = artworkUrl;
|
||||||
|
this.playing = playing;
|
||||||
|
this.positionMs = positionMs;
|
||||||
|
this.durationMs = durationMs;
|
||||||
|
this.receivedAt = SystemClock.elapsedRealtime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Where the song is now: what the page said, plus the time that has passed if it plays. */
|
||||||
|
long positionNow() {
|
||||||
|
long position = playing ? positionMs + (SystemClock.elapsedRealtime() - receivedAt) : positionMs;
|
||||||
|
return durationMs > 0 ? Math.min(position, durationMs) : position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The JSON the page sends; null when it is not what was expected. */
|
||||||
|
static NowPlaying parse(String json) {
|
||||||
|
try {
|
||||||
|
JSONObject o = new JSONObject(json);
|
||||||
|
return new NowPlaying(
|
||||||
|
o.optString("title"),
|
||||||
|
o.optString("artist"),
|
||||||
|
o.optString("album"),
|
||||||
|
o.optString("artworkUrl"),
|
||||||
|
o.optBoolean("playing"),
|
||||||
|
Math.max(0, o.optLong("positionMs")),
|
||||||
|
Math.max(0, o.optLong("durationMs")));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
47
android/android/app/src/main/java/app/sonda/SondaNative.java
Normal file
47
android/android/app/src/main/java/app/sonda/SondaNative.java
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
package app.sonda;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.webkit.JavascriptInterface;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the web page can ask of the app. A WebView has no Media Session API, so the page tells the app what plays
|
||||||
|
* and the app keeps a notification with the controls, and the playback alive while the screen is off.
|
||||||
|
* It is on every page the WebView loads, which is the server the person chose.
|
||||||
|
*/
|
||||||
|
final class SondaNative {
|
||||||
|
private final Activity activity;
|
||||||
|
private boolean askedForNotifications = false;
|
||||||
|
|
||||||
|
SondaNative(Activity activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void update(String json) {
|
||||||
|
NowPlaying now = NowPlaying.parse(json);
|
||||||
|
if (now == null) return;
|
||||||
|
activity.runOnUiThread(() -> {
|
||||||
|
askForNotifications();
|
||||||
|
MediaService.show(activity, now);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void stop() {
|
||||||
|
activity.runOnUiThread(() -> MediaService.end(activity));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** From Android 13 a notification needs a yes. Without it the playback goes on, only the notification is hidden. */
|
||||||
|
private void askForNotifications() {
|
||||||
|
if (askedForNotifications || Build.VERSION.SDK_INT < 33) return;
|
||||||
|
askedForNotifications = true;
|
||||||
|
if (ContextCompat.checkSelfPermission(activity, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
ActivityCompat.requestPermissions(activity, new String[] {Manifest.permission.POST_NOTIFICATIONS}, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
android/android/app/src/main/res/drawable/ic_stat_sonda.xml
Normal file
10
android/android/app/src/main/res/drawable/ic_stat_sonda.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M12,3v10.55c-0.59,-0.34 -1.27,-0.55 -2,-0.55 -2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4V7h4V3h-6z" />
|
||||||
|
</vector>
|
||||||
6
android/android/app/src/main/res/drawable/splash.xml
Normal file
6
android/android/app/src/main/res/drawable/splash.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<color android:color="#08161D" />
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
12
android/android/app/src/main/res/layout/activity_main.xml
Normal file
12
android/android/app/src/main/res/layout/activity_main.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue