Compare commits

..

31 Commits

Author SHA1 Message Date
Jules Aguillon
8662f3afd4 Ignore presses too close from an other pointer
These might be gliches.
2022-03-16 12:35:14 +01:00
igorSilCar
2dae2105b2 Brazilian portuguese layout (#91)
* Providing a comprehensible Brazilian Portuguese keyboard layout

removed cedille as it is already provided by an independent key;
changed layout to correspond to the locale
2022-03-15 21:05:16 +01:00
Jules Aguillon
d53ee811d9 Handle CANCEL touch events
Handling this event is part of the API but was never done. This caused
unstoppable key-repeat.

This event isn't common, the only way I found on Android 10 is to switch
to the emoji keyboard while holding a key. Some apps might cause this
event more often.
2022-03-15 20:44:02 +01:00
Jacob Strömgren
fadedfd58f Add Swedish layout 2022-03-15 18:42:29 +01:00
Jules Aguillon
f9cd4ca2d8 Log editor infos while debugging
Useful when debugging why the keyboard doesn't work as expected with a
specific app.
2022-03-15 18:42:29 +01:00
Jules Aguillon
9bb7c7e66f Identify debug version in app name
Using the --product option of aapt.

Remove the app name from translations because it is never translated. It
is still possible to translate it by specifying 'product="default"'.
2022-03-14 18:37:37 +01:00
Jules Aguillon
f4978f5266 Fix crash since 2ea256e 2022-03-13 00:45:16 +01:00
Jules Aguillon
a0d90496c1 Improve symbols for Sup, Sub and Ord 2022-03-13 00:43:11 +01:00
Jules Aguillon
7aa241b10a Make superscript and subscript modifiers lockable 2022-03-13 00:40:39 +01:00
Jules Aguillon
a57bdf8cfb Avoid showing some symbols twice in Fn mode 2022-03-13 00:35:15 +01:00
Jules Aguillon
ee6e892ef4 Define localized keys as a set instead of flags
Using flags for removing keys like € and ß need too many flags and won't
scale to more localized keys.
2022-03-13 00:14:18 +01:00
Jules Aguillon
2ea256e769 Fix inconsistent highlighting of lockable keys
Pointers.getKeyFlags might receive a different KeyValue than what's
stored in the pointer due to caching. Compare names instead.
2022-03-12 21:38:47 +01:00
igorSilCar
5665d6a7c5 Brazilian portuguese translations (#100)
* Translations for new setting, lockable modifier keys

Co-authored-by: Igor da Silva de Carvalho <igu@coiso.meanhouse>
2022-03-09 10:49:13 +01:00
Jules Aguillon
534e4cb843 Make the font smaller for the action key 2022-03-06 19:36:09 +01:00
Jules Aguillon
e303008e66 Fix action key not updating when switching field
The keyboard was updated before the action key is.
2022-03-05 20:21:37 +01:00
Raphael
5404e7432d Clicking twice on CTRL or ALT will lock them in 'ON' state (#72)
* Clicking twice on CTRL or ALT will lock them in 'ON' state

* Make Locking behaviour optional, configurable in preferences

* Nest the new settings into a different page

To avoid spamming the settings page and repetition in the summaries.
Cannot be a popup unfortunately because that would require API >= 11.

* Add Fn and Meta

Co-authored-by: Jules Aguillon <jules@j3s.fr>
2022-03-05 20:17:45 +01:00
Jules Aguillon
e92504ae92 Improve the code for dynamic updates of the layout 2022-03-05 19:22:01 +01:00
igorSilCar
4964bfb87f Brazilian portuguese translations (#87)
* Added brazilian portuguese translations for app description and settings

* making the swiping option more intelligible

* fix typo on full_description pt-BR translation

Co-authored-by: Igor da Silva de Carvalho <igu@coiso.meanhouse>
2022-03-05 17:33:04 +01:00
Jules Aguillon
39da035135 Release 1.13.1 (18) 2022-02-27 18:41:03 +01:00
Jules Aguillon
4ee29f355e Use the Material theme for the settings activity
This is a dark theme. It's probably better than the default theme for
most users.
2022-02-27 18:31:17 +01:00
Jules Aguillon
87144fd3a8 Reduce the text size for some keys
The symbols are now smaller for Shift, Space, Backspace, Delete and
some keys on the bottom row.

The previous rule was to make the text smaller for symbols made of
several characters.
This is changed to a flag approach.
2022-02-27 15:23:36 +01:00
Jules Aguillon
f6d4554669 Increase contrasts
For the Dark and Light theme. At the same time, use only "web safe
colors" to have nice round numbers and ensure enough contrasts between
colors.

The background color is kept at the previous value, there's not enough
contrast between the background and the keys but that's better than a
solid black background.
2022-02-27 15:08:38 +01:00
Jules Aguillon
1451857c92 Compute text size depending on actual row height
Use the height of the row currently being rendered instead of the base
row size.
Concretely, the bottom row is slightly smaller and will get slightly
smaller text.

Also:
- Rewrite the label rendering code
- Render labels at the middle of the key (was slightly off)
2022-02-27 02:26:45 +01:00
Jules Aguillon
23685ddb3c Compute text size relative to key height
Instead of a fixed size that don't work at all for bigger screens.

Other tweaks:
- Use the value-land dimens to vary 'extra_horizontal_margin'
- Move label size to Config, because it can change at runtime (rotation)
- Slightly decrease the size of "long" symbols
2022-02-27 01:50:24 +01:00
Jules Aguillon
ce5cee42a1 Add attributions for font glyphs 2022-02-26 20:49:09 +01:00
Raphael
067ab90847 Update symbols from unicode to font-Icon 2022-02-26 20:49:09 +01:00
Jules Aguillon
937d5d728e Fix typo in subtype description for Bulgarian
This causes a crash.
2022-02-26 20:27:08 +01:00
Edgars
d6757019dc Add a missing full stop to Latvian QWERTY layout
`res/xml/qwerty_lv.xml` was updated to add the missing full stop
character (`.`) as it got lost when the bottom row was moved to a
separate XML `res/xml/bottom_row.xml` as it was placed on the
arrows key.

Additionally `?` was relocated, giving its place to the full stop.
2022-02-26 13:12:10 +01:00
Jules Aguillon
5581cf33f9 Merge pull request #81 from polyctena/german
German translation
2022-02-26 13:06:00 +01:00
Benjamin
35058628c1 German translation 2022-02-25 17:29:52 +01:00
Benjamin
d581c8b1e4 German translation strings.xml and full_description.txt 2022-02-25 17:14:58 +01:00
34 changed files with 539 additions and 273 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="juloo.keyboard2" android:versionCode="17" android:versionName="1.13.0" android:hardwareAccelerated="false"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="juloo.keyboard2" android:versionCode="18" android:versionName="1.13.1" android:hardwareAccelerated="false">
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="30"/> <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="30"/>
<application android:label="@string/app_name" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:hardwareAccelerated="false"> <application android:label="@string/app_name" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:hardwareAccelerated="false">
<service android:name="juloo.keyboard2.Keyboard2" android:label="@string/app_name" android:permission="android.permission.BIND_INPUT_METHOD"> <service android:name="juloo.keyboard2.Keyboard2" android:label="@string/app_name" android:permission="android.permission.BIND_INPUT_METHOD">
@@ -8,7 +8,7 @@
</intent-filter> </intent-filter>
<meta-data android:name="android.view.im" android:resource="@xml/method"/> <meta-data android:name="android.view.im" android:resource="@xml/method"/>
</service> </service>
<activity android:name="juloo.keyboard2.SettingsActivity" android:icon="@drawable/ic_launcher" android:label="@string/settings_activity_label"> <activity android:name="juloo.keyboard2.SettingsActivity" android:icon="@drawable/ic_launcher" android:label="@string/settings_activity_label" android:theme="@style/android:Theme.Material">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
</intent-filter> </intent-filter>

View File

@@ -3,7 +3,7 @@
PACKAGE_NAME = juloo.keyboard2 PACKAGE_NAME = juloo.keyboard2
ANDROID_PLATFORM_VERSION = android-30 ANDROID_PLATFORM_VERSION = android-30
JAVA_VERSION = 1.7 JAVA_VERSION = 1.8
SRC_DIR = srcs SRC_DIR = srcs
ASSETS_DIR = assets ASSETS_DIR = assets
@@ -19,7 +19,11 @@ release: _build/$(PACKAGE_NAME).apk
installd: _build/$(PACKAGE_NAME).debug.apk installd: _build/$(PACKAGE_NAME).debug.apk
adb install "$<" adb install "$<"
.PHONY: release debug installd clean:
rm -rf _build/*.dex _build/class _build/gen _build/*.apk _build/*.unsigned-apk \
_build/*.idsig
.PHONY: release debug installd clean
$(shell mkdir -p _build) $(shell mkdir -p _build)
@@ -60,7 +64,7 @@ _build/%.debug.apk: _build/%.debug.unsigned-apk $(DEBUG_KEYSTORE)
# Debug apk # Debug apk
_build/$(PACKAGE_NAME).debug.unsigned-apk: AAPT_PACKAGE_FLAGS+=--rename-manifest-package $(PACKAGE_NAME).debug _build/$(PACKAGE_NAME).debug.unsigned-apk: AAPT_PACKAGE_FLAGS+=--rename-manifest-package $(PACKAGE_NAME).debug --product debug
# Release signing # Release signing

15
assets/fonts/README.md Normal file
View File

@@ -0,0 +1,15 @@
# Fonts
The glyphs from this font are made by:
- Home and End
Author: @sdrapha
- Cog
Copyright (C) 2016 by Dave Gandy
Author: Dave Gandy
License: SIL ()
- Emoticon, PageUp and PageDown
IcoMoon-Free is a free vector icon pack by Keyamoon.
License: Attribution 4.0 International (CC BY 4.0)

Binary file not shown.

View File

@@ -0,0 +1,18 @@
Diese App ist eine virtuelle Tastatur für Android. Hauptfunktionen sind das einfache Tippen eines jeden ASCII-Zeichens durch Wischgesten, Hilfstasten, Tottasten für Akzente, sowie das Vorhandensein spezieller Tasten (Tabulator, Esc, Pfeiltasten etc.).
Die Tastatur hat bis zu vier Extrazeichen in den Ecken jeder Taste. Diese Extrazeichen werden durch das Wischen mit dem Finger auf der Taste ausgewählt.
Highlights mancher Funktionen:
- Jedes Zeichen und jede spezielle Taste gibt es auch auf einer PC-Tastatur. Das ist perfekt für die Nutzung von Anwendungen wie Termux.
- Dies schließt auch Tab, Esc und die Pfeil- und Funktionstasten sowie Strg und Alt mit ein!
- Akzenttasten sind über Tottasten verfügbar. Nach Aktivieren des Akzents kan der akzentuierte Buchstabe getippt werden.
- Sehr schlank und schnell. Braucht 500x weniger Speicherplatz als Googles Tastatur und 15x weniger als die Standardtastatur. Keine Werbung, kein Tracking.
- Verschiedene Layouts: QWERTY, QWERTZ, AZERTY. Themes: Weiß, Dunkel, OLED Schwarz. Und viele weitere Optionen.
Wie jede andere virtuelle Tastatur muss diese Tastatur in den Systemeinstellungen aktiviert werden. Dazu Systemeinstellungen öffnen und wie folgt vorgehen:
System > Sprachen und Eingabe > Bildschirmtastatur > Bildschirmtastaturen verwalten.

View File

@@ -0,0 +1,5 @@
Improved text size, especially on large screens
Increased contrasts
Improved symbols (thanks @sdrapha)
German translation (thanks @polyctena)
Fix to some layouts.

View File

@@ -0,0 +1,18 @@
Um teclado virtual para aparelhos Android. Os recursos principais são facilidade de digitar todos os caracteres ASCII deslizando o dedo, teclas "mortas" para acentos e teclas modificadoras e a presença de teclas especiais (tab, esc, setas, etc..).
O teclado mostra até 4 caracteres extras nos cantos de cada tecla. Esses caracteres são digitáveis com o deslizar do dedo na tecla.
Alguns dos recursos interessantes:
- Todos caracteres e teclas especiais que também estão disponíveis num teclado de PC. Perfeito para usar com aplicativos como Termux.
- Incluindo Tab, Esc, as setas e teclas de função, e também Ctrl e Alt!
- Caracteres acentuados são digitáveis usando teclas "mortas". Primeiro ative o acento e depois digite a letra.
- Muito leve e rápido. Ocupa 500x menos espaço que o teclado da Google e 15x menos espaço que o teclado padrão. Sem propaganda, sem rastreio.
- Vários layouts: QWERTY, QWERTZ, AZERTY. Temas: Branco, Escuro, Preto OLED. E muitas outras opções.
Como qualquer outro teclado virtual, tem de ser ativado nas configurações de sistema. Abra as configurações e vá para:
Sistema > Idioma e entrada > Teclado virtual > Gerenciar teclados virtuais.

View File

@@ -0,0 +1 @@
Um teclado virtual leve para desenvolvedores.

View File

@@ -0,0 +1 @@
Unexpected Keyboard

47
res/values-de/strings.xml Normal file
View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="settings_activity_label">Unexpected Keyboard - Einstellungen</string>
<string name="pref_category_layout">Layout</string>
<string name="pref_layout_title">Tastaturlayout ändern</string>
<string name="pref_layout_e_system">Systemeinstellung</string>
<string name="pref_accents_title">Akzente</string>
<string name="pref_accents_e_all_installed">Akzente für alle installierten Sprachen anzeigen</string>
<string name="pref_accents_e_selected">Akzente nur für die gewählte Sprache anzeigen</string>
<string name="pref_accents_e_all">Alle Akzente anzeigen</string>
<string name="pref_accents_e_none">Akzente verbergen</string>
<string name="pref_category_typing">Tippen</string>
<string name="pref_swipe_dist_title">Länge der Wischgeste</string>
<string name="pref_swipe_dist_summary">Abstand der Zeichen in den Ecken der Tasten (%s)</string>
<string name="pref_long_timeout_title">Zeitüberschreitung bei Tastenwiederholung</string>
<string name="pref_long_interval_title">Intervall der Tastenwiederholung</string>
<string name="pref_category_vibrate">Vibration</string>
<string name="pref_vibrate_title">Vibration</string>
<string name="pref_vibrate_summary">Vibration bei Tastendruck ein-/ausschalten</string>
<string name="pref_vibrate_duration_title">Dauer</string>
<string name="pref_precise_repeat_title">Präzise Cursorsteuerung</string>
<string name="pref_precise_repeat_summary">Geschwindigkeit der Tastenwiederholung durch weniger oder mehr Wischen anpassen</string>
<string name="pref_category_style">Design</string>
<string name="pref_margin_bottom_title">Unterer Abstand</string>
<string name="pref_keyboard_height_title">Höhe der Tastatur</string>
<string name="pref_horizontal_margin_title">Horizontaler Abstand</string>
<string name="pref_character_size_title">Größe der Beschriftung</string>
<string name="pref_character_size_summary">Größe der Buchstaben auf den Tasten (%.2fx)</string>
<string name="pref_theme">Theme</string>
<string name="pref_theme_e_system">Systemeinstellung</string>
<string name="pref_theme_e_dark">Dunkel</string>
<string name="pref_theme_e_light">Hell</string>
<string name="pref_theme_e_black">Schwarz</string>
<string name="pref_swipe_dist_e_very_short">Sehr kurz</string>
<string name="pref_swipe_dist_e_short">Kurz</string>
<string name="pref_swipe_dist_e_default">Normal</string>
<string name="pref_swipe_dist_e_far">Weit</string>
<string name="pref_swipe_dist_e_very_far">Sehr weit</string>
<string name="pref_key_horizontal_space">Horizontaler Abstand zwischen den Tasten</string>
<string name="pref_key_vertical_space">Vertikaler Abstand zwischen den Tasten</string>
<string name="key_action_next">Nächstes</string>
<string name="key_action_done">Fertig</string>
<string name="key_action_go">Los</string>
<string name="key_action_prev">Vorheriges</string>
<string name="key_action_search">Suchen</string>
<string name="key_action_send">Senden</string>
</resources>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Unexpected Keyboard</string>
<string name="settings_activity_label">Ajustes de Unexpected Keyboard</string> <string name="settings_activity_label">Ajustes de Unexpected Keyboard</string>
<string name="pref_category_layout">Formato</string> <string name="pref_category_layout">Formato</string>
<string name="pref_layout_title">Cambiar formato de teclado</string> <string name="pref_layout_title">Cambiar formato de teclado</string>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Unexpected Keyboard</string>
<string name="settings_activity_label">Unexpected Keyboard Paramètres</string> <string name="settings_activity_label">Unexpected Keyboard Paramètres</string>
<string name="pref_category_layout">Disposition</string> <string name="pref_category_layout">Disposition</string>
<string name="pref_layout_title">Disposition des touches</string> <string name="pref_layout_title">Disposition des touches</string>

View File

@@ -4,7 +4,8 @@
<dimen name="margin_bottom">3dp</dimen> <dimen name="margin_bottom">3dp</dimen>
<dimen name="key_padding">3dp</dimen> <dimen name="key_padding">3dp</dimen>
<dimen name="key_height">36dp</dimen> <dimen name="key_height">36dp</dimen>
<dimen name="label_text_size">18dp</dimen> <item name="label_text_size" type="integer" format="float">0.4</item>
<dimen name="sublabel_text_size">11dp</dimen> <item name="sublabel_text_size" type="integer" format="float">0.3</item>
<dimen name="emoji_type_button_height">48dp</dimen> <dimen name="emoji_type_button_height">48dp</dimen>
<dimen name="extra_horizontal_margin">20dp</dimen>
</resources> </resources>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Unexpected Keyboard</string>
<string name="settings_activity_label">Unexpected Keyboard iestatījumi</string> <string name="settings_activity_label">Unexpected Keyboard iestatījumi</string>
<string name="pref_category_layout">Izkārtojums</string> <string name="pref_category_layout">Izkārtojums</string>
<string name="pref_layout_title">Mainīt tastatūras izkārtojumu</string> <string name="pref_layout_title">Mainīt tastatūras izkārtojumu</string>

49
res/values-pt/strings.xml Normal file
View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="settings_activity_label">Configurações Unexpected Keyboard</string>
<string name="pref_category_layout">Layout</string>
<string name="pref_layout_title">Mudar layout do teclado</string>
<string name="pref_layout_e_system">Mesmo do sistema</string>
<string name="pref_accents_title">Acentos</string>
<string name="pref_accents_e_all_installed">Mostrar acentos para todos idiomas instalados</string>
<string name="pref_accents_e_selected">Mostrar acentos só para o idioma selecionado</string>
<string name="pref_accents_e_all">Mostrar todos acentos</string>
<string name="pref_accents_e_none">Esconder acentos</string>
<string name="pref_category_typing">Digitação</string>
<string name="pref_swipe_dist_title">Distância a deslizar</string>
<string name="pref_swipe_dist_summary">Distância até acionar os cantos das teclas (%s)</string>
<string name="pref_long_timeout_title">Tempo até repetir tecla</string>
<string name="pref_long_interval_title">Intervalo para repetir tecla</string>
<string name="pref_category_vibrate">Vibração</string>
<string name="pref_vibrate_title">Vibração</string>
<string name="pref_vibrate_summary">Ativar/desativar vibração ao digitar</string>
<string name="pref_vibrate_duration_title">Duração</string>
<string name="pref_precise_repeat_title">Precisão nos movimentos do cursor</string>
<string name="pref_precise_repeat_summary">Varia a velocidade de repetição ao depender de quanto deslizar</string>
<string name="pref_lockable_keys_title">Segurar teclas</string>
<string name="pref_lockable_keys_summary">Teclas que podem ficar seguradas ao teclar duas vezes</string>
<string name="pref_category_style">Estilo</string>
<string name="pref_margin_bottom_title">Margem de baixo</string>
<string name="pref_keyboard_height_title">Altura do teclado</string>
<string name="pref_horizontal_margin_title">Margem horizontal</string>
<string name="pref_character_size_title">Tamanho dos indicadores</string>
<string name="pref_character_size_summary">Tamanho dos caracteres visíveis no teclado (%.2fx)</string>
<string name="pref_theme">Tema</string>
<string name="pref_theme_e_system">Mesmo do sistema</string>
<string name="pref_theme_e_dark">Escuro</string>
<string name="pref_theme_e_light">Claro</string>
<string name="pref_theme_e_black">Preto</string>
<string name="pref_swipe_dist_e_very_short">Muito curto</string>
<string name="pref_swipe_dist_e_short">Curto</string>
<string name="pref_swipe_dist_e_default">Normal</string>
<string name="pref_swipe_dist_e_far">Longo</string>
<string name="pref_swipe_dist_e_very_far">Muito longo</string>
<string name="pref_key_horizontal_space">Distância horizontal entre teclas</string>
<string name="pref_key_vertical_space">Distância vertical entre teclas</string>
<string name="key_action_next">Próximo</string>
<string name="key_action_done">Pronto</string>
<string name="key_action_go">Ir</string>
<string name="key_action_prev">Anterior</string>
<string name="key_action_search">Buscar</string>
<string name="key_action_send">Enviar</string>
</resources>

View File

@@ -4,8 +4,10 @@
<item>system</item> <item>system</item>
<item>azerty</item> <item>azerty</item>
<item>qwerty</item> <item>qwerty</item>
<item>qwerty_pt</item>
<item>qwerty_es</item> <item>qwerty_es</item>
<item>qwerty_lv</item> <item>qwerty_lv</item>
<item>qwerty_sv_se</item>
<item>ru_jcuken</item> <item>ru_jcuken</item>
<item>qwertz</item> <item>qwertz</item>
<item>bgph1</item> <item>bgph1</item>
@@ -15,8 +17,10 @@
<item>@string/pref_layout_e_system</item> <item>@string/pref_layout_e_system</item>
<item>AZERTY</item> <item>AZERTY</item>
<item>QWERTY</item> <item>QWERTY</item>
<item>QWERTY (Brasileiro)</item>
<item>QWERTY (Español)</item> <item>QWERTY (Español)</item>
<item>QWERTY (Latvian)</item> <item>QWERTY (Latvian)</item>
<item>QWERTY (Swedish)</item>
<item>ЙЦУКЕН (Русский)</item> <item>ЙЦУКЕН (Русский)</item>
<item>QWERTZ</item> <item>QWERTZ</item>
<item>Bulgarian (Phonetic Traditional)</item> <item>Bulgarian (Phonetic Traditional)</item>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Unexpected Keyboard</string> <string name="app_name" product="debug">Unexpected Keyboard (debug)</string>
<string name="app_name" product="default">Unexpected Keyboard</string>
<string name="settings_activity_label">Unexpected Keyboard Settings</string> <string name="settings_activity_label">Unexpected Keyboard Settings</string>
<string name="pref_category_layout">Layout</string> <string name="pref_category_layout">Layout</string>
<string name="pref_layout_title">Change keyboard layout</string> <string name="pref_layout_title">Change keyboard layout</string>
@@ -21,6 +22,8 @@
<string name="pref_vibrate_duration_title">Duration</string> <string name="pref_vibrate_duration_title">Duration</string>
<string name="pref_precise_repeat_title">Precise cursor movements</string> <string name="pref_precise_repeat_title">Precise cursor movements</string>
<string name="pref_precise_repeat_summary">Modulate key repeat speed by swiping more or less</string> <string name="pref_precise_repeat_summary">Modulate key repeat speed by swiping more or less</string>
<string name="pref_lockable_keys_title">Lockable modifiers</string>
<string name="pref_lockable_keys_summary">Modifier that can be locked by typing them twice</string>
<string name="pref_category_style">Style</string> <string name="pref_category_style">Style</string>
<string name="pref_margin_bottom_title">Margin bottom</string> <string name="pref_margin_bottom_title">Margin bottom</string>
<string name="pref_keyboard_height_title">Keyboard height</string> <string name="pref_keyboard_height_title">Keyboard height</string>

View File

@@ -3,10 +3,10 @@
<style name="emojiTypeButton"> <style name="emojiTypeButton">
<item name="android:padding">1px</item> <item name="android:padding">1px</item>
<item name="android:gravity">center</item> <item name="android:gravity">center</item>
<item name="android:minHeight">@dimen/label_text_size</item> <item name="android:minHeight">18dp</item>
<item name="android:background">?attr/emoji_button_bg</item> <item name="android:background">?attr/emoji_button_bg</item>
<item name="android:textColor">?attr/emoji_key_text</item> <item name="android:textColor">?attr/emoji_key_text</item>
<item name="android:textSize">@dimen/label_text_size</item> <item name="android:textSize">18dp</item>
</style> </style>
<style name="emojiKeyButton"> <style name="emojiKeyButton">
<item name="android:layout_width">0px</item> <item name="android:layout_width">0px</item>
@@ -15,7 +15,7 @@
<item name="android:padding">0px</item> <item name="android:padding">0px</item>
<item name="android:background">?attr/emoji_key_bg</item> <item name="android:background">?attr/emoji_key_bg</item>
<item name="android:textColor">?attr/emoji_key_text</item> <item name="android:textColor">?attr/emoji_key_text</item>
<item name="android:textSize">@dimen/label_text_size</item> <item name="android:textSize">18dp</item>
</style> </style>
<!-- Passed to TextView.setTextAppearance --> <!-- Passed to TextView.setTextAppearance -->
<style name="emojiGridButton"> <style name="emojiGridButton">

View File

@@ -24,16 +24,16 @@
<style name="Dark"> <style name="Dark">
<item name="android:isLightTheme">false</item> <item name="android:isLightTheme">false</item>
<item name="android:forceDarkAllowed">false</item> <item name="android:forceDarkAllowed">false</item>
<item name="colorKeyboard">#1B1B1B</item> <item name="colorKeyboard">#1b1b1b</item>
<item name="colorKey">#303030</item> <item name="colorKey">#333333</item>
<item name="colorKeyActivated">#1B1B1B</item> <item name="colorKeyActivated">#1b1b1b</item>
<item name="colorLabel">#FFFFFF</item> <item name="colorLabel">#ffffff</item>
<item name="colorLabelActivated">#226b99</item> <item name="colorLabelActivated">#3399ff</item>
<item name="colorLabelLocked">#229933</item> <item name="colorLabelLocked">#33cc33</item>
<item name="colorSubLabel">#A0A0A0</item> <item name="colorSubLabel">#cccccc</item>
<item name="keyBorderRadius">5dp</item> <item name="keyBorderRadius">5dp</item>
<item name="emoji_button_bg" type="color">#202020</item> <item name="emoji_button_bg" type="color">#202020</item>
<item name="emoji_color" type="color">#FFFFFF</item> <item name="emoji_color" type="color">#ffffff</item>
<item name="emoji_key_bg" type="color">?attr/emoji_button_bg</item> <item name="emoji_key_bg" type="color">?attr/emoji_button_bg</item>
<item name="emoji_key_text" type="color">?attr/colorLabel</item> <item name="emoji_key_text" type="color">?attr/colorLabel</item>
</style> </style>
@@ -41,12 +41,12 @@
<item name="android:isLightTheme">true</item> <item name="android:isLightTheme">true</item>
<item name="android:forceDarkAllowed">false</item> <item name="android:forceDarkAllowed">false</item>
<item name="colorKeyboard">#e3e3e3</item> <item name="colorKeyboard">#e3e3e3</item>
<item name="colorKey">#cfcfcf</item> <item name="colorKey">#cccccc</item>
<item name="colorKeyActivated">#e3e3e3</item> <item name="colorKeyActivated">#e3e3e3</item>
<item name="colorLabel">#000000</item> <item name="colorLabel">#000000</item>
<item name="colorLabelActivated">#64afdd</item> <item name="colorLabelActivated">#0066cc</item>
<item name="colorLabelLocked">#64dd76</item> <item name="colorLabelLocked">#33cc33</item>
<item name="colorSubLabel">#5e5e5e</item> <item name="colorSubLabel">#333333</item>
<item name="keyBorderRadius">5dp</item> <item name="keyBorderRadius">5dp</item>
<item name="emoji_button_bg" type="color">#dedede</item> <item name="emoji_button_bg" type="color">#dedede</item>
<item name="emoji_color" type="color">#000000</item> <item name="emoji_color" type="color">#000000</item>

View File

@@ -7,10 +7,13 @@
<dimen name="key_vertical_interval">2dp</dimen> <dimen name="key_vertical_interval">2dp</dimen>
<dimen name="key_horizontal_interval">2dp</dimen> <dimen name="key_horizontal_interval">2dp</dimen>
<dimen name="key_height">51dp</dimen> <dimen name="key_height">51dp</dimen>
<dimen name="label_text_size">18dp</dimen> <item name="label_text_size" type="integer" format="float">0.33</item>
<dimen name="sublabel_text_size">12dp</dimen> <item name="sublabel_text_size" type="integer" format="float">0.22</item>
<dimen name="emoji_type_button_height">56dp</dimen> <dimen name="emoji_type_button_height">56dp</dimen>
<dimen name="emoji_grid_height">250dp</dimen> <dimen name="emoji_grid_height">250dp</dimen>
<dimen name="emoji_text_size">28dp</dimen> <dimen name="emoji_text_size">28dp</dimen>
<dimen name="landscape_extra_horizontal_margin">20dp</dimen> <dimen name="extra_horizontal_margin">0dp</dimen>
<bool name="debug_logs" product="debug">true</bool>
<bool name="debug_logs" product="default">false</bool>
<dimen name="pointer_too_close">10dp</dimen>
</resources> </resources>

View File

@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<input-method xmlns:android="http://schemas.android.com/apk/res/android" android:settingsActivity="juloo.keyboard2.SettingsActivity" android:supportsSwitchingToNextInputMethod="true"> <input-method xmlns:android="http://schemas.android.com/apk/res/android" android:settingsActivity="juloo.keyboard2.SettingsActivity" android:supportsSwitchingToNextInputMethod="true">
<subtype android:label="%s" android:languageTag="bg" android:imeSubtypeLocale="bg_BG" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=bgph1|euro"/> <subtype android:label="%s" android:languageTag="bg" android:imeSubtypeLocale="bg_BG" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=bgph1,extra_keys=€"/>
<subtype android:label="%s" android:languageTag="de" android:imeSubtypeLocale="de_DE" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwertz,extra_keys=trema|szlig|euro"/> <subtype android:label="%s" android:languageTag="de" android:imeSubtypeLocale="de_DE" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwertz,extra_keys=accent_trema|ß|€"/>
<subtype android:label="%s" android:languageTag="en-GB" android:imeSubtypeLocale="en_GB" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,extra_keys=pound|euro"/> <subtype android:label="%s" android:languageTag="en-GB" android:imeSubtypeLocale="en_GB" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,extra_keys=£|€"/>
<subtype android:label="%s" android:languageTag="en-US" android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty"/> <subtype android:label="%s" android:languageTag="en-US" android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty"/>
<subtype android:label="%s" android:languageTag="es" android:imeSubtypeLocale="es_ES" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty_es,extra_keys=grave|aigu|tilde|trema|euro"/> <subtype android:label="%s" android:languageTag="es" android:imeSubtypeLocale="es_ES" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty_es,extra_keys=accent_grave|accent_aigu|accent_tilde|accent_trema|"/>
<subtype android:label="%s" android:languageTag="fr" android:imeSubtypeLocale="fr_FR" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=azerty,extra_keys=grave|aigu|circonflexe|cedille|trema|euro"/> <subtype android:label="%s" android:languageTag="fr" android:imeSubtypeLocale="fr_FR" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=azerty,extra_keys=accent_grave|accent_aigu|accent_circonflexe|accent_cedille|accent_trema|"/>
<subtype android:label="%s" android:languageTag="it" android:imeSubtypeLocale="it_IT" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,extra_keys=grave|aigu|euro"/> <subtype android:label="%s" android:languageTag="it" android:imeSubtypeLocale="it_IT" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,extra_keys=accent_grave|accent_aigu|€"/>
<subtype android:label="%s" android:languageTag="lv" android:imeSubtypeLocale="lv_LV" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty_lv,extra_keys=caron|cedille|macron|euro"/> <subtype android:label="%s" android:languageTag="lv" android:imeSubtypeLocale="lv_LV" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty_lv,extra_keys=accent_caron|accent_cedille|accent_macron|"/>
<subtype android:label="%s" android:languageTag="pt" android:imeSubtypeLocale="pt_BR" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,extra_keys=aigu|cedille|circonflexe|grave|tilde|euro"/> <subtype android:label="%s" android:languageTag="pt" android:imeSubtypeLocale="pt_BR" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty_pt,extra_keys=accent_aigu|accent_cedille|accent_circonflexe|accent_grave|accent_tilde|"/>
<subtype android:label="%s" android:languageTag="ru" android:imeSubtypeLocale="ru_RU" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=ru_jcuken"/> <subtype android:label="%s" android:languageTag="ru" android:imeSubtypeLocale="ru_RU" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=ru_jcuken"/>
<subtype android:label="%s" android:languageTag="sv" android:imeSubtypeLocale="sv_SE" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,extra_keys=aigu|trema|ring|euro"/> <subtype android:label="%s" android:languageTag="sv" android:imeSubtypeLocale="sv_SE" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty_sv_se,extra_keys=accent_aigu|accent_trema|accent_ring|"/>
</input-method> </input-method>

View File

@@ -29,9 +29,9 @@
<key key0="x"/> <key key0="x"/>
<key key0="c" key1="č"/> <key key0="c" key1="č"/>
<key key0="v"/> <key key0="v"/>
<key key0="b" key3="&lt;" key4="&gt;"/> <key key0="b" key2="\?" key3="&lt;" key4="&gt;"/>
<key key0="n" key1="ņ" key2="`" key3=":" key4=";"/> <key key0="n" key1="ņ" key2="`" key3=":" key4=";"/>
<key key0="m" key1="'" key2="&quot;" key3="," key4="\?"/> <key key0="m" key1="'" key2="&quot;" key3="," key4="."/>
<key width="1.5" key0="backspace" key2="delete"/> <key width="1.5" key0="backspace" key2="delete"/>
</row> </row>
</keyboard> </keyboard>

38
res/xml/qwerty_pt.xml Normal file
View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<keyboard>
<row>
<key key0="q" key1="esc" key2="1" key3="~" key4="!"/>
<key key0="w" key2="2" key3="\@"/>
<key key0="e" key1="£" key2="3" key3="\#" key4="€"/>
<key key0="r" key2="4" key3="$"/>
<key key0="t" key2="5" key3="%"/>
<key key0="y" key1="accent_caron" key2="6" key3="^" key4="accent_trema"/>
<key key0="u" key2="7" key3="&amp;"/>
<key key0="i" key2="8" key3="*"/>
<key key0="o" key2="9" key3="(" key4=")"/>
<key key0="p" key2="0" key3="\\" key4="|"/>
</row>
<row>
<key key0="a" key1="tab" key2="'" key3="`" key4="&quot;"/>
<key key0="s" key1="accent_ring" key2="accent_caron" key3="ß" key4="accent_cedille"/>
<key key0="d"/>
<key key0="f"/>
<key key0="g"/>
<key key0="h"/>
<key key0="j" key1="-" key2="=" key4="+" key3="_"/>
<key key0="k" key1="accent_grave" key2="accent_aigu" key3="accent_tilde" key4="accent_circonflexe"/>
<key key0="l" key1="[" key2="]" key3="{" key4="}"/>
<key key0="ç"/>
</row>
<row>
<key width="1.5" key0="shift"/>
<key key0="z"/>
<key key0="x"/>
<key key0="c"/>
<key key0="v"/>
<key key0="b"/>
<key key0="n" key1="&lt;" key2="&gt;" key3="," key4="."/>
<key key0="m" key1=":" key2=";" key3="/" key4="\?"/>
<key width="1.5" key0="backspace" key2="delete"/>
</row>
</keyboard>

42
res/xml/qwerty_sv_se.xml Normal file
View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<keyboard>
<row>
<key key0="q" key1="esc" key2="1"/>
<key key0="w" key2="2" key4="\@"/>
<key key0="e" key2="3" key4="\#" key3="€"/>
<key key0="r" key2="4" key4="$"/>
<key key0="t" key2="5" key3="&amp;" key4="|" />
<key key0="y" key2="6" key3="^" key4="%"/>
<key key0="u" key2="7" key3="~" key4="\\" />
<key key0="i" key2="8" key3="*" key4="/" />
<key key0="o" key2="9" key3="+" key4="-"/>
<key key0="p" key2="0" key3="=" />
<key key0="å" key1="\?" key3="!" key2="`" />
</row>
<row>
<key key0="a" key1="tab" />
<key key0="s" key1="accent_ring" key2="accent_cedille" key3="ß" key4="accent_tilde"/>
<key key0="d" key1="accent_grave" key2="accent_caron" key3="accent_aigu"/>
<key key0="f" key1="accent_trema" key2="accent_circonflexe"/>
<key key0="g" />
<key key0="h" />
<key key0="j" key1="{" key4="}" />
<key key0="k" key1="[" key4="]" />
<key key0="l" key1="(" key4=")" />
<key key0="ö" key1="&lt;" key4="&gt;" />
<key key0="ä" key1="'" key3="&quot;"/>
</row>
<row>
<key width="1.5" key0="shift"/>
<key key0="z" />
<key key0="x" />
<key key0="c" />
<key key0="v" />
<key key0="b" key2=";" key4=","/>
<key key0="n" key2=":" key4="."/>
<key key0="m" key2="-" key4="_"/>
<key width="1.0" key0="." key1="!" key2="\?" key3="'" key4="," />
<key width="1.5" key0="backspace" key2="delete"/>
</row>
</keyboard>

View File

@@ -9,6 +9,15 @@
<juloo.common.IntSlideBarPreference android:key="longpress_timeout" android:title="@string/pref_long_timeout_title" android:summary="%sms" android:defaultValue="600" min="50" max="2000"/> <juloo.common.IntSlideBarPreference android:key="longpress_timeout" android:title="@string/pref_long_timeout_title" android:summary="%sms" android:defaultValue="600" min="50" max="2000"/>
<juloo.common.IntSlideBarPreference android:key="longpress_interval" android:title="@string/pref_long_interval_title" android:summary="%sms" android:defaultValue="25" min="5" max="100"/> <juloo.common.IntSlideBarPreference android:key="longpress_interval" android:title="@string/pref_long_interval_title" android:summary="%sms" android:defaultValue="25" min="5" max="100"/>
<CheckBoxPreference android:key="precise_repeat" android:title="@string/pref_precise_repeat_title" android:summary="@string/pref_precise_repeat_summary" android:defaultValue="true"/> <CheckBoxPreference android:key="precise_repeat" android:title="@string/pref_precise_repeat_title" android:summary="@string/pref_precise_repeat_summary" android:defaultValue="true"/>
<PreferenceScreen android:title="@string/pref_lockable_keys_title" android:summary="@string/pref_lockable_keys_summary">
<CheckBoxPreference android:key="lockable_shift" android:title="Shift" android:defaultValue="true"/>
<CheckBoxPreference android:key="lockable_ctrl" android:title="Ctrl" android:defaultValue="false"/>
<CheckBoxPreference android:key="lockable_alt" android:title="Alt" android:defaultValue="false"/>
<CheckBoxPreference android:key="lockable_fn" android:title="Fn" android:defaultValue="false"/>
<CheckBoxPreference android:key="lockable_meta" android:title="Meta" android:defaultValue="false"/>
<CheckBoxPreference android:key="lockable_sup" android:title="Sup" android:defaultValue="false"/>
<CheckBoxPreference android:key="lockable_sub" android:title="Sub" android:defaultValue="false"/>
</PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_vibrate"> <PreferenceCategory android:title="@string/pref_category_vibrate">
<CheckBoxPreference android:key="vibrate_enabled" android:title="@string/pref_vibrate_title" android:summary="@string/pref_vibrate_summary" android:defaultValue="true"/> <CheckBoxPreference android:key="vibrate_enabled" android:title="@string/pref_vibrate_title" android:summary="@string/pref_vibrate_summary" android:defaultValue="true"/>

View File

@@ -8,12 +8,19 @@ import android.os.Build;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.KeyEvent;
import java.util.Set;
import java.util.HashSet;
final class Config final class Config
{ {
// From resources // From resources
public final float marginTop; public final float marginTop;
public final float keyPadding; public final float keyPadding;
public final float labelTextSize;
public final float sublabelTextSize;
/** Presses within this radius of an other pointer are ignored */
public final float pointerTooClose;
// From preferences // From preferences
public int layout; // Or '-1' for the system defaults public int layout; // Or '-1' for the system defaults
@@ -29,16 +36,17 @@ final class Config
public float keyVerticalInterval; public float keyVerticalInterval;
public float keyHorizontalInterval; public float keyHorizontalInterval;
public boolean preciseRepeat; public boolean preciseRepeat;
public int lockable_modifiers;
public float characterSize; // Ratio public float characterSize; // Ratio
public int accents; // Values are R.values.pref_accents_v_* public int accents; // Values are R.values.pref_accents_v_*
public int theme; // Values are R.style.* public int theme; // Values are R.style.*
// Dynamically set // Dynamically set
public boolean shouldOfferSwitchingToNextInputMethod; public boolean shouldOfferSwitchingToNextInputMethod;
public int key_flags_to_remove;
public String actionLabel; // Might be 'null' public String actionLabel; // Might be 'null'
public int actionId; // Meaningful only when 'actionLabel' isn't 'null' public int actionId; // Meaningful only when 'actionLabel' isn't 'null'
public boolean swapEnterActionKey; // Swap the "enter" and "action" keys public boolean swapEnterActionKey; // Swap the "enter" and "action" keys
public Set<String> extra_keys; // 'null' means all the keys
public final IKeyEventHandler handler; public final IKeyEventHandler handler;
@@ -48,6 +56,9 @@ final class Config
// static values // static values
marginTop = res.getDimension(R.dimen.margin_top); marginTop = res.getDimension(R.dimen.margin_top);
keyPadding = res.getDimension(R.dimen.key_padding); keyPadding = res.getDimension(R.dimen.key_padding);
labelTextSize = res.getFloat(R.integer.label_text_size);
sublabelTextSize = res.getFloat(R.integer.sublabel_text_size);
pointerTooClose = res.getDimension(R.dimen.pointer_too_close);
// default values // default values
layout = -1; layout = -1;
vibrateEnabled = true; vibrateEnabled = true;
@@ -66,10 +77,10 @@ final class Config
refresh(context); refresh(context);
// initialized later // initialized later
shouldOfferSwitchingToNextInputMethod = false; shouldOfferSwitchingToNextInputMethod = false;
key_flags_to_remove = 0;
actionLabel = null; actionLabel = null;
actionId = 0; actionId = 0;
swapEnterActionKey = false; swapEnterActionKey = false;
extra_keys = null;
handler = h; handler = h;
} }
@@ -85,16 +96,13 @@ final class Config
// is not the actual size of the keyboard, which will be bigger if the // is not the actual size of the keyboard, which will be bigger if the
// layout has a fifth row. // layout has a fifth row.
int keyboardHeightPercent; int keyboardHeightPercent;
float extra_horizontal_margin;
if (res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) // Landscape mode if (res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) // Landscape mode
{ {
keyboardHeightPercent = 55; keyboardHeightPercent = 55;
extra_horizontal_margin = res.getDimension(R.dimen.landscape_extra_horizontal_margin);
} }
else else
{ {
keyboardHeightPercent = prefs.getInt("keyboard_height", 35); keyboardHeightPercent = prefs.getInt("keyboard_height", 35);
extra_horizontal_margin = 0.f;
} }
layout = layoutId_of_string(prefs.getString("layout", "system")); layout = layoutId_of_string(prefs.getString("layout", "system"));
swipe_dist_dp = Float.valueOf(prefs.getString("swipe_dist", "15")); swipe_dist_dp = Float.valueOf(prefs.getString("swipe_dist", "15"));
@@ -109,13 +117,58 @@ final class Config
// Do not substract keyVerticalInterval from keyHeight because this is done // Do not substract keyVerticalInterval from keyHeight because this is done
// during rendered. // during rendered.
keyHeight = dm.heightPixels * keyboardHeightPercent / 100 / 4; keyHeight = dm.heightPixels * keyboardHeightPercent / 100 / 4;
horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin) + extra_horizontal_margin; horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin) + res.getDimension(R.dimen.extra_horizontal_margin);
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat); preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
lockable_modifiers =
(prefs.getBoolean("lockable_shift", true) ? KeyValue.FLAG_SHIFT : 0)
| (prefs.getBoolean("lockable_ctrl", false) ? KeyValue.FLAG_CTRL : 0)
| (prefs.getBoolean("lockable_alt", false) ? KeyValue.FLAG_ALT : 0)
| (prefs.getBoolean("lockable_fn", false) ? KeyValue.FLAG_FN : 0)
| (prefs.getBoolean("lockable_meta", false) ? KeyValue.FLAG_META : 0)
| (prefs.getBoolean("lockable_sup", false) ? KeyValue.FLAG_ACCENT_SUPERSCRIPT : 0)
| (prefs.getBoolean("lockable_sub", false) ? KeyValue.FLAG_ACCENT_SUBSCRIPT : 0);
characterSize = prefs.getFloat("character_size", characterSize); characterSize = prefs.getFloat("character_size", characterSize);
accents = Integer.valueOf(prefs.getString("accents", "1")); accents = Integer.valueOf(prefs.getString("accents", "1"));
theme = getThemeId(res, prefs.getString("theme", "")); theme = getThemeId(res, prefs.getString("theme", ""));
} }
/** Update the layout according to the configuration.
* - Remove the switching key if it isn't needed
* - Remove keys from other locales (not in 'extra_keys')
* - Replace the action key to show the right label
* - Swap the enter and action keys
*/
public KeyboardData modify_layout(KeyboardData kw)
{
// Update the name to avoid caching in KeyModifier
KeyValue action_key = (actionLabel == null) ? null :
KeyValue.getKeyByName("action").withNameAndSymbol(actionLabel, actionLabel);
return kw.replaceKeys(key -> {
if (key == null)
return null;
switch (key.eventCode)
{
case KeyValue.EVENT_CHANGE_METHOD:
return shouldOfferSwitchingToNextInputMethod ? key : null;
case KeyEvent.KEYCODE_ENTER:
return (swapEnterActionKey && action_key != null) ? action_key : key;
case KeyValue.EVENT_ACTION:
return (swapEnterActionKey && action_key != null) ?
KeyValue.getKeyByName("enter") : action_key;
default:
if (key.flags != 0)
{
if ((key.flags & KeyValue.FLAG_LOCALIZED) != 0 &&
extra_keys != null &&
!extra_keys.contains(key.name))
return null;
if ((key.flags & lockable_modifiers) != 0)
return key.withFlags(key.flags | KeyValue.FLAG_LOCK);
}
return key;
}});
}
private float getDipPref(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def) private float getDipPref(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def)
{ {
float value; float value;
@@ -150,38 +203,19 @@ final class Config
switch (name) switch (name)
{ {
case "azerty": return R.xml.azerty; case "azerty": return R.xml.azerty;
case "qwerty": return R.xml.qwerty;
case "qwerty_lv": return R.xml.qwerty_lv;
case "qwerty_es": return R.xml.qwerty_es;
case "ru_jcuken": return R.xml.local_ru_jcuken;
case "qwertz": return R.xml.qwertz;
case "bgph1": return R.xml.local_bgph1; case "bgph1": return R.xml.local_bgph1;
case "dvorak": return R.xml.dvorak; case "dvorak": return R.xml.dvorak;
case "qwerty_es": return R.xml.qwerty_es;
case "qwerty_lv": return R.xml.qwerty_lv;
case "qwerty_pt": return R.xml.qwerty_pt;
case "qwerty": return R.xml.qwerty;
case "qwerty_sv_se": return R.xml.qwerty_sv_se;
case "qwertz": return R.xml.qwertz;
case "ru_jcuken": return R.xml.local_ru_jcuken;
case "system": default: return -1; case "system": default: return -1;
} }
} }
/* Used for the accents option. */
public static int extra_key_flag_of_name(String name)
{
switch (name)
{
case "aigu": return KeyValue.FLAG_ACCENT2;
case "caron": return KeyValue.FLAG_ACCENT_CARON;
case "cedille": return KeyValue.FLAG_ACCENT5;
case "circonflexe": return KeyValue.FLAG_ACCENT3;
case "grave": return KeyValue.FLAG_ACCENT1;
case "macron": return KeyValue.FLAG_ACCENT_MACRON;
case "ring": return KeyValue.FLAG_ACCENT_RING;
case "szlig": return KeyValue.FLAG_LANG_SZLIG;
case "euro": return KeyValue.FLAG_LANG_EURO;
case "pound": return KeyValue.FLAG_LANG_POUND;
case "tilde": return KeyValue.FLAG_ACCENT4;
case "trema": return KeyValue.FLAG_ACCENT6;
default: throw new RuntimeException(name);
}
}
public static int themeId_of_string(String name) public static int themeId_of_string(String name)
{ {
switch (name) switch (name)

View File

@@ -14,6 +14,8 @@ class KeyEventHandler implements Config.IKeyEventHandler
public void handleKeyUp(KeyValue key, int flags) public void handleKeyUp(KeyValue key, int flags)
{ {
key = KeyModifier.handleFlags(key, flags); key = KeyModifier.handleFlags(key, flags);
if (key == null || (key.flags & KeyValue.FLAG_NOCHAR) != 0)
return;
switch (key.eventCode) switch (key.eventCode)
{ {
case KeyValue.EVENT_CONFIG: _recv.showKeyboardConfig(); return; case KeyValue.EVENT_CONFIG: _recv.showKeyboardConfig(); return;

View File

@@ -14,7 +14,7 @@ class KeyModifier
/* Modify a key according to modifiers. */ /* Modify a key according to modifiers. */
public static KeyValue handleFlags(KeyValue k, int flags) public static KeyValue handleFlags(KeyValue k, int flags)
{ {
if (flags == 0) // No modifier if (k == null || flags == 0) // No modifier
return k; return k;
SparseArray<KeyValue> ks = cacheEntry(k); SparseArray<KeyValue> ks = cacheEntry(k);
KeyValue r = ks.get(flags); KeyValue r = ks.get(flags);
@@ -22,7 +22,9 @@ class KeyModifier
return r; return r;
r = k; r = k;
r = handleFn(r, flags); r = handleFn(r, flags);
if (r != null)
r = handleShift(r, flags); r = handleShift(r, flags);
if (r != null)
r = handleAccents(r, flags); r = handleAccents(r, flags);
ks.put(flags, r); ks.put(flags, r);
return r; return r;
@@ -211,6 +213,7 @@ class KeyModifier
case "#": name = "£"; break; case "#": name = "£"; break;
case "*": name = "°"; break; case "*": name = "°"; break;
case "tab": name = "\\t"; break; case "tab": name = "\\t"; break;
case "": case "£": return null; // Avoid showing these twice
default: return k; default: return k;
} }
return KeyValue.getKeyByName(name); return KeyValue.getKeyByName(name);

View File

@@ -22,7 +22,10 @@ class KeyValue
public static final int FLAG_NOREPEAT = (1 << 2); public static final int FLAG_NOREPEAT = (1 << 2);
public static final int FLAG_NOCHAR = (1 << 3); public static final int FLAG_NOCHAR = (1 << 3);
public static final int FLAG_PRECISE_REPEAT = (1 << 4); public static final int FLAG_PRECISE_REPEAT = (1 << 4);
// Rendering flags
public static final int FLAG_KEY_FONT = (1 << 5); public static final int FLAG_KEY_FONT = (1 << 5);
public static final int FLAG_SMALLER_FONT = (1 << 6);
// Internal flags // Internal flags
public static final int FLAG_LOCKED = (1 << 8); public static final int FLAG_LOCKED = (1 << 8);
@@ -48,25 +51,13 @@ class KeyValue
public static final int FLAG_ACCENT_MACRON = (1 << 27); public static final int FLAG_ACCENT_MACRON = (1 << 27);
public static final int FLAG_ACCENT_ORDINAL = (1 << 28); public static final int FLAG_ACCENT_ORDINAL = (1 << 28);
public static final int FLAGS_ACCENTS = FLAG_ACCENT1 | FLAG_ACCENT2 | public static final int FLAGS_ACCENTS = FLAG_ACCENT1 | FLAG_ACCENT2 |
FLAG_ACCENT3 | FLAG_ACCENT4 | FLAG_ACCENT5 | FLAG_ACCENT6 | FLAG_ACCENT3 | FLAG_ACCENT4 | FLAG_ACCENT5 | FLAG_ACCENT6 |
FLAG_ACCENT_CARON | FLAG_ACCENT_MACRON | FLAG_ACCENT_SUPERSCRIPT | FLAG_ACCENT_CARON | FLAG_ACCENT_MACRON | FLAG_ACCENT_SUPERSCRIPT |
FLAG_ACCENT_SUBSCRIPT | FLAG_ACCENT_ORDINAL | FLAG_ACCENT_RING; FLAG_ACCENT_SUBSCRIPT | FLAG_ACCENT_ORDINAL | FLAG_ACCENT_RING;
// Language specific keys // Language specific keys that are removed from the keyboard by default
public static final int FLAG_LANG_SZLIG = (1 << 25); public static final int FLAG_LOCALIZED = (1 << 25);
public static final int FLAG_LANG_EURO = (1 << 29);
public static final int FLAG_LANG_POUND = (1 << 30);
public static final int FLAGS_LANGS = FLAG_LANG_SZLIG | FLAG_LANG_EURO |
FLAG_LANG_POUND;
public static final int FLAGS_NOT_HIDDEN_ACCENTS = FLAG_ACCENT_SUPERSCRIPT |
FLAG_ACCENT_SUBSCRIPT | FLAG_ACCENT_ORDINAL;
// Keys that have to be enabled per language
public static final int FLAGS_HIDDEN_KEYS =
(FLAGS_ACCENTS & ~FLAGS_NOT_HIDDEN_ACCENTS) | FLAGS_LANGS;
public final String name; public final String name;
public final String symbol; public final String symbol;
@@ -85,6 +76,16 @@ class KeyValue
return new KeyValue(name, s, c, eventCode, flags); return new KeyValue(name, s, c, eventCode, flags);
} }
public KeyValue withNameAndSymbol(String n, String s)
{
return new KeyValue(n, s, char_, eventCode, flags);
}
public KeyValue withFlags(int f)
{
return new KeyValue(name, symbol, char_, eventCode, f);
}
private static HashMap<String, KeyValue> keys = new HashMap<String, KeyValue>(); private static HashMap<String, KeyValue> keys = new HashMap<String, KeyValue>();
public KeyValue(String n, String s, char c, int e, int f) public KeyValue(String n, String s, char c, int e, int f)
@@ -151,22 +152,23 @@ class KeyValue
static static
{ {
addModifierKey("shift", "\uE808", FLAG_LOCK | FLAG_SHIFT | FLAG_KEY_FONT); addModifierKey("shift", "\uE808",
addModifierKey("ctrl", "Ctrl", FLAG_CTRL); FLAG_SHIFT | FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addModifierKey("alt", "Alt", FLAG_ALT); addModifierKey("ctrl", "Ctrl", FLAG_CTRL | FLAG_SMALLER_FONT);
addModifierKey("accent_aigu", "◌́", FLAG_ACCENT2); addModifierKey("alt", "Alt", FLAG_ALT | FLAG_SMALLER_FONT);
addModifierKey("accent_caron", "̌", FLAG_ACCENT_CARON); addModifierKey("accent_aigu", "́", FLAG_ACCENT2 | FLAG_LOCALIZED);
addModifierKey("accent_cedille", "̧", FLAG_ACCENT5); addModifierKey("accent_caron", "̌", FLAG_ACCENT_CARON | FLAG_LOCALIZED);
addModifierKey("accent_circonflexe", "̂", FLAG_ACCENT3); addModifierKey("accent_cedille", "̧", FLAG_ACCENT5 | FLAG_LOCALIZED);
addModifierKey("accent_grave", "̀", FLAG_ACCENT1); addModifierKey("accent_circonflexe", "̂", FLAG_ACCENT3 | FLAG_LOCALIZED);
addModifierKey("accent_macron", "̄", FLAG_ACCENT_MACRON); addModifierKey("accent_grave", "̀", FLAG_ACCENT1 | FLAG_LOCALIZED);
addModifierKey("accent_tilde", "̃", FLAG_ACCENT4); addModifierKey("accent_macron", "̄", FLAG_ACCENT_MACRON | FLAG_LOCALIZED);
addModifierKey("accent_trema", "̈", FLAG_ACCENT6); addModifierKey("accent_tilde", "̃", FLAG_ACCENT4 | FLAG_LOCALIZED);
addModifierKey("accent_ring", "̊", FLAG_ACCENT_RING); addModifierKey("accent_trema", "̈", FLAG_ACCENT6 | FLAG_LOCALIZED);
addModifierKey("superscript", "͆", FLAG_ACCENT_SUPERSCRIPT); addModifierKey("accent_ring", "̊", FLAG_ACCENT_RING | FLAG_LOCALIZED);
addModifierKey("subscript", "◌̺", FLAG_ACCENT_SUBSCRIPT); addModifierKey("superscript", "Sup", FLAG_ACCENT_SUPERSCRIPT | FLAG_SMALLER_FONT);
addModifierKey("ordinal", "ºʳᵈ", FLAG_ACCENT_ORDINAL); addModifierKey("subscript", "Sub", FLAG_ACCENT_SUBSCRIPT | FLAG_SMALLER_FONT);
addModifierKey("fn", "Fn", FLAG_FN); addModifierKey("ordinal", "Ord", FLAG_ACCENT_ORDINAL | FLAG_SMALLER_FONT);
addModifierKey("fn", "Fn", FLAG_FN | FLAG_SMALLER_FONT);
addModifierKey("meta", "", FLAG_META); addModifierKey("meta", "", FLAG_META);
addCharKey('a', KeyEvent.KEYCODE_A); addCharKey('a', KeyEvent.KEYCODE_A);
@@ -222,32 +224,31 @@ class KeyValue
addCharKey('#', KeyEvent.KEYCODE_POUND); addCharKey('#', KeyEvent.KEYCODE_POUND);
addCharKey('(', KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN); addCharKey('(', KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN);
addCharKey(')', KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN); addCharKey(')', KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN);
addCharKey('ß', EVENT_NONE, FLAG_LANG_SZLIG); addCharKey('ß', EVENT_NONE, FLAG_LOCALIZED);
addCharKey('€', EVENT_NONE, FLAG_LANG_EURO); addCharKey('€', EVENT_NONE, FLAG_LOCALIZED);
addCharKey('£', EVENT_NONE, FLAG_LANG_POUND); addCharKey('£', EVENT_NONE, FLAG_LOCALIZED);
addSpecialKey("config", "", EVENT_CONFIG); addSpecialKey("config", "\uE806", EVENT_CONFIG, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addSpecialKey("switch_text", "ABC", EVENT_SWITCH_TEXT); addSpecialKey("switch_text", "ABC", EVENT_SWITCH_TEXT);
addSpecialKey("switch_numeric", "123+", EVENT_SWITCH_NUMERIC); addSpecialKey("switch_numeric", "123+", EVENT_SWITCH_NUMERIC);
addSpecialKey("switch_emoji", "", EVENT_SWITCH_EMOJI); addSpecialKey("switch_emoji", "\uE812" , EVENT_SWITCH_EMOJI, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addSpecialKey("switch_back_emoji", "ABC", EVENT_SWITCH_BACK_EMOJI); addSpecialKey("switch_back_emoji", "ABC", EVENT_SWITCH_BACK_EMOJI);
addSpecialKey("change_method", "\ue807", EVENT_CHANGE_METHOD, FLAG_KEY_FONT); addSpecialKey("change_method", "\ue807", EVENT_CHANGE_METHOD, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addSpecialKey("action", "Action", EVENT_ACTION); // Will always be replaced addSpecialKey("action", "Action", EVENT_ACTION, FLAG_SMALLER_FONT); // Will always be replaced
addEventKey("esc", "Esc", KeyEvent.KEYCODE_ESCAPE); addEventKey("esc", "Esc", KeyEvent.KEYCODE_ESCAPE, FLAG_SMALLER_FONT);
// Enter should be '\u23CE' but using what is in the font file at the moment
addEventKey("enter", "\ue800", KeyEvent.KEYCODE_ENTER, FLAG_KEY_FONT); addEventKey("enter", "\ue800", KeyEvent.KEYCODE_ENTER, FLAG_KEY_FONT);
addEventKey("up", "\uE80B", KeyEvent.KEYCODE_DPAD_UP, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT); addEventKey("up", "\uE80B", KeyEvent.KEYCODE_DPAD_UP, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT);
addEventKey("right", "\uE80C", KeyEvent.KEYCODE_DPAD_RIGHT, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT); addEventKey("right", "\uE80C", KeyEvent.KEYCODE_DPAD_RIGHT, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT);
addEventKey("down", "\uE809", KeyEvent.KEYCODE_DPAD_DOWN, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT); addEventKey("down", "\uE809", KeyEvent.KEYCODE_DPAD_DOWN, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT);
addEventKey("left", "\uE80A", KeyEvent.KEYCODE_DPAD_LEFT, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT); addEventKey("left", "\uE80A", KeyEvent.KEYCODE_DPAD_LEFT, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT);
addEventKey("page_up", "", KeyEvent.KEYCODE_PAGE_UP); addEventKey("page_up", "\uE810", KeyEvent.KEYCODE_PAGE_UP, FLAG_KEY_FONT);
addEventKey("page_down", "", KeyEvent.KEYCODE_PAGE_DOWN); addEventKey("page_down", "\uE811", KeyEvent.KEYCODE_PAGE_DOWN, FLAG_KEY_FONT);
addEventKey("home", "", KeyEvent.KEYCODE_MOVE_HOME); addEventKey("home", "\uE80E", KeyEvent.KEYCODE_MOVE_HOME, FLAG_KEY_FONT);
addEventKey("end", "", KeyEvent.KEYCODE_MOVE_END); addEventKey("end", "\uE80F", KeyEvent.KEYCODE_MOVE_END, FLAG_KEY_FONT);
addEventKey("backspace", "", KeyEvent.KEYCODE_DEL); addEventKey("backspace", "", KeyEvent.KEYCODE_DEL, FLAG_SMALLER_FONT);
addEventKey("delete", "", KeyEvent.KEYCODE_FORWARD_DEL); addEventKey("delete", "", KeyEvent.KEYCODE_FORWARD_DEL, FLAG_SMALLER_FONT);
addEventKey("insert", "Ins", KeyEvent.KEYCODE_INSERT); addEventKey("insert", "Ins", KeyEvent.KEYCODE_INSERT, FLAG_SMALLER_FONT);
addEventKey("f1", "F1", KeyEvent.KEYCODE_F1); addEventKey("f1", "F1", KeyEvent.KEYCODE_F1);
addEventKey("f2", "F2", KeyEvent.KEYCODE_F2); addEventKey("f2", "F2", KeyEvent.KEYCODE_F2);
addEventKey("f3", "F3", KeyEvent.KEYCODE_F3); addEventKey("f3", "F3", KeyEvent.KEYCODE_F3);
@@ -261,6 +262,6 @@ class KeyValue
addEventKey("tab", "", KeyEvent.KEYCODE_TAB); addEventKey("tab", "", KeyEvent.KEYCODE_TAB);
addKey("\\t", "\\t", '\t', EVENT_NONE, 0); // Send the tab character addKey("\\t", "\\t", '\t', EVENT_NONE, 0); // Send the tab character
addKey("space", "\ue80d", ' ', KeyEvent.KEYCODE_SPACE, FLAG_KEY_FONT); addKey("space", "\ue80d", ' ', KeyEvent.KEYCODE_SPACE, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
} }
} }

View File

@@ -18,17 +18,25 @@ import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent; import android.view.ViewParent;
import android.util.Log;
import android.util.LogPrinter;
import java.util.List; import java.util.List;
import java.util.HashSet;
import java.util.Set;
public class Keyboard2 extends InputMethodService public class Keyboard2 extends InputMethodService
implements SharedPreferences.OnSharedPreferenceChangeListener implements SharedPreferences.OnSharedPreferenceChangeListener
{ {
static private final String TAG = "Keyboard2";
private Keyboard2View _keyboardView; private Keyboard2View _keyboardView;
private int _currentTextLayout; private int _currentTextLayout;
private ViewGroup _emojiPane = null; private ViewGroup _emojiPane = null;
private Config _config; private Config _config;
private boolean _debug_logs = false;
private KeyboardData getLayout(int resId) private KeyboardData getLayout(int resId)
{ {
return KeyboardData.load(getResources(), resId); return KeyboardData.load(getResources(), resId);
@@ -45,6 +53,7 @@ public class Keyboard2 extends InputMethodService
_config.refresh(this); _config.refresh(this);
_keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard); _keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard);
_keyboardView.reset(); _keyboardView.reset();
_debug_logs = getResources().getBoolean(R.bool.debug_logs);
} }
private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm) private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm)
@@ -70,32 +79,34 @@ public class Keyboard2 extends InputMethodService
_currentTextLayout = l; _currentTextLayout = l;
} }
private int extra_keys_of_subtype(InputMethodSubtype subtype) private void extra_keys_of_subtype(Set<String> dst, InputMethodSubtype subtype)
{ {
String extra_keys = subtype.getExtraValueOf("extra_keys"); String extra_keys = subtype.getExtraValueOf("extra_keys");
int flags = 0; if (extra_keys == null)
if (extra_keys != null) return;
for (String acc : extra_keys.split("\\|")) String[] ks = extra_keys.split("\\|");
flags |= Config.extra_key_flag_of_name(acc); for (int i = 0; i < ks.length; i++)
return flags; dst.add(ks[i]);
} }
private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype) private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype)
{ {
int to_keep = 0; HashSet<String> extra_keys = new HashSet<String>();
switch (_config.accents) switch (_config.accents)
{ {
case 1: case 1:
to_keep |= extra_keys_of_subtype(subtype); extra_keys_of_subtype(extra_keys, subtype);
for (InputMethodSubtype s : getEnabledSubtypes(imm)) for (InputMethodSubtype s : getEnabledSubtypes(imm))
to_keep |= extra_keys_of_subtype(s); extra_keys_of_subtype(extra_keys, s);
break; break;
case 2: to_keep |= extra_keys_of_subtype(subtype); break; case 2:
case 3: to_keep = KeyValue.FLAGS_HIDDEN_KEYS; break; extra_keys_of_subtype(extra_keys, subtype);
break;
case 3: extra_keys = null; break;
case 4: break; case 4: break;
default: throw new IllegalArgumentException(); default: throw new IllegalArgumentException();
} }
_config.key_flags_to_remove = ~to_keep & KeyValue.FLAGS_HIDDEN_KEYS; _config.extra_keys = extra_keys;
} }
private void refreshSubtypeLegacyFallback() private void refreshSubtypeLegacyFallback()
@@ -103,8 +114,8 @@ public class Keyboard2 extends InputMethodService
// Fallback for the accents option: Only respect the "None" case // Fallback for the accents option: Only respect the "None" case
switch (_config.accents) switch (_config.accents)
{ {
case 1: case 2: case 3: _config.key_flags_to_remove = 0; break; case 1: case 2: case 3: _config.extra_keys = null; break;
case 4: _config.key_flags_to_remove = KeyValue.FLAGS_HIDDEN_KEYS; break; case 4: _config.extra_keys = new HashSet<String>(); break;
} }
// Fallback for the layout option: Use qwerty in the "system settings" case // Fallback for the layout option: Use qwerty in the "system settings" case
_currentTextLayout = (_config.layout == -1) ? R.xml.qwerty : _config.layout; _currentTextLayout = (_config.layout == -1) ? R.xml.qwerty : _config.layout;
@@ -176,7 +187,16 @@ public class Keyboard2 extends InputMethodService
_keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard); _keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard);
_emojiPane = null; _emojiPane = null;
} }
_keyboardView.setKeyboard(getLayout(_currentTextLayout)); }
private void log_editor_info(EditorInfo info)
{
LogPrinter p = new LogPrinter(Log.DEBUG, TAG);
info.dump(p, "");
if (info.extras != null)
Log.d(TAG, "extras: "+info.extras.toString());
Log.d(TAG, "swapEnterActionKey: "+_config.swapEnterActionKey);
Log.d(TAG, "actionLabel: "+_config.actionLabel);
} }
@Override @Override
@@ -186,7 +206,11 @@ public class Keyboard2 extends InputMethodService
refreshEditorInfo(info); refreshEditorInfo(info);
if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0) if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0)
_keyboardView.setKeyboard(getLayout(R.xml.numeric)); _keyboardView.setKeyboard(getLayout(R.xml.numeric));
else
_keyboardView.setKeyboard(getLayout(_currentTextLayout));
setInputView(_keyboardView); setInputView(_keyboardView);
if (_debug_logs)
log_editor_info(info);
} }
@Override @Override

View File

@@ -55,28 +55,7 @@ public class Keyboard2View extends View
public void setKeyboard(KeyboardData kw) public void setKeyboard(KeyboardData kw)
{ {
if (!_config.shouldOfferSwitchingToNextInputMethod) _keyboard = _config.modify_layout(kw);
kw = kw.replaceKeys(
new KeyboardData.ReplaceKeysByEvent(KeyValue.EVENT_CHANGE_METHOD, null));
if (_config.key_flags_to_remove != 0)
kw = kw.replaceKeys(
new KeyboardData.ReplaceKeysByFlags(_config.key_flags_to_remove, null));
// Replace the action key to show the right label.
KeyValue action_key = null;
if (_config.actionLabel != null)
{
action_key = new KeyValue(_config.actionLabel, _config.actionLabel,
KeyValue.CHAR_NONE, KeyValue.EVENT_ACTION, KeyValue.FLAG_NOREPEAT);
}
if (_config.swapEnterActionKey && action_key != null)
kw = kw.replaceKeys(
new KeyboardData.ReplaceKeysByEvent2(KeyEvent.KEYCODE_ENTER,
action_key, KeyValue.EVENT_ACTION,
KeyValue.getKeyByName("enter")));
else
kw = kw.replaceKeys(
new KeyboardData.ReplaceKeysByEvent(KeyValue.EVENT_ACTION, action_key));
_keyboard = kw;
reset(); reset();
} }
@@ -106,7 +85,6 @@ public class Keyboard2View extends View
public void onPointerUp(KeyValue k) public void onPointerUp(KeyValue k)
{ {
if (k != null && (k.flags & KeyValue.FLAG_NOCHAR) == 0)
_config.handler.handleKeyUp(k, _flags); _config.handler.handleKeyUp(k, _flags);
updateFlags(); updateFlags();
invalidate(); invalidate();
@@ -114,7 +92,6 @@ public class Keyboard2View extends View
public void onPointerHold(KeyValue k) public void onPointerHold(KeyValue k)
{ {
if (k != null)
_config.handler.handleKeyUp(k, _flags); _config.handler.handleKeyUp(k, _flags);
} }
@@ -152,6 +129,9 @@ public class Keyboard2View extends View
for (p = 0; p < event.getPointerCount(); p++) for (p = 0; p < event.getPointerCount(); p++)
_pointers.onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p)); _pointers.onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p));
break; break;
case MotionEvent.ACTION_CANCEL:
_pointers.onTouchCancel(event.getPointerId(event.getActionIndex()));
break;
default: default:
return (false); return (false);
} }
@@ -236,30 +216,20 @@ public class Keyboard2View extends View
_tmpRect.set(x, y, x + keyW, y + keyH); _tmpRect.set(x, y, x + keyW, y + keyH);
canvas.drawRoundRect(_tmpRect, _theme.keyBorderRadius, _theme.keyBorderRadius, canvas.drawRoundRect(_tmpRect, _theme.keyBorderRadius, _theme.keyBorderRadius,
isKeyDown ? _theme.keyDownBgPaint : _theme.keyBgPaint); isKeyDown ? _theme.keyDownBgPaint : _theme.keyBgPaint);
if (k.key0 != null) drawLabel(canvas, k.key0, keyW / 2f + x, y, keyH, isKeyDown);
drawLabel(canvas, k.key0, keyW / 2f + x, (keyH + _theme.labelTextSize) / 2f + y, isKeyDown);
float subPadding = _config.keyPadding;
if (k.edgekeys) if (k.edgekeys)
{ {
if (k.key1 != null) // top key drawSubLabel(canvas, k.key1, x, y, keyW, keyH, Paint.Align.CENTER, Vertical.TOP, isKeyDown);
drawSubLabel(canvas, k.key1, x + keyW / 2f, y + subPadding, Paint.Align.CENTER, Vertical.TOP, isKeyDown); drawSubLabel(canvas, k.key3, x, y, keyW, keyH, Paint.Align.LEFT, Vertical.CENTER, isKeyDown);
if (k.key3 != null) // left key drawSubLabel(canvas, k.key2, x, y, keyW, keyH, Paint.Align.RIGHT, Vertical.CENTER, isKeyDown);
drawSubLabel(canvas, k.key3, x + subPadding, y + keyH / 2f, Paint.Align.LEFT, Vertical.CENTER, isKeyDown); drawSubLabel(canvas, k.key4, x, y, keyW, keyH, Paint.Align.CENTER, Vertical.BOTTOM, isKeyDown);
if (k.key2 != null) // right key
drawSubLabel(canvas, k.key2, x + keyW - subPadding, y + keyH / 2f, Paint.Align.RIGHT, Vertical.CENTER, isKeyDown);
if (k.key4 != null) // bottom key
drawSubLabel(canvas, k.key4, x + keyW / 2f, y + keyH - subPadding, Paint.Align.CENTER, Vertical.BOTTOM, isKeyDown);
} }
else else
{ {
if (k.key1 != null) // top left key drawSubLabel(canvas, k.key1, x, y, keyW, keyH, Paint.Align.LEFT, Vertical.TOP, isKeyDown);
drawSubLabel(canvas, k.key1, x + subPadding, y + subPadding, Paint.Align.LEFT, Vertical.TOP, isKeyDown); drawSubLabel(canvas, k.key3, x, y, keyW, keyH, Paint.Align.LEFT, Vertical.BOTTOM, isKeyDown);
if (k.key3 != null) // bottom left key drawSubLabel(canvas, k.key2, x, y, keyW, keyH, Paint.Align.RIGHT, Vertical.TOP, isKeyDown);
drawSubLabel(canvas, k.key3, x + subPadding, y + keyH - subPadding, Paint.Align.LEFT, Vertical.BOTTOM, isKeyDown); drawSubLabel(canvas, k.key4, x, y, keyW, keyH, Paint.Align.RIGHT, Vertical.BOTTOM, isKeyDown);
if (k.key2 != null) // top right key
drawSubLabel(canvas, k.key2, x + keyW - subPadding, y + subPadding, Paint.Align.RIGHT, Vertical.TOP, isKeyDown);
if (k.key4 != null) // bottom right key
drawSubLabel(canvas, k.key4, x + keyW - subPadding, y + keyH - subPadding, Paint.Align.RIGHT, Vertical.BOTTOM, isKeyDown);
} }
x += _keyWidth * k.width; x += _keyWidth * k.width;
} }
@@ -289,30 +259,42 @@ public class Keyboard2View extends View
return defaultColor; return defaultColor;
} }
private void drawLabel(Canvas canvas, KeyValue k, float x, float y, boolean isKeyDown) private void drawLabel(Canvas canvas, KeyValue k, float x, float y, float keyH, boolean isKeyDown)
{ {
k = KeyModifier.handleFlags(k, _flags); k = KeyModifier.handleFlags(k, _flags);
if (k == null)
return;
float textSize = scaleTextSize(k, _config.labelTextSize, keyH);
Paint p = _theme.labelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0)); Paint p = _theme.labelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0));
p.setColor(labelColor(k, isKeyDown, _theme.labelColor)); p.setColor(labelColor(k, isKeyDown, _theme.labelColor));
p.setTextSize(_theme.labelTextSize * scaleTextSize(k)); p.setTextSize(textSize);
canvas.drawText(k.symbol, x, y, p); canvas.drawText(k.symbol, x, (keyH - p.ascent() - p.descent()) / 2f + y, p);
} }
private void drawSubLabel(Canvas canvas, KeyValue k, float x, float y, Paint.Align a, Vertical v, boolean isKeyDown) private void drawSubLabel(Canvas canvas, KeyValue k, float x, float y, float keyW, float keyH, Paint.Align a, Vertical v, boolean isKeyDown)
{ {
k = KeyModifier.handleFlags(k, _flags); k = KeyModifier.handleFlags(k, _flags);
if (k == null)
return;
float textSize = scaleTextSize(k, _config.sublabelTextSize, keyH);
Paint p = _theme.subLabelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0), a); Paint p = _theme.subLabelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0), a);
p.setColor(labelColor(k, isKeyDown, _theme.subLabelColor)); p.setColor(labelColor(k, isKeyDown, _theme.subLabelColor));
p.setTextSize(_theme.sublabelTextSize * scaleTextSize(k)); p.setTextSize(textSize);
float subPadding = _config.keyPadding;
if (v == Vertical.CENTER) if (v == Vertical.CENTER)
y -= (p.ascent() + p.descent()) / 2f; y += (keyH - p.ascent() - p.descent()) / 2f;
else else
y -= (v == Vertical.TOP) ? p.ascent() : p.descent(); y += (v == Vertical.TOP) ? subPadding - p.ascent() : keyH - subPadding - p.descent();
if (a == Paint.Align.CENTER)
x += keyW / 2f;
else
x += (a == Paint.Align.LEFT) ? subPadding : keyW - subPadding;
canvas.drawText(k.symbol, x, y, p); canvas.drawText(k.symbol, x, y, p);
} }
private float scaleTextSize(KeyValue k) private float scaleTextSize(KeyValue k, float rel_size, float keyH)
{ {
return ((k.symbol.length() < 2) ? 1.f : 0.8f) * _config.characterSize; float smaller_font = ((k.flags & KeyValue.FLAG_SMALLER_FONT) == 0) ? 1.f : 0.75f;
return keyH * rel_size * smaller_font * _config.characterSize;
} }
} }

View File

@@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
class KeyboardData class KeyboardData
{ {
@@ -184,7 +185,8 @@ class KeyboardData
public Key replaceKeys(MapKeys f) public Key replaceKeys(MapKeys f)
{ {
return new Key(f.map(key0), f.map(key1), f.map(key2), f.map(key3), f.map(key4), width, shift, edgekeys); return new Key(f.apply(key0), f.apply(key1), f.apply(key2),
f.apply(key3), f.apply(key4), width, shift, edgekeys);
} }
/** New key with the width multiplied by 's'. */ /** New key with the width multiplied by 's'. */
@@ -194,70 +196,7 @@ class KeyboardData
} }
} }
public static abstract interface MapKeys public static abstract interface MapKeys extends Function<KeyValue, KeyValue> { }
{
public abstract KeyValue map(KeyValue k);
}
public static class ReplaceKeysByFlags implements MapKeys
{
private final int _flags;
private final KeyValue _replacement;
public ReplaceKeysByFlags(int flags, KeyValue r)
{
_flags = flags;
_replacement = r;
}
public KeyValue map(KeyValue k)
{
return (k != null && (k.flags & _flags) != 0) ? _replacement : k;
}
}
public static class ReplaceKeysByEvent implements MapKeys
{
private final int _eventCode;
private final KeyValue _replacement;
public ReplaceKeysByEvent(int ev, KeyValue r)
{
_eventCode = ev;
_replacement = r;
}
public KeyValue map(KeyValue k)
{
return (k != null && k.eventCode == _eventCode) ? _replacement : k;
}
}
/* Replace two keys at the same time. Used for swaping keys. */
public static class ReplaceKeysByEvent2 implements MapKeys
{
private final int _e1;
private final KeyValue _r1;
private final int _e2;
private final KeyValue _r2;
public ReplaceKeysByEvent2(int e1, KeyValue r1, int e2, KeyValue r2)
{
_e1 = e1;
_r1 = r1;
_e2 = e2;
_r2 = r2;
}
public KeyValue map(KeyValue k)
{
if (k == null)
return null;
if (k.eventCode == _e1) return _r1;
if (k.eventCode == _e2) return _r2;
return k;
}
}
/** Parsing utils */ /** Parsing utils */

View File

@@ -53,7 +53,7 @@ public final class Pointers implements Handler.Callback
public int getKeyFlags(KeyValue kv) public int getKeyFlags(KeyValue kv)
{ {
for (Pointer p : _ptrs) for (Pointer p : _ptrs)
if (p.value == kv) if (p.value != null && p.value.name == kv.name) // Physical equality
return p.flags; return p.flags;
return -1; return -1;
} }
@@ -95,8 +95,22 @@ public final class Pointers implements Handler.Callback
} }
} }
public void onTouchCancel(int pointerId)
{
Pointer ptr = getPtr(pointerId);
if (ptr == null)
return;
stopKeyRepeat(ptr);
removePtr(ptr);
_handler.onPointerFlagsChanged();
}
public void onTouchDown(float x, float y, int pointerId, KeyboardData.Key key) public void onTouchDown(float x, float y, int pointerId, KeyboardData.Key key)
{ {
// Ignore new pointers that are too close to an existing pointer. This
// might be glitches.
if (isPointerNearby(x, y))
return;
KeyValue value = key.key0; KeyValue value = key.key0;
Pointer ptr = new Pointer(pointerId, key, value, x, y); Pointer ptr = new Pointer(pointerId, key, value, x, y);
_ptrs.add(ptr); _ptrs.add(ptr);
@@ -113,7 +127,8 @@ public final class Pointers implements Handler.Callback
float dx = x - ptr.downX; float dx = x - ptr.downX;
float dy = y - ptr.downY; float dy = y - ptr.downY;
float dist = Math.abs(dx) + Math.abs(dy); float dist = Math.abs(dx) + Math.abs(dy);
ptr.ptrDist = dist; ptr.ptrDistX = dx;
ptr.ptrDistY = dy;
KeyValue newValue; KeyValue newValue;
if (dist < _config.swipe_dist_px) if (dist < _config.swipe_dist_px)
{ {
@@ -189,6 +204,20 @@ public final class Pointers implements Handler.Callback
} }
} }
/** Check if a pointer is within a radius of 'pointerTooClose' */
private boolean isPointerNearby(float x, float y)
{
for (Pointer p : _ptrs)
{
float dx = p.downX + p.ptrDistX - x;
float dy = p.downY + p.ptrDistY - y;
float d = Math.abs(dx) + Math.abs(dy);
if (d < _config.pointerTooClose)
return true;
}
return false;
}
// Key repeat // Key repeat
/** Message from [_keyrepeat_handler]. */ /** Message from [_keyrepeat_handler]. */
@@ -240,12 +269,13 @@ public final class Pointers implements Handler.Callback
private float modulatePreciseRepeat(Pointer ptr) private float modulatePreciseRepeat(Pointer ptr)
{ {
float ptrDist = Math.abs(ptr.ptrDistX) + Math.abs(ptr.ptrDistY);
if (ptr.repeatingPtrDist < 0.f) if (ptr.repeatingPtrDist < 0.f)
ptr.repeatingPtrDist = ptr.ptrDist; // First repeat ptr.repeatingPtrDist = ptrDist; // First repeat
if (ptr.ptrDist > ptr.repeatingPtrDist * 2.f) if (ptrDist > ptr.repeatingPtrDist * 2.f)
ptr.repeatingPtrDist = ptr.ptrDist / 2.f; // Large swipe, move the middle point ptr.repeatingPtrDist = ptrDist / 2.f; // Large swipe, move the middle point
float left = ptr.repeatingPtrDist / 2.f; float left = ptr.repeatingPtrDist / 2.f;
float accel = (ptr.ptrDist - left) / (ptr.repeatingPtrDist - left); float accel = (ptrDist - left) / (ptr.repeatingPtrDist - left);
return Math.min(8.f, Math.max(0.1f, accel)); return Math.min(8.f, Math.max(0.1f, accel));
} }
@@ -258,7 +288,8 @@ public final class Pointers implements Handler.Callback
public float downX; public float downX;
public float downY; public float downY;
/** Distance of the pointer to the initial press. */ /** Distance of the pointer to the initial press. */
public float ptrDist; public float ptrDistX;
public float ptrDistY;
public int flags; public int flags;
/** Identify timeout messages. */ /** Identify timeout messages. */
public int timeoutWhat; public int timeoutWhat;
@@ -272,7 +303,8 @@ public final class Pointers implements Handler.Callback
value = v; value = v;
downX = x; downX = x;
downY = y; downY = y;
ptrDist = 0.f; ptrDistX = 0.f;
ptrDistY = 0.f;
flags = (v == null) ? 0 : v.flags; flags = (v == null) ? 0 : v.flags;
timeoutWhat = -1; timeoutWhat = -1;
repeatingPtrDist = -1.f; repeatingPtrDist = -1.f;

View File

@@ -16,9 +16,6 @@ public class Theme
public final int labelColor; public final int labelColor;
public final int subLabelColor; public final int subLabelColor;
public final float labelTextSize;
public final float sublabelTextSize;
public final float keyBorderRadius; public final float keyBorderRadius;
private final Paint _keyLabelPaint; private final Paint _keyLabelPaint;
@@ -38,9 +35,6 @@ public class Theme
subLabelColor = s.getColor(R.styleable.keyboard_colorSubLabel, 0); subLabelColor = s.getColor(R.styleable.keyboard_colorSubLabel, 0);
keyBorderRadius = s.getDimension(R.styleable.keyboard_keyBorderRadius, 0); keyBorderRadius = s.getDimension(R.styleable.keyboard_keyBorderRadius, 0);
s.recycle(); s.recycle();
Resources res = context.getResources();
labelTextSize = res.getDimension(R.dimen.label_text_size);
sublabelTextSize = res.getDimension(R.dimen.sublabel_text_size);
_keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null); _keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null);
_keySubLabelPaint = initLabelPaint(Paint.Align.LEFT, null); _keySubLabelPaint = initLabelPaint(Paint.Align.LEFT, null);
Typeface specialKeyFont = getSpecialKeyFont(context); Typeface specialKeyFont = getSpecialKeyFont(context);