diff --git a/build.gradle b/build.gradle
index 0cb6160..686f84f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -21,7 +21,7 @@ android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = ['srcs']
+ java.srcDirs = ['srcs/juloo.keyboard2']
res.srcDirs = ['res', 'build/generated-resources']
assets.srcDirs = ['assets']
}
diff --git a/res/drawable/doc_anim_swipe.xml b/res/drawable/doc_anim_swipe.xml
new file mode 100644
index 0000000..6e91d30
--- /dev/null
+++ b/res/drawable/doc_anim_swipe.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/drawable/doc_key_u.xml b/res/drawable/doc_key_u.xml
new file mode 100644
index 0000000..4a94fe2
--- /dev/null
+++ b/res/drawable/doc_key_u.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
diff --git a/res/layout/launcher_activity.xml b/res/layout/launcher_activity.xml
index 4e0cc0c..67b3eb6 100644
--- a/res/layout/launcher_activity.xml
+++ b/res/layout/launcher_activity.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/res/raw/intro_video.mp4 b/res/raw/intro_video.mp4
deleted file mode 100644
index 9eefe52..0000000
Binary files a/res/raw/intro_video.mp4 and /dev/null differ
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8705d98..56edbde 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -56,5 +56,12 @@
- 16dp
- center
+
diff --git a/srcs/juloo.keyboard2/LauncherActivity.java b/srcs/juloo.keyboard2/LauncherActivity.java
index 2ca241a..57c5e2b 100644
--- a/srcs/juloo.keyboard2/LauncherActivity.java
+++ b/srcs/juloo.keyboard2/LauncherActivity.java
@@ -3,11 +3,14 @@ package juloo.keyboard2;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
+import android.graphics.drawable.Animatable;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
import android.provider.Settings;
import android.view.KeyEvent;
import android.view.Menu;
@@ -15,28 +18,49 @@ import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
+import android.widget.ImageView;
import android.widget.TextView;
-import android.widget.VideoView;
+import java.util.ArrayList;
+import java.util.List;
-public class LauncherActivity extends Activity
+public class LauncherActivity extends Activity implements Handler.Callback
{
/** Text is replaced when receiving key events. */
- VideoView _intro_video;
TextView _tryhere_text;
EditText _tryhere_area;
+ /** Periodically restart the animations. */
+ List _animations;
+ Handler _handler;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.launcher_activity);
- _intro_video = (VideoView)findViewById(R.id.launcher_intro_video);
_tryhere_text = (TextView)findViewById(R.id.launcher_tryhere_text);
_tryhere_area = (EditText)findViewById(R.id.launcher_tryhere_area);
if (VERSION.SDK_INT >= 28)
_tryhere_area.addOnUnhandledKeyEventListener(
this.new Tryhere_OnUnhandledKeyEventListener());
- setup_intro_video(_intro_video);
+ }
+
+ @Override
+ public void onStart()
+ {
+ super.onStart();
+ _animations = new ArrayList();
+ _animations.add(find_anim(R.id.launcher_anim_swipe));
+ _handler = new Handler(getMainLooper(), this);
+ _handler.sendEmptyMessageDelayed(0, 500);
+ }
+
+ @Override
+ public boolean handleMessage(Message _msg)
+ {
+ for (Animatable anim : _animations)
+ anim.start();
+ _handler.sendEmptyMessageDelayed(0, 3000);
+ return true;
}
@Override
@@ -70,31 +94,10 @@ public class LauncherActivity extends Activity
imm.showInputMethodPicker();
}
- static void setup_intro_video(final VideoView v)
+ Animatable find_anim(int id)
{
- if (VERSION.SDK_INT >= 26)
- v.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE);
- v.setVideoURI(Uri.parse("android.resource://" +
- v.getContext().getPackageName() + "/" + R.raw.intro_video));
- v.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
- {
- @Override
- public void onPrepared(MediaPlayer mp)
- {
- mp.setLooping(true);
- }
- });
- v.setOnErrorListener(new MediaPlayer.OnErrorListener()
- {
- @Override
- public boolean onError(MediaPlayer mp, int what, int extra)
- {
- v.stopPlayback();
- v.setVisibility(View.GONE);
- return true;
- }
- });
- v.start();
+ ImageView img = (ImageView)findViewById(id);
+ return (Animatable)img.getDrawable();
}
@TargetApi(28)
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 @@
+
+
+
+
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"