Improve Android app UI and controller flows

This commit is contained in:
2026-10-09 16:43:58 +08:00
parent c0e26b97fe
commit 608229a497
90 changed files with 8103 additions and 1133 deletions
+34 -4
View File
@@ -249,6 +249,15 @@ class PaletteColorRequest(BaseModel):
color: str
class LayerAppendRequest(BaseModel):
model_config = ConfigDict(extra="forbid")
layer: dict[str, Any]
class FrameLayerAppendRequest(LayerAppendRequest):
frame_ids: list[str] = Field(min_length=1)
class TemplateCreateRequest(BaseModel):
name: str
scene: dict[str, Any]
@@ -353,6 +362,7 @@ class TextRequest(BaseModel):
class TextLayerRequest(BaseModel):
edit_size: Literal[64, 192] = 64
text: str = Field(min_length=0, max_length=512)
font: str = "default"
size: int = 12
@@ -1337,6 +1347,23 @@ def create_app(
except TemplateError as exc:
raise template_error(exc) from exc
@app.post("/api/templates/{template_id}/layers")
def append_template_layer(template_id: str, request: LayerAppendRequest, if_match: str | None = Header(default=None, alias="If-Match")) -> dict:
try:
if template_id == DEMO_STATIC_ID:
raise TemplateConflictError(DEMO_RESTRICTED_MESSAGE)
return templates.append_layer(template_id, request.layer, normalize_if_match(if_match))
except TemplateError as exc:
raise template_error(exc) from exc
@app.post("/api/animations/{animation_id}/frames/layers")
def append_animation_layer(animation_id: str, request: FrameLayerAppendRequest, if_match: str | None = Header(default=None, alias="If-Match")) -> dict:
try:
reject_demo_animation(animation_id)
return animations.append_layer(animation_id, request.layer, request.frame_ids, normalize_if_match(if_match))
except TemplateError as exc:
raise template_error(exc) from exc
@app.put("/api/templates/{template_id}")
def update_template(
template_id: str,
@@ -1344,7 +1371,8 @@ def create_app(
if_match: str | None = Header(default=None, alias="If-Match"),
) -> dict:
try:
reject_demo_template(template_id)
if template_id == DEMO_STATIC_ID:
raise TemplateConflictError(DEMO_RESTRICTED_MESSAGE)
return templates.update_scene(template_id, request.scene, normalize_if_match(if_match))
except TemplateError as exc:
raise template_error(exc) from exc
@@ -1356,7 +1384,8 @@ def create_app(
if_match: str | None = Header(default=None, alias="If-Match"),
) -> dict:
try:
reject_demo_template(template_id)
if template_id == DEMO_STATIC_ID:
raise TemplateConflictError(DEMO_RESTRICTED_MESSAGE)
return templates.rename(template_id, request.name, normalize_if_match(if_match))
except TemplateError as exc:
raise template_error(exc) from exc
@@ -1408,7 +1437,8 @@ def create_app(
if_match: str | None = Header(default=None, alias="If-Match"),
) -> dict:
try:
reject_demo_template(template_id)
if template_id == DEMO_STATIC_ID:
raise TemplateConflictError(DEMO_RESTRICTED_MESSAGE)
expected = normalize_if_match(if_match)
current = templates.get(template_id)
if current["revision"] != expected:
@@ -1909,7 +1939,7 @@ def create_app(
try:
image = render_text_layer(
text_layer_options_from_request(request),
size=(display.width, display.height),
size=(request.edit_size, request.edit_size),
font_resolver=fonts.resolve,
)
return image_png_response(image)