Skip to content

Commit

Permalink
Merge pull request #12861 from keymanapp/fix/android/kmmanager-api-15
Browse files Browse the repository at this point in the history
fix(android/engine): Cleanup KMManager API keys and calls
  • Loading branch information
darcywong00 authored Jan 8, 2025
2 parents 74bf4c2 + 2454be9 commit 268f06e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
27 changes: 1 addition & 26 deletions android/KMEA/app/src/main/java/com/keyman/engine/KMManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public int toInt() {

public final static String predictionPrefSuffix = ".mayPredict";
public final static String correctionPrefSuffix = ".mayCorrect";
public final static String autoCorrectionPrefSuffix = ".mayAutoCorect";
public final static String autoCorrectionPrefSuffix = ".mayAutoCorrect";

// Special override for when the keyboard may have haptic feedback when typing.
// haptic feedback disabled for hardware keystrokes
Expand Down Expand Up @@ -305,11 +305,6 @@ public int toInt() {
public static final String KMKey_LexicalModelVersion = "lmVersion";
public static final String KMKey_LexicalModelPackageFilename = "kmpPackageFilename";

// DEPRECATED keys
public static final String KMKey_CustomKeyboard = "CustomKeyboard";
public static final String KMKey_CustomModel = "CustomModel";
public static final String KMKey_HelpLink = "helpLink";

// Keyman internal keys
protected static final String KMKey_ShouldShowHelpBubble = "ShouldShowHelpBubble";

Expand Down Expand Up @@ -1714,26 +1709,6 @@ public static boolean addKeyboard(Context context, Keyboard keyboardInfo) {
return KeyboardPickerActivity.addKeyboard(context, keyboardInfo);
}

// Intend to deprecate in Keyman 15.0
public static boolean addKeyboard(Context context, HashMap<String, String> keyboardInfo) {
String packageID = keyboardInfo.get(KMManager.KMKey_PackageID);
String keyboardID = keyboardInfo.get(KMManager.KMKey_KeyboardID);
String keyboardName = keyboardInfo.get(KMManager.KMKey_KeyboardName);
String languageID = keyboardInfo.get(KMManager.KMKey_LanguageID);
String languageName = keyboardInfo.get(KMManager.KMKey_LanguageName);
String version = keyboardInfo.get(KMManager.KMKey_KeyboardVersion);
String helpLink = keyboardInfo.get(KMManager.KMKey_CustomHelpLink);
String kmpLink = MapCompat.getOrDefault(keyboardInfo, KMManager.KMKey_KMPLink, "");
String font = keyboardInfo.get(KMManager.KMKey_Font);
String oskFont = keyboardInfo.get(KMManager.KMKey_OskFont);
boolean isNewKeyboard = true;

Keyboard k = new Keyboard(packageID, keyboardID, keyboardName,
languageID, languageName, version, helpLink, kmpLink,
isNewKeyboard, font, oskFont);
return addKeyboard(context, k);
}

public static boolean removeKeyboard(Context context, int position) {
return KeyboardPickerActivity.removeKeyboard(context, position);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public void create_newKeyboardsList() {
HashMap<String, String> kmInfo = new HashMap<String, String>();
kmInfo.put(KMManager.KMKey_PackageID, "khmer_angkor");
kmInfo.put(KMManager.KMKey_KeyboardID, "khmer_angkor");
kmInfo.put(KMManager.KMKey_CustomKeyboard, "Y");
kmInfo.put(KMManager.KMKey_LanguageID, "km");
kmInfo.put(KMManager.KMKey_KeyboardName, "Khmer Angkor");
kmInfo.put(KMManager.KMKey_LanguageName, "Central Khmer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,21 @@ static void installCustomKeyboard(File aKPMFile) throws IOException, JSONExcepti

Assert.assertEquals(installedKbds.size(),1);

KMManager.addKeyboard(ApplicationProvider.getApplicationContext(),(HashMap<String, String>) installedKbds.get(0));
HashMap<String, String> map = (HashMap<String, String>)installedKbds.get(0);
Keyboard keyboard = new Keyboard(
map.get(KMManager.KMKey_PackageID),
map.get(KMManager.KMKey_KeyboardID),
map.get(KMManager.KMKey_KeyboardName),
map.get(KMManager.KMKey_LanguageID),
map.get(KMManager.KMKey_LanguageName),
map.get(KMManager.KMKey_KeyboardVersion),
map.get(KMManager.KMKey_CustomHelpLink),
map.get(KMManager.KMKey_KMPLink),
true,
null,
null
);
KMManager.addKeyboard(ApplicationProvider.getApplicationContext(), keyboard);
}


Expand Down

0 comments on commit 268f06e

Please sign in to comment.