diff --git a/soup/build.gradle b/soup/build.gradle
index 678e0cb..02baf42 100644
--- a/soup/build.gradle
+++ b/soup/build.gradle
@@ -27,8 +27,8 @@ android {
applicationId "com.thunsaker.soup"
minSdkVersion 9
targetSdkVersion 19
- versionCode 25
- versionName "2.6.2"
+ versionCode 26
+ versionName "2.6.3"
resConfigs "en", "es", "fr", "pt", "ru"
}
@@ -98,4 +98,5 @@ dependencies {
compile 'com.squareup:android-times-square:1.2.1@aar'
compile 'com.tundem.aboutlibraries:library:3.0.0@aar'
+ compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
}
\ No newline at end of file
diff --git a/soup/src/androidTest/java/com/thunsaker/soup/data/CategoriesDataSourceTest.java b/soup/src/androidTest/java/com/thunsaker/soup/data/CategoriesDataSourceTest.java
new file mode 100644
index 0000000..4edde9a
--- /dev/null
+++ b/soup/src/androidTest/java/com/thunsaker/soup/data/CategoriesDataSourceTest.java
@@ -0,0 +1,7 @@
+package com.thunsaker.soup.data;
+
+import android.test.InstrumentationTestCase;
+
+public class CategoriesDataSourceTest extends InstrumentationTestCase {
+
+}
diff --git a/soup/src/main/assets/categories.db b/soup/src/main/assets/categories.db
new file mode 100644
index 0000000..e69de29
diff --git a/soup/src/main/java/com/thunsaker/soup/data/CategoriesDataSource.java b/soup/src/main/java/com/thunsaker/soup/data/CategoriesDataSource.java
new file mode 100644
index 0000000..90f67bf
--- /dev/null
+++ b/soup/src/main/java/com/thunsaker/soup/data/CategoriesDataSource.java
@@ -0,0 +1,57 @@
+package com.thunsaker.soup.data;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+
+import java.sql.SQLException;
+
+public class CategoriesDataSource {
+ private SQLiteDatabase db;
+ private CategoriesDb dbHelper;
+ private String[] catColumns = { CategoriesDb.COLUMN_ID, CategoriesDb.COLUMN_FOURSQUARE_ID, CategoriesDb.COLUMN_NAME, CategoriesDb.COLUMN_PARENT };
+
+ public CategoriesDataSource (Context context) {
+ dbHelper = new CategoriesDb(context);
+ }
+
+ public void open() throws SQLException {
+ db = dbHelper.getWritableDatabase();
+ }
+
+ public void close() {
+ dbHelper.close();
+ }
+
+ public CategoryInfo createCategoryInfo(String categoryId, String name) {
+ return this.createCategoryInfo(categoryId, name, "");
+ }
+
+ public CategoryInfo createCategoryInfo(String categoryId, String name, String parentId) {
+ ContentValues vals = new ContentValues();
+ vals.put(CategoriesDb.COLUMN_FOURSQUARE_ID, categoryId);
+ vals.put(CategoriesDb.COLUMN_NAME, name);
+ vals.put(CategoriesDb.COLUMN_PARENT, parentId);
+ long insertId = db.insert(CategoriesDb.TABLE_CATEGORIES, null, vals);
+ Cursor cursor = db.query(CategoriesDb.TABLE_CATEGORIES, catColumns, CategoriesDb.COLUMN_ID + " = " + insertId, null, null, null, null);
+ cursor.moveToFirst();
+ CategoryInfo newCatInfo = cursorToCategory(cursor);
+ cursor.close();
+ return newCatInfo;
+ }
+
+ public void deleteCategoryInfo(String foursquareCategoryId) throws SQLException {
+ db.delete(CategoriesDb.TABLE_CATEGORIES, CategoriesDb.COLUMN_FOURSQUARE_ID + " = " + foursquareCategoryId, null);
+ }
+
+ private CategoryInfo cursorToCategory(Cursor cursor) {
+ CategoryInfo catInfo = new CategoryInfo();
+ catInfo.id = cursor.getLong(0);
+ catInfo.categoryId = cursor.getString(1);
+ catInfo.name = cursor.getString(2);
+ // TODO: This may be empty, if no parent is given
+ catInfo.parentId = cursor.getString(3);
+ return catInfo;
+ }
+}
\ No newline at end of file
diff --git a/soup/src/main/java/com/thunsaker/soup/data/CategoriesDb.java b/soup/src/main/java/com/thunsaker/soup/data/CategoriesDb.java
new file mode 100644
index 0000000..c0ea5ed
--- /dev/null
+++ b/soup/src/main/java/com/thunsaker/soup/data/CategoriesDb.java
@@ -0,0 +1,25 @@
+package com.thunsaker.soup.data;
+
+import android.content.Context;
+
+import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
+
+public class CategoriesDb extends SQLiteAssetHelper {
+ private static final String DATABASE_NAME = "categories.db";
+ private static final int DATABASE_VERSION = 1;
+
+ public static final String TABLE_CATEGORIES = "categories";
+ public static final String COLUMN_ID = "_id";
+ public static final String COLUMN_FOURSQUARE_ID = "foursquareId";
+ public static final String COLUMN_NAME = "name";
+ public static final String COLUMN_PARENT = "parentId";
+ // Consider adding the category color here.
+
+ private static final String DATABASE_CREATE =
+ String.format("create table %s (%s integer primary key autoincrement, %s text not null, %s text not null, %s);",
+ TABLE_CATEGORIES, COLUMN_ID, COLUMN_FOURSQUARE_ID, COLUMN_NAME, COLUMN_PARENT);
+
+ public CategoriesDb(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ }
+}
diff --git a/soup/src/main/java/com/thunsaker/soup/data/CategoryInfo.java b/soup/src/main/java/com/thunsaker/soup/data/CategoryInfo.java
new file mode 100644
index 0000000..cc15ed7
--- /dev/null
+++ b/soup/src/main/java/com/thunsaker/soup/data/CategoryInfo.java
@@ -0,0 +1,8 @@
+package com.thunsaker.soup.data;
+
+public class CategoryInfo {
+ public long id;
+ public String categoryId;
+ public String name;
+ public String parentId;
+}
diff --git a/soup/src/main/res/values/donottranslate.xml b/soup/src/main/res/values/donottranslate.xml
index cd3fe18..355dcc7 100644
--- a/soup/src/main/res/values/donottranslate.xml
+++ b/soup/src/main/res/values/donottranslate.xml
@@ -3,8 +3,8 @@
Soup
Soup Pro
Soup Dev
- 2.6.2
- Soup v.2.6.2
+ 2.6.3
+ Soup v.2.6.3
soup_foursquare_connected
soup_foursquare_token