summaryrefslogtreecommitdiff
path: root/src/us/minak/SettingsUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/us/minak/SettingsUtil.java')
-rw-r--r--src/us/minak/SettingsUtil.java19
1 files changed, 19 insertions, 0 deletions
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) {