Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package ai.elimu.content_provider.provider

import ai.elimu.content_provider.BuildConfig
import ai.elimu.content_provider.room.db.RoomDb
import ai.elimu.content_provider.room.entity.Emoji
import android.content.ContentProvider
import android.content.ContentValues
import android.content.UriMatcher
import android.database.Cursor
import android.net.Uri
import android.os.Bundle
import android.util.Log

class EmojiContentProvider : ContentProvider() {
Expand Down Expand Up @@ -51,6 +53,8 @@ class EmojiContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_EMOJI_ID -> {
Expand All @@ -67,6 +71,8 @@ class EmojiContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_EMOJIS_BY_WORD_LABEL_ID -> {
Expand All @@ -83,6 +89,8 @@ class EmojiContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
else -> {
Expand All @@ -91,6 +99,23 @@ class EmojiContentProvider : ContentProvider() {
}
}

/**
* Prepare database column names needed by the Cursor-to-Gson converter in the `:utils` module.
*/
private fun prepareBundle(): Bundle {
Log.i(this::class.simpleName, "prepareBundle")
val bundle = Bundle().apply {
putInt("version_code", BuildConfig.VERSION_CODE)
putString("id", Emoji::id.name)
putString("revision_number", Emoji::revisionNumber.name)
putString("usage_count", Emoji::usageCount.name)
putString("glyph", Emoji::glyph.name)
putString("unicode_version", Emoji::unicodeVersion.name)
putString("unicode_emoji_version", Emoji::unicodeEmojiVersion.name)
}
return bundle
}

/**
* Handles requests for the MIME type of the data at the given URI.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package ai.elimu.content_provider.provider

import ai.elimu.content_provider.BuildConfig
import ai.elimu.content_provider.room.db.RoomDb
import ai.elimu.content_provider.room.entity.Image
import ai.elimu.content_provider.util.FileHelper.getImageFile
import android.content.ContentProvider
import android.content.ContentValues
import android.content.UriMatcher
import android.database.Cursor
import android.net.Uri
import android.os.Bundle
import android.os.ParcelFileDescriptor
import android.util.Log
import java.io.FileNotFoundException
Expand Down Expand Up @@ -58,6 +60,8 @@ class ImageContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_IMAGE_ID -> {
Expand All @@ -74,6 +78,8 @@ class ImageContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_IMAGES_BY_WORD_LABEL_ID -> {
Expand All @@ -90,6 +96,8 @@ class ImageContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
else -> {
Expand All @@ -98,6 +106,23 @@ class ImageContentProvider : ContentProvider() {
}
}

/**
* Prepare database column names needed by the Cursor-to-Gson converter in the `:utils` module.
*/
private fun prepareBundle(): Bundle {
Log.i(this::class.simpleName, "prepareBundle")
val bundle = Bundle().apply {
putInt("version_code", BuildConfig.VERSION_CODE)
putString("id", Image::id.name)
putString("revision_number", Image::revisionNumber.name)
putString("usage_count", Image::usageCount.name)
putString("title", Image::title.name)
putString("image_format", Image::imageFormat.name)
putString("checksum_md5", Image::checksumMd5.name)
}
return bundle
}

/**
* Handles requests for the MIME type of the data at the given URI.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package ai.elimu.content_provider.provider

import ai.elimu.content_provider.BuildConfig
import ai.elimu.content_provider.room.db.RoomDb
import ai.elimu.content_provider.room.entity.Letter
import android.content.ContentProvider
import android.content.ContentValues
import android.content.UriMatcher
import android.database.Cursor
import android.net.Uri
import android.os.Bundle
import android.util.Log

class LetterContentProvider : ContentProvider() {
Expand Down Expand Up @@ -47,6 +49,8 @@ class LetterContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_LETTERS_BY_LETTER_SOUND_ID -> {
Expand All @@ -63,6 +67,8 @@ class LetterContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_LETTER_ID -> {
Expand All @@ -79,6 +85,8 @@ class LetterContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
else -> {
Expand All @@ -87,6 +95,22 @@ class LetterContentProvider : ContentProvider() {
}
}

/**
* Prepare database column names needed by the Cursor-to-Gson converter in the `:utils` module.
*/
private fun prepareBundle(): Bundle {
Log.i(this::class.simpleName, "prepareBundle")
val bundle = Bundle().apply {
putInt("version_code", BuildConfig.VERSION_CODE)
putString("id", Letter::id.name)
putString("revision_number", Letter::revisionNumber.name)
putString("usage_count", Letter::usageCount.name)
putString("text", Letter::text.name)
putString("diacritic", Letter::diacritic.name)
}
return bundle
}

override fun getType(uri: Uri): String? {
Log.i(TAG, "getType")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package ai.elimu.content_provider.provider

import ai.elimu.content_provider.BuildConfig
import ai.elimu.content_provider.room.db.RoomDb
import ai.elimu.content_provider.room.entity.LetterSound
import android.content.ContentProvider
import android.content.ContentValues
import android.content.UriMatcher
import android.database.Cursor
import android.net.Uri
import android.os.Bundle
import android.util.Log

class LetterSoundContentProvider : ContentProvider() {
Expand Down Expand Up @@ -49,6 +51,8 @@ class LetterSoundContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_LETTER_SOUND_ID -> {
Expand All @@ -65,6 +69,8 @@ class LetterSoundContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
else -> {
Expand All @@ -73,6 +79,20 @@ class LetterSoundContentProvider : ContentProvider() {
}
}

/**
* Prepare database column names needed by the Cursor-to-Gson converter in the `:utils` module.
*/
private fun prepareBundle(): Bundle {
Log.i(this::class.simpleName, "prepareBundle")
val bundle = Bundle().apply {
putInt("version_code", BuildConfig.VERSION_CODE)
putString("id", LetterSound::id.name)
putString("revision_number", LetterSound::revisionNumber.name)
putString("usage_count", LetterSound::usageCount.name)
}
return bundle
}

override fun getType(uri: Uri): String? {
Log.i(TAG, "getType")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package ai.elimu.content_provider.provider

import ai.elimu.content_provider.BuildConfig
import ai.elimu.content_provider.room.db.RoomDb
import ai.elimu.content_provider.room.entity.Sound
import android.content.ContentProvider
import android.content.ContentValues
import android.content.UriMatcher
import android.database.Cursor
import android.net.Uri
import android.os.Bundle
import android.util.Log

class SoundContentProvider : ContentProvider() {
Expand Down Expand Up @@ -49,6 +51,8 @@ class SoundContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_SOUNDS_BY_LETTER_SOUND_ID -> {
Expand All @@ -65,6 +69,8 @@ class SoundContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_SOUND_ID -> {
Expand All @@ -81,6 +87,8 @@ class SoundContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
else -> {
Expand All @@ -89,6 +97,22 @@ class SoundContentProvider : ContentProvider() {
}
}

/**
* Prepare database column names needed by the Cursor-to-Gson converter in the `:utils` module.
*/
private fun prepareBundle(): Bundle {
Log.i(this::class.simpleName, "prepareBundle")
val bundle = Bundle().apply {
putInt("version_code", BuildConfig.VERSION_CODE)
putString("id", Sound::id.name)
putString("revision_number", Sound::revisionNumber.name)
putString("usage_count", Sound::usageCount.name)
putString("value_ipa", Sound::valueIpa.name)
putString("diacritic", Sound::diacritic.name)
}
return bundle
}

override fun getType(uri: Uri): String? {
Log.i(TAG, "getType")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package ai.elimu.content_provider.provider

import ai.elimu.content_provider.BuildConfig
import ai.elimu.content_provider.room.db.RoomDb
import ai.elimu.content_provider.room.entity.StoryBook
import android.content.ContentProvider
import android.content.ContentValues
import android.content.UriMatcher
import android.database.Cursor
import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.core.net.toUri

Expand Down Expand Up @@ -58,6 +60,8 @@ class StoryBookContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_STORYBOOK_ID -> {
Expand All @@ -77,6 +81,8 @@ class StoryBookContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_STORYBOOK_CHAPTERS -> {
Expand All @@ -96,6 +102,8 @@ class StoryBookContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
CODE_STORYBOOK_CHAPTER_PARAGRAPHS -> {
Expand All @@ -114,6 +122,8 @@ class StoryBookContentProvider : ContentProvider() {

cursor.setNotificationUri(context.contentResolver, uri)

cursor.extras = prepareBundle()

return cursor
}
else -> {
Expand All @@ -122,6 +132,24 @@ class StoryBookContentProvider : ContentProvider() {
}
}

/**
* Prepare database column names needed by the Cursor-to-Gson converter in the `:utils` module.
*/
private fun prepareBundle(): Bundle {
Log.i(this::class.simpleName, "prepareBundle")
val bundle = Bundle().apply {
putInt("version_code", BuildConfig.VERSION_CODE)
putString("id", StoryBook::id.name)
putString("revision_number", StoryBook::revisionNumber.name)
putString("usage_count", StoryBook::usageCount.name)
putString("title", StoryBook::title.name)
putString("description", StoryBook::description.name)
putString("cover_image_id", StoryBook::coverImageId.name)
putString("reading_level", StoryBook::readingLevel.name)
}
return bundle
}

/**
* Handles requests for the MIME type of the data at the given URI.
*/
Expand Down
Loading
Loading