Files
kidstube/AGENTS.md
T
lotherk ec3fd61756 KidsTube: offline iOS-look kids player for local videos
Scaffold and first working build of an Android app that reproduces the iOS
YouTube Kids interface over a local folder: shelves of 16:9 rounded
thumbnails, fullscreen player, bottom bar, search grid and a parent gate.

- minSdk 21, AGP 8.13.2 / Gradle 8.13 / Kotlin 2.1.20, compileSdk 35
- library from Movies/KidsTube via MediaStore, or a SAF tree the parent picks
- no INTERNET permission: verified against the built APK with aapt2
- thumbnails decoded once into filesDir and cached, never on the bind path
- player: VideoView, immersive, chrome auto-hides, tap_catcher restores it

Verified on the AGS2-W09 (API 30): shelves with real frames, playback,
search filtering, parent gate, back navigation.
2026-10-28 13:51:10 +00:00

5.4 KiB

KidsTube

Android app that reproduces the iOS YouTube Kids interface — thumbnail shelves, fullscreen player, bottom bar — while playing video from a local folder only. No network, no account, no recommendations. It exists because the son accepts the iOS kids UI and rejects the Android one, so this is a convincing shell around local files. Floor: Android 5.0 / API 21. App name: KidsTube.

State 2026-10-28: builds, installs and plays on the target tablet; shelves, search, player and the parent gate were verified on the device.

Non-negotiables

  • No network. The APK must carry no INTERNET permission and no HTTP client: unzip -p app/build/outputs/apk/debug/app-debug.apk AndroidManifest.xml | strings | grep -ci internet must print 0, and /home/lotherk/android-sdk/build-tools/35.0.0/aapt2 dump permissions app/build/outputs/apk/debug/app-debug.apk must list only the two storage permissions.
  • minSdk stays 21. Check any new AAR's minSdk before adding it — much of current androidx sits at 23+.
  • When the choice is "Material default" vs "the iOS app's proportions", take iOS.

Environment (this machine, verified)

  • JDK 21 (/usr/lib/jvm/java-21-openjdk-amd64); no JDK 8 or 17 installed.
  • SDK lives in /home/lotherk/android-sdk (user-local). The distro's /usr/lib/android-sdk has no platforms/ or build-tools/, and its bundled sdkmanager/apkanalyzer die on JDK 21 with NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema (JAXB removed in JDK 11) — do not use it.
  • gradle is not on PATH; the standalone distribution is /home/lotherk/android-tools/gradle-8.13. The wrapper is pinned to 8.13 and local.properties points at the SDK.
  • AGP 8.13.2, Kotlin 2.1.20, compileSdk 35, build-tools 35.0.0. AGP 8.13 requires Gradle >= 8.13, Build-Tools >= 35.0.0, JDK >= 17.

Build, install, run

export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
export ANDROID_HOME=/home/lotherk/android-sdk

./gradlew :app:assembleDebug          # apk -> app/build/outputs/apk/debug/
./gradlew :app:lintDebug              # must stay green; abortOnError = true
adb install -r app/build/outputs/apk/debug/app-debug.apk
adb shell pm grant dev.lotherk.kidstube android.permission.READ_EXTERNAL_STORAGE
adb shell am start -n dev.lotherk.kidstube/.ui.MainActivity
adb exec-out screencap -p > /tmp/kt.png
adb logcat -d | grep -E 'kidstube|AndroidRuntime'

Target device: Huawei AGS2-W09, LineageOS 18.1 (18.1-20220523-UNOFFICIAL-prague), Android 11 / API 30, arm64-v8a, 1200x1920 at 480 dpi = 400dp wide. API 21 cannot be exercised here — that needs an emulator image and none is installed.

Content

The library is Movies/KidsTube (/storage/emulated/0/Movies/KidsTube), scanned through MediaStore; a SAF tree picked from the Profile screen takes precedence. Copy files with

adb push video.mp4 /sdcard/Movies/KidsTube/
adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///sdcard/Movies/KidsTube/video.mp4

The broadcast is not optional: a pushed file stays invisible until MediaStore indexes it, and from API 29 scoped storage forbids directory listing (the app uid gets EACCES), so there is no fallback route.

Layout and conventions

  • data/ — Library (SAF tree, else MediaStore; folder grouping; MediaItem carries a sha1 key), MediaItem.
  • media/ThumbCache — decode via MediaMetadataRetriever, write JPEGs to filesDir/thumbs, LruCache in memory, 3-thread pool, tag-guarded binds.
  • ui/ — MainActivity (shelves, search grid, parent gate), SectionAdapter (vertical shelves, each a horizontal RecyclerView), VideoAdapter (modes HERO / CAROUSEL / GRID), PlayerActivity (VideoView, immersive, auto-hiding chrome), ThumbView.
  • ThumbView owns the two numbers the look depends on — 16:9 and 12dp corner radius — plus the duration pill. Never re-implement them per layout.
  • Kotlin + Views + AppCompat, single :app module, viewBinding, no Compose. Every dimension in dp/sp, designed against 400dp width.

Pitfalls

  • reload() must treat "no SAF tree, storage permission granted" as a valid source. Gating on the tree alone silently shows an empty home screen.
  • VideoView swallows touches, so its OnClickListener never fires; the player uses a transparent tap_catcher view above it to bring the chrome back.
  • Tint AppCompat widgets with app:tint, never android:tint — lint fails the build on UseAppTint, and the vector drawables are white by default, so a missing tint makes an icon invisible rather than obviously wrong.
  • The system "Viewing full screen" confirmation appears on first launch and holds focus — dismiss it before trusting any UI dump.
  • uiautomator dump takes seconds here, longer than the 4s chrome timeout, so a dump right after a tap shows stale state. Screenshot instead.
  • adbd on the device crash-loops (Could not install *smartsocket* listener); a dropped adb connection is the device, not the app. Reconnect and check sys.boot_completed.
  • The tablet randomly brings up the camera app between commands. Force-stop com.android.camera2 and restart the activity if the focus looks wrong.
  • File paths: /storage/emulated/0 is the real mount; /sdcard works for ls but not for df.

Repo

Initialised locally (one commit), no remote yet; Konrad's convention is origin = hiddenbox when one is added. Short imperative commit subjects, no conventional-commit prefixes.