orangethewell / open-witness-library

Open source bible study program on Linux!
MIT License
9 stars 0 forks source link

Add Markup Functionality #2

Open livrasand opened 10 months ago

livrasand commented 10 months ago

Hello friend, I would like to help you with the implementation of text markup. Below I'll provide a simplified example of how you can approach this functionality in your project. Please note that this is a conceptual example.

First, here's a general approach to how you might implement the text markup functionality and save the markup:

1. User Interface:

2. Dialing Logic:

3. Marking Storage:

4. Upload Marking:

Here's a simplified example of how you might structure the code:

// En el código Kotlin (app/src/main/kotlin/...):

// Almacenamiento de marcadores
val markersJsonFile = File("markers.json")

fun saveMarker(selectionRange: String, markedText: String) {
    val markers = loadMarkers()
    markers[selectionRange] = markedText
    markersJsonFile.writeText(Json.encodeToString(markers))
}

fun loadMarkers(): MutableMap<String, String> {
    if (markersJsonFile.exists()) {
        val markersJson = markersJsonFile.readText()
        return Json.decodeFromString(markersJson)
    }
    return mutableMapOf()
}

Keep in mind that you will have to adapt it to the structure of the "Open Witness Library" project.

orangethewell commented 10 months ago

Ooh, thank you for this! I will keep an eye on your suggestion. But there's a worry for making open witness library compatible with JW Library markups, since the backup file export markups too.

I don't know for now if I will add a new approach or try to decode the backup file approach (with seems to be very simple and optimized)

Anyway, thank you for this, I will assign a branch for this soon! 😄