summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-05-05 01:49:10 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-05-05 01:49:10 -0400
commit8a9dab5a8faa9659f8ba610b1b176ceb09a16640 (patch)
tree3520a32bd56151053846398ff4566c59e6bdb410
parentf6ac8024e9e111da85230332765d2e98cd090819 (diff)
Load the default gestures
-rw-r--r--res/raw/gestures.ttf (renamed from res/raw/gestures)bin93080 -> 93080 bytes
-rw-r--r--src/us/minak/SettingsUtil.java19
2 files changed, 19 insertions, 0 deletions
diff --git a/res/raw/gestures b/res/raw/gestures.ttf
index 3cc9d7c..3cc9d7c 100644
--- a/res/raw/gestures
+++ b/res/raw/gestures.ttf
Binary files 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) {