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.
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 3 build types:
debug
qa_test
release
By default, both debug
and qa_test
are pointing to a webapp
test 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 --distribution-type all
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
@Entity
toapp/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
entities
section of the@Database
inapp/src/main/java/ai/elimu/content_provider/room/db/RoomDb.java
-
Bump the
@Database
version 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 matchingtableName
and copy its SQL script from thecreateSql
property.
- Under
-
Open
RoomDb.java
and 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
getDatabase
method 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:
![](https://private-user-images.githubusercontent.com/1451036/285725218-4c462813-bac0-4d4c-9f62-8c4aa12252d9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYwODE2MjMsIm5iZiI6MTcyNjA4MTMyMywicGF0aCI6Ii8xNDUxMDM2LzI4NTcyNTIxOC00YzQ2MjgxMy1iYWMwLTRkNGMtOWY2Mi04YzRhYTEyMjUyZDkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MTFUMTkwMjAzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTBmZGM2Mjc3YWFkZGI1NWI4YjljY2U0ZDdkMmE2MWFlZjE5MDQxMWMyYzA1MDU1MGZkYjNiMjIzMDczYTFlZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.rnW_KNh8dZ3xS0UJg3cR8zPvdYdkMHidkHKU6Ys__e8)
To perform a release, follow these steps:
- Create a new branch for the release
- Remove
-SNAPSHOT
- from the
versionName
inapp/build.gradle
- from the
versionName
inutils/build.gradle
- from the
version
inutils/build.gradle
underpublishing
- 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
versionCode
inapp/build.gradle
- in the
versionName
inapp/build.gradle
- in the
versionCode
inutils/build.gradle
- in the
versionName
inutils/build.gradle
- in the
version
inutils/build.gradle
underpublishing
- in the
- Commit the changes
- Create a pull request for merging your branch into
main
- Create a pull request for merging your branch into
elimu.ai - Free open-source learning software for out-of-school children β¨π
Website π Β β’Β Wiki π Β β’Β Projects π©π½βπ» Β β’Β Milestones π― Β β’Β Community ππ½ Β β’Β Support π