Musyx Mobile: Android TV player for Yandex Music
Kotlin, Compose for TV and Media3 port of the desktop Musyx, with device-code sign-in, Home, My Wave, search, collection, detail pages, Now Playing with queue and lyrics, and settings for streaming quality, appearance, font size (small, medium, large) and language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
46610d95fa
217 files changed
+26144
No files matched your search
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Draws the Android launcher assets from the shared design.
|
||||
|
||||
- The Android TV banner (320x180 px, drawable-xhdpi): the `musyx` wordmark in Unbounded
|
||||
SemiBold with the amber dot, centred on the dark `bg`, as in the desktop sidebar.
|
||||
- The launcher icons (mipmap-*dpi/ic_launcher.png), scaled from assets/icon/musyx.png
|
||||
(run tool/make_icon.py first if it changes).
|
||||
|
||||
Needs Pillow (pip install Pillow), unlike make_icon.py, because it sets type.
|
||||
Usage: python3 tool/make_tv_assets.py [app/src/main/res]
|
||||
"""
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
FONT = ROOT / "assets/fonts/Unbounded-SemiBold.ttf"
|
||||
ICON = ROOT / "assets/icon/musyx.png"
|
||||
|
||||
# DESIGN.md tokens (dark).
|
||||
BG = (0x1C, 0x1A, 0x22)
|
||||
FG = (0xEE, 0xEA, 0xF3)
|
||||
ACCENT = (0xF0, 0xB2, 0x3E)
|
||||
|
||||
BANNER = (320, 180)
|
||||
SUPERSAMPLE = 4
|
||||
# The wordmark is set at 20px with a 7px dot, 3px after the text, and -0.01em tracking.
|
||||
WORDMARK_PX = 20.0
|
||||
DOT, GAP, TRACKING = 7 / WORDMARK_PX, 3 / WORDMARK_PX, -0.01
|
||||
# Share of the banner width the wordmark spans.
|
||||
WIDTH_SHARE = 0.62
|
||||
|
||||
# Legacy launcher icon sizes, px per density bucket.
|
||||
MIPMAPS = {"mdpi": 48, "hdpi": 72, "xhdpi": 96, "xxhdpi": 144, "xxxhdpi": 192}
|
||||
# make_icon.py draws an 824px body on a 1024px canvas. Keep a thin margin around it.
|
||||
ICON_BODY, ICON_MARGIN = 824, 0.03
|
||||
|
||||
|
||||
def wordmark_width(font, em):
|
||||
advances = sum(font.getlength(c) for c in "musyx") + TRACKING * em * 4
|
||||
return advances + (GAP + DOT) * em
|
||||
|
||||
|
||||
def banner(out):
|
||||
w, h = (d * SUPERSAMPLE for d in BANNER)
|
||||
# Size the type so the whole wordmark spans WIDTH_SHARE of the banner.
|
||||
em = 100.0
|
||||
font = ImageFont.truetype(str(FONT), int(em))
|
||||
em *= w * WIDTH_SHARE / wordmark_width(font, em)
|
||||
font = ImageFont.truetype(str(FONT), round(em))
|
||||
total = wordmark_width(font, em)
|
||||
|
||||
img = Image.new("RGB", (w, h), BG)
|
||||
draw = ImageDraw.Draw(img)
|
||||
# Centre on the x-height band, which is what the eye reads for an all-lowercase word.
|
||||
x_height = font.getbbox("x", anchor="ls")[1]
|
||||
baseline = h / 2 - x_height / 2
|
||||
x = (w - total) / 2
|
||||
for c in "musyx":
|
||||
draw.text((x, baseline), c, font=font, fill=FG, anchor="ls")
|
||||
x += font.getlength(c) + TRACKING * em
|
||||
x += GAP * em - TRACKING * em
|
||||
d = DOT * em
|
||||
draw.ellipse((x, baseline - d, x + d, baseline), fill=ACCENT)
|
||||
|
||||
img = img.resize(BANNER, Image.LANCZOS)
|
||||
out.parent.mkdir(parents=True, exist_ok=True)
|
||||
img.save(out, optimize=True)
|
||||
|
||||
|
||||
def launcher_icons(res):
|
||||
src = Image.open(ICON).convert("RGBA")
|
||||
side = src.width
|
||||
pad = (side - ICON_BODY) / 2 - ICON_BODY * ICON_MARGIN
|
||||
body = src.crop((round(pad), round(pad), round(side - pad), round(side - pad)))
|
||||
for bucket, px in MIPMAPS.items():
|
||||
out = res / f"mipmap-{bucket}" / "ic_launcher.png"
|
||||
out.parent.mkdir(parents=True, exist_ok=True)
|
||||
body.resize((px, px), Image.LANCZOS).save(out, optimize=True)
|
||||
|
||||
|
||||
def main(res):
|
||||
res = Path(res)
|
||||
banner(res / "drawable-xhdpi" / "banner.png")
|
||||
launcher_icons(res)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1] if len(sys.argv) > 1 else ROOT / "app/src/main/res")
|
||||
Reference in new issue
Block a user