Skip to content

Commit

Permalink
Merge pull request #369 from jogrimst/master
Browse files Browse the repository at this point in the history
Release 1.5.3
  • Loading branch information
literacyapp authored Feb 25, 2017
2 parents 75a504b + feaebc8 commit c220644
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 46 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.literacyapp"
minSdkVersion 21
targetSdkVersion 23
versionCode 1005002
versionName "1.5.2"
versionCode 1005003
versionName "1.5.3"

// jackOptions {
// enabled true
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/org/literacyapp/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
import android.util.Log;
import android.widget.Toast;

import org.literacyapp.contentprovider.ContentProvider;
import org.literacyapp.contentprovider.dao.LetterDao;
import org.literacyapp.contentprovider.model.content.Letter;
import org.literacyapp.service.synchronization.ReadDeviceAsyncTask;
import org.literacyapp.util.ConnectivityHelper;
import org.literacyapp.util.RootHelper;

import java.io.IOException;
import java.util.List;

public class MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -60,9 +63,9 @@ protected void onStart() {
LiteracyApplication literacyApplication = (LiteracyApplication) getApplication();
letterDao = literacyApplication.getDaoSession().getLetterDao();

// ContentProvider.initializeDb(this);
// List<Letter> letters = ContentProvider.getAvailableLetters();
// Log.i(getClass().getName(), "letters: " + letters);
ContentProvider.initializeDb(this);
List<Letter> letters = ContentProvider.getUnlockedLetters();
Log.i(getClass().getName(), "letters: " + letters);

if (letterDao.loadAll().isEmpty()) {
// Download content
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/literacyapp/logic/CurriculumHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CurriculumHelper(Context context) {
* default list.
*/
public List<Letter> getAvailableLetters(Student student) {
Log.i(getClass().getName(), "getAvailableLetters");
Log.i(getClass().getName(), "getUnlockedLetters");

List<Letter> letters = new ArrayList<>();

Expand Down Expand Up @@ -72,7 +72,7 @@ public List<Letter> getAvailableLetters(Student student) {
* default list.
*/
public List<Number> getAvailableNumbers(Student student) {
Log.i(getClass().getName(), "getAvailableNumbers");
Log.i(getClass().getName(), "getUnlockedNumbers");

List<Number> numbers = new ArrayList<>();

Expand Down
4 changes: 2 additions & 2 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 1005002
versionName "1.5.2"
versionCode 1005003
versionName "1.5.3"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import android.util.Log;

import org.literacyapp.contentprovider.dao.AudioDao;
import org.literacyapp.contentprovider.dao.CustomDaoMaster;
import org.literacyapp.contentprovider.dao.DaoMaster;
import org.literacyapp.contentprovider.dao.DaoSession;
import org.literacyapp.contentprovider.dao.ImageDao;
import org.literacyapp.contentprovider.dao.LetterDao;
Expand All @@ -29,9 +29,9 @@
*/
public class ContentProvider {

public static final int INITIAL_LETTER_COUNT = 3;
private static final int INITIAL_LETTER_COUNT = 3;

public static final int INITIAL_NUMBER_COUNT = 3;
private static final int INITIAL_NUMBER_COUNT = 3;

private static DaoSession daoSession;

Expand All @@ -40,16 +40,16 @@ public static DaoSession initializeDb(Context context) {

// Initialize greenDAO database
String dbName = Environment.getExternalStorageDirectory() + "/.literacyapp/database/literacyapp-db";
CustomDaoMaster.DevOpenHelper openHelper = new CustomDaoMaster.DevOpenHelper(context, dbName, null);
DaoMaster.DevOpenHelper openHelper = new DaoMaster.DevOpenHelper(context, dbName);
SQLiteDatabase db = openHelper.getReadableDatabase(); // read-only
CustomDaoMaster daoMaster = new CustomDaoMaster(db);
DaoMaster daoMaster = new DaoMaster(db);
daoSession = daoMaster.newSession();

return daoSession;
}

public static List<Letter> getAvailableLetters() {
Log.i(ContentProvider.class.getName(), "getAvailableLetters");
public static List<Letter> getUnlockedLetters() {
Log.i(ContentProvider.class.getName(), "getUnlockedLetters");

// TODO: get current Student
Student student = null;
Expand Down Expand Up @@ -85,8 +85,18 @@ public static List<Letter> getAvailableLetters() {
return letters;
}

public static List<Number> getAvailableNumbers() {
Log.i(ContentProvider.class.getName(), "getAvailableNumbers");
public static List<Letter> getAllLetters() {
Log.i(ContentProvider.class.getName(), "getAllLetters");

LetterDao letterDao = daoSession.getLetterDao();

List<Letter> letters = letterDao.loadAll();

return letters;
}

public static List<Number> getUnlockedNumbers() {
Log.i(ContentProvider.class.getName(), "getUnlockedNumbers");

// TODO: get current Student
Student student = null;
Expand Down Expand Up @@ -123,7 +133,7 @@ public static List<Number> getAvailableNumbers() {
}

public static List<Number> getAllNumbers() {
Log.i(ContentProvider.class.getName(), "getAvailableNumbers");
Log.i(ContentProvider.class.getName(), "getAllNumbers");

NumberDao numberDao = daoSession.getNumberDao();

Expand All @@ -132,18 +142,18 @@ public static List<Number> getAllNumbers() {
return numbers;
}

public static List<Letter> getAllLetters() {
Log.i(ContentProvider.class.getName(), "getAvailableLetters");

LetterDao letterDao = daoSession.getLetterDao();

List<Letter> letters = letterDao.loadAll();

return letters;
}
// public static List<Word> getUnlockedWords() {
// Log.i(ContentProvider.class.getName(), "getUnlockedWords");
//
// WordDao wordDao = daoSession.getWordDao();
//
// // TODO
//
// return words;
// }

public static List<Word> getAllWords() {
Log.i(ContentProvider.class.getName(), "getAvailableWords");
Log.i(ContentProvider.class.getName(), "getAllWords");

WordDao wordDao = daoSession.getWordDao();

Expand All @@ -152,20 +162,12 @@ public static List<Word> getAllWords() {
return words;
}

public static List<Word> getAllWordsOrderedByFrequency() {
Log.i(ContentProvider.class.getName(), "getAvailableWords");

WordDao wordDao = daoSession.getWordDao();

List<Word> words = wordDao.loadAll();

return words;
}
// TODO: getUnlockedStoryBooks()

// TODO: getAllStoryBooks()

public static List<Audio> getAllAudios() {
Log.i(ContentProvider.class.getName(), "getAvailableNumbers");
Log.i(ContentProvider.class.getName(), "getUnlockedNumbers");

AudioDao audioDao = daoSession.getAudioDao();

Expand All @@ -175,7 +177,7 @@ public static List<Audio> getAllAudios() {
}

public static List<Image> getAllImages() {
Log.i(ContentProvider.class.getName(), "getAvailableNumbers");
Log.i(ContentProvider.class.getName(), "getUnlockedNumbers");

ImageDao imageDao = daoSession.getImageDao();

Expand All @@ -184,12 +186,20 @@ public static List<Image> getAllImages() {
return images;
}

// public static List<Image> getImages(Word word) {
// // TODO
// }
public static Image getImage(String title) {
Log.i(ContentProvider.class.getName(), "getImage");

ImageDao imageDao = daoSession.getImageDao();

Image image = imageDao.queryBuilder()
.where(ImageDao.Properties.Title.eq(title))
.unique();

return image;
}

public static List<Video> getAllVideos() {
Log.i(ContentProvider.class.getName(), "getAvailableNumbers");
Log.i(ContentProvider.class.getName(), "getUnlockedNumbers");

VideoDao videoDao = daoSession.getVideoDao();

Expand Down
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 1005002): knows all DAOs.
* Master of DAO (schema version 1005003): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 1005002;
public static final int SCHEMA_VERSION = 1005003;

/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
Expand Down

0 comments on commit c220644

Please sign in to comment.