From 997b7be4c005696df91dc1833b4fb4db6c984991 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 18 Nov 2024 00:13:08 +0100 Subject: launcher: Animated vector describing swipe gesture Replace the short video with an animated vector image that shows the swipe gesture. This is much lighter and reliable than the mp4 video, which failed to play on many devices. Source for the image of the key is in inkscape SVG format in srcs/res and is converted to an android drawable when needed. The swipe animation is hand-written. --- srcs/res/SvgToVector.java | 32 +++++++ srcs/res/doc_key.svg | 192 ++++++++++++++++++++++++++++++++++++++ srcs/res/gen_doc_key_drawables.sh | 25 +++++ 3 files changed, 249 insertions(+) create mode 100644 srcs/res/SvgToVector.java create mode 100644 srcs/res/doc_key.svg create mode 100644 srcs/res/gen_doc_key_drawables.sh (limited to 'srcs/res') diff --git a/srcs/res/SvgToVector.java b/srcs/res/SvgToVector.java new file mode 100644 index 0000000..78486fe --- /dev/null +++ b/srcs/res/SvgToVector.java @@ -0,0 +1,32 @@ +package srcs.res; + +import com.android.ide.common.vectordrawable.Svg2Vector; +import java.io.File; +import java.io.FileOutputStream; + +/** Inspired from Bernard Ladenthin's answer: + https://stackoverflow.com/a/78898372 */ +public class SvgToVector +{ + public static void main(String[] args) + { + if (args.length != 2) + { + System.out.println("Usage: svg_to_vector "); + return; + } + try + { + File input_file = new File(args[0]); + FileOutputStream output_stream = new FileOutputStream(args[1]); + String warnings; + warnings = Svg2Vector.parseSvgToXml(input_file, output_stream); + System.err.println(warnings); + } + catch (Exception e) + { + e.printStackTrace(); + System.exit(2); + } + } +} diff --git a/srcs/res/doc_key.svg b/srcs/res/doc_key.svg new file mode 100644 index 0000000..73e6a2a --- /dev/null +++ b/srcs/res/doc_key.svg @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + u + & + 7 + + + + + + _ + g + - + + diff --git a/srcs/res/gen_doc_key_drawables.sh b/srcs/res/gen_doc_key_drawables.sh new file mode 100644 index 0000000..ff89793 --- /dev/null +++ b/srcs/res/gen_doc_key_drawables.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -e +cd "$(dirname $0)" + +DRAWABLE_DIR=../../res/drawable +ANDROID_LIB=$ANDROID_SDK_ROOT/tools/lib + +first () { echo "$1"; } +JAVA_ARGS=( + -classpath + "$(first $ANDROID_LIB/sdk-common-*.jar):$(first $ANDROID_LIB/common-*.jar)" +) +svg_to_vector () +{ + java "${JAVA_ARGS[@]}" SvgToVector.java "$@" +} + +TMP=`mktemp -d` +trap "rm -r '$TMP'" EXIT +set -x + +inkscape doc_key.svg -o "$TMP/doc_key_u.svg" -C --export-page 2 --export-plain-svg --export-text-to-path + +svg_to_vector "$TMP/doc_key_u.svg" "$DRAWABLE_DIR/doc_key_u.xml" -- cgit v1.2.3