Implemented methods needed for chan support (no GUI yet, though)

This commit is contained in:
Christian Basler 2016-04-25 09:27:36 +02:00
parent 59f0bc7b74
commit 0ecfbd3fb8
6 changed files with 26 additions and 10 deletions

View File

@ -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 {

View File

@ -0,0 +1 @@
ALTER TABLE Address ADD COLUMN chan BIT NOT NULL DEFAULT '0';

View File

@ -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<BitmessageAddress> getChans() {
return find("chan = '1'");
}
@Override
public List<BitmessageAddress> 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);

View File

@ -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.
}

View File

@ -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

View File

@ -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