Android application which downloads educational content (e.g. letters, words, audios, storybooks, videos, etc) to the device and provides it to other elimu.ai apps.
See software architecture diagram at https://github.com/elimu-ai/model/blob/main/README.md
The Content Provider comes with a utils library (.aar) which makes it easier for other Android apps to fetch content from the Content Provider.
Note
Here is how to use the utils library in another Android app:
-
Add repository to
./build.gradle:allprojects { repositories { ... + maven { url 'https://jitpack.io' } } } -
Add dependency to
./app/build.gradle:dependencies { + implementation 'ai.elimu:content-provider:<version>' }
See https://jitpack.io/#ai.elimu/content-provider/ for the latest version available.
- Publish the library to your local Maven repository:
./gradlew clean build utils:publishAarPublicationToMavenLocal
- In the app that will be testing the
-SNAPSHOTversion of the library, addmavenLocal():allprojects { repositories { google() mavenCentral() maven { url "https://jitpack.io" } + mavenLocal() } } - Then change to your
-SNAPSHOTversion of the library:[versions] elimuModel = "model-2.0.101" -elimuContentProvider = "1.2.42" +elimuContentProvider = "1.2.43-SNAPSHOT"
For an example of another Android app using the utils library, see the Vitabu app's Gradle configuration:
- https://github.com/elimu-ai/vitabu/blob/main/build.gradle
- https://github.com/elimu-ai/vitabu/blob/main/app/build.gradle
During development, you can choose between two build types:
debugrelease
By default, both debug and release are pointing to a webapp
prod server. And if you want
to run the webapp yourself on localhost while testing the Content Provider app, you can change
the return value of the getBaseUrl method in
BaseApplication.kt:
// return url;
return "http://192.168.xxx.xxx:8080/webapp";Use the ifconfig or ipconfig to get your IPv4 address.
You will also have to enable http connections by adding the following file to
app/src/main/res/xml/network_security_config.xml:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>And then adding it to AndroidManifest.xml:
<application
android:networkSecurityConfig="@xml/network_security_config"After that, connect your Android device to the same Wi-Fi network as your computer, and run the app.
./gradlew wrapper --gradle-version x.x.x
Important
When adding a new database @Entity (or modifying an existing one), you need to prepare a database
migration (SQL script) in
app/src/main/java/ai/elimu/content_provider/room/db/RoomDb.java.
Follow these steps:
-
Add the new/modified
@Entitytoapp/src/main/java/ai/elimu/content_provider/room/entity/ -
Add the entity's DAO interface to
app/src/main/java/ai/elimu/content_provider/room/dao/ -
Include the DAO interface in
app/src/main/java/ai/elimu/content_provider/room/db/RoomDb.java -
Include the entity in the
entitiessection of the@Databaseinapp/src/main/java/ai/elimu/content_provider/room/db/RoomDb.java -
Bump the
@Databaseversion inapp/src/main/java/ai/elimu/content_provider/room/db/RoomDb.java -
Build the code with
./gradlew clean build -
Open the new database schema generated at
app/schemas/ai.elimu.content_provider.room.db.RoomDb/<version>.json- Under
entities, find the matchingtableNameand copy its SQL script from thecreateSqlproperty.
- Under
-
Open
RoomDb.javaand add a new method for the latest migration- Paste the SQL script from the above JSON schema, and replace
${TABLE_NAME}with the name of the table you created/modified. - Include the migration in the
getDatabasemethod inRoomDb.java.
- Paste the SQL script from the above JSON schema, and replace
-
To run the database migration, launch the application on your device.
-
To verify that your database migration ran successfully, look at the Logcat output and ensure that there are no RoomDb errors:
2023-11-27 11:46:50.662 6124-13233 ai.elimu.c....RoomDb$18 ai.elimu.content_provider.debug I migrate (23 --> 24) 2023-11-27 11:46:50.663 6124-13233 ai.elimu.c....RoomDb$18 ai.elimu.content_provider.debug I sql: CREATE TABLE IF NOT EXISTS `LetterSound` (`revisionNumber` INTEGER NOT NULL, `usageCount` INTEGER, `id` INTEGER, PRIMARY KEY(`id`))
Tip
You can also use Android Studio's Database Inspector to verify that the database migration succeeded:
To perform a release, follow these steps:
- Merge your PR into the
mainbranch - Wait for the "Gradle Release" workflow to complete
- Ensure that the new release version appears at https://github.com/elimu-ai/content-provider/releases
Important
After you publish a new release, remember to also bump the version in all Android app repos that depend on the utils library:
- https://github.com/elimu-ai/kukariri/blob/main/gradle/libs.versions.toml
- https://github.com/elimu-ai/herufi/blob/main/gradle/libs.versions.toml
- https://github.com/elimu-ai/vitabu/blob/main/gradle/libs.versions.toml
- https://github.com/elimu-ai/filamu/blob/main/gradle/libs.versions.toml
elimu.ai - Free open-source learning software for out-of-school children πβ¨
Website π Β β’Β Wiki π Β β’Β Projects π©π½βπ» Β β’Β Milestones π― Β β’Β Community ππ½ Β β’Β Support π

