Skip to content

Commit

Permalink
Merge pull request #361 from jogrimst/master
Browse files Browse the repository at this point in the history
#126 Select letter after hearing sound
  • Loading branch information
literacyapp authored Jan 29, 2017
2 parents e21784e + 138e7c4 commit b2b00e5
Show file tree
Hide file tree
Showing 18 changed files with 433 additions and 38 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
<activity
android:name=".content.task.NumberActivity"
android:screenOrientation="fullSensor" />
<activity
android:name=".content.task.SelectLetterActivity"
android:screenOrientation="fullSensor" />
<activity
android:name=".content.task.StarActivity"
android:screenOrientation="fullSensor" />
Expand Down
Binary file removed app/src/main/ic_launcher_authentication_2-web.png
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
*/

public class AuthenticationHelper {

private static final double[] countSteps = { 0, 5, 10, 15, 20, 25, 30, 35, 40, 45 };
private static final double[] exponentialDelayStepsInMinutes = { 30, 60, 120, 240, 480, 960, 1920, 3840, 7680, 15360 };

public static synchronized void updateCurrentStudent(Student student, Context context, boolean isFallback){
public static synchronized void updateCurrentStudent(Student student, Context context, boolean isFallback) {
Log.i(context.getClass().getName(), "updateCurrentStudent");

LiteracyApplication literacyApplication = (LiteracyApplication) context;
DaoSession daoSession = literacyApplication.getDaoSession();
AuthenticationEventDao authenticationEventDao = daoSession.getAuthenticationEventDao();
Expand All @@ -46,6 +49,8 @@ public static synchronized void updateCurrentStudent(Student student, Context co
}

private static void addExponentialDelayIfSameStudent(Context context, AuthenticationEventDao authenticationEventDao, Student newStudent){
Log.i(context.getClass().getName(), "addExponentialDelayIfSameStudent");

List<AuthenticationEvent> authenticationEvents = authenticationEventDao.queryBuilder().orderDesc(AuthenticationEventDao.Properties.Time).list();
if (authenticationEvents.size() > 0){
int countOfRecurrentLogins = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@
import org.literacyapp.dao.VideoDao;
import org.literacyapp.model.content.Letter;
import org.literacyapp.model.content.multimedia.Audio;
import org.literacyapp.model.content.multimedia.JoinVideosWithLetters;
import org.literacyapp.model.content.multimedia.Video;
import org.literacyapp.util.MediaPlayerHelper;
import org.literacyapp.util.MultimediaHelper;
import org.literacyapp.util.TtsHelper;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class LetterGraphemeActivity extends AppCompatActivity {

Expand Down Expand Up @@ -93,28 +89,32 @@ public void onClick(View view) {
public void onClick(View view) {
Log.i(getClass().getName(), "onClick");

// Look up video(s) containing letter
List<Video> videosContainingLetter = new ArrayList<Video>();
List<JoinVideosWithLetters> joinVideosWithLettersList = joinVideosWithLettersDao.queryBuilder()
.where(JoinVideosWithLettersDao.Properties.LetterId.eq(letter.getId()))
.list();
Log.d(getClass().getName(), "joinVideosWithLettersList.size(): " + joinVideosWithLettersList.size());
if (!joinVideosWithLettersList.isEmpty()) {
for (JoinVideosWithLetters joinVideosWithLetters : joinVideosWithLettersList) {
Video video = videoDao.load(joinVideosWithLetters.getVideoId());
Log.d(getClass().getName(), "Adding video with id " + video.getId());
videosContainingLetter.add(video);
}
}
Log.d(getClass().getName(), "videosContainingLetter.size(): " + videosContainingLetter.size());
if (!videosContainingLetter.isEmpty()) {
// Redirect to video(s)
Intent intent = new Intent(getApplicationContext(), VideoActivity.class);
int randomIndex = (int) (Math.random() * videosContainingLetter.size());
Video video = videosContainingLetter.get(randomIndex); // TODO: iterate all videos
intent.putExtra(VideoActivity.EXTRA_KEY_VIDEO_ID, video.getId());
startActivity(intent);
}
// // Look up video(s) containing letter
// List<Video> videosContainingLetter = new ArrayList<Video>();
// List<JoinVideosWithLetters> joinVideosWithLettersList = joinVideosWithLettersDao.queryBuilder()
// .where(JoinVideosWithLettersDao.Properties.LetterId.eq(letter.getId()))
// .list();
// Log.d(getClass().getName(), "joinVideosWithLettersList.size(): " + joinVideosWithLettersList.size());
// if (!joinVideosWithLettersList.isEmpty()) {
// for (JoinVideosWithLetters joinVideosWithLetters : joinVideosWithLettersList) {
// Video video = videoDao.load(joinVideosWithLetters.getVideoId());
// Log.d(getClass().getName(), "Adding video with id " + video.getId());
// videosContainingLetter.add(video);
// }
// }
// Log.d(getClass().getName(), "videosContainingLetter.size(): " + videosContainingLetter.size());
// if (!videosContainingLetter.isEmpty()) {
// // Redirect to video(s)
// Intent intent = new Intent(getApplicationContext(), VideoActivity.class);
// int randomIndex = (int) (Math.random() * videosContainingLetter.size());
// Video video = videosContainingLetter.get(randomIndex); // TODO: iterate all videos
// intent.putExtra(VideoActivity.EXTRA_KEY_VIDEO_ID, video.getId());
// startActivity(intent);
// }

Intent intent = new Intent(getApplicationContext(), SelectLetterActivity.class);
intent.putExtra("letter", letter.getText());
startActivity(intent);

finish();
}
Expand Down
Loading

0 comments on commit b2b00e5

Please sign in to comment.