From 8a9dab5a8faa9659f8ba610b1b176ceb09a16640 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 5 May 2014 01:49:10 -0400 Subject: Load the default gestures --- res/raw/gestures | Bin 93080 -> 0 bytes res/raw/gestures.ttf | Bin 0 -> 93080 bytes src/us/minak/SettingsUtil.java | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+) delete mode 100644 res/raw/gestures create mode 100644 res/raw/gestures.ttf diff --git a/res/raw/gestures b/res/raw/gestures deleted file mode 100644 index 3cc9d7c..0000000 Binary files a/res/raw/gestures and /dev/null differ diff --git a/res/raw/gestures.ttf b/res/raw/gestures.ttf new file mode 100644 index 0000000..3cc9d7c Binary files /dev/null and b/res/raw/gestures.ttf differ diff --git a/src/us/minak/SettingsUtil.java b/src/us/minak/SettingsUtil.java index c3c0603..8fe710f 100644 --- a/src/us/minak/SettingsUtil.java +++ b/src/us/minak/SettingsUtil.java @@ -3,7 +3,11 @@ package us.minak; import android.content.ContextWrapper; import android.gesture.GestureLibrary; import android.gesture.GestureLibraries; + import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; public class SettingsUtil { private static File sGestureFile = null; @@ -12,6 +16,21 @@ public class SettingsUtil { public static File getGestureFile(ContextWrapper context) { if (sGestureFile == null) sGestureFile = new File(context.getExternalFilesDir(null), "gestures.ttf"); + // If the gestures file doesn't exist, copy the default gestures to it + if (!sGestureFile.exists()) { + try { + InputStream in = context.getResources().openRawResource(R.raw.gestures); + OutputStream out = new FileOutputStream(sGestureFile); + byte[] buf = new byte[1024]; + int len; + while ( (len = in.read(buf, 0, buf.length)) != -1) + out.write(buf, 0, len); + in.close(); + out.close(); + } catch (Exception e) { + // TODO: better error handling + } + } return sGestureFile; } public static GestureLibrary getGestureLibrary(ContextWrapper context) { -- cgit v1.2.3-54-g00ecf