Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>

<activity android:name="juloo.keyboard2.dict.PersonalDictionaryActivity" android:icon="@mipmap/ic_launcher" android:theme="@style/appTheme" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
</application>

<!-- To query enabled input methods for voice IME detection -->
Expand Down
Binary file modified assets/special_font.ttf
Binary file not shown.
28 changes: 28 additions & 0 deletions res/layout/dictionary_picker_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingHorizontal="12dp"
android:paddingVertical="7dp"
android:gravity="center_vertical"
android:minHeight="28dp">

<TextView
android:id="@+id/dict_picker_item_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="14sp"
android:textColor="?attr/colorLabel"/>

<TextView
android:id="@+id/dict_picker_item_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="✓"
android:textSize="16sp"
android:textColor="?attr/colorLabelActivated"
android:visibility="gone"/>

</LinearLayout>
77 changes: 77 additions & 0 deletions res/layout/dictionary_picker_pane.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorKeyboard">

<!-- Left column: autocorrect toggle at top, ABC back button at bottom -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:paddingVertical="8dp"
android:paddingHorizontal="6dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Auto"
android:textColor="?attr/colorLabel"
android:textSize="11sp"
android:gravity="center"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Correct"
android:textColor="?attr/colorLabel"
android:textSize="11sp"
android:gravity="center"/>

<Switch
android:id="@+id/dict_picker_autocorrect_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"/>

<Space
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>

<TextView
android:id="@+id/dict_picker_abc_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ABC"
android:textColor="?attr/colorLabel"
android:textSize="14sp"
android:gravity="center"
android:padding="8dp"/>

</LinearLayout>

<!-- Vertical divider -->
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/colorKey"/>

<!-- Right column: scrollable list of dictionaries -->
<ScrollView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">

<LinearLayout
android:id="@+id/dict_picker_list"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="4dp"/>

</ScrollView>

</LinearLayout>
1 change: 1 addition & 0 deletions res/layout/keyboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TextView android:id="@+id/candidates_left" style="@style/candidates_item"/>
<TextView android:id="@+id/candidates_middle" style="@style/candidates_item"/>
<TextView android:id="@+id/candidates_right" style="@style/candidates_item"/>
<TextView android:id="@+id/candidates_add_word" android:layout_width="36dp" android:layout_height="36dp" android:layout_gravity="center_vertical" android:layout_marginEnd="4dp" android:gravity="center" android:text="@string/candidates_add_word" android:textColor="?attr/colorLabel" android:textSize="18sp" android:visibility="visible" android:contentDescription="@string/candidates_add_word_desc"/>
</juloo.keyboard2.suggestions.CandidatesView>
<juloo.keyboard2.Keyboard2View android:id="@+id/keyboard_view" android:layout_width="match_parent" android:layout_height="wrap_content"/>
</LinearLayout>
13 changes: 13 additions & 0 deletions res/layout/personal_dict_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<LinearLayout
android:id="@+id/personal_dict_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>

</ScrollView>
28 changes: 28 additions & 0 deletions res/layout/personal_dict_entry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingHorizontal="16dp"
android:paddingVertical="12dp"
android:gravity="center_vertical"
android:minHeight="48dp">

<TextView
android:id="@+id/personal_dict_entry_word"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"/>

<TextView
android:id="@+id/personal_dict_entry_replacement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorSecondary"
android:maxWidth="160dp"
android:ellipsize="end"
android:singleLine="true"/>

</LinearLayout>
6 changes: 6 additions & 0 deletions res/menu/personal_dict_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/personal_dict_menu_add"
android:title="@string/personal_dict_add_btn"
android:showAsAction="always"/>
</menu>
6 changes: 6 additions & 0 deletions res/values/layouts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<item>latn_azerty_fr</item>
<item>latn_bepo_fr</item>
<item>latn_bone</item>
<item>latn_dvorak_landscape</item>
<item>latn_dvorak_left</item>
<item>latn_neo2</item>
<item>latn_qwerty_apl</item>
<item>latn_qwerty_az</item>
Expand Down Expand Up @@ -141,6 +143,8 @@
<item>AZERTY (Français)</item>
<item>BEPO (Français)</item>
<item>Bone</item>
<item>Dvorak-Landscape</item>
<item>Dvorak-Left</item>
<item>Neo 2</item>
<item>QWERTY (APL)</item>
<item>QWERTY (Azərbaycanca)</item>
Expand Down Expand Up @@ -235,6 +239,8 @@
<item>@xml/latn_azerty_fr</item>
<item>@xml/latn_bepo_fr</item>
<item>@xml/latn_bone</item>
<item>@xml/latn_dvorak_landscape</item>
<item>@xml/latn_dvorak_left</item>
<item>@xml/latn_neo2</item>
<item>@xml/latn_qwerty_apl</item>
<item>@xml/latn_qwerty_az</item>
Expand Down
24 changes: 24 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
<string name="pref_margin_bottom_title">Margin bottom</string>
<string name="pref_keyboard_height_title">Keyboard height</string>
<string name="pref_horizontal_margin_title">Horizontal margin</string>
<string name="pref_margin_for_display_cutout_title">Margin for display cutout</string>
<string name="pref_margin_for_display_cutout_summary">Add extra margin to avoid drawing keys behind the camera cutout</string>
<string name="pref_character_size_title">Label size</string>
<string name="pref_character_size_summary">Size of characters displayed on the keyboard (%.2fx)</string>
<string name="pref_theme">Theme</string>
Expand Down Expand Up @@ -161,5 +163,27 @@
<string name="dictionaries_download_success">Dictionary installed</string>
<string name="dictionaries_download_failed">Download failed</string>
<string name="dictionaries_activity_not_enabled">You must first enable the keyboard to download dictionaries.</string>
<string name="candidates_status_no_dict">No dictionary installed</string>
<string name="candidates_status_install">Install</string>
<string name="candidates_status_click_to_install">Click to install a dictionary for %s</string>
<string name="candidates_add_word">+</string>
<string name="candidates_add_word_desc">Add word to personal dictionary</string>
<string name="pref_selected_dictionary_title">Active dictionary</string>
<string name="pref_selected_dictionary_auto">Auto (based on language)</string>
<string name="dict_picker_title">Select dictionary</string>
<string name="dict_picker_autocorrect_label">Auto-correct with space bar</string>
<string name="pref_manage_dictionaries_title">Manage dictionaries</string>
<string name="pref_manage_dictionaries_summary">Download or remove language dictionaries</string>
<string name="pref_personal_dictionary_title">Personal dictionary</string>
<string name="pref_personal_dictionary_summary">Custom words and autocorrections</string>
<string name="personal_dict_title">Personal dictionary</string>
<string name="personal_dict_add_btn">Add word</string>
<string name="personal_dict_add_title">Add word</string>
<string name="personal_dict_edit_title">Edit word</string>
<string name="personal_dict_word_hint">Word (trigger)</string>
<string name="personal_dict_replacement_hint">Replacement (leave blank to use word as-is)</string>
<string name="personal_dict_save">Save</string>
<string name="personal_dict_delete">Delete</string>
<string name="personal_dict_word_empty">Word cannot be empty</string>
<string name="personal_dict_empty">No words added yet. Tap \"Add word\" or use the + button while typing.</string>
</resources>
6 changes: 6 additions & 0 deletions res/xml/dict_picker_bottom_row.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<keyboard bottom_row="false">
<row height="0.95">
<key key0="switch_back_dict_picker"/>
</row>
</keyboard>
4 changes: 4 additions & 0 deletions res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<PreferenceCategory android:title="@string/pref_category_suggestions">
<CheckBoxPreference android:key="suggestions" android:title="@string/pref_suggestions_title" android:summary="@string/pref_suggestions_summary" android:defaultValue="true"/>
<CheckBoxPreference android:key="space_bar_auto_complete" android:title="@string/pref_space_bar_auto_complete_title" android:summary="@string/pref_space_bar_auto_complete_summary" android:defaultValue="false"/>
<juloo.keyboard2.prefs.DictionaryPickerPreference android:key="selected_dictionary" android:title="@string/pref_selected_dictionary_title" android:summary="%s" android:defaultValue="auto" android:dependency="suggestions"/>
<Preference android:key="pref_manage_dictionaries" android:title="@string/pref_manage_dictionaries_title" android:summary="@string/pref_manage_dictionaries_summary" android:dependency="suggestions"/>
<Preference android:key="pref_personal_dictionary" android:title="@string/pref_personal_dictionary_title" android:summary="@string/pref_personal_dictionary_summary" android:dependency="suggestions"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_typing">
<ListPreference android:key="swipe_dist" android:title="@string/pref_swipe_dist_title" android:summary="@string/pref_swipe_dist_summary" android:defaultValue="15" android:entries="@array/pref_swipe_dist_entries" android:entryValues="@array/pref_swipe_dist_values"/>
Expand Down Expand Up @@ -55,6 +58,7 @@
<juloo.keyboard2.prefs.IntSlideBarPreference android:key="horizontal_margin_landscape" android:title="@string/pref_landscape" android:summary="%sdp" android:defaultValue="28" min="0" max="200"/>
<juloo.keyboard2.prefs.IntSlideBarPreference android:key="horizontal_margin_portrait_unfolded" android:title="@string/pref_portrait_unfolded" android:summary="%sdp" android:defaultValue="3" min="0" max="30"/>
<juloo.keyboard2.prefs.IntSlideBarPreference android:key="horizontal_margin_landscape_unfolded" android:title="@string/pref_landscape_unfolded" android:summary="%sdp" android:defaultValue="28" min="0" max="200"/>
<CheckBoxPreference android:key="margin_for_display_cutout" android:title="@string/pref_margin_for_display_cutout_title" android:summary="@string/pref_margin_for_display_cutout_summary" android:defaultValue="false"/>
</PreferenceScreen>
<juloo.keyboard2.prefs.SlideBarPreference android:key="character_size" android:title="@string/pref_character_size_title" android:summary="@string/pref_character_size_summary" android:defaultValue="1.15" min="0.75" max="1.5"/>
<juloo.keyboard2.prefs.SlideBarPreference android:key="key_vertical_margin" android:title="@string/pref_key_vertical_space" android:summary="%s%%" android:defaultValue="1.5" min="0" max="5"/>
Expand Down
7 changes: 7 additions & 0 deletions srcs/juloo.keyboard2/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Map;
import juloo.cdict.Cdict;
import juloo.keyboard2.dict.Dictionaries;
import juloo.keyboard2.dict.PersonalDictionary;
import juloo.keyboard2.prefs.CustomExtraKeysPreference;
import juloo.keyboard2.prefs.ExtraKeysPreference;
import juloo.keyboard2.prefs.LayoutsPreference;
Expand Down Expand Up @@ -56,6 +57,7 @@ public final class Config
public int keyboard_rows_height_pixels;
public int screenHeightPixels;
public float horizontal_margin;
public boolean margin_for_display_cutout;
public float key_vertical_margin;
public float key_horizontal_margin;
public int labelBrightness; // 0 - 255
Expand Down Expand Up @@ -85,6 +87,9 @@ public final class Config
public Map<KeyValue, KeyboardData.PreferredPos> extra_keys_custom;
public DeviceLocales device_locales = null;
public Cdict current_dictionary = null; // Might be 'null'.
public PersonalDictionary personal_dictionary = null; // Might be 'null'.
/** "auto" means use the locale-based dictionary. */
public String selected_dictionary;
public Cdict emoji_dictionary = null; // Might be 'null'.
public IKeyEventHandler handler;
public boolean orientation_landscape = false;
Expand Down Expand Up @@ -179,6 +184,7 @@ public void refresh(Resources res, Boolean foldableUnfolded, Dictionaries dicts)
keyboard_rows_height_pixels = screenHeightPixels * keyboardHeightPercent / 395;
horizontal_margin =
get_dip_pref_oriented(dm, "horizontal_margin", 3, 28);
margin_for_display_cutout = _prefs.getBoolean("margin_for_display_cutout", false);
double_tap_lock_shift = _prefs.getBoolean("lock_double_tap", false);
characterSize =
_prefs.getFloat("character_size", 1.15f)
Expand All @@ -195,6 +201,7 @@ public void refresh(Resources res, Boolean foldableUnfolded, Dictionaries dicts)
clipboard_history_enabled = _prefs.getBoolean("clipboard_history_enabled", false);
clipboard_history_duration = Integer.parseInt(_prefs.getString("clipboard_history_duration", "5"));
space_bar_auto_complete = _prefs.getBoolean("space_bar_auto_complete", false);
selected_dictionary = _prefs.getString("selected_dictionary", "auto");

float screen_width_dp = dm.widthPixels / dm.density;
wide_screen = screen_width_dp >= WIDE_DEVICE_THRESHOLD;
Expand Down
15 changes: 15 additions & 0 deletions srcs/juloo.keyboard2/KeyEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public void suggestion_entered(String text)
int cur_rel = _typedword.cursor_relative();
replace_surrounding_text(old.length() + cur_rel, -cur_rel, text + " ");
last_replaced_word = old;
last_correction_word = text;
last_replacement_word_len = text.length() + 1;
_next_last_action = LastAction.SUGGESTION_ENTERED;
}
Expand All @@ -159,6 +160,11 @@ public void ime_subtype_changed()
_suggestions.currently_typed_word(_typedword.get());
}

public void set_space_bar_auto_complete(boolean enabled)
{
_space_bar_auto_complete = enabled;
}

/** Update [_mods] to be consistent with the [mods], sending key events if
needed. */
void update_meta_state(Pointers.Modifiers mods)
Expand Down Expand Up @@ -525,6 +531,8 @@ void cancel_selection()
enter a suggestion (with the space bar or the candidates view) or [null]
otherwise. */
String last_replaced_word = null;
/** The suggestion that replaced [last_replaced_word]. */
String last_correction_word = null;
/** Length of the text before the cursor that should be replaced by
backspace. */
int last_replacement_word_len = 0;
Expand All @@ -548,7 +556,11 @@ void handle_backspace()
{
replace_surrounding_text(last_replacement_word_len, 0,
last_replaced_word + " ");
String original = last_replaced_word;
String corrected = last_correction_word;
last_replaced_word = null;
last_correction_word = null;
_recv.on_autocorrect_undone(original, corrected);
}
else
{
Expand All @@ -564,6 +576,9 @@ public static interface IReceiver extends Suggestions.Callback
public void selection_state_changed(boolean selection_is_ongoing);
public InputConnection getCurrentInputConnection();
public Handler getHandler();
/** Called after backspace undoes an autocorrect. [original] is the word
the user typed, [corrected] is what autocorrect inserted. */
public void on_autocorrect_undone(String original, String corrected);
}

class Autocapitalisation_callback implements Autocapitalisation.Callback
Expand Down
4 changes: 4 additions & 0 deletions srcs/juloo.keyboard2/KeyValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public static enum Event
CAPS_LOCK,
SWITCH_VOICE_TYPING,
SWITCH_VOICE_TYPING_CHOOSER,
SWITCH_DICTIONARY,
SWITCH_BACK_DICT_PICKER,
}

// Must be evaluated in the reverse order of their values.
Expand Down Expand Up @@ -643,6 +645,8 @@ public static KeyValue getSpecialKeyByName(String name)
case "capslock": return eventKey(0xE012, Event.CAPS_LOCK, 0);
case "voice_typing": return eventKey(0xE015, Event.SWITCH_VOICE_TYPING, FLAG_SMALLER_FONT);
case "voice_typing_chooser": return VOICE_TYPING_CHOOSER;
case "switch_dictionary": return eventKey(0xE01D, Event.SWITCH_DICTIONARY, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
case "switch_back_dict_picker": return eventKey("ABC", Event.SWITCH_BACK_DICT_PICKER, 0);

/* Key events */
case "esc": return keyeventKey("Esc", KeyEvent.KEYCODE_ESCAPE, FLAG_SMALLER_FONT);
Expand Down
Loading