Skip to content

Commit

Permalink
Merge pull request #82 from SUPLA/develop
Browse files Browse the repository at this point in the history
v2.3.14
  • Loading branch information
przemyslawzygmunt authored Jul 6, 2019
2 parents 8ca6f5d + 2601cdc commit fbee73e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.supla.android"
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 67
versionName "2.3.13"
versionCode 68
versionName "2.3.14"

sourceSets.main {
jniLibs.srcDir 'src/main/libs'
Expand Down
33 changes: 23 additions & 10 deletions app/src/main/java/org/supla/android/db/DbHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ of the License, or (at your option) any later version.
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

Expand Down Expand Up @@ -68,6 +69,18 @@ private void execSQL(SQLiteDatabase db, String sql) {
db.execSQL(sql);
}

private void addColumn(SQLiteDatabase db, String sql) {
try {
execSQL(db, sql);
} catch(SQLException e) {
if ( !e.getMessage().contains("duplicate column name:") ) {
throw e;
} else {
e.getStackTrace();
}
}
}

private void createIndex(SQLiteDatabase db, String tableName, String fieldName) {
final String SQL_CREATE_INDEX = "CREATE INDEX " + tableName + "_"
+ fieldName + "_index ON " + tableName + "(" + fieldName + ")";
Expand Down Expand Up @@ -554,15 +567,15 @@ private void upgradeToV2(SQLiteDatabase db) {

private void upgradeToV3(SQLiteDatabase db) {
Trace.d(DbHelper.class.getName(), "upgradeToV3");
execSQL(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.ChannelEntry.COLUMN_NAME_ALTICON
+ " INTEGER NOT NULL default 0");

execSQL(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.ChannelEntry.COLUMN_NAME_FLAGS
+ " INTEGER NOT NULL default 0");

execSQL(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.ChannelEntry.COLUMN_NAME_PROTOCOLVERSION
+ " INTEGER NOT NULL default 0");
}
Expand Down Expand Up @@ -607,31 +620,31 @@ private void upgradeToV6(SQLiteDatabase db) {

createElectricityMeterLogTable(db);

execSQL(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.ChannelEntry.COLUMN_NAME_DEVICEID
+ " INTEGER NOT NULL default 0");

execSQL(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.ChannelEntry.COLUMN_NAME_USERICON
+ " INTEGER NOT NULL default 0");

execSQL(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.ChannelEntry.COLUMN_NAME_MANUFACTURERID
+ " SMALLINT NOT NULL default 0");

execSQL(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.ChannelEntry.COLUMN_NAME_TYPE
+ " INTEGER NOT NULL default 0");

execSQL(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.ChannelEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.ChannelEntry.COLUMN_NAME_PRODUCTID
+ " SMALLINT NOT NULL default 0");

execSQL(db, "ALTER TABLE " + SuplaContract.ChannelGroupEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.ChannelGroupEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.ChannelEntry.COLUMN_NAME_USERICON
+ " INTEGER NOT NULL default 0");

execSQL(db, "ALTER TABLE " + SuplaContract.LocationEntry.TABLE_NAME
addColumn(db, "ALTER TABLE " + SuplaContract.LocationEntry.TABLE_NAME
+ " ADD COLUMN " + SuplaContract.LocationEntry.COLUMN_NAME_COLLAPSED
+ " INTEGER NOT NULL default 0");

Expand Down

0 comments on commit fbee73e

Please sign in to comment.