parent
b90af30496
commit
dc999bacca
@ -14,6 +14,8 @@ disable_translator_summary=Disable auto translation and enable source translatio
|
||||
translate_dialog_box_title=Translator
|
||||
translate_dialog_box_summary=Engine used to translate dialog boxes
|
||||
translate_dialog_box_toast=The translator has been changed to
|
||||
enable_manga_details_translation_title=Enable translation of manga details
|
||||
enable_manga_details_translation_summary=This option will slow down the loading of manga details
|
||||
chapter_unavailable_message=Chapter cannot be translated
|
||||
dialog_box_scale_title=Dialog box scale
|
||||
dialog_box_scale_default=Default
|
||||
dialog_box_scale_summary=Customize the size of the dialog box. This can be useful if you want larger fonts. Setting a value greater than 1.0x will cause the text to overflow the expected dialog box
|
||||
dialog_box_scale_message=Dialog box scale changed to %s
|
||||
|
@ -14,6 +14,8 @@ disable_translator_summary=Desativar tradução automática e ativar tradução
|
||||
translate_dialog_box_title=Tradutor
|
||||
translate_dialog_box_summary=Motor utilizado para traduzir caixas de diálogo
|
||||
translate_dialog_box_toast=O tradutor foi alterado para
|
||||
enable_manga_details_translation_title=Habilitar tradução dos detalhes do manga
|
||||
enable_manga_details_translation_summary=Esta opção tornará o carregamento dos detalhes do mangá mais lento
|
||||
chapter_unavailable_message=O capítulo não pode ser traduzido
|
||||
dialog_box_scale_title=Escala da caixa de diálogo
|
||||
dialog_box_scale_default=Padrão
|
||||
dialog_box_scale_summary=Personalize o tamanho da caixa de diálogo. Isso pode ser útil se você desejar fontes maiores. Definir um valor maior que 1,0x fará com que o texto ultrapasse os limites da caixa de diálogo esperada
|
||||
dialog_box_scale_message=A escala da caixa de diálogo foi alterada para %s
|
||||
|
@ -3,7 +3,7 @@ ext {
|
||||
extClass = '.ManhuarmFactory'
|
||||
themePkg = 'madara'
|
||||
baseUrl = 'https://manhuarm.com'
|
||||
overrideVersionCode = 1
|
||||
overrideVersionCode = 2
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,10 @@ class Manhuarm(
|
||||
get() = preferences.getString(FONT_SIZE_PREF, DEFAULT_FONT_SIZE)!!.toInt()
|
||||
set(value) = preferences.edit().putString(FONT_SIZE_PREF, value.toString()).apply()
|
||||
|
||||
private var dialogBoxScale: Float
|
||||
get() = preferences.getString(DIALOG_BOX_SCALE_PREF, language.dialogBoxScale.toString())!!.toFloat()
|
||||
set(value) = preferences.edit().putString(DIALOG_BOX_SCALE_PREF, value.toString()).apply()
|
||||
|
||||
private var fontName: String
|
||||
get() = preferences.getString(FONT_NAME_PREF, language.fontName)!!
|
||||
set(value) = preferences.edit().putString(FONT_NAME_PREF, value).apply()
|
||||
@ -79,12 +83,13 @@ class Manhuarm(
|
||||
baseLanguage = "en",
|
||||
availableLanguages = setOf("en", "es", "fr", "id", "it", "pt-BR"),
|
||||
classLoader = this::class.java.classLoader!!,
|
||||
createMessageFileName = { createDefaultMessageFileName("${name.lowercase()}_${language.lang}") },
|
||||
createMessageFileName = { createDefaultMessageFileName("${name.lowercase()}_$it") },
|
||||
)
|
||||
|
||||
private val settings get() = language.copy(
|
||||
fontSize = this@Manhuarm.fontSize,
|
||||
fontName = this@Manhuarm.fontName,
|
||||
dialogBoxScale = this@Manhuarm.dialogBoxScale,
|
||||
disableWordBreak = this@Manhuarm.disableWordBreak,
|
||||
disableTranslator = this@Manhuarm.disableTranslator,
|
||||
disableFontSettings = this@Manhuarm.fontName == DEVICE_FONT,
|
||||
@ -195,6 +200,8 @@ class Manhuarm(
|
||||
"80", "88", "96",
|
||||
)
|
||||
|
||||
val scale = (0..10).map { 1f + it / 10f }.toTypedArray()
|
||||
|
||||
val fonts = arrayOf(
|
||||
i18n["font_name_device_title"] to DEVICE_FONT,
|
||||
"Anime Ace" to "animeace2_regular",
|
||||
@ -234,6 +241,38 @@ class Manhuarm(
|
||||
}
|
||||
}.also(screen::addPreference)
|
||||
|
||||
ListPreference(screen.context).apply {
|
||||
key = DIALOG_BOX_SCALE_PREF
|
||||
title = i18n["dialog_box_scale_title"]
|
||||
entries = scale.map {
|
||||
"${it}x" + if (it == 1f) " - ${i18n["dialog_box_scale_default"]}" else ""
|
||||
}.toTypedArray()
|
||||
entryValues = scale.map(Float::toString).toTypedArray()
|
||||
|
||||
summary = buildString {
|
||||
appendLine(i18n["dialog_box_scale_summary"])
|
||||
append("\t* %s")
|
||||
}
|
||||
|
||||
setDefaultValue(dialogBoxScale.toString())
|
||||
|
||||
setOnPreferenceChange { _, newValue ->
|
||||
val selected = newValue as String
|
||||
val index = this.findIndexOfValue(selected)
|
||||
val entry = entries[index] as String
|
||||
|
||||
dialogBoxScale = selected.toFloat()
|
||||
|
||||
Toast.makeText(
|
||||
screen.context,
|
||||
i18n["dialog_box_scale_message"].format(entry),
|
||||
Toast.LENGTH_LONG,
|
||||
).show()
|
||||
|
||||
true // It's necessary to update the user interface
|
||||
}
|
||||
}.also(screen::addPreference)
|
||||
|
||||
if (!language.disableFontSettings) {
|
||||
ListPreference(screen.context).apply {
|
||||
key = FONT_NAME_PREF
|
||||
@ -345,6 +384,7 @@ class Manhuarm(
|
||||
const val DEVICE_FONT = "device:"
|
||||
private const val FONT_SIZE_PREF = "fontSizePref"
|
||||
private const val FONT_NAME_PREF = "fontNamePref"
|
||||
private const val DIALOG_BOX_SCALE_PREF = "dialogBoxScalePref"
|
||||
private const val DISABLE_WORD_BREAK_PREF = "disableWordBreakPref"
|
||||
private const val DISABLE_TRANSLATOR_PREF = "disableTranslatorPref"
|
||||
private const val TRANSLATOR_PROVIDER_PREF = "translatorProviderPref"
|
||||
|
@ -31,16 +31,16 @@ class PageDto(
|
||||
data class Dialog(
|
||||
val x: Float,
|
||||
val y: Float,
|
||||
val width: Float,
|
||||
val height: Float,
|
||||
private val _width: Float,
|
||||
private val _height: Float,
|
||||
val angle: Float = 0f,
|
||||
val isBold: Boolean = false,
|
||||
val isNewApi: Boolean = false,
|
||||
val textByLanguage: Map<String, String> = emptyMap(),
|
||||
val type: String = "normal",
|
||||
private val fbColor: List<Int> = emptyList(),
|
||||
private val bgColor: List<Int> = emptyList(),
|
||||
) {
|
||||
var scale: Float = 1F
|
||||
|
||||
val height: Float get() = scale * _height
|
||||
val width: Float get() = scale * _width
|
||||
|
||||
val text: String get() = textByLanguage["text"] ?: throw Exception("Dialog not found")
|
||||
fun getTextBy(language: Language) = when {
|
||||
!language.disableTranslator -> textByLanguage[language.origin]
|
||||
@ -61,8 +61,8 @@ private object DialogListSerializer :
|
||||
buildJsonObject {
|
||||
put("x", coordinates[0])
|
||||
put("y", coordinates[1])
|
||||
put("width", coordinates[2])
|
||||
put("height", coordinates[3])
|
||||
put("_width", coordinates[2])
|
||||
put("_height", coordinates[3])
|
||||
put("textByLanguage", textByLanguage)
|
||||
}
|
||||
},
|
||||
|
@ -7,6 +7,7 @@ data class Language(
|
||||
val target: String = lang,
|
||||
val origin: String = "en",
|
||||
val fontSize: Int = 28,
|
||||
val dialogBoxScale: Float = 1f,
|
||||
val disableFontSettings: Boolean = false,
|
||||
val disableWordBreak: Boolean = false,
|
||||
val disableTranslator: Boolean = false,
|
||||
|
@ -58,6 +58,7 @@ class ComposedImageInterceptor(
|
||||
val canvas = Canvas(bitmap)
|
||||
|
||||
dialogues.forEach { dialog ->
|
||||
dialog.scale = language.dialogBoxScale
|
||||
val textPaint = createTextPaint(selectFontFamily())
|
||||
val dialogBox = createDialogBox(dialog, textPaint)
|
||||
val y = getYAxis(textPaint, dialog, dialogBox)
|
||||
|
Loading…
x
Reference in New Issue
Block a user