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:
allprojects { repositories { ... maven { url 'https://jitpack.io' } } } -
Add dependency:
dependencies { implementation 'com.github.elimu-ai:content-provider:<version>@aar' }
See https://jitpack.io/#elimu-ai/content-provider/ for the latest version available.
- Change
versionName,versionCodeand publicationversionin https://github.com/elimu-ai/content-provider/blob/main/utils/build.gradle - Under
publishing->repositoriesblock: Replace the existingmavenrepo bymavenLocal() - Run
./gradlew clean utils:publishReleasePublicationToMavenLocalfrom project's root folder - In app side: Add
mavenLocal()torepositsoriesblock inbuild.gradlescript - Implement
ai.elimu.content_provider:utils:$snapshot_versionin app'sbuild.gradlefile
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.java:
// 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:
- Create a new branch for the release
- Remove
-SNAPSHOT- from the
versionNameinapp/build.gradle - from the
versionNameinutils/build.gradle - from the
versioninutils/build.gradleunderpublishing
- from the
- Commit the changes
- Click "Draft a new release" at https://github.com/elimu-ai/content-provider/releases
- Pick the new branch you created as the target branch
- Create a new tag (e.g.
1.2.19) - Choose a release title, and click "Publish release"
- Ensure that the release appears at https://jitpack.io/#elimu-ai/content-provider with "Status: ok"
- Prepare for next development iteration by bumping the version and adding
-SNAPSHOT- in the
versionCodeinapp/build.gradle - in the
versionNameinapp/build.gradle - in the
versionCodeinutils/build.gradle - in the
versionNameinutils/build.gradle - in the
versioninutils/build.gradleunderpublishing
- in the
- Commit the changes
- Create a pull request for merging your branch into
main
- Create a pull request for merging your branch into
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/common-utils/blob/main/gradle/libs.versions.toml
- 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 π

