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

fix(layout): add extended layout for kannada #444

Merged
merged 6 commits into from
May 2, 2024
Merged

fix(layout): add extended layout for kannada #444

merged 6 commits into from
May 2, 2024

Conversation

pixincreate
Copy link
Contributor

@pixincreate pixincreate commented Jan 24, 2024

This PR improves the existing Kannada language layout making it more intuitive and usable.

Modified layout a bit to make it resemble GBoard layout as I found the layout to be more intuitive.

Also, compiler guided code formatting.

image image image [when number row is forcefully enabled, at least on GBoard, `%\|=[]<>{}` is non-existent, since hiding it on OpenBoard, I found it to be a bit too much of a work, so restored the old layout partially]

P.S: Just checked #417 on top level, will have a deeper look depending on the available time to improve it further. Existing works flawlessly though.

@Helium314
Copy link
Owner

You modify MUCH more than the Kannada layout here. Especially you change the symbols layout to your taste for everyone.
Personally I am not interested in needing to learn where keys moved just because you find it more intuitive. At the same time I also think that some of these changes seem reasonable, so I suggest you open an issue about this, whether this is wanted.

For the Kannada layout this is somewhat similar. I doubt someone who used the current Kannada layout on AOSP keyboard or forks for many years will be happy about being forced to learn a new layout.
Adding a new layout instead of replacing the current one makes much more sense in this case.

@pixincreate
Copy link
Contributor Author

  • Will revert the symbol layout
  • Instead of modifying the existing Kannada Layout, will add it as yet another layout so that no one is harmed if that's okay

@Helium314
Copy link
Owner

Instead of modifying the existing Kannada Layout, will add it as yet another layout so that no one is harmed if that's okay

Sure, that would be very welcome!
I had planned to add some rough outline on how to add new layouts, but still didn't get around to do this. So if there is anything unclear, e.g. in the locale_key_texts file or in the layout format, I hope I can help.

@Helium314
Copy link
Owner

Helium314 commented Jan 28, 2024

Does the kn_ex file actually work? Considering that the name to look up is decided from the language, I would expect this file is ignored.
The [morekeys] in language_key_texts file should contain popup keys that are similar to the letter, so all layouts have them in common. Other popup keys should be in the layout.
Here it looks like your kn_ex file does a much better job than the current kn file (which even contains numbers in the morekeys section). Could you merge the language_key_texts files, and maybe move unsuitable morekeys to the old kannada layout?

What is the point of the changes to the English language_key_texts file? It appears to duplicate the defaults, and doesn't appear to be related to adding the new layout.
Why the changes in KeyboardState? They also don't appear to be related to adding the layout.

@pixincreate
Copy link
Contributor Author

Does the kn_ex file actually work?

No, I'm yet to update that (couldn't work on the PR due to other work, will pick this up).
Since that was not working as expected, I was planning to replace the txt file json file as I found that to allow adding extra keys with a bit ease.

What is the point of the changes to the English language_key_texts file? It appears to duplicate the defaults, and doesn't appear to be related to adding the new layout.

Will revert this change

Why the changes in KeyboardState?

That was compiler guided optimizations suggested by the Android Studio.

@Helium314
Copy link
Owner

Since that was not working as expected, I was planning to replace the txt file json file as I found that to allow adding extra keys with a bit ease.

You do not need a json file if you're referring to the popup keys.
For txt files you can add them like in language_key_texts, with the difference that the will show up only for this layout, and in the layout category (relevant when selecting popup key order).
For assigning keys to the correct category it's necessary to consider whether to add them to the layout or to language_key_texts.

After you started the PR, I updated layouts.md, not sure whether there is anything new for you though.

@pixincreate
Copy link
Contributor Author

Looks like code refactoring is going on in the repo? I even did a fresh clone of the repo and the paths still point have /org/dslul/openboard instead of helium314/keyboard but most of the files are non-existent in the path.

@Helium314
Copy link
Owner

Looks like code refactoring is going on in the repo? I even did a fresh clone of the repo and the paths still point have /org/dslul/openboard instead of helium314/keyboard but most of the files are non-existent in the path.

Yes, I did a lot of renaming, which was planned for quite a while to happen before the F-Droid release.

I think the rename should not affect this PR too much, as it does only minimal changes to the code.
I will do the relevant changes to KeyboardParser and PreferencesSettingsFragment in upstream, so you will not need to touch any Java/Kotlin code.

Helium314 added a commit that referenced this pull request Feb 10, 2024
@Helium314
Copy link
Owner

I also moved the number keys to properly use the number row in the current kannada layout.
So you can undo the code changes and merge the current code, then it should be able to continue.

@pixincreate
Copy link
Contributor Author

Here it looks like your kn_ex file does a much better job than the current kn file (which even contains numbers in the morekeys section). Could you merge the language_key_texts files, and maybe move unsuitable morekeys to the old kannada layout?

I still have kn_ex.txt file in language_key_texts dir, is it possible to have both kn_ex and kn files separated? Asking because I don't think it is worth merging these 2 files a it would result in confusion in old layout.

image

@Helium314
Copy link
Owner

The file must have the same name as the language tag, otherwise it will not be found.
What could be done is moving popup keys into the layout file. Ideally the language_key_texts file contains only popup keys that are similar to the base key (see the section in layouts.md). I have absolutely no understanding of Kannada, but it appears that this is not done correctly in kn.txt.

Alternatively, if there is little overlap between the base keys (didn't check), the popup keys could be merged relatively easily.

@pixincreate
Copy link
Contributor Author

Yeah, but the existing kannada layout is incomplete and hence the kannada_extended layout. Since the layout/kannada_extended.txt has completely different layout when compared to layout/kannada.txt, I got into dilemma of how can I proceed with language_key_texts/kn.txt.

Like, if I override the existing language_key_texts/kn.txt with the values that are in language_key_texts/kn_ex.txt, that would result in confusion for the existing users and might possibly crash as the existing layout supports 3 rows while the layout that I'm targeting has 5 rows (from GBoard).

@Helium314
Copy link
Owner

language_key_texts files do not know anything about number of rows. They only provide popup keys that should be added to specific keys.

I proposed a while ago to move kn popup keys into the layout, why doesn't this work?

@pixincreate
Copy link
Contributor Author

Number row is not the problem here but rather other content in layout_key_texts/kn.txt. kn.txt and kn_ex.txt are way too different in terms of the contents that is used in pop-up.

@pixincreate
Copy link
Contributor Author

pixincreate commented Mar 23, 2024

i decided to treat the layout as a separate language's layout instead of just adding it to the existing kannada layout. The reason being the already existing kannada layout's popup keys are way too restricted and minimal and does not align with the the extended layout.

i'm afraid whether i can achieve this or it might require core changes to done.
when you select type a letter, 1st 2 rows (greyed ones) get updated corresponding to that typed letter:

image

other than that, for some reason, even after doing all the necessary changes, it shows the language as knx instead of kannada which i'm unable to understand why. other than that, good to go.

@pixincreate pixincreate changed the title fix(layout): modify kannada layout to make it more usable fix(layout): add extended layout for kannada Mar 23, 2024
@Helium314
Copy link
Owner

Number row is not the problem here but rather other content in layout_key_texts/kn.txt. kn.txt and kn_ex.txt are way too different in terms of the contents that is used in pop-up.

I still do not understand this. When you move the popup keys into the layout, there are no popup keys left in the language_key_texts/kn.txt file. Then the only difference could be in [number_row] and [labels] sections... and they are still too different?

The reason being the already existing kannada layout's popup keys [...]

Currently the layout does not have any popup keys. That is part of why I suggested to move the popup keys from language_key_texts/kn.txt into the layout.

when you select type a letter, 1st 2 rows (greyed ones) get updated corresponding to that typed letter:

I'm not sure I understand this. The letters on the keyboard change depending on the previously typed letter?
If that should happen, then probably (much) bigger changes to the keyboard are necessary.

other than that, for some reason, even after doing all the necessary changes, it shows the language as knx instead of kannada which i'm unable to understand why.

This is because knx is not a valid language code, and thus Android cannot associate it with the Kannada language.

@pixincreate
Copy link
Contributor Author

When you move the popup keys into the layout, there are no popup keys left in the language_key_texts/kn.txt file.

Shit! I never really understood this until now! My bad! Had to go back to previous conversations to get context. So, I'll now have to move kn.txt contents to Kannada.txt. After that add the new layouts popup keys to kn.txt.

Got it, got it.

The letters on the keyboard change depending on the previously typed letter?

I observed this behaviour on gboard after I made changes to heliboard but yeah!

This is because knx is not a valid language code, and thus Android cannot associate it with the Kannada language.

So this part of code has nothing to do with heliboard in the first place, it is just android doing its stuff of validating language code? Will get this corrected once apply above changes.

@Helium314
Copy link
Owner

I observed this behaviour on gboard after I made changes to heliboard but yeah!

If reproducing this behavior is necessary, it will likely be a lot of work (depending a bit on what exactly may change).
Do you think the layout would also be well usable without this functionality?

So this part of code has nothing to do with heliboard in the first place, it is just android doing its stuff of validating language code? Will get this corrected once apply above changes.

Yes, this is coming from Android. There is a way of getting a different (correct) name displayed, but other things will not work properly. E.g. it will try using knx dictionaries, and thus not use words from an existing personal kn dictionary.
And the more special treatment a language gets, the harder it is to maintain / debug.

Shit! I never really understood this until now! My bad! Had to go back to previous conversations to get context. So, I'll now have to move kn.txt contents to Kannada.txt. After that add the new layouts popup keys to kn.txt.

I had thought you knew and were talking about different issues before my comment above... sorry, I could have saved us both a lot of time by clarifying this before.

@pixincreate
Copy link
Contributor Author

Do you think the layout would also be well usable without this functionality?

If that functionality exists, it will ease typing, without which, typing every letter would take significant time (as shown in example below).

GBoard currently eases by automatically appending "swaras" (which is the name for to ಅಃ) to every "vyanjana" ( to ) and "yogavaaha" ( to ).

In short, swaras is added to everything to make the word meaningful.

Example: ನ = ನ್ + ಅ, ಕನ್ನಡ = ಕ್ + ಅ; ನ್ + ನ್ + ಅ; ಡ್ + ಅ.

Yeah, I would have to make changes to layout further to make the layout properly usable if the changes are to the core is not made (I prefer this to reduce effort, but having that change would actually impact all Asian languages if I'm not wrong.)

I had thought you knew and were talking about different issues before my comment above... sorry, I could have saved us both a lot of time by clarifying this before.

Not a problem, it was my fault of not reading properly.😬

@Helium314
Copy link
Owner

Currently there is no way of changing the keyboard like that.
It might be possible to use 2 or 3 similar layouts (i.e. only the grey keys different) by some sort of fake shift/capslock presses that switch between them. But that's probably not enough variation, and prone to bugs, and still considerable work.

* 'main' of github.com:helium314/heliboard: (71 commits)
  fix issues with clipboard after switching keyboard (#728)
  simplify loading pinned clips we don't need to read a file any more also makes sure pinned clips are initially loaded before fetching the primary clip
  avoid crashes when logging exceptions
  upgrade dependencies
  lint
  update version and translations
  fix unit tests
  Update Estonian layout (#693)
  reduce margin in reorder dialogs now with the icons for toolbar keys more space is preferable
  add izzy badge to download links, update translation fetch script
  add logging for finish input (view)
  mark some getText methods as nullable and avoid related issues fixes one of the crashes in #723
  fix toolbar reorder dialog icons color (#716)
  New fastlane images (#713)
  Only add text clips to clipboard history (#711)
  fix spellchecker crash when keyboard has never been initialized, fixes #684
  allow line breaks in setting titles only necessary for PreferenceScreen and ListPreference, others already allow it be default
  fix duplicated pinned clipboard entries (#680)
  Update Serbian Cyrillic layout (#705)
  upgrade version and update translations
  ...
@pixincreate
Copy link
Contributor Author

pixincreate commented Apr 24, 2024

One more question, is it possible fix the layout size (I mean, for a single language)

image

similar to the one shown in #444 (comment) (GBoard layout for Kannada).

Also, sorry for being delayed, had been occupied with other work these days.

@Helium314
Copy link
Owner

One more question, is it possible fix the layout size (I mean, for a single language)

I don't understand what you mean. You want the keyboard to be higher?
Or do you mean the letter size?

Also, sorry for being delayed, had been occupied with other work these days.

Same for me...

@pixincreate
Copy link
Contributor Author

Letter size

@Helium314
Copy link
Owner

I remember there is some label flag that should work here. Can you try playing with this, possibly it's LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO?
You can add the label flag for the entire language in LocaleKeyboardInfos.labelFlags.

@pixincreate
Copy link
Contributor Author

image

As a last minute change, I added ``್` so that people who gonna use kannada for typing will find it useful as we decided to not go with core refactor just for the sake of a single language.

@Helium314
Copy link
Owner

Thanks, I think we're finally done! Only some minor things I noticed (will comment on the lines)

@pixincreate pixincreate requested a review from Helium314 May 1, 2024 17:00
@Helium314
Copy link
Owner

Only one more thing I hadn't noticed before: the last row of the old Kannada layout now has fewer keys.
was ೆ ಂ ಮ ನ ವ ಲ ಸ ಋ ಷ ಯ
now ೆ ಂ ನ ಲ ಸ ಋ ಷ ಯ

Is that on purpose? I fear users of the current layout may not like this change.

@pixincreate
Copy link
Contributor Author

My bad! I had just copy pasted from kn.txt, added them back!

@Helium314 Helium314 merged commit 955359e into Helium314:main May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants