summaryrefslogtreecommitdiff
path: root/src/us
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-05-04 22:27:46 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-05-04 22:27:46 -0400
commit604905937c8d4a1db42a34a61973d4c4490c3403 (patch)
tree6cfa9c7bf563d23c45a1956bbbc7f4438689d0d0 /src/us
parent8001e3284e069dded37a1aa42b25c201102b9460 (diff)
grr
Diffstat (limited to 'src/us')
-rw-r--r--src/us/minak/CreateGestureActivity.java2
-rw-r--r--src/us/minak/OnCharacterEnteredListener.java5
-rw-r--r--src/us/minak/SettingsActivity.java37
-rw-r--r--src/us/minak/SettingsUtil.java22
4 files changed, 43 insertions, 23 deletions
diff --git a/src/us/minak/CreateGestureActivity.java b/src/us/minak/CreateGestureActivity.java
index 6844b36..19fbc83 100644
--- a/src/us/minak/CreateGestureActivity.java
+++ b/src/us/minak/CreateGestureActivity.java
@@ -83,7 +83,7 @@ public class CreateGestureActivity extends Activity {
return;
}
- final GestureLibrary store = SettingsActivity.getStore();
+ final GestureLibrary store = SettingsUtil.getGestureLibrary(this);
store.addGesture(name.toString(), mGesture);
store.save();
diff --git a/src/us/minak/OnCharacterEnteredListener.java b/src/us/minak/OnCharacterEnteredListener.java
new file mode 100644
index 0000000..82226b6
--- /dev/null
+++ b/src/us/minak/OnCharacterEnteredListener.java
@@ -0,0 +1,5 @@
+package us.minak;
+
+public interface OnCharacterEnteredListener {
+ void characterEntered(String character);
+} \ No newline at end of file
diff --git a/src/us/minak/SettingsActivity.java b/src/us/minak/SettingsActivity.java
index b366826..30b1e7b 100644
--- a/src/us/minak/SettingsActivity.java
+++ b/src/us/minak/SettingsActivity.java
@@ -27,9 +27,8 @@ import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.LayoutInflater;
import android.view.ViewGroup;
-import android.gesture.GestureLibrary;
import android.gesture.Gesture;
-import android.gesture.GestureLibraries;
+import android.gesture.GestureLibrary;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.AdapterView;
@@ -49,7 +48,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Comparator;
import java.util.Set;
-import java.io.File;
public class SettingsActivity extends ListActivity {
private static final int STATUS_SUCCESS = 0;
@@ -67,16 +65,12 @@ public class SettingsActivity extends ListActivity {
// Type: long (id)
private static final String GESTURES_INFO_ID = "gestures.info_id";
- private final File mStoreFile = new File(Environment.getExternalStorageDirectory(), "gestures");
-
private final Comparator<NamedGesture> mSorter = new Comparator<NamedGesture>() {
public int compare(NamedGesture object1, NamedGesture object2) {
return object1.name.compareTo(object2.name);
}
};
- private static GestureLibrary sStore;
-
private GesturesAdapter mAdapter;
private GesturesLoadTask mTask;
private TextView mEmpty;
@@ -85,6 +79,12 @@ public class SettingsActivity extends ListActivity {
private EditText mInput;
private NamedGesture mCurrentRenameGesture;
+ private SettingsActivity mThis;
+ public SettingsActivity() {
+ super();
+ mThis = this;
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -94,19 +94,12 @@ public class SettingsActivity extends ListActivity {
mAdapter = new GesturesAdapter(this);
setListAdapter(mAdapter);
- if (sStore == null) {
- sStore = GestureLibraries.fromFile(mStoreFile);
- }
mEmpty = (TextView) findViewById(android.R.id.empty);
loadGestures();
registerForContextMenu(getListView());
}
- static GestureLibrary getStore() {
- return sStore;
- }
-
public void reloadGestures(View v) {
loadGestures();
}
@@ -169,9 +162,9 @@ public class SettingsActivity extends ListActivity {
long id = state.getLong(GESTURES_INFO_ID, -1);
if (id != -1) {
- final Set<String> entries = sStore.getGestureEntries();
+ final Set<String> entries = SettingsUtil.getGestureLibrary(this).getGestureEntries();
out: for (String name : entries) {
- for (Gesture gesture : sStore.getGestures(name)) {
+ for (Gesture gesture : SettingsUtil.getGestureLibrary(this).getGestures(name)) {
if (gesture.getID() == id) {
mCurrentRenameGesture = new NamedGesture();
mCurrentRenameGesture.name = name;
@@ -279,9 +272,9 @@ out: for (String name : entries) {
for (int i = 0; i < count; i++) {
final NamedGesture gesture = adapter.getItem(i);
if (gesture.gesture.getID() == renameGesture.gesture.getID()) {
- sStore.removeGesture(gesture.name, gesture.gesture);
+ SettingsUtil.getGestureLibrary(this).removeGesture(gesture.name, gesture.gesture);
gesture.name = mInput.getText().toString();
- sStore.addGesture(gesture.name, gesture.gesture);
+ SettingsUtil.getGestureLibrary(this).addGesture(gesture.name, gesture.gesture);
break;
}
}
@@ -300,8 +293,8 @@ out: for (String name : entries) {
}
private void deleteGesture(NamedGesture gesture) {
- sStore.removeGesture(gesture.name, gesture.gesture);
- sStore.save();
+ SettingsUtil.getGestureLibrary(this).removeGesture(gesture.name, gesture.gesture);
+ SettingsUtil.getGestureLibrary(this).save();
final GesturesAdapter adapter = mAdapter;
adapter.setNotifyOnChange(false);
@@ -341,7 +334,7 @@ out: for (String name : entries) {
return STATUS_NO_STORAGE;
}
- final GestureLibrary store = sStore;
+ final GestureLibrary store = SettingsUtil.getGestureLibrary(mThis);
if (store.load()) {
for (String name : store.getGestureEntries()) {
@@ -388,7 +381,7 @@ out: for (String name : entries) {
getListView().setVisibility(View.GONE);
mEmpty.setVisibility(View.VISIBLE);
mEmpty.setText(getString(R.string.gestures_error_loading,
- mStoreFile.getAbsolutePath()));
+ SettingsUtil.getGestureFile(mThis).getAbsolutePath()));
} else {
findViewById(R.id.addButton).setEnabled(true);
findViewById(R.id.reloadButton).setEnabled(true);
diff --git a/src/us/minak/SettingsUtil.java b/src/us/minak/SettingsUtil.java
new file mode 100644
index 0000000..c3c0603
--- /dev/null
+++ b/src/us/minak/SettingsUtil.java
@@ -0,0 +1,22 @@
+package us.minak;
+
+import android.content.ContextWrapper;
+import android.gesture.GestureLibrary;
+import android.gesture.GestureLibraries;
+import java.io.File;
+
+public class SettingsUtil {
+ private static File sGestureFile = null;
+ private static GestureLibrary sGestureLibrary = null;
+
+ public static File getGestureFile(ContextWrapper context) {
+ if (sGestureFile == null)
+ sGestureFile = new File(context.getExternalFilesDir(null), "gestures.ttf");
+ return sGestureFile;
+ }
+ public static GestureLibrary getGestureLibrary(ContextWrapper context) {
+ if (sGestureLibrary == null)
+ sGestureLibrary = GestureLibraries.fromFile(getGestureFile(context));
+ return sGestureLibrary;
+ }
+}