Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[versions]
agp = "9.2.1"
kotlin = "2.4.0"
kotlin = "2.4.10"
android-compileSdk = "37"
android-minSdk = "26"
android-targetSdk = "37"
app-version-name = "2.0.0"
app-version-code = "58"
app-version-code = "59"
androidx-activity = "1.13.0"
androidx-lifecycle = "2.10.0"
androidx-lifecycle = "2.11.0"
composeHotReload = "1.1.1"
composeMultiplatform = "1.11.1"
kotlinx-coroutines = "1.11.0"
Expand Down
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#Tue Jul 14 19:25:38 GET 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions shared/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<string name="reg_type">Regular</string>
<string name="ulb_type">Unlocked Literal Bible</string>
<string name="udb_type">Unlocked Dynamic Bible</string>
<string name="resource_options">Resource Options</string>
<string name="obs_type">Open Bible Stories</string>
<string name="tn_type">Notes</string>
<string name="tq_type">Questions</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.bibletranslationtools.logger.Logger
import org.bibletranslationtools.resourcecatalog.library.models.TargetLanguage
import org.bibletranslationtools.resourcecatalog.library.models.Translation
import org.bibletranslationtools.resourcecontainer.ContainerTools
import org.bibletranslationtools.resourcecontainer.Resource
import org.bibletranslationtools.resourcecontainer.ResourceContainer
import org.bibletranslationtools.writer.DirectoryProvider
import org.bibletranslationtools.writer.Platform
Expand Down Expand Up @@ -531,6 +532,16 @@ class TargetTranslation private constructor(
targetLanguageName = targetLanguage.name
}

fun changeResourceType(resourceSlug: String) {
if (translationType != ResourceType.TEXT) return
val resourceName = getResourceName(resourceSlug)
manifestAccessor.save(
manifest.copy(resource = Manifest.Resource(resourceSlug, resourceName))
)
this.resourceSlug = resourceSlug
this.resourceName = resourceName
}

fun unlockRepo(): Boolean {
var cleaned = false
val gitDir = File(path.absolutePath, ".git")
Expand Down Expand Up @@ -714,7 +725,6 @@ class TargetTranslation private constructor(
const val LICENSE_FILE = "LICENSE.md"

const val APPLICATION_NAME = "ts-android"
const val OBS_PROJECT_TYPE = "obs"

fun generateTargetTranslationId(
targetLanguageSlug: String,
Expand All @@ -730,7 +740,7 @@ class TargetTranslation private constructor(
}

fun isObsProject(projectId: String): Boolean =
OBS_PROJECT_TYPE.equals(projectId, ignoreCase = true)
Resource.OBS_SLUG.equals(projectId, ignoreCase = true)

suspend fun open(targetTranslationDir: File, onError: (suspend () -> Unit)? = null): TargetTranslation? {
if (targetTranslationDir.exists()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.bibletranslationtools.writer.core

import java.util.regex.Pattern

const val WORDS_CHAPTER = "01"
val WORD_PATTERN: Pattern = Pattern.compile("#+([^\\n]+)\\n+([\\s\\S]*)")
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bibletranslationtools.writer.ui.dialogs.project

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -49,11 +50,18 @@ import btt_writer.shared.generated.resources.label_unknown
import btt_writer.shared.generated.resources.print
import btt_writer.shared.generated.resources.progress
import btt_writer.shared.generated.resources.publish
import btt_writer.shared.generated.resources.reg_type
import btt_writer.shared.generated.resources.resource_options
import btt_writer.shared.generated.resources.target_language
import btt_writer.shared.generated.resources.title_cancel
import btt_writer.shared.generated.resources.translators
import btt_writer.shared.generated.resources.type_label
import btt_writer.shared.generated.resources.udb_type
import btt_writer.shared.generated.resources.ulb_type
import org.bibletranslationtools.resourcecontainer.Resource
import org.bibletranslationtools.writer.DirectoryProvider
import org.bibletranslationtools.writer.core.NativeSpeaker
import org.bibletranslationtools.writer.core.ResourceType
import org.bibletranslationtools.writer.core.TextStyleType
import org.bibletranslationtools.writer.core.TranslationType
import org.bibletranslationtools.writer.core.Typography
Expand All @@ -74,6 +82,7 @@ fun ProjectDetailsDialog(
project: TranslationItem,
onDismiss: () -> Unit,
onChangeLanguage: () -> Unit,
onChangeResourceType: (String) -> Unit,
onDelete: () -> Unit,
onPublish: () -> Unit,
onExport: (Boolean) -> Unit
Expand Down Expand Up @@ -141,6 +150,10 @@ fun ProjectDetailsDialog(
}
var showContributorsDialog by rememberSaveable { mutableStateOf(false) }
var showDeleteDialog by rememberSaveable { mutableStateOf(false) }
var showResourceOptions by rememberSaveable { mutableStateOf(false) }

val canChangeResourceType = project.translation.translationType == ResourceType.TEXT &&
project.translation.resourceSlug != Resource.OBS_SLUG

Dialog(onDismissRequest = onDismiss) {
Surface(
Expand Down Expand Up @@ -196,11 +209,31 @@ fun ProjectDetailsDialog(
}
}

DetailRow(
label = stringResource(Res.string.type_label),
value = project.translation.resourceSlug?.uppercase()
?: project.translation.translationType.title
)
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(Res.string.type_label),
color = MaterialTheme.colorScheme.onSurfaceVariant
)

Text(
text = project.translation.resourceSlug?.uppercase()
?: project.translation.translationType.title,
modifier = Modifier.weight(1f)
)

if (canChangeResourceType) {
TextButton(onClick = { showResourceOptions = true }) {
Text(
text = stringResource(Res.string.label_change),
fontWeight = FontWeight.Bold
)
}
}
}

DetailRow(
label = stringResource(Res.string.progress),
Expand Down Expand Up @@ -305,6 +338,85 @@ fun ProjectDetailsDialog(
onDismiss = { showDeleteDialog = false }
)
}

if (showResourceOptions) {
ResourceOptionsDialog(
currentResourceSlug = project.translation.resourceSlug,
onSelect = { slug ->
showResourceOptions = false
onChangeResourceType(slug)
},
onDismiss = { showResourceOptions = false }
)
}
}

@Composable
private fun ResourceOptionsDialog(
currentResourceSlug: String?,
onSelect: (String) -> Unit,
onDismiss: () -> Unit
) {
val options = listOf(
Resource.ULB_SLUG to stringResource(Res.string.ulb_type),
Resource.UDB_SLUG to stringResource(Res.string.udb_type),
Resource.REGULAR_SLUG to stringResource(Res.string.reg_type)
)

Dialog(onDismissRequest = onDismiss) {
Surface(
modifier = Modifier.fillMaxWidth(0.8f)
.padding(32.dp),
shape = RoundedCornerShape(8.dp),
color = MaterialTheme.colorScheme.surface
) {
Column(modifier = Modifier.fillMaxWidth()) {
Text(
text = stringResource(Res.string.resource_options),
style = MaterialTheme.typography.titleLarge,
modifier = Modifier
.align(Alignment.CenterHorizontally)
.padding(24.dp)
)

options.forEach { (slug, name) ->
val isCurrent = slug == currentResourceSlug
Column(
modifier = Modifier
.fillMaxWidth()
.then(
if (isCurrent) {
Modifier.background(
MaterialTheme.colorScheme.surfaceVariant
)
} else {
Modifier.clickable { onSelect(slug) }
}
)
) {
Text(
text = name,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(
horizontal = 24.dp,
vertical = 16.dp
)
)
HorizontalDivider()
}
}

TextButton(
onClick = onDismiss,
modifier = Modifier
.align(Alignment.End)
.padding(8.dp)
) {
Text(stringResource(Res.string.title_cancel))
}
}
}
}
}

private fun getTranslatorNames(contributors: List<NativeSpeaker>): String {
Expand Down
Loading
Loading