Fix "Unknown character" for action key with Talkback

This commit is contained in:
Aleksandras Kostarevas 2024-07-13 04:39:43 +03:00
parent 4c04bb8375
commit 593ac9e35e
2 changed files with 11 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import org.futo.inputmethod.keyboard.KeyboardId;
import org.futo.inputmethod.latin.R;
import org.futo.inputmethod.latin.common.Constants;
import org.futo.inputmethod.latin.common.StringUtils;
import org.futo.inputmethod.latin.uix.actions.ActionRegistry;
import java.util.Locale;
@ -285,6 +286,12 @@ final class KeyCodeDescriptionMapper {
if (Character.isDefined(codePoint) && !Character.isISOControl(codePoint)) {
return StringUtils.newSingleCodePointString(codePoint);
}
if(codePoint <= Constants.CODE_ACTION_MAX && codePoint >= Constants.CODE_ACTION_0) {
final int actionId = codePoint - Constants.CODE_ACTION_0;
return ActionRegistry.INSTANCE.actionIdToName(context, actionId);
}
return null;
}

View File

@ -89,6 +89,10 @@ object ActionRegistry {
return action.toIntOrNull() ?: ActionIdToInt[action] ?: throw IllegalArgumentException("Unknown action $actionString")
}
fun actionIdToName(context: Context, id: Int): String {
return context.getString(AllActions[id].name)
}
}
val DefaultActions = listOf(