From 4217a73c06cc30e2d3fac9caa5649ebd95da2cd5 Mon Sep 17 00:00:00 2001
From: jo-elimu <1451036+jo-elimu@users.noreply.github.com>
Date: Wed, 25 Sep 2024 17:06:16 +0700
Subject: [PATCH 1/5] chore: 3.1.22-SNAPSHOT
---
app/build.gradle | 4 ++--
utils/build.gradle | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index 7ec4c73..580ece0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -7,8 +7,8 @@ android {
applicationId "ai.elimu.analytics"
minSdkVersion 24
targetSdkVersion 33
- versionCode 3001021
- versionName "3.1.21"
+ versionCode 3001022
+ versionName "3.1.22-SNAPSHOT"
setProperty("archivesBaseName", "${applicationId}-${versionCode}")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
diff --git a/utils/build.gradle b/utils/build.gradle
index 11b63c0..a074280 100644
--- a/utils/build.gradle
+++ b/utils/build.gradle
@@ -9,7 +9,7 @@ android {
defaultConfig {
minSdkVersion 24
targetSdkVersion 33
- versionName "3.1.21"
+ versionName "3.1.22-SNAPSHOT"
setProperty("archivesBaseName", "utils-${versionName}")
}
@@ -36,7 +36,7 @@ publishing {
utils(MavenPublication) {
groupId 'ai.elimu.analytics'
artifactId 'utils'
- version '3.1.21'
+ version '3.1.22-SNAPSHOT'
artifact("${buildDir}/outputs/aar/utils-${version}-release.aar")
}
}
From 2ac13b9ff6d995fe63afdd7e962ad276c77abce6 Mon Sep 17 00:00:00 2001
From: jo-elimu <1451036+jo-elimu@users.noreply.github.com>
Date: Wed, 25 Sep 2024 17:08:16 +0700
Subject: [PATCH 2/5] chore: upgrade to model-2.0.74
References #155
---
app/build.gradle | 2 +-
utils/build.gradle | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index 580ece0..00d7184 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -40,7 +40,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'com.github.elimu-ai:model:model-2.0.73' // See https://jitpack.io/#elimu-ai/model
+ implementation 'com.github.elimu-ai:model:model-2.0.74' // See https://jitpack.io/#elimu-ai/model
implementation 'com.jakewharton.timber:timber:5.0.1'
implementation 'com.google.android.material:material:1.5.0'
diff --git a/utils/build.gradle b/utils/build.gradle
index a074280..7224df2 100644
--- a/utils/build.gradle
+++ b/utils/build.gradle
@@ -25,7 +25,7 @@ android {
}
dependencies {
- implementation 'com.github.elimu-ai:model:model-2.0.73' // See https://jitpack.io/#elimu-ai/model
+ implementation 'com.github.elimu-ai:model:model-2.0.74' // See https://jitpack.io/#elimu-ai/model
testImplementation 'junit:junit:4.13.2'
}
From 1b4de73c67b4445a721234e5e776083addf71168 Mon Sep 17 00:00:00 2001
From: jo-elimu <1451036+jo-elimu@users.noreply.github.com>
Date: Thu, 26 Sep 2024 20:26:08 +0700
Subject: [PATCH 3/5] feat: add video learning event - receiver
Refs #155
---
app/src/main/AndroidManifest.xml | 7 ++++
.../receiver/VideoLearningEventReceiver.java | 39 +++++++++++++++++++
2 files changed, 46 insertions(+)
create mode 100644 app/src/main/java/ai/elimu/analytics/receiver/VideoLearningEventReceiver.java
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1755f79..2d43938 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -67,6 +67,13 @@
+
+
+
+
+
diff --git a/app/src/main/java/ai/elimu/analytics/receiver/VideoLearningEventReceiver.java b/app/src/main/java/ai/elimu/analytics/receiver/VideoLearningEventReceiver.java
new file mode 100644
index 0000000..6e952a3
--- /dev/null
+++ b/app/src/main/java/ai/elimu/analytics/receiver/VideoLearningEventReceiver.java
@@ -0,0 +1,39 @@
+package ai.elimu.analytics.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+import java.util.Calendar;
+
+import ai.elimu.model.v2.enums.analytics.LearningEventType;
+import timber.log.Timber;
+
+public class VideoLearningEventReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Timber.i("onReceive");
+
+ String packageName = intent.getStringExtra("packageName");
+ Timber.i("packageName: \"" + packageName + "\"");
+
+ Calendar timestamp = Calendar.getInstance();
+ Timber.i("timestamp.getTime(): " + timestamp.getTime());
+
+ Long videoId = intent.getLongExtra("videoId", 0);
+ Timber.i("videoId: " + videoId);
+
+ String videoTitle = intent.getStringExtra("videoTitle");
+ Timber.i("videoTitle: \"" + videoTitle + "\"");
+
+ String learningEventTypeAsString = intent.getStringExtra("learningEventType");
+ Timber.i("learningEventTypeAsString: \"" + learningEventTypeAsString + "\"");
+ LearningEventType learningEventType = LearningEventType.valueOf(learningEventTypeAsString);
+ Timber.i("learningEventType: " + learningEventType);
+
+ // TODO: new VideoLearningEvent()
+
+ // TODO: Store in database
+ }
+}
From f64029bd027f5bf8a98b879ff74643a7217d1fc0 Mon Sep 17 00:00:00 2001
From: jo-elimu <1451036+jo-elimu@users.noreply.github.com>
Date: Fri, 27 Sep 2024 16:09:36 +0700
Subject: [PATCH 4/5] feat: add video learning event - learning event util
Refs #155
---
.../analytics/utils/LearningEventUtil.java | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/utils/src/main/java/ai/elimu/analytics/utils/LearningEventUtil.java b/utils/src/main/java/ai/elimu/analytics/utils/LearningEventUtil.java
index 6e363e4..56c157f 100644
--- a/utils/src/main/java/ai/elimu/analytics/utils/LearningEventUtil.java
+++ b/utils/src/main/java/ai/elimu/analytics/utils/LearningEventUtil.java
@@ -11,6 +11,7 @@
import ai.elimu.model.v2.gson.content.LetterSoundGson;
import ai.elimu.model.v2.gson.content.SoundGson;
import ai.elimu.model.v2.gson.content.StoryBookGson;
+import ai.elimu.model.v2.gson.content.VideoGson;
import ai.elimu.model.v2.gson.content.WordGson;
/**
@@ -92,4 +93,23 @@ public static void reportStoryBookLearningEvent(StoryBookGson storyBookGson, Lea
broadcastIntent.setPackage(analyticsApplicationId);
context.sendBroadcast(broadcastIntent);
}
+
+ /**
+ * @param videoGson The video that the student is learning from.
+ * @param learningEventType The type of learning (i.e. the learning format) that is presented to the student in the application ({@code packageName}).
+ * @param context Needed to fetch the {@code packageName} of the application where the learning event occurred.
+ * @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event.
+ */
+ public static void reportVideoLearningEvent(VideoGson videoGson, LearningEventType learningEventType, Context context, String analyticsApplicationId) {
+ Log.i(LearningEventUtil.class.getName(),"reportVideoLearningEvent");
+
+ Intent broadcastIntent = new Intent();
+ broadcastIntent.setAction("ai.elimu.intent.action.VIDEO_LEARNING_EVENT");
+ broadcastIntent.putExtra("packageName", context.getPackageName());
+ broadcastIntent.putExtra("videoId", videoGson.getId());
+ broadcastIntent.putExtra("videoTitle", videoGson.getTitle());
+ broadcastIntent.putExtra("learningEventType", learningEventType.toString());
+ broadcastIntent.setPackage(analyticsApplicationId);
+ context.sendBroadcast(broadcastIntent);
+ }
}
From f48be3c6aef99e752df8a7e64d8489c5f1fef496 Mon Sep 17 00:00:00 2001
From: jo-elimu <1451036+jo-elimu@users.noreply.github.com>
Date: Fri, 27 Sep 2024 17:52:49 +0700
Subject: [PATCH 5/5] feat: add video learning event - add db entity
Refs #155
---
README.md | 2 -
.../ai.elimu.analytics.db.RoomDb/7.json | 412 ++++++++++++++++++
.../java/ai/elimu/analytics/db/RoomDb.java | 17 +-
.../analytics/entity/VideoLearningEvent.java | 42 ++
.../receiver/VideoLearningEventReceiver.java | 27 +-
5 files changed, 488 insertions(+), 12 deletions(-)
create mode 100644 app/schemas/ai.elimu.analytics.db.RoomDb/7.json
create mode 100644 app/src/main/java/ai/elimu/analytics/entity/VideoLearningEvent.java
diff --git a/README.md b/README.md
index 2c9ffaa..a8ad1c1 100644
--- a/README.md
+++ b/README.md
@@ -74,8 +74,6 @@ migration (SQL script) in
Follow these steps:
1. Add the new/modified `@Entity` to [`app/src/main/java/ai/elimu/analytics/entity/`](app/src/main/java/ai/elimu/analytics/entity/)
-1. Add the entity's DAO interface to [`app/src/main/java/ai/elimu/analytics/dao/`](app/src/main/java/ai/elimu/analytics/dao/)
-1. Include the DAO interface in [`app/src/main/java/ai/elimu/analytics/db/RoomDb.java`](app/src/main/java/ai/elimu/analytics/db/RoomDb.java)
1. Include the entity in the `entities` section of the `@Database` in [`app/src/main/java/ai/elimu/analytics/db/RoomDb.java`](app/src/main/java/ai/elimu/analytics/db/RoomDb.java)
1. Bump the `@Database` version in [`app/src/main/java/ai/elimu/analytics/db/RoomDb.java`](app/src/main/java/ai/elimu/analytics/db/RoomDb.java)
1. Build the code with `./gradlew clean build`
diff --git a/app/schemas/ai.elimu.analytics.db.RoomDb/7.json b/app/schemas/ai.elimu.analytics.db.RoomDb/7.json
new file mode 100644
index 0000000..42c8384
--- /dev/null
+++ b/app/schemas/ai.elimu.analytics.db.RoomDb/7.json
@@ -0,0 +1,412 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 7,
+ "identityHash": "d5ac45a7057d09a8aaf670fbc2725b4c",
+ "entities": [
+ {
+ "tableName": "LetterLearningEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`letterId` INTEGER, `letterText` TEXT NOT NULL, `learningEventType` TEXT NOT NULL, `androidId` TEXT NOT NULL, `packageName` TEXT NOT NULL, `time` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)",
+ "fields": [
+ {
+ "fieldPath": "letterId",
+ "columnName": "letterId",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "letterText",
+ "columnName": "letterText",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "learningEventType",
+ "columnName": "learningEventType",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidId",
+ "columnName": "androidId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "packageName",
+ "columnName": "packageName",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "time",
+ "columnName": "time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [],
+ "foreignKeys": []
+ },
+ {
+ "tableName": "LetterAssessmentEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`letterId` INTEGER, `letterText` TEXT NOT NULL, `masteryScore` REAL NOT NULL, `timeSpentMs` INTEGER NOT NULL, `androidId` TEXT NOT NULL, `packageName` TEXT NOT NULL, `time` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)",
+ "fields": [
+ {
+ "fieldPath": "letterId",
+ "columnName": "letterId",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "letterText",
+ "columnName": "letterText",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "masteryScore",
+ "columnName": "masteryScore",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "timeSpentMs",
+ "columnName": "timeSpentMs",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidId",
+ "columnName": "androidId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "packageName",
+ "columnName": "packageName",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "time",
+ "columnName": "time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [],
+ "foreignKeys": []
+ },
+ {
+ "tableName": "LetterSoundLearningEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`letterSoundId` INTEGER, `letterSoundLetterTexts` TEXT NOT NULL, `letterSoundSoundValuesIpa` TEXT NOT NULL, `androidId` TEXT NOT NULL, `packageName` TEXT NOT NULL, `time` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)",
+ "fields": [
+ {
+ "fieldPath": "letterSoundId",
+ "columnName": "letterSoundId",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "letterSoundLetterTexts",
+ "columnName": "letterSoundLetterTexts",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "letterSoundSoundValuesIpa",
+ "columnName": "letterSoundSoundValuesIpa",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidId",
+ "columnName": "androidId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "packageName",
+ "columnName": "packageName",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "time",
+ "columnName": "time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [],
+ "foreignKeys": []
+ },
+ {
+ "tableName": "WordLearningEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wordId` INTEGER, `wordText` TEXT NOT NULL, `learningEventType` TEXT NOT NULL, `androidId` TEXT NOT NULL, `packageName` TEXT NOT NULL, `time` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)",
+ "fields": [
+ {
+ "fieldPath": "wordId",
+ "columnName": "wordId",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "wordText",
+ "columnName": "wordText",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "learningEventType",
+ "columnName": "learningEventType",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidId",
+ "columnName": "androidId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "packageName",
+ "columnName": "packageName",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "time",
+ "columnName": "time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [],
+ "foreignKeys": []
+ },
+ {
+ "tableName": "WordAssessmentEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`wordId` INTEGER, `wordText` TEXT NOT NULL, `masteryScore` REAL NOT NULL, `timeSpentMs` INTEGER NOT NULL, `androidId` TEXT NOT NULL, `packageName` TEXT NOT NULL, `time` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)",
+ "fields": [
+ {
+ "fieldPath": "wordId",
+ "columnName": "wordId",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "wordText",
+ "columnName": "wordText",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "masteryScore",
+ "columnName": "masteryScore",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "timeSpentMs",
+ "columnName": "timeSpentMs",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidId",
+ "columnName": "androidId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "packageName",
+ "columnName": "packageName",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "time",
+ "columnName": "time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [],
+ "foreignKeys": []
+ },
+ {
+ "tableName": "StoryBookLearningEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`storyBookId` INTEGER NOT NULL, `learningEventType` TEXT NOT NULL, `androidId` TEXT NOT NULL, `packageName` TEXT NOT NULL, `time` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)",
+ "fields": [
+ {
+ "fieldPath": "storyBookId",
+ "columnName": "storyBookId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "learningEventType",
+ "columnName": "learningEventType",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidId",
+ "columnName": "androidId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "packageName",
+ "columnName": "packageName",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "time",
+ "columnName": "time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [],
+ "foreignKeys": []
+ },
+ {
+ "tableName": "VideoLearningEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`videoId` INTEGER, `videoTitle` TEXT NOT NULL, `learningEventType` TEXT NOT NULL, `androidId` TEXT NOT NULL, `packageName` TEXT NOT NULL, `time` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)",
+ "fields": [
+ {
+ "fieldPath": "videoId",
+ "columnName": "videoId",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "videoTitle",
+ "columnName": "videoTitle",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "learningEventType",
+ "columnName": "learningEventType",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidId",
+ "columnName": "androidId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "packageName",
+ "columnName": "packageName",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "time",
+ "columnName": "time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": false
+ }
+ ],
+ "primaryKey": {
+ "columnNames": [
+ "id"
+ ],
+ "autoGenerate": true
+ },
+ "indices": [],
+ "foreignKeys": []
+ }
+ ],
+ "views": [],
+ "setupQueries": [
+ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd5ac45a7057d09a8aaf670fbc2725b4c')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/ai/elimu/analytics/db/RoomDb.java b/app/src/main/java/ai/elimu/analytics/db/RoomDb.java
index 6bfdd49..df15ffe 100644
--- a/app/src/main/java/ai/elimu/analytics/db/RoomDb.java
+++ b/app/src/main/java/ai/elimu/analytics/db/RoomDb.java
@@ -23,11 +23,12 @@
import ai.elimu.analytics.entity.LetterLearningEvent;
import ai.elimu.analytics.entity.LetterSoundLearningEvent;
import ai.elimu.analytics.entity.StoryBookLearningEvent;
+import ai.elimu.analytics.entity.VideoLearningEvent;
import ai.elimu.analytics.entity.WordAssessmentEvent;
import ai.elimu.analytics.entity.WordLearningEvent;
import timber.log.Timber;
-@Database(version = 6, entities = {LetterLearningEvent.class, LetterAssessmentEvent.class, LetterSoundLearningEvent.class, WordLearningEvent.class, WordAssessmentEvent.class, StoryBookLearningEvent.class})
+@Database(version = 7, entities = {LetterLearningEvent.class, LetterAssessmentEvent.class, LetterSoundLearningEvent.class, WordLearningEvent.class, WordAssessmentEvent.class, StoryBookLearningEvent.class, VideoLearningEvent.class})
@TypeConverters({Converters.class})
public abstract class RoomDb extends RoomDatabase {
@@ -58,7 +59,8 @@ public static RoomDb getDatabase(final Context context) {
MIGRATION_2_3,
MIGRATION_3_4,
MIGRATION_4_5,
- MIGRATION_5_6
+ MIGRATION_5_6,
+ MIGRATION_6_7
)
.build();
}
@@ -122,4 +124,15 @@ public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL(sql);
}
};
+
+ private static final Migration MIGRATION_6_7 = new Migration(6, 7) {
+ @Override
+ public void migrate(@NonNull SupportSQLiteDatabase database) {
+ Timber.i("migrate (" + database.getVersion() + " --> 7)");
+
+ String sql = "CREATE TABLE IF NOT EXISTS `VideoLearningEvent` (`videoId` INTEGER, `videoTitle` TEXT NOT NULL, `learningEventType` TEXT NOT NULL, `androidId` TEXT NOT NULL, `packageName` TEXT NOT NULL, `time` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)";
+ Timber.i("sql: " + sql);
+ database.execSQL(sql);
+ }
+ };
}
diff --git a/app/src/main/java/ai/elimu/analytics/entity/VideoLearningEvent.java b/app/src/main/java/ai/elimu/analytics/entity/VideoLearningEvent.java
new file mode 100644
index 0000000..5dcb993
--- /dev/null
+++ b/app/src/main/java/ai/elimu/analytics/entity/VideoLearningEvent.java
@@ -0,0 +1,42 @@
+package ai.elimu.analytics.entity;
+
+import androidx.annotation.NonNull;
+import androidx.room.Entity;
+
+import ai.elimu.model.v2.enums.analytics.LearningEventType;
+
+@Entity
+public class VideoLearningEvent extends LearningEvent {
+
+ private Long videoId;
+
+ @NonNull
+ private String videoTitle;
+
+ @NonNull
+ private LearningEventType learningEventType;
+
+ public Long getVideoId() {
+ return videoId;
+ }
+
+ public void setVideoId(Long videoId) {
+ this.videoId = videoId;
+ }
+
+ public String getVideoTitle() {
+ return videoTitle;
+ }
+
+ public void setVideoTitle(String videoTitle) {
+ this.videoTitle = videoTitle;
+ }
+
+ public LearningEventType getLearningEventType() {
+ return learningEventType;
+ }
+
+ public void setLearningEventType(LearningEventType learningEventType) {
+ this.learningEventType = learningEventType;
+ }
+}
diff --git a/app/src/main/java/ai/elimu/analytics/receiver/VideoLearningEventReceiver.java b/app/src/main/java/ai/elimu/analytics/receiver/VideoLearningEventReceiver.java
index 6e952a3..2602d0a 100644
--- a/app/src/main/java/ai/elimu/analytics/receiver/VideoLearningEventReceiver.java
+++ b/app/src/main/java/ai/elimu/analytics/receiver/VideoLearningEventReceiver.java
@@ -3,9 +3,11 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.provider.Settings;
import java.util.Calendar;
+import ai.elimu.analytics.entity.VideoLearningEvent;
import ai.elimu.model.v2.enums.analytics.LearningEventType;
import timber.log.Timber;
@@ -15,24 +17,33 @@ public class VideoLearningEventReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Timber.i("onReceive");
- String packageName = intent.getStringExtra("packageName");
- Timber.i("packageName: \"" + packageName + "\"");
-
Calendar timestamp = Calendar.getInstance();
Timber.i("timestamp.getTime(): " + timestamp.getTime());
- Long videoId = intent.getLongExtra("videoId", 0);
- Timber.i("videoId: " + videoId);
+ String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
+ Timber.i("androidId: \"" + androidId + "\"");
- String videoTitle = intent.getStringExtra("videoTitle");
- Timber.i("videoTitle: \"" + videoTitle + "\"");
+ String packageName = intent.getStringExtra("packageName");
+ Timber.i("packageName: \"" + packageName + "\"");
String learningEventTypeAsString = intent.getStringExtra("learningEventType");
Timber.i("learningEventTypeAsString: \"" + learningEventTypeAsString + "\"");
LearningEventType learningEventType = LearningEventType.valueOf(learningEventTypeAsString);
Timber.i("learningEventType: " + learningEventType);
- // TODO: new VideoLearningEvent()
+ Long videoId = intent.getLongExtra("videoId", 0);
+ Timber.i("videoId: " + videoId);
+
+ String videoTitle = intent.getStringExtra("videoTitle");
+ Timber.i("videoTitle: \"" + videoTitle + "\"");
+
+ VideoLearningEvent videoLearningEvent = new VideoLearningEvent();
+ videoLearningEvent.setTime(timestamp);
+ videoLearningEvent.setAndroidId(androidId);
+ videoLearningEvent.setPackageName(packageName);
+ videoLearningEvent.setLearningEventType(learningEventType);
+ videoLearningEvent.setVideoId(videoId);
+ videoLearningEvent.setVideoTitle(videoTitle);
// TODO: Store in database
}