-
Notifications
You must be signed in to change notification settings - Fork 238
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
make "hide letters" only hide letters, add new toggle "hide symbols" (fixes #299) #370
Conversation
Okay, I have no idea what I've done wrong here, ugh. I don't know why the CI is upset about this. edit: I guess it's fine now? |
@@ -363,7 +364,12 @@ fun KeyText(key: KeyC, keySize: Dp, hideLetters: Boolean, capsLock: Boolean) { | |||
} | |||
is KeyDisplay.TextDisplay -> { | |||
// Only hide the letters for text, not symbols | |||
if (!hideLetters) { | |||
val showKey = if (!display.text.any { !it.isLetter() }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's going on here?
This isn't going to work for things like multiple letter keys, etc. You're going to need to add a KeyType enum {Letter, Symbol}
to each key, probably with a default of KeyType.Letter
, and alter every keyboard to set that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using isLetter() on every character in the string. For example: "a" is a letter, "abc" is a letter, and "?" is a symbol, but "a?" is also a symbol. My assumption is that anything that is purely letter-characters is probably basically a letter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, but I'd move the isLetter
check above, and have this do a simple if (!hideLetters && !isMadeOfLetters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I made hiding symbols a separate toggle, I found that I have to use the isLetter
check to determine which of hideLetters
and hideSymbols
to apply. I tried a bunch of logic like what you're describing in a python script and none of my attempts correctly resolved every possibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you haven't tested this code in thumbkey?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, .com
is hidden with hideSymbols. I'm not sure if I necessarily intended that when I initially wrote it, but in a way it feels like the behaviour you would expect? Obviously, this is a particular edge case that could go either way, and it's a reason to potentially explicitly label each key as a symbol or not a symbol, but I think it's probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad news: it does cause issues with the Greek keyboard, because combining accents are not letters:
thumb-key/app/src/main/java/com/dessalines/thumbkey/keyboards/ThumbKeyGRv1.kt
Lines 294 to 295 in 7134891
display = KeyDisplay.TextDisplay("Ϋ́"), | |
action = KeyAction.CommitText("Ϋ́"), |
thumb-key/app/src/main/java/com/dessalines/thumbkey/keyboards/ThumbKeyGRv1.kt
Lines 320 to 321 in 7134891
display = KeyDisplay.TextDisplay("Ϊ́"), | |
action = KeyAction.CommitText("Ϊ́"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm... Could you check if there exists any other kotlin / java function would work? Might be something better than isLetter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not, even if imperfect, this would probably still be better than just hiding everything as it currently does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no better single function to my knowledge. It's possible to compare the character's Unicode category, and check if it's one of the 3 "mark" categories. I'm not 100% what all is in the mark categories overall, but punctuation and other special symbols generally shouldn't be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually DB migrations are still broken.
val MIGRATION_7_8 = object : Migration(7, 8) { | ||
override fun migrate(database: SupportSQLiteDatabase) { | ||
database.execSQL( | ||
"alter table AppSettings add column hide_symbols BOOLEAN NOT NULL default $DEFAULT_HIDE_SYMBOLS", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whew, good thing I tested this, because it breaks existing installations. This needed to be an INTEGER, not a boolean. I'm fixing it now.
Okay I fixed this up. In the future please actually test this. If you did so, you'd see that it would cause an immediate crash on startup, because sqlite doesn't have a boolean type. |
@@ -363,7 +364,15 @@ fun KeyText(key: KeyC, keySize: Dp, hideLetters: Boolean, capsLock: Boolean) { | |||
} | |||
is KeyDisplay.TextDisplay -> { | |||
// Only hide the letters for text, not symbols | |||
if (!hideLetters) { | |||
val containsLetters = display.text.any { it.isLetter() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this to be clearer, and not use a triple negative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually changes the logic, but after thinking it over, I do agree that this is probably the better of the two choices here anyway.
I think this PR is set up correctly this time, and I already figured out how to use the linter, so it should be pretty much good.