Skip to content

Commit

Permalink
Merge pull request #404 from jogrimst/master
Browse files Browse the repository at this point in the history
#403 Use Number Words instead of Number Word
  • Loading branch information
literacyapp authored May 5, 2017
2 parents b755282 + c735fa4 commit 25a2bf9
Show file tree
Hide file tree
Showing 14 changed files with 286 additions and 145 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 "org.literacyapp"
minSdkVersion 21
targetSdkVersion 23
versionCode 1006000
versionName "1.6.0"
versionCode 1006001
versionName "1.6.1"

// jackOptions {
// enabled true
Expand Down Expand Up @@ -56,7 +56,7 @@ android {
}

greendao {
schemaVersion 2000001 // Must match greendao.schemaVersion in contentprovider/build.gradle
schemaVersion 2000003 // Must match greendao.schemaVersion in contentprovider/build.gradle
daoPackage 'org.literacyapp.contentprovider.dao'
targetGenDir '../contentprovider/src/main/java'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.literacyapp.contentprovider.dao.AudioDao;
import org.literacyapp.contentprovider.dao.NumberDao;
import org.literacyapp.contentprovider.model.content.Number;
import org.literacyapp.contentprovider.model.content.Word;
import org.literacyapp.contentprovider.model.content.multimedia.Audio;
import org.literacyapp.logic.CurriculumHelper;
import org.literacyapp.model.enums.content.NumeracySkill;
Expand Down Expand Up @@ -75,9 +76,11 @@ public void onClick(View v) {

Log.i(getClass().getName(), "number.getValue(): " + number.getValue());
Log.i(getClass().getName(), "number.getSymbol(): " + number.getSymbol());
Log.i(getClass().getName(), "number.getWord(): " + number.getWord());
if (number.getWord() != null) {
Log.i(getClass().getName(), "number.getWord().getText(): " + number.getWord().getText());
Log.i(getClass().getName(), "number.getWords(): " + number.getWords());
if (!number.getWords().isEmpty()) {
for (Word numberWord : number.getWords()) {
Log.i(getClass().getName(), "numberWord.getText(): " + numberWord.getText());
}
}

playNumberSound(number);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.literacyapp.contentprovider.dao.NumberDao;
import org.literacyapp.contentprovider.model.Student;
import org.literacyapp.contentprovider.model.content.Number;
import org.literacyapp.contentprovider.model.content.Word;
import org.literacyapp.contentprovider.model.content.multimedia.Audio;
import org.literacyapp.logic.CurriculumHelper;
import org.literacyapp.util.MediaPlayerHelper;
Expand Down Expand Up @@ -275,11 +276,15 @@ public void onCompletion(MediaPlayer mediaPlayer) {
MediaPlayerHelper.play(getApplicationContext(), resourceId);
} else {
// Fall-back to TTS
TtsHelper.speak(getApplicationContext(), number.getWord().getText());
Word numberWord = number.getWords().get(0);
// TODO: concatenate text from all number words into one String
TtsHelper.speak(getApplicationContext(), numberWord.getText());
}
} catch (Resources.NotFoundException e) {
// Fall-back to TTS
TtsHelper.speak(getApplicationContext(), number.getWord().getText());
Word numberWord = number.getWords().get(0);
// TODO: concatenate text from all number words into one String
TtsHelper.speak(getApplicationContext(), numberWord.getText());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.literacyapp.contentprovider.dao.NumberDao;
import org.literacyapp.contentprovider.dao.VideoDao;
import org.literacyapp.contentprovider.model.content.Number;
import org.literacyapp.contentprovider.model.content.Word;
import org.literacyapp.contentprovider.model.content.multimedia.Audio;
import org.literacyapp.contentprovider.model.content.multimedia.JoinVideosWithNumbers;
import org.literacyapp.contentprovider.model.content.multimedia.Video;
Expand Down Expand Up @@ -261,11 +262,15 @@ public void onCompletion(MediaPlayer mediaPlayer) {
MediaPlayerHelper.play(getApplicationContext(), resourceId);
} else {
// Fall-back to TTS
TtsHelper.speak(getApplicationContext(), number.getWord().getText());
Word numberWord = number.getWords().get(0);
// TODO: concatenate text from all number words into one String
TtsHelper.speak(getApplicationContext(), numberWord.getText());
}
} catch (Resources.NotFoundException e) {
// Fall-back to TTS
TtsHelper.speak(getApplicationContext(), number.getWord().getText());
Word numberWord = number.getWords().get(0);
// TODO: concatenate text from all number words into one String
TtsHelper.speak(getApplicationContext(), numberWord.getText());
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/literacyapp/dao/CustomDaoMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.greenrobot.greendao.database.Database;
import org.literacyapp.contentprovider.dao.AllophoneDao;
import org.literacyapp.contentprovider.dao.DaoMaster;
import org.literacyapp.contentprovider.dao.JoinNumbersWithWordsDao;
import org.literacyapp.contentprovider.model.JoinNumbersWithWords;

public class CustomDaoMaster extends DaoMaster {

Expand Down Expand Up @@ -43,6 +45,14 @@ public void onUpgrade(Database db, int oldVersion, int newVersion) {
db.execSQL("ALTER TABLE ALLOPHONE ADD COLUMN `USAGE_COUNT` INTEGER NOT NULL DEFAULT 0;");
}

if (oldVersion < 2000003) {
// Add new tables and/or columns automatically (include only the DAO classes that have been modified)
DbMigrationHelper.migrate(db,
AllophoneDao.class, // Added "words"
JoinNumbersWithWordsDao.class
);
}

// if (oldVersion < ???) {
// // Add new tables and/or columns automatically (include only the DAO classes that have been modified)
// DbMigrationHelper.migrate(db,
Expand Down
8 changes: 4 additions & 4 deletions contentprovider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 23
versionCode 1000005
versionName "1.0.5"
versionCode 1000006
versionName "1.0.6"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand All @@ -26,7 +26,7 @@ android {
}

greendao {
schemaVersion 2000001 // Must match greendao.schemaVersion in app/build.gradle
schemaVersion 2000003 // Must match greendao.schemaVersion in app/build.gradle
daoPackage 'org.literacyapp.contentprovider.dao'
targetGenDir '../contentprovider/src/main/java'
}
Expand All @@ -49,7 +49,7 @@ dependencies {
})
testCompile 'junit:junit:4.12'

compile 'org.literacyapp:literacyapp-model:1.1.38'
compile 'org.literacyapp:literacyapp-model:1.1.41'
compile 'org.greenrobot:greendao:3.2.0'
compile 'com.android.support:appcompat-v7:23.4.0'
}
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 2000001): knows all DAOs.
* Master of DAO (schema version 2000003): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 2000001;
public static final int SCHEMA_VERSION = 2000003;

/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
Expand All @@ -40,6 +40,7 @@ public static void createAllTables(Database db, boolean ifNotExists) {
NumberDao.createTable(db, ifNotExists);
WordDao.createTable(db, ifNotExists);
DeviceDao.createTable(db, ifNotExists);
JoinNumbersWithWordsDao.createTable(db, ifNotExists);
JoinStudentsWithDevicesDao.createTable(db, ifNotExists);
StudentDao.createTable(db, ifNotExists);
StudentImageDao.createTable(db, ifNotExists);
Expand Down Expand Up @@ -67,6 +68,7 @@ public static void dropAllTables(Database db, boolean ifExists) {
NumberDao.dropTable(db, ifExists);
WordDao.dropTable(db, ifExists);
DeviceDao.dropTable(db, ifExists);
JoinNumbersWithWordsDao.dropTable(db, ifExists);
JoinStudentsWithDevicesDao.dropTable(db, ifExists);
StudentDao.dropTable(db, ifExists);
StudentImageDao.dropTable(db, ifExists);
Expand Down Expand Up @@ -108,6 +110,7 @@ public DaoMaster(Database db) {
registerDaoClass(NumberDao.class);
registerDaoClass(WordDao.class);
registerDaoClass(DeviceDao.class);
registerDaoClass(JoinNumbersWithWordsDao.class);
registerDaoClass(JoinStudentsWithDevicesDao.class);
registerDaoClass(StudentDao.class);
registerDaoClass(StudentImageDao.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.literacyapp.contentprovider.model.content.Number;
import org.literacyapp.contentprovider.model.content.Word;
import org.literacyapp.contentprovider.model.Device;
import org.literacyapp.contentprovider.model.JoinNumbersWithWords;
import org.literacyapp.contentprovider.model.JoinStudentsWithDevices;
import org.literacyapp.contentprovider.model.Student;
import org.literacyapp.contentprovider.model.StudentImage;
Expand All @@ -51,6 +52,7 @@
import org.literacyapp.contentprovider.dao.NumberDao;
import org.literacyapp.contentprovider.dao.WordDao;
import org.literacyapp.contentprovider.dao.DeviceDao;
import org.literacyapp.contentprovider.dao.JoinNumbersWithWordsDao;
import org.literacyapp.contentprovider.dao.JoinStudentsWithDevicesDao;
import org.literacyapp.contentprovider.dao.StudentDao;
import org.literacyapp.contentprovider.dao.StudentImageDao;
Expand Down Expand Up @@ -84,6 +86,7 @@ public class DaoSession extends AbstractDaoSession {
private final DaoConfig numberDaoConfig;
private final DaoConfig wordDaoConfig;
private final DaoConfig deviceDaoConfig;
private final DaoConfig joinNumbersWithWordsDaoConfig;
private final DaoConfig joinStudentsWithDevicesDaoConfig;
private final DaoConfig studentDaoConfig;
private final DaoConfig studentImageDaoConfig;
Expand All @@ -108,6 +111,7 @@ public class DaoSession extends AbstractDaoSession {
private final NumberDao numberDao;
private final WordDao wordDao;
private final DeviceDao deviceDao;
private final JoinNumbersWithWordsDao joinNumbersWithWordsDao;
private final JoinStudentsWithDevicesDao joinStudentsWithDevicesDao;
private final StudentDao studentDao;
private final StudentImageDao studentImageDao;
Expand Down Expand Up @@ -174,6 +178,9 @@ public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends Abstr
deviceDaoConfig = daoConfigMap.get(DeviceDao.class).clone();
deviceDaoConfig.initIdentityScope(type);

joinNumbersWithWordsDaoConfig = daoConfigMap.get(JoinNumbersWithWordsDao.class).clone();
joinNumbersWithWordsDaoConfig.initIdentityScope(type);

joinStudentsWithDevicesDaoConfig = daoConfigMap.get(JoinStudentsWithDevicesDao.class).clone();
joinStudentsWithDevicesDaoConfig.initIdentityScope(type);

Expand Down Expand Up @@ -205,6 +212,7 @@ public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends Abstr
numberDao = new NumberDao(numberDaoConfig, this);
wordDao = new WordDao(wordDaoConfig, this);
deviceDao = new DeviceDao(deviceDaoConfig, this);
joinNumbersWithWordsDao = new JoinNumbersWithWordsDao(joinNumbersWithWordsDaoConfig, this);
joinStudentsWithDevicesDao = new JoinStudentsWithDevicesDao(joinStudentsWithDevicesDaoConfig, this);
studentDao = new StudentDao(studentDaoConfig, this);
studentImageDao = new StudentImageDao(studentImageDaoConfig, this);
Expand All @@ -229,6 +237,7 @@ public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends Abstr
registerDao(Number.class, numberDao);
registerDao(Word.class, wordDao);
registerDao(Device.class, deviceDao);
registerDao(JoinNumbersWithWords.class, joinNumbersWithWordsDao);
registerDao(JoinStudentsWithDevices.class, joinStudentsWithDevicesDao);
registerDao(Student.class, studentDao);
registerDao(StudentImage.class, studentImageDao);
Expand All @@ -255,6 +264,7 @@ public void clear() {
numberDaoConfig.clearIdentityScope();
wordDaoConfig.clearIdentityScope();
deviceDaoConfig.clearIdentityScope();
joinNumbersWithWordsDaoConfig.clearIdentityScope();
joinStudentsWithDevicesDaoConfig.clearIdentityScope();
studentDaoConfig.clearIdentityScope();
studentImageDaoConfig.clearIdentityScope();
Expand Down Expand Up @@ -337,6 +347,10 @@ public DeviceDao getDeviceDao() {
return deviceDao;
}

public JoinNumbersWithWordsDao getJoinNumbersWithWordsDao() {
return joinNumbersWithWordsDao;
}

public JoinStudentsWithDevicesDao getJoinStudentsWithDevicesDao() {
return joinStudentsWithDevicesDao;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public static Number getNumber(NumberGson numberGson) {

number.setValue(numberGson.getValue());
number.setSymbol(numberGson.getSymbol());
number.setWord(getWord(numberGson.getWord()));

return number;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package org.literacyapp.contentprovider.dao;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import org.literacyapp.contentprovider.model.JoinNumbersWithWords;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "JOIN_NUMBERS_WITH_WORDS".
*/
public class JoinNumbersWithWordsDao extends AbstractDao<JoinNumbersWithWords, Long> {

public static final String TABLENAME = "JOIN_NUMBERS_WITH_WORDS";

/**
* Properties of entity JoinNumbersWithWords.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property NumberId = new Property(1, long.class, "numberId", false, "NUMBER_ID");
public final static Property WordId = new Property(2, long.class, "wordId", false, "WORD_ID");
}


public JoinNumbersWithWordsDao(DaoConfig config) {
super(config);
}

public JoinNumbersWithWordsDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}

/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"JOIN_NUMBERS_WITH_WORDS\" (" + //
"\"_id\" INTEGER PRIMARY KEY ," + // 0: id
"\"NUMBER_ID\" INTEGER NOT NULL ," + // 1: numberId
"\"WORD_ID\" INTEGER NOT NULL );"); // 2: wordId
}

/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"JOIN_NUMBERS_WITH_WORDS\"";
db.execSQL(sql);
}

@Override
protected final void bindValues(DatabaseStatement stmt, JoinNumbersWithWords entity) {
stmt.clearBindings();

Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindLong(2, entity.getNumberId());
stmt.bindLong(3, entity.getWordId());
}

@Override
protected final void bindValues(SQLiteStatement stmt, JoinNumbersWithWords entity) {
stmt.clearBindings();

Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindLong(2, entity.getNumberId());
stmt.bindLong(3, entity.getWordId());
}

@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}

@Override
public JoinNumbersWithWords readEntity(Cursor cursor, int offset) {
JoinNumbersWithWords entity = new JoinNumbersWithWords( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.getLong(offset + 1), // numberId
cursor.getLong(offset + 2) // wordId
);
return entity;
}

@Override
public void readEntity(Cursor cursor, JoinNumbersWithWords entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setNumberId(cursor.getLong(offset + 1));
entity.setWordId(cursor.getLong(offset + 2));
}

@Override
protected final Long updateKeyAfterInsert(JoinNumbersWithWords entity, long rowId) {
entity.setId(rowId);
return rowId;
}

@Override
public Long getKey(JoinNumbersWithWords entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}

@Override
public boolean hasKey(JoinNumbersWithWords entity) {
return entity.getId() != null;
}

@Override
protected final boolean isEntityUpdateable() {
return true;
}

}
Loading

0 comments on commit 25a2bf9

Please sign in to comment.