Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Little need to keep empty_card_warning string? #17132

Open
snowtimeglass opened this issue Sep 25, 2024 · 4 comments
Open

Little need to keep empty_card_warning string? #17132

snowtimeglass opened this issue Sep 25, 2024 · 4 comments
Labels
Accepted Maintainers welcome a PR implementing this feature Priority-Low

Comments

@snowtimeglass
Copy link
Contributor

The following string of empty_card_warning has already been replaced (with another string reused from the desktop version) at least in some situation in the app as the following images.

This card is empty. Use the “Empty cards” option from the menu on the deck list screen.

image

https://crowdin.com/editor/ankidroid/7291/en-eo?view=comfortable&filter=basic&value=0#6534296

image

However, the string still exists in the current code:

https://github.com/search?q=repo%3Aankidroid%2FAnki-Android%20empty_card_warning&type=code

/**
* Optional warning for when a typed answer can't be displayed
*
* * empty card [R.string.empty_card_warning]
* * unknown field specified [R.string.unknown_type_field_warning]
* */
var warning: String? = null
private set
/**
* @return true If entering input via EditText
* and if the current card has a `{{type:field}}` on the card template
*/
fun validForEditText(): Boolean {
return !useInputTag && correct != null
}
fun autoFocusEditText(): Boolean {
return validForEditText() && autoFocus
}
/**
* Extract type answer/cloze text and font/size
* @param card The next card to display
*/
fun updateInfo(col: Collection, card: Card, res: Resources) {
correct = null
val q = card.question(col)
val m = PATTERN.matcher(q)
var clozeIdx = 0
if (!m.find()) {
return
}
var fldTag = m.group(1)!!
// if it's a cloze, extract data
if (fldTag.startsWith("cloze:")) {
// get field and cloze position
clozeIdx = card.ord + 1
fldTag = fldTag.split(":").toTypedArray()[1]
}
// loop through fields for a match
val flds: JSONArray = card.noteType(col).getJSONArray("flds")
for (fld in flds.jsonObjectIterable()) {
val name = fld.getString("name")
if (name == fldTag) {
correct = card.note(col).getItem(name)
if (clozeIdx != 0) {
// narrow to cloze
correct = contentForCloze(correct!!, clozeIdx)
}
font = fld.getString("font")
size = fld.getInt("size")
languageHint = LanguageHintService.getLanguageHintForField(fld)
break
}
}
when (correct) {
null -> {
warning = if (clozeIdx != 0) {
res.getString(R.string.empty_card_warning)
} else {
res.getString(R.string.unknown_type_field_warning, fldTag)
}
}
"" -> {
correct = null
}
else -> {
warning = null
}
}

I'm wondering about whether or not there still are situations where the message actually appears in the app. Additionally, even if it still is used, I suspect it would be better to replace it with the string reused from the desktop version, as in the case in the images above.

(Optional) Anything else you want to share?

For context: https://discord.com/channels/368267295601983490/701922522836369498/1288172228369973358

@Giyutomioka-SS
Copy link
Contributor

Looking into this.

@Giyutomioka-SS
Copy link
Contributor

@snowtimeglass , could you explain a little more about what can be done here?

@snowtimeglass
Copy link
Contributor Author

After considering whether there is a need to keep that string or not, the string could possibly be removed (replaced with the desktop string above).

@david-allison
Copy link
Member

It doesn't need to be used. Issue accepted and can be worked on

@david-allison david-allison added Accepted Maintainers welcome a PR implementing this feature Priority-Low labels Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Maintainers welcome a PR implementing this feature Priority-Low
Projects
None yet
Development

No branches or pull requests

3 participants