Skip to content

Commit dccfbb0

Browse files
committed
Merge remote-tracking branch 'openboard-team/master' into develop
2 parents cbf3e54 + c3772cd commit dccfbb0

67 files changed

Lines changed: 2666 additions & 875 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
applicationId "io.github.sds100.keymapper.inputmethod.latin"
1010
minSdkVersion 19
1111
targetSdkVersion 31
12-
versionCode 18
13-
versionName '1.4.4'
12+
versionCode 19
13+
versionName '1.4.5'
1414
}
1515

1616
buildTypes {

app/src/main/java/io/github/sds100/keymapper/inputmethod/keyboard/internal/KeyboardTextsTable.java

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,9 +1139,10 @@ public static String[] getTextsTable(final Locale locale) {
11391139
/* morekeys_c */ null,
11401140
/* double_quotes */ "!text/double_9qm_lqm",
11411141
// U+00DF: "ß" LATIN SMALL LETTER SHARP S
1142+
// U+1E9E: "ẞ" LATIN CAPITAL LETTER SHARP S
11421143
// U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE
11431144
// U+0161: "š" LATIN SMALL LETTER S WITH CARON
1144-
/* morekeys_s */ "\u00DF,\u015B,\u0161",
1145+
/* morekeys_s */ "\u00DF,%,\u1E9E,\u015B,\u0161",
11451146
/* single_quotes */ "!text/single_9qm_lqm",
11461147
/* keyspec_currency ~ */
11471148
null, null, null, null, null, null, null,
@@ -1207,9 +1208,10 @@ public static String[] getTextsTable(final Locale locale) {
12071208
/* morekeys_c */ null,
12081209
/* double_quotes */ "!text/double_9qm_lqm",
12091210
// U+00DF: "ß" LATIN SMALL LETTER SHARP S
1211+
// U+1E9E: "ẞ" LATIN CAPITAL LETTER SHARP S
12101212
// U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE
12111213
// U+0161: "š" LATIN SMALL LETTER S WITH CARON
1212-
/* morekeys_s */ "\u00DF,%,\u015B,\u0161",
1214+
/* morekeys_s */ "\u00DF,%,\u1E9E,\u015B,\u0161",
12131215
/* single_quotes */ "!text/single_9qm_lqm",
12141216
/* keyspec_currency ~ */
12151217
null, null, null, null, null, null, null,
@@ -2169,27 +2171,35 @@ public static String[] getTextsTable(final Locale locale) {
21692171
/* morekeys_nordic_row2_11 ~ */
21702172
null, null, null, null, null, null, null,
21712173
/* ~ morekeys_swiss_row2_11 */
2172-
// U+055E: "՞" ARMENIAN QUESTION MARK
2173-
// U+055C: "՜" ARMENIAN EXCLAMATION MARK
2174-
// U+055A: "՚" ARMENIAN APOSTROPHE
2175-
// U+0559: "ՙ" ARMENIAN MODIFIER LETTER LEFT HALF RING
2176-
// U+055D: "՝" ARMENIAN COMMA
2177-
// U+055B: "՛" ARMENIAN EMPHASIS MARK
2178-
// U+058A: "֊" ARMENIAN HYPHEN
2179-
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
2180-
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
2181-
// U+055F: "՟" ARMENIAN ABBREVIATION MARK
2182-
/* morekeys_punctuation */ "!autoColumnOrder!8,\\,,\u055E,\u055C,.,\u055A,\u0559,?,!,\u055D,\u055B,\u058A,\u00BB,\u00AB,\u055F,;,:",
2183-
/* keyspec_tablet_comma */ "\u055D",
2174+
//
2175+
// ( U+0028 "(" Բացվող փակագիծ - OPENING PARENTHESES
2176+
// ) U+0029 ")" Փակվող փակագիծ - CLOSING PARENTHESES
2177+
// ' U+0027 "'" Ապաթարց - APOSTROPHE
2178+
// … U+2026 "…" Կախման կետեր - HORIZONTAL ELLIPSIS
2179+
// ՞ U+055E "՞" Հարցական - ARMENIAN QUESTION MARK
2180+
// ՜ U+055C "՜" Բացականչական - ARMENIAN EXCLAMATION MARK
2181+
// ՛ U+055B "՛" Շեշտ - ARMENIAN EMPHASIS MARK
2182+
// ՝ U+055D "՝" Բութ - ARMENIAN COMMA
2183+
// !! (the unicode name is Armenian Comma, which isn't really accurate since Armenian Comma is U+002C)
2184+
// ֊ U+058A "֊" Միության գծիկ - ARMENIAN HYPHEN
2185+
// ― U+2015 "―" Անջատման գժիկ - ARMENIAN SEPARATION MARK
2186+
// « U+00AB "«" Բացվող չակերտ - LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
2187+
// » U+00BB "»" Փակվող չակերտ - RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
2188+
// , U+002C "," Ստօրակետ - ARMENIAN COMMA
2189+
// ։ U+0589 "։" Վերջակետ - ARMENIAN COLON
2190+
// ․ U+2024 "․" Միջակետ - One dot leader
2191+
//
2192+
/* morekeys_punctuation */ "!autoColumnOrder!8,\\,,\u055E,\u055C,\u2024,\u2026,',=,/,\u055D,\u055B,\u058A,\u00BB,\u00AB,\u2015,),(",
2193+
/* keyspec_tablet_comma */ ",",
21842194
/* morekeys_star ~ */
21852195
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
21862196
/* ~ keyspec_right_single_angle_quote */
21872197
// U+058F: "֏" ARMENIAN DRAM SIGN
21882198
// TODO: Enable this when we have glyph for the following letter
21892199
// <string name="keyspec_currency">&#x058F;</string>
21902200
//
2191-
// U+055D: "՝" ARMENIAN COMMA
2192-
/* keyspec_comma */ "\u055D",
2201+
// U+002C: "," ARMENIAN COMMA
2202+
/* keyspec_comma */ ",",
21932203
/* morekeys_tablet_comma */ null,
21942204
/* keyhintlabel_period */ null,
21952205
// U+055E: "՞" ARMENIAN QUESTION MARK

app/src/main/java/io/github/sds100/keymapper/inputmethod/latin/settings/CorrectionSettingsFragment.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package io.github.sds100.keymapper.inputmethod.latin.settings;
1818

19-
import android.Manifest;
2019
import android.app.Activity;
2120
import android.content.Context;
2221
import android.content.Intent;
@@ -25,12 +24,8 @@
2524
import android.content.pm.ResolveInfo;
2625
import android.os.Bundle;
2726
import android.preference.Preference;
28-
import android.preference.SwitchPreference;
29-
import android.text.TextUtils;
3027

3128
import io.github.sds100.keymapper.inputmethod.latin.R;
32-
import io.github.sds100.keymapper.inputmethod.latin.permissions.PermissionsManager;
33-
import io.github.sds100.keymapper.inputmethod.latin.permissions.PermissionsUtil;
3429
import io.github.sds100.keymapper.inputmethod.latin.userdictionary.UserDictionaryList;
3530
import io.github.sds100.keymapper.inputmethod.latin.userdictionary.UserDictionarySettings;
3631

@@ -44,6 +39,7 @@
4439
* - Add-on dictionaries
4540
* - Block offensive words
4641
* - Auto-correction
42+
* - Auto-correction confidence
4743
* - Show correction suggestions
4844
* - Personalized suggestions
4945
* - Suggest Contact names
@@ -73,6 +69,18 @@ public void onCreate(final Bundle icicle) {
7369
if (ri == null) {
7470
overwriteUserDictionaryPreference(editPersonalDictionary);
7571
}
72+
73+
refreshEnabledSettings();
74+
}
75+
76+
@Override
77+
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
78+
refreshEnabledSettings();
79+
}
80+
81+
private void refreshEnabledSettings() {
82+
setPreferenceEnabled(Settings.PREF_AUTO_CORRECTION_CONFIDENCE,
83+
Settings.readAutoCorrectEnabled(getSharedPreferences(), getResources()));
7684
}
7785

7886
private void overwriteUserDictionaryPreference(final Preference userDictionaryPreference) {

app/src/main/java/io/github/sds100/keymapper/inputmethod/latin/settings/Settings.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
6565
public static final String PREF_VOICE_INPUT_KEY = "pref_voice_input_key";
6666
public static final String PREF_CLIPBOARD_CLIPBOARD_KEY = "pref_clipboard_clipboard_key";
6767
public static final String PREF_EDIT_PERSONAL_DICTIONARY = "edit_personal_dictionary";
68-
// PREF_AUTO_CORRECTION_THRESHOLD_OBSOLETE is obsolete. Use PREF_AUTO_CORRECTION instead.
69-
public static final String PREF_AUTO_CORRECTION_THRESHOLD_OBSOLETE =
70-
"auto_correction_threshold";
7168
public static final String PREF_AUTO_CORRECTION = "pref_key_auto_correction";
69+
public static final String PREF_AUTO_CORRECTION_CONFIDENCE = "pref_key_auto_correction_confidence";
7270
// PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE is obsolete. Use PREF_SHOW_SUGGESTIONS instead.
7371
public static final String PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE = "show_suggestions_setting";
7472
public static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
@@ -173,7 +171,6 @@ private void onCreate(final Context context) {
173171
mRes = context.getResources();
174172
mPrefs = DeviceProtectedUtils.getSharedPreferences(context);
175173
mPrefs.registerOnSharedPreferenceChangeListener(this);
176-
upgradeAutocorrectionSettings(mPrefs, mRes);
177174
}
178175

179176
public void onDestroy() {
@@ -247,6 +244,12 @@ public static boolean readAutoCorrectEnabled(final SharedPreferences prefs,
247244
return prefs.getBoolean(PREF_AUTO_CORRECTION, true);
248245
}
249246

247+
public static String readAutoCorrectConfidence(final SharedPreferences prefs,
248+
final Resources res) {
249+
return prefs.getString(PREF_AUTO_CORRECTION_CONFIDENCE,
250+
res.getString(R.string.auto_correction_threshold_mode_index_modest));
251+
}
252+
250253
public static float readPlausibilityThreshold(final Resources res) {
251254
return Float.parseFloat(res.getString(R.string.plausibility_threshold));
252255
}
@@ -513,21 +516,4 @@ public static int readLastShownEmojiCategoryPageId(
513516
final SharedPreferences prefs, final int defValue) {
514517
return prefs.getInt(PREF_LAST_SHOWN_EMOJI_CATEGORY_PAGE_ID, defValue);
515518
}
516-
517-
private void upgradeAutocorrectionSettings(final SharedPreferences prefs, final Resources res) {
518-
final String thresholdSetting =
519-
prefs.getString(PREF_AUTO_CORRECTION_THRESHOLD_OBSOLETE, null);
520-
if (thresholdSetting != null) {
521-
SharedPreferences.Editor editor = prefs.edit();
522-
editor.remove(PREF_AUTO_CORRECTION_THRESHOLD_OBSOLETE);
523-
final String autoCorrectionOff =
524-
res.getString(R.string.auto_correction_threshold_mode_index_off);
525-
if (thresholdSetting.equals(autoCorrectionOff)) {
526-
editor.putBoolean(PREF_AUTO_CORRECTION, false);
527-
} else {
528-
editor.putBoolean(PREF_AUTO_CORRECTION, true);
529-
}
530-
editor.commit();
531-
}
532-
}
533519
}

app/src/main/java/io/github/sds100/keymapper/inputmethod/latin/settings/SettingsValues.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class SettingsValues {
5353
private static final String FLOAT_NEGATIVE_INFINITY_MARKER_STRING = "floatNegativeInfinity";
5454
private static final int TIMEOUT_TO_GET_TARGET_PACKAGE = 5; // seconds
5555
public static final float DEFAULT_SIZE_SCALE = 1.0f; // 100%
56+
public static final float AUTO_CORRECTION_DISABLED_THRESHOLD = Float.MAX_VALUE;
5657

5758
// From resources:
5859
public final SpacingAndPunctuations mSpacingAndPunctuations;
@@ -163,9 +164,9 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
163164
&& inputAttributes.mIsGeneralTextInput;
164165
mBlockPotentiallyOffensive = Settings.readBlockPotentiallyOffensive(prefs, res);
165166
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(prefs, res);
166-
final String autoCorrectionThresholdRawValue = mAutoCorrectEnabled
167-
? res.getString(R.string.auto_correction_threshold_mode_index_modest)
168-
: res.getString(R.string.auto_correction_threshold_mode_index_off);
167+
mAutoCorrectionThreshold = mAutoCorrectEnabled
168+
? readAutoCorrectionThreshold(res, prefs)
169+
: AUTO_CORRECTION_DISABLED_THRESHOLD;
169170
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
170171
mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);
171172
mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration());
@@ -183,8 +184,6 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
183184
Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY, true);
184185
mShowAppIcon = Settings.readShowSetupWizardIcon(prefs, context);
185186
mIsShowAppIconSettingInPreferences = prefs.contains(Settings.PREF_SHOW_SETUP_WIZARD_ICON);
186-
mAutoCorrectionThreshold = readAutoCorrectionThreshold(res,
187-
autoCorrectionThresholdRawValue);
188187
mPlausibilityThreshold = Settings.readPlausibilityThreshold(res);
189188
mGestureInputEnabled = Settings.readGestureInputEnabled(prefs, res);
190189
mGestureTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true);
@@ -331,7 +330,8 @@ private static boolean readBigramPredictionEnabled(final SharedPreferences prefs
331330
}
332331

333332
private static float readAutoCorrectionThreshold(final Resources res,
334-
final String currentAutoCorrectionSetting) {
333+
final SharedPreferences prefs) {
334+
final String currentAutoCorrectionSetting = Settings.readAutoCorrectConfidence(prefs, res);
335335
final String[] autoCorrectionThresholdValues = res.getStringArray(
336336
R.array.auto_correction_threshold_values);
337337
// When autoCorrectionThreshold is greater than 1.0, it's like auto correction is off.

app/src/main/java/io/github/sds100/keymapper/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ private static String getKeyboardLayoutNameForLocale(final Locale locale) {
113113
switch (script) {
114114
case ScriptUtils.SCRIPT_LATIN:
115115
return "qwerty";
116+
case ScriptUtils.SCRIPT_ARMENIAN:
117+
return "armenian_phonetic";
116118
case ScriptUtils.SCRIPT_CYRILLIC:
117119
return "east_slavic";
118120
case ScriptUtils.SCRIPT_GREEK:

app/src/main/java/io/github/sds100/keymapper/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import java.util.ArrayList;
4646
import java.util.List;
4747
import java.util.Locale;
48+
import java.util.Map;
49+
import java.util.TreeMap;
4850

4951
public abstract class AndroidWordLevelSpellCheckerSession extends Session {
5052
private static final String TAG = AndroidWordLevelSpellCheckerSession.class.getSimpleName();
@@ -62,6 +64,16 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
6264
private static final String quotesRegexp =
6365
"(\\u0022|\\u0027|\\u0060|\\u00B4|\\u2018|\\u2018|\\u201C|\\u201D)";
6466

67+
private static final Map<Integer, String> scriptToPunctuationRegexMap = new TreeMap<>();
68+
69+
static {
70+
// TODO: add other non-English language specific punctuation later.
71+
scriptToPunctuationRegexMap.put(
72+
ScriptUtils.SCRIPT_ARMENIAN,
73+
"(\\u0028|\\u0029|\\u0027|\\u2026|\\u055E|\\u055C|\\u055B|\\u055D|\\u058A|\\u2015|\\u00AB|\\u00BB|\\u002C|\\u0589|\\u2024)"
74+
);
75+
}
76+
6577
private static final class SuggestionsParams {
6678
public final String[] mSuggestions;
6779
public final int mFlags;
@@ -260,12 +272,22 @@ protected SuggestionsInfo onGetSuggestionsInternal(
260272
final TextInfo textInfo, final NgramContext ngramContext, final int suggestionsLimit) {
261273
try {
262274
updateLocale();
263-
final String text = textInfo.getText().
275+
// It's good to keep this not local specific since the standard
276+
// ones may show up in other languages also.
277+
String text = textInfo.getText().
264278
replaceAll(AndroidSpellCheckerService.APOSTROPHE,
265279
AndroidSpellCheckerService.SINGLE_QUOTE).
266280
replaceAll("^" + quotesRegexp, "").
267281
replaceAll(quotesRegexp + "$", "");
268282

283+
final String localeRegex = scriptToPunctuationRegexMap.get(
284+
ScriptUtils.getScriptFromSpellCheckerLocale(mLocale)
285+
);
286+
287+
if (localeRegex != null) {
288+
text = text.replaceAll(localeRegex, "");
289+
}
290+
269291
if (!mService.hasMainDictionaryForLocale(mLocale)) {
270292
return AndroidSpellCheckerService.getNotInDictEmptySuggestions(
271293
false /* reportAsTypo */);

app/src/main/res/raw/main_hy.dict

1.98 MB
Binary file not shown.

0 commit comments

Comments
 (0)