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
37 changes: 34 additions & 3 deletions app/src/main/java/helium314/keyboard/keyboard/PointerTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
private static final boolean DEBUG_MOVE_EVENT = false;
private static final boolean DEBUG_LISTENER = false;
private static final boolean DEBUG_MODE = DebugFlags.DEBUG_ENABLED || DEBUG_EVENT;

private int mWordDeleteTickCounter = 0;
static final class PointerTrackerParams {
public final boolean mKeySelectionByDraggingFinger;
public final int mTouchNoiseThresholdTime;
Expand All @@ -59,6 +59,7 @@ static final class PointerTrackerParams {
public final int mKeyRepeatStartTimeout;
public final int mKeyRepeatInterval;


public PointerTrackerParams(final TypedArray mainKeyboardViewAttr) {
mKeySelectionByDraggingFinger = mainKeyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_keySelectionByDraggingFinger, false);
Expand Down Expand Up @@ -1158,9 +1159,24 @@ public void onLongPressed() {
sListener.onReleaseKey(popupKeyCode, false);
return;
}

final int code = key.getCode();

// Delete Word Feature
if (code == KeyCode.DELETE && Settings.getValues().mDeleteLongPressEnabled) {
mWordDeleteTickCounter = 0; // Reset the pace counter

// Fire the first word instantly
sListener.onCodeInput(KeyCode.DELETE_WORD, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false);

// Tell the static timer proxy to start looping this tracker's onKeyRepeat
startKeyRepeatTimer(1);
return;
}
// --------------------------------------

if (code == KeyCode.LANGUAGE_SWITCH
|| (code == Constants.CODE_SPACE && key.getPopupKeys() == null && Settings.getValues().mSpaceForLangChange)
|| (code == Constants.CODE_SPACE && key.getPopupKeys() == null && Settings.getValues().mSpaceForLangChange)
) {
// Long pressing the space key invokes IME switcher dialog.
if (sListener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) {
Expand Down Expand Up @@ -1319,7 +1335,22 @@ public void onKeyRepeat(final int code, final int repeatCount) {
}
mIsDetectingGesture = false;
final int nextRepeatCount = repeatCount + 1;
startKeyRepeatTimer(nextRepeatCount);
startKeyRepeatTimer(nextRepeatCount); // Tell the timer to queue up the next 50ms tick

// Long Press Delete button (Delete Word)
if (code == KeyCode.DELETE && Settings.getValues().mDeleteLongPressEnabled) {
mWordDeleteTickCounter++;

// Only execute on every after long press delay
if (mWordDeleteTickCounter %
Math.round(Settings.getValues().mKeyLongpressTimeout / 50f) == 0) {
// FIRE CUSTOM -8 CODE, NOT THE INCOMING -7
callListenerOnCodeInput(key, KeyCode.DELETE_WORD, mKeyX, mKeyY, SystemClock.uptimeMillis(), true);
}
return;
}
// -----------------------------------

callListenerOnPressAndCheckKeyboardLayoutChange(key, repeatCount);
callListenerOnCodeInput(key, code, mKeyX, mKeyY, SystemClock.uptimeMillis(), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object KeyCode {
const val FN = -5
const val FN_LOCK = -6
const val DELETE = -7
//const val DELETE_WORD = -8
const val DELETE_WORD = -8
//const val FORWARD_DELETE = -9
//const val FORWARD_DELETE_WORD = -10
const val SHIFT = -11
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/helium314/keyboard/latin/LatinIME.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import helium314.keyboard.latin.common.CoordinateUtils;
import helium314.keyboard.latin.common.InputPointers;
import helium314.keyboard.latin.common.ViewOutlineProviderUtilsKt;
import helium314.keyboard.latin.common.StringUtilsKt;
import helium314.keyboard.latin.define.DebugFlags;
import helium314.keyboard.latin.inputlogic.InputLogic;
import helium314.keyboard.latin.personalization.PersonalizationHelper;
Expand All @@ -86,6 +87,7 @@
import helium314.keyboard.latin.utils.SubtypeLocaleUtils;
import helium314.keyboard.latin.utils.SubtypeSettings;
import helium314.keyboard.latin.utils.SubtypeState;
import helium314.keyboard.latin.utils.TextRange;
import helium314.keyboard.latin.utils.ToolbarMode;
import helium314.keyboard.settings.SettingsActivity2;
import kotlin.Unit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public static String printableCode(final int code) {
case KeyCode.SYMBOL: return "symbol";
case KeyCode.MULTIPLE_CODE_POINTS: return "text";
case KeyCode.DELETE: return "delete";
case KeyCode.DELETE_WORD: return "deleteWord";
case KeyCode.SETTINGS: return "settings";
case KeyCode.VOICE_INPUT: return "shortcut";
case KeyCode.ACTION_NEXT: return "actionNext";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ private void handleFunctionalEvent(Event event, InputTransaction inputTransactio
// Backspace is a functional key, but it affects the contents of the editor.
inputTransaction.setDidAffectContents();
break;

case KeyCode.DELETE_WORD:
handleDeleteWordEvent(event, inputTransaction, currentKeyboardScript);
inputTransaction.setDidAffectContents();
break;

case KeyCode.SHIFT:
if (KeyboardSwitcher.getInstance().getKeyboard() != null && !KeyboardSwitcher.getInstance().getKeyboard().mId.isAlphabetKeyboard())
break; // recapitalization and follow-up code should only trigger for alphabet shift, see #1256
Expand Down Expand Up @@ -1440,6 +1446,62 @@ private void handleBackspaceEvent(final Event event, final InputTransaction inpu
}
}

/**
* Handle a press on the swipe-to-delete-word gesture.
* @param event The event to handle.
* @param inputTransaction The transaction in progress.
*/
private void handleDeleteWordEvent(final Event event, final InputTransaction inputTransaction,
final String currentKeyboardScript) {

mSpaceState = SpaceState.NONE;
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);

// Delete the highlighted text, if any
if (mConnection.hasSelection()) {
final int numCharsDeleted = mConnection.getExpectedSelectionEnd()
- mConnection.getExpectedSelectionStart();
mConnection.setSelection(mConnection.getExpectedSelectionEnd(),
mConnection.getExpectedSelectionEnd());
mConnection.deleteTextBeforeCursor(numCharsDeleted);
StatsUtils.onBackspaceSelectedText(numCharsDeleted);
return;
}

// Clear active composing state (to not skip current word)
if (mWordComposer.isComposingWord()) {
unlearnWord(mWordComposer.getTypedWord(), inputTransaction.getSettingsValues(),
Constants.EVENT_BACKSPACE);
resetEntireInputState(mConnection.getExpectedSelectionStart(),
mConnection.getExpectedSelectionEnd(), true);
}
mConnection.finishComposingText();

// Getting word boundary
final TextRange textRange = mConnection.getWordRangeAtCursor(
inputTransaction.getSettingsValues().mSpacingAndPunctuations,
currentKeyboardScript);

int charsToDelete = 1;
if (textRange != null) {
charsToDelete = textRange.getNumberOfCharsInWordBeforeCursor();
}

// For spaces/punctuation, force at least 1 character deletion
if (charsToDelete <= 0) {
charsToDelete = 1;
}

// Delete word
mConnection.deleteTextBeforeCursor(charsToDelete);
StatsUtils.onBackspacePressed(charsToDelete);

// Update the suggestion strip for the new word cursor stopped at
if (!mConnection.hasSlowInputConnection() && inputTransaction.getSettingsValues().needsToLookupSuggestions()
&& inputTransaction.getSettingsValues().mSpacingAndPunctuations.mCurrentLanguageHasSpaces) {
restartSuggestionsOnWordTouchedByCursor(inputTransaction.getSettingsValues(), currentKeyboardScript);
}
}
String getWordAtCursor(final SettingsValues settingsValues, final String currentKeyboardScript) {
if (!mConnection.hasSelection()
&& settingsValues.needsToLookupSuggestions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ object Defaults {
@JvmField
val PREF_SPACE_VERTICAL_SWIPE = KeyboardActionListener.SwipeAction.NONE.name
const val PREF_DELETE_SWIPE = true
const val PREF_DELETE_LONGPRESS = false
const val PREF_AUTOSPACE_AFTER_PUNCTUATION = false
const val PREF_AUTOSPACE_AFTER_SUGGESTION = true
const val PREF_AUTOSPACE_AFTER_GESTURE_TYPING = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_SPACE_HORIZONTAL_SWIPE = "horizontal_space_swipe";
public static final String PREF_SPACE_VERTICAL_SWIPE = "vertical_space_swipe";
public static final String PREF_DELETE_SWIPE = "delete_swipe";
public static final String PREF_DELETE_LONGPRESS = "delete_word_long_press";
public static final String PREF_AUTOSPACE_AFTER_PUNCTUATION = "autospace_after_punctuation";
public static final String PREF_AUTOSPACE_AFTER_SUGGESTION = "autospace_after_suggestion";
public static final String PREF_AUTOSPACE_AFTER_GESTURE_TYPING = "autospace_after_gesture_typing";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class SettingsValues {
public final int mTouchpadSensitivity;
public final boolean mTouchpadEdgeScroll;
public final boolean mDeleteSwipeEnabled;
public final boolean mDeleteLongPressEnabled;
public final boolean mAutospaceAfterPunctuation;
public final boolean mAutospaceAfterSuggestion;
public final boolean mAutospaceAfterGestureTyping;
Expand Down Expand Up @@ -276,6 +277,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
Defaults.PREF_TOUCHPAD_SENSITIVITY);
mTouchpadEdgeScroll = prefs.getBoolean(Settings.PREF_TOUCHPAD_EDGE_SCROLL, Defaults.PREF_TOUCHPAD_EDGE_SCROLL);
mDeleteSwipeEnabled = prefs.getBoolean(Settings.PREF_DELETE_SWIPE, Defaults.PREF_DELETE_SWIPE);
mDeleteLongPressEnabled = prefs.getBoolean(Settings.PREF_DELETE_LONGPRESS, Defaults.PREF_DELETE_LONGPRESS);
mAutospaceAfterPunctuation = prefs.getBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, Defaults.PREF_AUTOSPACE_AFTER_PUNCTUATION);
mAutospaceAfterSuggestion = prefs.getBoolean(Settings.PREF_AUTOSPACE_AFTER_SUGGESTION, Defaults.PREF_AUTOSPACE_AFTER_SUGGESTION);
mAutospaceAfterGestureTyping = prefs.getBoolean(Settings.PREF_AUTOSPACE_AFTER_GESTURE_TYPING, Defaults.PREF_AUTOSPACE_AFTER_GESTURE_TYPING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fun AdvancedSettingsScreen(
if (Settings.readVerticalSpaceSwipe(prefs) == KeyboardActionListener.SwipeAction.TOUCHPAD_MODE)
Settings.PREF_TOUCHPAD_EDGE_SCROLL else null,
Settings.PREF_DELETE_SWIPE,
Settings.PREF_DELETE_LONGPRESS,
Settings.PREF_SPACE_TO_CHANGE_LANG,
Settings.PREFS_LONG_PRESS_SYMBOLS_FOR_NUMPAD,
Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY,
Expand Down Expand Up @@ -161,6 +162,9 @@ fun createAdvancedSettings(context: Context) = listOf(
Setting(context, Settings.PREF_DELETE_SWIPE, R.string.delete_swipe, R.string.delete_swipe_summary) {
SwitchPreference(it, Defaults.PREF_DELETE_SWIPE)
},
Setting(context, Settings.PREF_DELETE_LONGPRESS, R.string.delete_word_long_press, R.string.delete_word_long_press_summary){
SwitchPreference(it, Defaults.PREF_DELETE_LONGPRESS)
},
Setting(context, Settings.PREF_SPACE_TO_CHANGE_LANG,
R.string.prefs_long_press_keyboard_to_change_lang,
R.string.prefs_long_press_keyboard_to_change_lang_summary)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-af/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
<string name="prefs_keyboard_height_scale">Sleutelbord hoogte-skaal</string>
<string name="delete_swipe">Skrap met vee</string>
<string name="show_emoji_key">Emoji sleutel</string>
<string name="delete_word_long_press">Skrap woord met langdruk</string>
<string name="delete_word_long_press_summary">Deur die skrap-sleutel lank te druk, word hele woorde aaneenlopend geskrap</string>
<string name="delete_swipe_summary">Doen \'n vee van die skrap sleutel om \'n groter seleksie van teks eenmaal te skrap</string>
<string name="subtype_akkhor_bn_BD">%s (Akkhor)</string>
<string name="incognito">Dwing incognito-modus</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
<string name="delete_swipe">احذف بالسحب</string>
<string name="key_borders">الحدود الرئيسة</string>
<string name="delete_swipe_summary">أجرِ سحبًا سريعًا على مفتاح الحذف لتُحدِّد وتُزيل أجزاءً كبيرة من النص دفعةً واحدة</string>
<string name="delete_word_long_press">احذف الكلمات بالضغط المطول</string>
<string name="delete_word_long_press_summary">يؤدي الضغط المطول على مفتاح الحذف إلى حذف كلمات كاملة بشكل مستمر</string>
<string name="show_hints">أظهِر تلميحات المفاتيح</string>
<string name="select_input_method">"اختيار أسلوب الإدخال"</string>
<string name="show_hints_summary">أظهِر تلميحات المفاتيح عند الضغط لفترة طويلة</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-az/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@
<string name="clipboard_history_pinned_first">Bərkidilmiş elementləri yuxarıda göstər</string>
<string name="delete_swipe">Sürüşdürərək sil</string>
<string name="delete_swipe_summary">Bir dəfəyə mətnin böyük hissələrini seçib silmək üçün silmə düyməsindən başlayaraq sürüşdür</string>
<string name="delete_word_long_press">Uzun basaraq sözü sil</string>
<string name="delete_word_long_press_summary">Silmə düyməsini uzun basmaq bütöv sözləri davamlı olaraen silir</string>
<string name="backup_restore_title">Nüsxələ və bərpa et</string>
<string name="backup_restore_message">Saxla və ya fayldan yüklə. Diqqət: bərpa mövcud verilənlərin üzərinə yazılacaq</string>
<string name="backup_error">Nüsxələmə xətası: %s</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
<string name="gesture_floating_preview_dynamic_summary">Преместете визуализацията по време на жест</string>
<string name="gesture_trail_fadeout_duration">Продължителност на живота на следата на жеста</string>
<string name="delete_swipe">Изтриване с плъзгане</string>
<string name="delete_word_long_press">Изтриване на дума с дълго натискане</string>
<string name="delete_word_long_press_summary">Дългото натискане на клавиша за изтриване изтрива цели думи непрекъснато</string>
<string name="backup_restore_title">Архивиране и възстановяване</string>
<string name="load_gesture_library_summary">Осигурете собствена библиотека, за да активирате писането с жестове</string>
<string name="split_spacer_scale">Разделено разстояние</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-bn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
<string name="clipboard_history_retention_time">ইতিহাস স্থিতির সময়কাল</string>
<string name="delete_swipe">বিলোপ অভিস্পর্শ</string>
<string name="delete_swipe_summary">লেখার বড়ো অংশ একসাথে সিলেক্ট করে অপসারণ করার জন্য অভিস্পর্শ করুন</string>
<string name="delete_word_long_press">দীর্ঘ চাপে শব্দ বিলোপ</string>
<string name="delete_word_long_press_summary">মুছে ফেলার বোতামটি দীর্ঘক্ষণ চেপে রাখলে একের পর এক সম্পূর্ণ শব্দ মুছে যায়</string>
<string name="secondary_locale">বহুভাষী টাইপিং</string>
<string name="load_gesture_library">অঙ্গুলিহেলন টাইপিং লাইব্রেরি অধিযোগ</string>
<string name="load_gesture_library_summary">অঙ্গুলিহেলনের মাধ্যমে টাইপিং সক্রিয় করার জন্য স্থানীয় লাইব্রেরি সরবরাহ</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
<string name="enable_clipboard_history_summary">Si es desactiva, la tecla del porta-retalls enganxarà el contingut del porta-retalls si n\'hi ha</string>
<string name="clipboard_history_retention_time">Temps de manteniment a l\'historial</string>
<string name="delete_swipe_summary">Llisqueu damunt de la tecla d\'esborrar per seleccionar i treure grans parts de text d\'un sol cop</string>
<string name="delete_word_long_press">Esborra la paraula amb una pulsació llarga</string>
<string name="delete_word_long_press_summary">Mantenir premuda la tecla d\'esborrar elimina paraules senceres de manera contínua</string>
<string name="incognito">Força el mode d\'incògnit</string>
<string name="abbreviation_unit_minutes">%s min</string>
<string name="spell_checker_service_name">Corrector ortogràfic de l\'HeliBoard</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@
<string name="settings_category_input">Vstup</string>
<string name="settings_category_additional_keys">Dodatečné klávesy</string>
<string name="delete_swipe">Mazat posunutím</string>
<string name="delete_word_long_press">Mazat slova dlouhým stiskem</string>
<string name="delete_word_long_press_summary">Dlouhým stisknutím klávesy pro mazání budete nepřetržitě mazat celá slova</string>
<string name="number_row_summary">Vždy aktivní číselný řádek</string>
<string name="show_hints">Nápověda kláves</string>
<string name="show_hints_summary">Nápověda při dlouhém stisku</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
<string name="settings_category_miscellaneous">Diverse</string>
<string name="delete_swipe">Swipe-sletning</string>
<string name="delete_swipe_summary">Udfør et swipe fra slet-tasten for at vælge og fjerne større dele af teksten på én gang</string>
<string name="delete_word_long_press">Slet ord ved langt tryk</string>
<string name="delete_word_long_press_summary">Hvis du holder slet-tasten nede, slettes hele ord kontinuerligt</string>
<string name="incognito">Gennemtving inkognitotilstand</string>
<string name="prefs_force_incognito_mode_summary">Deaktiver indlæring af nye ord</string>
<string name="more_keys_strip_description">Flere taster</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
<string name="settings_category_miscellaneous">Sonstiges</string>
<string name="enable_clipboard_history">Zwischenablage-Verlauf aktivieren</string>
<string name="delete_swipe_summary">Wische über die Löschen-Taste, um mehr Text auf einmal auszuwählen und zu löschen</string>
<string name="delete_word_long_press">Wort löschen durch langes Drücken</string>
<string name="delete_word_long_press_summary">Durch langes Drücken der Löschen-Taste werden ganze Wörter kontinuierlich gelöscht</string>
<string name="clipboard_history_retention_time">Speicherdauer des Zwischenablage-Verlaufs</string>
<string name="delete_swipe">Löschen durch Wischen</string>
<string name="prefs_force_incognito_mode_summary">Deaktiviert das Lernen von neuen Wörtern</string>
Expand Down
Loading