Skip to content

Commit

Permalink
Merge pull request #199 from elimu-ai/198-Add-minSdkVersion-to-Applic…
Browse files Browse the repository at this point in the history
…ationVersion

#198 Add minSdkVersion to ApplicationVersion
  • Loading branch information
jo-elimu authored Mar 25, 2018
2 parents 975a8b1 + ec1215b commit dbd3907
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 19 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "ai.elimu.appstore"
minSdkVersion 21
targetSdkVersion 26
versionCode 2002001
versionName "2.2.1-SNAPSHOT"
versionCode 2002002
versionName "2.2.2-SNAPSHOT"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -72,7 +72,7 @@ greendao {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'ai.elimu:model:1.1.69'
implementation 'ai.elimu:model:1.1.70'
implementation "org.greenrobot:greendao:3.2.2"
implementation 'commons-io:commons-io:2.5'
implementation 'com.jakewharton.timber:timber:4.5.1'
Expand Down
38 changes: 26 additions & 12 deletions app/src/main/java/ai/elimu/appstore/dao/ApplicationVersionDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public static class Properties {
public final static Property VersionCode = new Property(6, Integer.class, "versionCode", false, "VERSION_CODE");
public final static Property VersionName = new Property(7, String.class, "versionName", false, "VERSION_NAME");
public final static Property Label = new Property(8, String.class, "label", false, "LABEL");
public final static Property StartCommand = new Property(9, String.class, "startCommand", false, "START_COMMAND");
public final static Property TimeUploaded = new Property(10, long.class, "timeUploaded", false, "TIME_UPLOADED");
public final static Property MinSdkVersion = new Property(9, Integer.class, "minSdkVersion", false, "MIN_SDK_VERSION");
public final static Property StartCommand = new Property(10, String.class, "startCommand", false, "START_COMMAND");
public final static Property TimeUploaded = new Property(11, long.class, "timeUploaded", false, "TIME_UPLOADED");
}

private DaoSession daoSession;
Expand Down Expand Up @@ -70,8 +71,9 @@ public static void createTable(Database db, boolean ifNotExists) {
"\"VERSION_CODE\" INTEGER NOT NULL ," + // 6: versionCode
"\"VERSION_NAME\" TEXT," + // 7: versionName
"\"LABEL\" TEXT," + // 8: label
"\"START_COMMAND\" TEXT," + // 9: startCommand
"\"TIME_UPLOADED\" INTEGER NOT NULL );"); // 10: timeUploaded
"\"MIN_SDK_VERSION\" INTEGER," + // 9: minSdkVersion
"\"START_COMMAND\" TEXT," + // 10: startCommand
"\"TIME_UPLOADED\" INTEGER NOT NULL );"); // 11: timeUploaded
}

/** Drops the underlying database table. */
Expand Down Expand Up @@ -105,11 +107,16 @@ protected final void bindValues(DatabaseStatement stmt, ApplicationVersion entit
stmt.bindString(9, label);
}

Integer minSdkVersion = entity.getMinSdkVersion();
if (minSdkVersion != null) {
stmt.bindLong(10, minSdkVersion);
}

String startCommand = entity.getStartCommand();
if (startCommand != null) {
stmt.bindString(10, startCommand);
stmt.bindString(11, startCommand);
}
stmt.bindLong(11, timeUploadedConverter.convertToDatabaseValue(entity.getTimeUploaded()));
stmt.bindLong(12, timeUploadedConverter.convertToDatabaseValue(entity.getTimeUploaded()));
}

@Override
Expand Down Expand Up @@ -137,11 +144,16 @@ protected final void bindValues(SQLiteStatement stmt, ApplicationVersion entity)
stmt.bindString(9, label);
}

Integer minSdkVersion = entity.getMinSdkVersion();
if (minSdkVersion != null) {
stmt.bindLong(10, minSdkVersion);
}

String startCommand = entity.getStartCommand();
if (startCommand != null) {
stmt.bindString(10, startCommand);
stmt.bindString(11, startCommand);
}
stmt.bindLong(11, timeUploadedConverter.convertToDatabaseValue(entity.getTimeUploaded()));
stmt.bindLong(12, timeUploadedConverter.convertToDatabaseValue(entity.getTimeUploaded()));
}

@Override
Expand All @@ -167,8 +179,9 @@ public ApplicationVersion readEntity(Cursor cursor, int offset) {
cursor.getInt(offset + 6), // versionCode
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // versionName
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // label
cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // startCommand
timeUploadedConverter.convertToEntityProperty(cursor.getLong(offset + 10)) // timeUploaded
cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9), // minSdkVersion
cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // startCommand
timeUploadedConverter.convertToEntityProperty(cursor.getLong(offset + 11)) // timeUploaded
);
return entity;
}
Expand All @@ -184,8 +197,9 @@ public void readEntity(Cursor cursor, ApplicationVersion entity, int offset) {
entity.setVersionCode(cursor.getInt(offset + 6));
entity.setVersionName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
entity.setLabel(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
entity.setStartCommand(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
entity.setTimeUploaded(timeUploadedConverter.convertToEntityProperty(cursor.getLong(offset + 10)));
entity.setMinSdkVersion(cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9));
entity.setStartCommand(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
entity.setTimeUploaded(timeUploadedConverter.convertToEntityProperty(cursor.getLong(offset + 11)));
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/ai/elimu/appstore/dao/CustomDaoMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public void onUpgrade(Database db, int oldVersion, int newVersion) {
dropAllTables(db, true);
onCreate(db);
}

if (oldVersion < 2002002) {
// Add minSdkVersion
DbMigrationHelper.migrate(db, ApplicationVersionDao.class);
}
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/ai/elimu/appstore/dao/DaoMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 2002001): knows all DAOs.
* Master of DAO (schema version 2002002): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 2002001;
public static final int SCHEMA_VERSION = 2002002;

/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/ai/elimu/appstore/model/ApplicationVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class ApplicationVersion {
// @NotNull
private String label;

// @NotNull
private Integer minSdkVersion;

private String startCommand;

@NotNull
Expand All @@ -60,10 +63,11 @@ public class ApplicationVersion {
@Generated(hash = 1339503542)
private transient ApplicationVersionDao myDao;

@Generated(hash = 985154034)
@Generated(hash = 932028413)
public ApplicationVersion(Long id, long applicationId, @NotNull Integer fileSizeInKb, @NotNull String fileUrl,
@NotNull String checksumMd5, @NotNull String contentType, @NotNull Integer versionCode,
String versionName, String label, String startCommand, @NotNull Calendar timeUploaded) {
String versionName, String label, Integer minSdkVersion, String startCommand,
@NotNull Calendar timeUploaded) {
this.id = id;
this.applicationId = applicationId;
this.fileSizeInKb = fileSizeInKb;
Expand All @@ -73,6 +77,7 @@ public ApplicationVersion(Long id, long applicationId, @NotNull Integer fileSize
this.versionCode = versionCode;
this.versionName = versionName;
this.label = label;
this.minSdkVersion = minSdkVersion;
this.startCommand = startCommand;
this.timeUploaded = timeUploaded;
}
Expand Down Expand Up @@ -248,4 +253,12 @@ public String getLabel() {
public void setLabel(String label) {
this.label = label;
}

public Integer getMinSdkVersion() {
return this.minSdkVersion;
}

public void setMinSdkVersion(Integer minSdkVersion) {
this.minSdkVersion = minSdkVersion;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ private void processAppListData(@NonNull Response<ResponseBody> response) {
applicationVersion.setVersionCode(applicationVersionGson.getVersionCode());
applicationVersion.setVersionName(applicationVersionGson.getVersionName());
applicationVersion.setLabel(applicationVersionGson.getLabel());
applicationVersion.setMinSdkVersion(applicationVersionGson.getMinSdkVersion());
applicationVersion.setStartCommand(applicationVersionGson.getStartCommand());
applicationVersion.setTimeUploaded(applicationVersionGson.getTimeUploaded());
long applicationVersionId = applicationVersionDao.insert(applicationVersion);
Expand Down Expand Up @@ -277,6 +278,7 @@ private void processAppListData(@NonNull Response<ResponseBody> response) {
applicationVersion.setVersionCode(applicationVersionGson.getVersionCode());
applicationVersion.setVersionName(applicationVersionGson.getVersionName());
applicationVersion.setLabel(applicationVersionGson.getLabel());
applicationVersion.setMinSdkVersion(applicationVersionGson.getMinSdkVersion());
applicationVersion.setStartCommand(applicationVersionGson.getStartCommand());
applicationVersion.setTimeUploaded(applicationVersionGson.getTimeUploaded());
long applicationVersionId = applicationVersionDao.insert(applicationVersion);
Expand Down

0 comments on commit dbd3907

Please sign in to comment.