From 7ea8da554f1022b4802234b91b98d418cdcb1d84 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 26 Mar 2019 16:40:20 +0700 Subject: [PATCH] Add associated lexical model --- .../kmea/KMKeyboardDownloaderActivity.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMKeyboardDownloaderActivity.java b/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMKeyboardDownloaderActivity.java index ca9def245a..d4f86f83c7 100644 --- a/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMKeyboardDownloaderActivity.java +++ b/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMKeyboardDownloaderActivity.java @@ -367,10 +367,16 @@ public class KMKeyboardDownloaderActivity extends AppCompatActivity { String pkgTarget = kmpProcessor.getPackageTarget(kmpFile); if (pkgTarget.equals(PackageProcessor.PP_TARGET_LEXICAL_MODELS)) { File unzipPath = kmpProcessor.unzipKMP(kmpFile); - // TODO: Propogate installedLexicalModels to KMW List> installedLexicalModels = kmpProcessor.processKMP(kmpFile, unzipPath, PackageProcessor.PP_LEXICAL_MODELS_KEY); + + boolean success = installedLexicalModels.size() != 0; + if (success) { + notifyLexicalModelInstallListeners(KeyboardEventHandler.EventType.LEXICAL_MODEL_INSTALLED, + installedLexicalModels, 1); + } } + } if (result < 0) { if (FileUtils.hasFontExtension(url)) { @@ -407,6 +413,19 @@ public class KMKeyboardDownloaderActivity extends AppCompatActivity { KeyboardEventHandler.notifyListeners(kbDownloadEventListeners, eventType, keyboardInfo, result); } } + + /** + * Notify listeners when a lexical model is installed + * @param eventType + * @param models + * @param result + */ + protected void notifyLexicalModelInstallListeners(KeyboardEventHandler.EventType eventType, + List> models, int result) { + if (kbDownloadEventListeners != null) { + KeyboardEventHandler.notifyListeners(kbDownloadEventListeners, eventType, models, result); + } + } } /**