Merge branch 'master' into android-view-welcome

This commit is contained in:
Darcy Wong 2020-01-10 08:32:35 +07:00
commit 70f925e508
9 changed files with 46 additions and 10 deletions

View file

@ -33,7 +33,7 @@ public class KMKeyboardDownloaderActivity extends AppCompatActivity {
public static final String ARG_MODEL_ID = "KMKeyboardActivity.modelID";
public static final String ARG_MODEL_NAME = "KMKeyboardActivity.modelName";
public static final String ARG_MODEL_URL = "KMKeyboardActivity.modelURL";
public static final String ARG_MODEL_CUSTOM_HELP_LINK = "KMKeyboardActivity.customHelpLink";
public static final String ARG_CUSTOM_HELP_LINK = "KMKeyboardActivity.customHelpLink";
// custom keyboard
public static final String ARG_KEYBOARD = "KMKeyboardActivity.keyboard";

View file

@ -37,7 +37,7 @@ public class CloudDataJsonUtil {
public static HashMap<String,String> createKeyboardInfoMap(String aPackageId,String aLanguageId, String aLanguageName, String aKeyboardId,
String aKeyboardName, String aKeyboardVersion, String anIsCustomKeyboard,
String aFont, String aOskFont)
String aFont, String aOskFont, String aCustomHelpLink)
{
HashMap<String, String> keyboardInfo = new HashMap<String, String>();
keyboardInfo.put(KMManager.KMKey_PackageID, aPackageId);
@ -48,8 +48,12 @@ public class CloudDataJsonUtil {
keyboardInfo.put(KMManager.KMKey_KeyboardVersion, aKeyboardVersion);
keyboardInfo.put(KMManager.KMKey_CustomKeyboard, anIsCustomKeyboard);
keyboardInfo.put(KMManager.KMKey_Font, aFont);
if (aOskFont != null)
if (aOskFont != null) {
keyboardInfo.put(KMManager.KMKey_OskFont, aOskFont);
}
if (aCustomHelpLink != null) {
keyboardInfo.put(KMManager.KMKey_CustomHelpLink, aCustomHelpLink);
}
return keyboardInfo;
}
@ -81,9 +85,10 @@ public class CloudDataJsonUtil {
String kbName = keyboardJSON.getString(KMManager.KMKey_Name);
String kbVersion = keyboardJSON.optString(KMManager.KMKey_KeyboardVersion, "1.0");
String kbFont = keyboardJSON.optString(KMManager.KMKey_Font, "");
String customHelpLink = keyboardJSON.optString(KMManager.KMKey_CustomHelpLink, null);
//String kbKey = String.format("%s_%s", langID, kbID);
HashMap<String, String> hashMap = createKeyboardInfoMap(pkgID,langID,langName,kbID,kbName,kbVersion,isCustom,kbFont,null);
HashMap<String, String> hashMap = createKeyboardInfoMap(pkgID,langID,langName,kbID,kbName,kbVersion,isCustom,kbFont,null, customHelpLink);
// if (keyboardModifiedDates.get(kbID) == null) {

View file

@ -271,12 +271,13 @@ public class CloudKeyboardMetaDataDownloadCallback implements ICloudDownloadCall
String _font = _keyboard.optString(KMManager.KMKey_Font);
String _oskFont = _keyboard.optString(KMManager.KMKey_OskFont);
String _customHelpLink = _keyboard.optString(KMManager.KMKey_CustomHelpLink, null);
theKbData.additionalDownloadid = CloudKeyboardDataDownloadCallback.createDownloadId(_key_id);
theKbData.keyboardInfo = CloudDataJsonUtil
.createKeyboardInfoMap(
_pkgID, _lang_id, _langName, _key_id, _kbName, _kbVersion, _kbIsCustom, _font, _oskFont);
_pkgID, _lang_id, _langName, _key_id, _kbName, _kbVersion, _kbIsCustom, _font, _oskFont, _customHelpLink);
theKbData.additionalDownloads = urls;
}
catch(JSONException _e)

View file

@ -5,6 +5,7 @@ import android.os.Bundle;
import com.tavultesoft.kmea.KMKeyboardDownloaderActivity;
import com.tavultesoft.kmea.KMManager;
import com.tavultesoft.kmea.KeyboardPickerActivity;
import com.tavultesoft.kmea.util.MapCompat;
import java.io.Serializable;
import java.util.Map;
@ -50,6 +51,13 @@ public class Keyboard implements Serializable, LanguageResource {
return this.map.get(KMManager.KMKey_KeyboardName);
}
public String getCustomHelpLink() {
if (this.map.containsKey(KMManager.KMKey_CustomHelpLink)) {
return this.map.get(KMManager.KMKey_CustomHelpLink);
}
return null;
}
public String getVersion() {
return this.map.get(KMManager.KMKey_KeyboardVersion);
}
@ -60,6 +68,7 @@ public class Keyboard implements Serializable, LanguageResource {
public Bundle buildDownloadBundle() {
Bundle bundle = new Bundle();
bundle.putString(KMKeyboardDownloaderActivity.ARG_PKG_ID, getPackage());
bundle.putString(KMKeyboardDownloaderActivity.ARG_KB_ID, getResourceId());
bundle.putString(KMKeyboardDownloaderActivity.ARG_LANG_ID, getLanguageCode());
@ -70,9 +79,13 @@ public class Keyboard implements Serializable, LanguageResource {
if(isCustom == null) {
isCustom = "N";
}
bundle.putBoolean(KMKeyboardDownloaderActivity.ARG_IS_CUSTOM, isCustom.equals("Y"));
String customHelpLink = map.get(KMManager.KMKey_CustomHelpLink);
if (customHelpLink != null) {
bundle.putString(KMKeyboardDownloaderActivity.ARG_CUSTOM_HELP_LINK, getCustomHelpLink());
}
return bundle;
}

View file

@ -9,6 +9,7 @@ public interface LanguageResource {
String getLanguageName();
String getVersion();
String getPackage();
String getCustomHelpLink();
Bundle buildDownloadBundle();
}

View file

@ -4,6 +4,7 @@ import android.os.Bundle;
import com.tavultesoft.kmea.KMKeyboardDownloaderActivity;
import com.tavultesoft.kmea.KMManager;
import com.tavultesoft.kmea.util.MapCompat;
import java.io.Serializable;
import java.util.Map;
@ -52,6 +53,13 @@ public class LexicalModel implements Serializable, LanguageResource {
return this.map.get(KMManager.KMKey_PackageID);
}
public String getCustomHelpLink() {
if (this.map.containsKey(KMManager.KMKey_CustomHelpLink)) {
return this.map.get(KMManager.KMKey_CustomHelpLink);
}
return null;
}
public Bundle buildDownloadBundle() {
Bundle bundle = new Bundle();
@ -64,8 +72,6 @@ public class LexicalModel implements Serializable, LanguageResource {
return null;
}
String customHelpLink = map.get(KMManager.KMKey_CustomHelpLink);
bundle.putString(KMKeyboardDownloaderActivity.ARG_PKG_ID, getPackage());
bundle.putString(KMKeyboardDownloaderActivity.ARG_MODEL_ID, getResourceId());
bundle.putString(KMKeyboardDownloaderActivity.ARG_LANG_ID, getLanguageCode());
@ -73,7 +79,11 @@ public class LexicalModel implements Serializable, LanguageResource {
bundle.putString(KMKeyboardDownloaderActivity.ARG_LANG_NAME, getLanguageName());
bundle.putBoolean(KMKeyboardDownloaderActivity.ARG_IS_CUSTOM, false);
bundle.putString(KMKeyboardDownloaderActivity.ARG_MODEL_URL, modelURL);
bundle.putString(KMKeyboardDownloaderActivity.ARG_MODEL_CUSTOM_HELP_LINK, customHelpLink);
String customHelpLink = map.get(KMManager.KMKey_CustomHelpLink);
if (customHelpLink != null) {
bundle.putString(KMKeyboardDownloaderActivity.ARG_CUSTOM_HELP_LINK, customHelpLink);
}
return bundle;
}

View file

@ -30,6 +30,7 @@ public class CloudDataJsonUtilTest {
private final String customKeyboard = "N";
private final String aFont = "AndikaAfr";
private final String oskFont = aFont;
private final String customHelpLink = "";
@Before
public void initializeTestPackage() {
@ -40,7 +41,7 @@ public class CloudDataJsonUtilTest {
public void shouldLowercaseLanguageID() {
// Test createKeyboardInfoMap() used by processKeyboardJSON()
HashMap<String, String> kbInfo = CloudDataJsonUtil.createKeyboardInfoMap(
pkgID, langID, langName, keyboardID, keyboardName, keyboardVersion, customKeyboard, aFont, oskFont);
pkgID, langID, langName, keyboardID, keyboardName, keyboardVersion, customKeyboard, aFont, oskFont, customHelpLink);
Assert.assertEquals(langID.toLowerCase(), kbInfo.get(KMManager.KMKey_LanguageID));
// Test processLexicalModelJSON()

View file

@ -22,6 +22,7 @@
* Fix memory issues during build process (#2361)
* Fix crashes when parsing JSON data from Cloud (#2393)
* Improve compatibility with applications such as Gmail, Chrome that do not conform to the Android input APIs (#2382, #2376)
* Propagate custom help links (#2448)
## 2019-12-12 12.0.4214 stable
* Bug fix:

View file

@ -1631,6 +1631,10 @@ namespace com.keyman {
// Display the OSK (again) if enabled, in order to set its position correctly after
// adding the UI to the page
this.keyman.osk._Show();
} else if(this.keyman.isEmbedded) {
// UI modules aren't utilized in embedded mode. There's nothing to init, so we simply
// return instead of waiting for a UI module that will never come.
return;
} else {
window.setTimeout(this.initializeUI.bind(this),1000);
}