Unexpected-Keyboard icon indicating copy to clipboard operation
Unexpected-Keyboard copied to clipboard

adding Fn alternative keys for new Persian layout

Open mksafavi opened this issue 3 years ago • 3 comments

Hi. I tried to add a Persian (Farsi) layout. So far it went well kudos to the smooth CONTRIBUTING.md.

My main issue is that I don't know how to set Fn alternative keys. The default behavior is Fn toggles F1 to F10 with the number keys. There are 12 keys on the first row of the Persian QWERTY layout. So I wanted to toggle '-' with F11 and '=' with F12.

Another question, should I make any changes to the method.xml file?

Any advice and recommendation on the layout are appreciated. Thank you.

image

some other issues that I noticed on my device (and scenarios I tested):

  1. changing shift and backspace width make the keyboard disappear

    • by changing backspace width to 2.
    • by changing backspace width to 2 and shift to 1.
  2. arrow keys make the keyboard disappear. (also happens with google play build)

    • arrow keys to move the cursor in the telegram.
    • left arrow key in Vivaldi browser when URL box is empty.

mksafavi avatar Jul 06 '22 07:07 mksafavi

I checked the apply_fn function and it seems like they are hardcoded. is it possible to have separate apply_fn for each layout?
for now, I used the f11_placeholder and f12_placeholder keys. another breaking change is that If I replace numeral keys with Persian numerals Fn toggle won't work on F# keys. adding the following cases to apply_fn_char would fix it though.

     case '۱': return "f1";
      case '۲': return "f2";
      case '۳': return "f3";
      case '۴': return "f4";
      case '۵': return "f5";
      case '۶': return "f6";
      case '۷': return "f7";
      case '۸': return "f8";
      case '۹': return "f9";
      case '۰': return "f10";

cheers

mksafavi avatar Jul 06 '22 08:07 mksafavi

one thing that I noticed with the width and height values in the xml, that may be tge cause of your issues, is that a float value is expected. So if I type width="1.0" it works, if I type width="1" it won't. See if that helps.

One last thing, the telegram cursor not working is a telegram bug. (#170 and https://bugs.telegram.org/c/16674)

sdrapha avatar Jul 06 '22 16:07 sdrapha

This looks promising ! Feel free to add more cases to apply_fn.

Unfortunately, it is not possible to make - and + turn into F11 and F12 without altering the other layouts. At the moment, the only solution is to add the f11_placeholder and f12_placeholder keys.

The method.xml file is mainly used to switch between languages using Android's persistent notification. You need to add an entry like this: (change layout_name to the name of the layout)

  <subtype android:label="%s" android:languageTag="fa" android:imeSubtypeLocale="fa_IR" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=layout_name"/>

Thanks @sdrapha for answering. It is indeed related to the format of numbers, when the keyboard don't show up, it is actually crashing.

Julow avatar Jul 09 '22 16:07 Julow

Does anyone have a patch for this ?

Julow avatar Jul 08 '23 13:07 Julow

Fixed in dcbb4c4 and 6054c2e

Julow avatar Aug 05 '23 17:08 Julow