forked from trav/lintunes
v0.19.0: andTunes plays music on the Rabbit
The Android half of andTunes had been paused on a 1 GB toolchain download (Gradle wrapper, Android Gradle Plugin, Kotlin). None of that was needed: platform 33 and build-tools 34 were already in ~/Android/Sdk, and an app that links no libraries needs five SDK steps, not a build system. andtunes/build.py runs aapt2 -> javac -> R8 -> zipalign -> apksigner and produces a 61 KiB APK. andTunes 0.1.0 is framework-only Java: a six-tile menu that loads nothing, a streaming library.json parse grouped into artists and albums in one pass, one ListActivity for every list (songs and artist songs open with Shuffle all, albums carry art thumbs, search as you type), a Now playing bar under every list, and a white Now Playing screen with square art, a slim scrubber, prev/play/next, shuffle and repeat, and no back button. A foreground PlaybackService owns the queue: audio focus, becoming-noisy, MediaSession and a MediaStyle notification, end of queue pauses, missing files skip, and the last queue and position come back on launch. Black on white, and every size doubled for the R1's override density. Cold start to the menu: 313-338 ms. The scroll wheel turned out to be DPAD_UP/DOWN (stock Generic.kl), not volume. The app takes both in dispatchKeyEvent: lists scroll a row per detent, and the menu and Now Playing get volume. LinTunes side: Connections > Install andTunes on Rabbit... installs the committed APK over adb and grants all-files access, or copies it to Download/ over MTP when there's no adb. Sync fills Buttons/ with default artwork only where a file is missing, so trav's own art is never overwritten. Verified against the dev library only, synced to the R1 and driven with adb input + screencap. Claude-Session: https://claude.ai/code/session_01KSsYtRn4WZx6xj4GEdVPt9
This commit is contained in:
@@ -11,6 +11,7 @@ from PyQt6.QtGui import QAction, QKeySequence
|
||||
|
||||
from lintunes import device_sync, mpris, music_folder, tagging, theme, url_import
|
||||
from lintunes.andtunes import layout as andtunes_layout
|
||||
from lintunes.andtunes import install as andtunes_install
|
||||
from lintunes.andtunes import sync as andtunes_sync
|
||||
from lintunes.art_search import AlbumArtFetcher
|
||||
from lintunes.cast.controller import CastController
|
||||
@@ -162,6 +163,7 @@ class MainWindow(QMainWindow):
|
||||
self.statusBar().addPermanentWidget(self._sync_progress)
|
||||
self._sync_worker = None
|
||||
self._andtunes_worker = None
|
||||
self._install_worker = None
|
||||
self._sync_device_name = ""
|
||||
# Export shares the status-bar progress widgets with device sync —
|
||||
# only one of the two may run at a time (each guards on the other).
|
||||
@@ -357,6 +359,9 @@ class MainWindow(QMainWindow):
|
||||
self._andtunes_action.setEnabled(False)
|
||||
self._add_action(connections_menu, "Rabbit Sync Settings…", "",
|
||||
self._show_device_sync_settings)
|
||||
self._install_action = self._add_action(
|
||||
connections_menu, "Install andTunes on Rabbit…", "",
|
||||
self._install_andtunes)
|
||||
connections_menu.addSeparator()
|
||||
# The per-playlist sync stays until andTunes can actually play a
|
||||
# song: it is what feeds Auxio, and pulling it in the same round that
|
||||
@@ -406,6 +411,13 @@ class MainWindow(QMainWindow):
|
||||
# Whole-library sync doesn't care which view is open — only that a
|
||||
# device is plugged in and at least one playlist is ticked.
|
||||
self._andtunes_action.setEnabled(not busy and device is not None)
|
||||
# Enabled whenever there's an APK to offer; the click finds the
|
||||
# Rabbit (adb or MTP) and says so if it can't — cheaper than asking
|
||||
# adb on every menu open.
|
||||
self._install_action.setEnabled(
|
||||
andtunes_install.bundled_apk() is not None
|
||||
and not (self._install_worker is not None
|
||||
and self._install_worker.busy()))
|
||||
|
||||
if self._cast.is_connected():
|
||||
self._cast_action.setText(
|
||||
@@ -657,6 +669,75 @@ class MainWindow(QMainWindow):
|
||||
msg += f", {summary['skipped']} skipped (no local file)"
|
||||
self.statusBar().showMessage(msg, 10000)
|
||||
|
||||
# ---- connections: install the andTunes app ----
|
||||
|
||||
def _install_andtunes(self):
|
||||
if self._install_worker is not None and self._install_worker.busy():
|
||||
return
|
||||
apk = andtunes_install.bundled_apk()
|
||||
if apk is None:
|
||||
return
|
||||
adb = andtunes_install.adb_path()
|
||||
serial = andtunes_install.rabbit_serial(adb) if adb else None
|
||||
device = device_sync.find_device()
|
||||
if serial is None and device is None:
|
||||
QMessageBox.information(
|
||||
self, "Rabbit not found",
|
||||
"Plug the Rabbit in with USB debugging on, or in "
|
||||
"File transfer mode, then try again.")
|
||||
return
|
||||
|
||||
ours = andtunes_install.bundled_version()
|
||||
ours_name = ours.get("version_name", "?")
|
||||
if serial:
|
||||
have = andtunes_install.installed_version(adb, serial)
|
||||
if have is None:
|
||||
verb = "Install"
|
||||
detail = f"Install andTunes {ours_name} on the Rabbit?"
|
||||
elif have["version_code"] < ours.get("version_code", 0):
|
||||
verb = "Update"
|
||||
detail = (f"The Rabbit has andTunes {have['version_name']}; "
|
||||
f"this LinTunes carries {ours_name}. Update it?")
|
||||
else:
|
||||
verb = "Reinstall"
|
||||
detail = (f"The Rabbit already has andTunes "
|
||||
f"{have['version_name']}. Reinstall {ours_name}?")
|
||||
else:
|
||||
verb = "Copy"
|
||||
detail = ("adb isn't available, so the app will be copied to "
|
||||
"Download/ on the Rabbit for you to open in the Files "
|
||||
"app and install by hand. Copy it?")
|
||||
box = QMessageBox(self)
|
||||
box.setWindowTitle(f"{verb} andTunes")
|
||||
box.setText(detail)
|
||||
go = box.addButton(verb, QMessageBox.ButtonRole.AcceptRole)
|
||||
box.addButton(QMessageBox.StandardButton.Cancel)
|
||||
box.setDefaultButton(go)
|
||||
box.exec()
|
||||
if box.clickedButton() is not go:
|
||||
return
|
||||
|
||||
self._install_worker = andtunes_install.InstallWorker(
|
||||
apk, adb, serial, device, self)
|
||||
self._install_worker.finished.connect(self._on_install_finished)
|
||||
self._install_worker.failed.connect(
|
||||
lambda message: QMessageBox.warning(self, "andTunes", message))
|
||||
self.statusBar().showMessage("Installing andTunes on the Rabbit…")
|
||||
self._install_worker.start()
|
||||
|
||||
def _on_install_finished(self, result):
|
||||
if result["method"] == "copied":
|
||||
self.statusBar().clearMessage()
|
||||
QMessageBox.information(
|
||||
self, "andTunes copied",
|
||||
f"Copied to {result['path']}.\n\nOn the Rabbit, open Files → "
|
||||
"Download → andTunes.apk to install it.")
|
||||
return
|
||||
msg = "andTunes is installed on the Rabbit"
|
||||
if not result.get("granted", True):
|
||||
msg += " — open it once to allow file access"
|
||||
self.statusBar().showMessage(msg, 8000)
|
||||
|
||||
# ---- export ----
|
||||
|
||||
def _refresh_export_action(self):
|
||||
|
||||
Reference in New Issue
Block a user