From 0ecfbd3fb8277fe5cd91d9504a3f0685349e209b Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Mon, 25 Apr 2016 09:27:36 +0200 Subject: [PATCH] Implemented methods needed for chan support (no GUI yet, though) --- app/build.gradle | 13 ++++++++----- .../db/migration/V3.0__Update_table_address.sql | 1 + .../abit/repository/AndroidAddressRepository.java | 12 +++++++++++- .../ch/dissem/apps/abit/repository/SqlHelper.java | 4 +++- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 6 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 app/src/main/assets/db/migration/V3.0__Update_table_address.sql diff --git a/app/build.gradle b/app/build.gradle index b4bafb0..c2f57a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 23 - buildToolsVersion "23.0.2" + buildToolsVersion "23.0.3" defaultConfig { applicationId "ch.dissem.apps.abit" @@ -29,12 +29,12 @@ android { } } -ext.jabitVersion = '1.0.1' +ext.jabitVersion = '1.1.0-SNAPSHOT' dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.1.1' - compile 'com.android.support:support-v4:23.1.1' - compile 'com.android.support:design:23.1.1' + compile 'com.android.support:appcompat-v7:23.3.0' + compile 'com.android.support:support-v4:23.3.0' + compile 'com.android.support:design:23.3.0' compile "ch.dissem.jabit:jabit-core:$jabitVersion" compile "ch.dissem.jabit:jabit-networking:$jabitVersion" @@ -58,6 +58,9 @@ dependencies { compile 'io.github.yavski:fab-speed-dial:1.0.2' compile 'com.github.amlcurran.showcaseview:library:5.4.0' + + testCompile 'junit:junit:4.12' + testCompile 'org.mockito:mockito-core:1.10.19' } idea.module { diff --git a/app/src/main/assets/db/migration/V3.0__Update_table_address.sql b/app/src/main/assets/db/migration/V3.0__Update_table_address.sql new file mode 100644 index 0000000..01e036b --- /dev/null +++ b/app/src/main/assets/db/migration/V3.0__Update_table_address.sql @@ -0,0 +1 @@ +ALTER TABLE Address ADD COLUMN chan BIT NOT NULL DEFAULT '0'; diff --git a/app/src/main/java/ch/dissem/apps/abit/repository/AndroidAddressRepository.java b/app/src/main/java/ch/dissem/apps/abit/repository/AndroidAddressRepository.java index 1e51643..25c9b2a 100644 --- a/app/src/main/java/ch/dissem/apps/abit/repository/AndroidAddressRepository.java +++ b/app/src/main/java/ch/dissem/apps/abit/repository/AndroidAddressRepository.java @@ -52,6 +52,7 @@ public class AndroidAddressRepository implements AddressRepository { private static final String COLUMN_PUBLIC_KEY = "public_key"; private static final String COLUMN_PRIVATE_KEY = "private_key"; private static final String COLUMN_SUBSCRIBED = "subscribed"; + private static final String COLUMN_CHAN = "chan"; private final SqlHelper sql; @@ -88,6 +89,11 @@ public class AndroidAddressRepository implements AddressRepository { return find("private_key IS NOT NULL"); } + @Override + public List getChans() { + return find("chan = '1'"); + } + @Override public List getSubscriptions() { return find("subscribed = '1'"); @@ -117,7 +123,8 @@ public class AndroidAddressRepository implements AddressRepository { COLUMN_ALIAS, COLUMN_PUBLIC_KEY, COLUMN_PRIVATE_KEY, - COLUMN_SUBSCRIBED + COLUMN_SUBSCRIBED, + COLUMN_CHAN }; SQLiteDatabase db = sql.getReadableDatabase(); @@ -150,6 +157,7 @@ public class AndroidAddressRepository implements AddressRepository { } } address.setAlias(c.getString(c.getColumnIndex(COLUMN_ALIAS))); + address.setChan(c.getInt(c.getColumnIndex(COLUMN_CHAN)) == 1); address.setSubscribed(c.getInt(c.getColumnIndex(COLUMN_SUBSCRIBED)) == 1); result.add(address); @@ -199,6 +207,7 @@ public class AndroidAddressRepository implements AddressRepository { if (address.getPrivateKey() != null) { values.put(COLUMN_PRIVATE_KEY, Encode.bytes(address.getPrivateKey())); } + values.put(COLUMN_CHAN, address.isChan()); values.put(COLUMN_SUBSCRIBED, address.isSubscribed()); int update = db.update(TABLE_NAME, values, "address = '" + address.getAddress() + @@ -227,6 +236,7 @@ public class AndroidAddressRepository implements AddressRepository { values.put(COLUMN_PUBLIC_KEY, (byte[]) null); } values.put(COLUMN_PRIVATE_KEY, Encode.bytes(address.getPrivateKey())); + values.put(COLUMN_CHAN, address.isChan()); values.put(COLUMN_SUBSCRIBED, address.isSubscribed()); long insert = db.insert(TABLE_NAME, null, values); diff --git a/app/src/main/java/ch/dissem/apps/abit/repository/SqlHelper.java b/app/src/main/java/ch/dissem/apps/abit/repository/SqlHelper.java index 9b5083a..3041020 100644 --- a/app/src/main/java/ch/dissem/apps/abit/repository/SqlHelper.java +++ b/app/src/main/java/ch/dissem/apps/abit/repository/SqlHelper.java @@ -26,7 +26,7 @@ import ch.dissem.apps.abit.util.Assets; */ public class SqlHelper extends SQLiteOpenHelper { // If you change the database schema, you must increment the database version. - public static final int DATABASE_VERSION = 2; + public static final int DATABASE_VERSION = 3; public static final String DATABASE_NAME = "jabit.db"; protected final Context ctx; @@ -51,6 +51,8 @@ public class SqlHelper extends SQLiteOpenHelper { case 1: // executeMigration(db, "V2.0__Update_table_message"); executeMigration(db, "V2.1__Create_table_POW"); + case 2: + executeMigration(db, "V3.0__Update_table_address"); default: // Nothing to do. Let's assume we won't upgrade from a version that's newer than DATABASE_VERSION. } diff --git a/build.gradle b/build.gradle index f0f1e2b..8484636 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.0' + classpath 'com.android.tools.build:gradle:2.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 07fc193..551b2fa 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 10 15:27:10 PDT 2013 +#Mon Apr 11 14:09:13 CEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip