Skip to content

Commit

Permalink
Merge pull request #429 from jogrimst/master
Browse files Browse the repository at this point in the history
#428 Add list of Allophones to Letter
  • Loading branch information
literacyapp authored Jun 26, 2017
2 parents 527607a + a521c6a commit 4b3aead
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 68 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 1006005
versionName "1.6.5"
versionCode 1006006
versionName "1.6.6"

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

greendao {
schemaVersion 2000006 // Must match greendao.schemaVersion in contentprovider/build.gradle
schemaVersion 2000007 // Must match greendao.schemaVersion in contentprovider/build.gradle
daoPackage 'org.literacyapp.contentprovider.dao'
targetGenDir '../contentprovider/src/main/java'
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/org/literacyapp/dao/CustomDaoMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.literacyapp.contentprovider.dao.AllophoneDao;
import org.literacyapp.contentprovider.dao.DaoMaster;
import org.literacyapp.contentprovider.dao.JoinNumbersWithWordsDao;
import org.literacyapp.contentprovider.dao.LetterDao;
import org.literacyapp.contentprovider.dao.StoryBookDao;
import org.literacyapp.contentprovider.dao.WordDao;
import org.literacyapp.contentprovider.model.JoinNumbersWithWords;
Expand Down Expand Up @@ -69,6 +70,14 @@ public void onUpgrade(Database db, int oldVersion, int newVersion) {
);
}

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

// if (oldVersion < ???) {
// // Add new tables and/or columns automatically (include only the DAO classes that have been modified)
// DbMigrationHelper.migrate(db,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.literacyapp.contentprovider.dao.JoinImagesWithLettersDao;
import org.literacyapp.contentprovider.dao.JoinImagesWithNumbersDao;
import org.literacyapp.contentprovider.dao.JoinImagesWithWordsDao;
import org.literacyapp.contentprovider.dao.JoinLettersWithAllophonesDao;
import org.literacyapp.contentprovider.dao.JoinVideosWithLettersDao;
import org.literacyapp.contentprovider.dao.JoinVideosWithNumbersDao;
import org.literacyapp.contentprovider.dao.JoinVideosWithWordsDao;
Expand All @@ -30,6 +31,7 @@
import org.literacyapp.contentprovider.dao.StoryBookDao;
import org.literacyapp.contentprovider.dao.VideoDao;
import org.literacyapp.contentprovider.dao.WordDao;
import org.literacyapp.contentprovider.model.JoinLettersWithAllophones;
import org.literacyapp.contentprovider.model.content.Allophone;
import org.literacyapp.contentprovider.model.content.Letter;
import org.literacyapp.contentprovider.model.content.Number;
Expand Down Expand Up @@ -80,6 +82,8 @@ public class DownloadContentAsyncTask extends AsyncTask<Void, String, String> {
private AudioDao audioDao;
private ImageDao imageDao;
private VideoDao videoDao;

private JoinLettersWithAllophonesDao joinLettersWithAllophonesDao;

private JoinVideosWithLettersDao joinVideosWithLettersDao;
private JoinVideosWithNumbersDao joinVideosWithNumbersDao;
Expand All @@ -105,6 +109,8 @@ public DownloadContentAsyncTask(Context context) {
audioDao = literacyApplication.getDaoSession().getAudioDao();
imageDao = literacyApplication.getDaoSession().getImageDao();
videoDao = literacyApplication.getDaoSession().getVideoDao();

joinLettersWithAllophonesDao = literacyApplication.getDaoSession().getJoinLettersWithAllophonesDao();

joinVideosWithLettersDao = literacyApplication.getDaoSession().getJoinVideosWithLettersDao();
joinVideosWithNumbersDao = literacyApplication.getDaoSession().getJoinVideosWithNumbersDao();
Expand Down Expand Up @@ -181,9 +187,26 @@ protected String doInBackground(Void... voids) {
if (existingLetter == null) {
Log.i(getClass().getName(), "Storing Letter, id: " + letter.getId() + ", text: \"" + letter.getText() + "\", revisionNumber: " + letter.getRevisionNumber());
letterDao.insert(letter);

for (AllophoneGson allophoneGson : letterGson.getAllophones()) {
Allophone allophone = allophoneDao.queryBuilder()
.where(
AllophoneDao.Properties.Locale.eq(allophoneGson.getLocale()),
AllophoneDao.Properties.ValueSampa.eq(allophoneGson.getValueSampa())
)
.unique();
Log.i(getClass().getName(), "Storing Allophone, id: " + allophone.getId() + ", valueIpa: /" + allophone.getValueIpa() + "/, valueSampa: \"" + allophone.getValueSampa() + "\", for letter '" + letter.getText() + "'");

JoinLettersWithAllophones joinLettersWithAllophones = new JoinLettersWithAllophones();
joinLettersWithAllophones.setLetterId(letter.getId());
joinLettersWithAllophones.setAllophoneId(allophone.getId());
joinLettersWithAllophonesDao.insert(joinLettersWithAllophones);
}
} else if (existingLetter.getRevisionNumber() < letter.getRevisionNumber()) {
Log.i(getClass().getName(), "Updating Letter with id " + existingLetter.getId() + " from revisionNumber " + existingLetter.getRevisionNumber() + " to revisionNumber " + letter.getRevisionNumber());
letterDao.update(letter);

// TODO: update JoinLettersWithAllophones
} else {
Log.i(getClass().getName(), "Letter \"" + letter.getText() + "\" already exists in database with id " + letter.getId() + " (revision " + letter.getRevisionNumber() + ")");
}
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 1000009
versionName "1.0.9"
versionCode 1001000
versionName "1.1.0"

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

greendao {
schemaVersion 2000006 // Must match greendao.schemaVersion in app/build.gradle
schemaVersion 2000007 // 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.53'
compile 'org.literacyapp:literacyapp-model:1.1.56'
compile 'org.greenrobot:greendao:3.2.0'
compile 'com.android.support:appcompat-v7:23.4.0'
}
Loading

0 comments on commit 4b3aead

Please sign in to comment.