refactor: introduce ScribeLanguage Enum to replace raw string comparisons (Part 4/6) (#426) - #672
Conversation
|
quick note, @prince-0408: Could we ask that you not have |
Thanks so much for heads-up and for editing that, @andrewtavis! Got it! I will make sure to use |
|
Would you be able to fix the merge conflicts here, @prince-0408? |
|
I'll get to the review soon after :) |
Hi @andrewtavis I have resolved all merge conflicts with Ready for your review whenever you have a moment. Thanks! 😊 |
andrewtavis
left a comment
There was a problem hiding this comment.
praise: All's working well here, @prince-0408! Thanks for this and the many other PRs recently 😊
Description
This PR is Part 4 of 6 in modularizing
GeneralKeyboardIMEfor #426.It introduces a strongly-typed
ScribeLanguageenum class to replace error-prone raw string comparisons (e.g.,"English","German") across keyboard services, subclasses, and helper classes.Detailed Changes Table:
ScribeLanguage.kt[NEW]ScribeLanguageenum inbe.scri.modelswithdisplayNameandisoCodeproperties, plusfromString(),fromDisplayName(), andfromIsoCode()parsing helpers.GeneralKeyboardIME.ktval scribeLanguage: ScribeLanguage, added overloaded string constructor, providedoverride val language: String get() = scribeLanguage.displayNamefor backwards compatibility, and replaced raw string comparisons withscribeLanguageenum checks.EnglishKeyboardIME,FrenchKeyboardIME,GermanKeyboardIME,ItalianKeyboardIME,PortugueseKeyboardIME,RussianKeyboardIME,SpanishKeyboardIME, andSwedishKeyboardIMEconstructors to passScribeLanguageenum instances (e.g.ScribeLanguage.ENGLISH).LanguageMappingConstants.ktgetLanguageAlias()to supportScribeLanguageenum directly.Key Benefits:
ScribeLanguageenum values.displayName,isoCode) in a single source of truth.language: Stringso existing callers continue working seamlessly.Related Issue
Refactors part of #426