mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-12 11:55:32 +00:00
fix(android): Additional cleanup
This commit is contained in:
parent
f5d9418f35
commit
9bbdd3409e
3 changed files with 27 additions and 32 deletions
|
|
@ -25,26 +25,24 @@ public class Keyboard extends LanguageResource implements Serializable {
|
|||
private String oskFont;
|
||||
|
||||
// JSON keys
|
||||
public static String KB_NEW_KEYBOARD_KEY = "isNewKeyboard";
|
||||
public static String KB_FONT_KEY = "font";
|
||||
public static String KB_OSK_FONT_KEY = "oskFont";
|
||||
private static String KB_NEW_KEYBOARD_KEY = "isNewKeyboard";
|
||||
private static String KB_FONT_KEY = "font";
|
||||
private static String KB_OSK_FONT_KEY = "oskFont";
|
||||
|
||||
/**
|
||||
* Constructor using JSON Objects from installed keyboards list
|
||||
* @param installedObj
|
||||
*/
|
||||
public Keyboard(JSONObject installedObj) {
|
||||
super(installedObj);
|
||||
this.fromJSON(installedObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor usong JSON Objects from keyboard cloud catalog
|
||||
* Constructor using JSON Objects from keyboard cloud catalog
|
||||
* @param languageJSON
|
||||
* @param keyboardJSON
|
||||
*/
|
||||
public Keyboard(JSONObject languageJSON, JSONObject keyboardJSON) {
|
||||
super(languageJSON, keyboardJSON);
|
||||
try {
|
||||
this.packageID = keyboardJSON.optString(KMManager.KMKey_PackageID, KMManager.KMDefault_UndefinedPackageID);
|
||||
|
||||
|
|
@ -76,10 +74,9 @@ public class Keyboard extends LanguageResource implements Serializable {
|
|||
String languageID, String languageName, String version,
|
||||
String helpLink,
|
||||
boolean isNewKeyboard, String font, String oskFont) {
|
||||
super(packageID, keyboardID, keyboardName, languageID, languageName, version);
|
||||
|
||||
this.helpLink = (FileUtils.isWelcomeFile(helpLink)) ? helpLink :
|
||||
String.format(HELP_URL_FORMATSTR, this.resourceID, this.version);
|
||||
super(packageID, keyboardID, keyboardName, languageID, languageName, version,
|
||||
(FileUtils.isWelcomeFile(helpLink)) ? helpLink :
|
||||
String.format(HELP_URL_FORMATSTR, keyboardID, version));
|
||||
|
||||
this.isNewKeyboard = isNewKeyboard;
|
||||
this.font = (font != null) ? font : "";
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ public abstract class LanguageResource implements Serializable {
|
|||
protected String helpLink;
|
||||
|
||||
// JSON keys
|
||||
public static String LR_PACKAGE_ID_KEY = "packageID";
|
||||
public static String LR_RESOURCE_ID_KEY = "resourceID";
|
||||
public static String LR_RESOURCE_NAME_KEY = "resourceName";
|
||||
public static String LR_LANGUAGE_ID_KEY = "languageID";
|
||||
public static String LR_LANGUAGE_NAME_KEY = "languageName";
|
||||
public static String LR_VERSION_KEY = "version";
|
||||
public static String LR_HELP_LINK_KEY = "helpLink";
|
||||
private static String LR_PACKAGE_ID_KEY = "packageID";
|
||||
private static String LR_RESOURCE_ID_KEY = "resourceID";
|
||||
private static String LR_RESOURCE_NAME_KEY = "resourceName";
|
||||
private static String LR_LANGUAGE_ID_KEY = "languageID";
|
||||
private static String LR_LANGUAGE_NAME_KEY = "languageName";
|
||||
private static String LR_VERSION_KEY = "version";
|
||||
private static String LR_HELP_LINK_KEY = "helpLink";
|
||||
|
||||
private static final String TAG = "LanguageResource";
|
||||
|
||||
|
|
@ -64,6 +64,10 @@ public abstract class LanguageResource implements Serializable {
|
|||
|
||||
public abstract Bundle buildDownloadBundle();
|
||||
|
||||
public LanguageResource() {
|
||||
// Noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor using JSON Objects from installed language resource list
|
||||
* @param installedObj
|
||||
|
|
@ -72,26 +76,19 @@ public abstract class LanguageResource implements Serializable {
|
|||
this.fromJSON(installedObj);
|
||||
}
|
||||
|
||||
public LanguageResource(JSONObject languageJSON, JSONObject keyboardJSON) {
|
||||
// Noop - needed for Keyboard()
|
||||
}
|
||||
|
||||
public LanguageResource(JSONObject lexicalModelJSON, boolean fromCloud) {
|
||||
// Noop - needed for LexicalModel()
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor using properties
|
||||
* For now, helpLink not included because it's only used by Keyboard
|
||||
* @param packageID
|
||||
* @param resourceID
|
||||
* @param resourceName
|
||||
* @param languageID
|
||||
* @param languageName
|
||||
* @param version
|
||||
* @param helpLink
|
||||
*/
|
||||
public LanguageResource(String packageID, String resourceID, String resourceName,
|
||||
String languageID, String languageName, String version) {
|
||||
String languageID, String languageName, String version,
|
||||
String helpLink) {
|
||||
this.packageID = (packageID != null) ? packageID : KMManager.KMDefault_UndefinedPackageID;
|
||||
this.resourceID = resourceID;
|
||||
this.resourceName = resourceName;
|
||||
|
|
@ -99,6 +96,7 @@ public abstract class LanguageResource implements Serializable {
|
|||
// If language name not provided, fallback to re-use language ID
|
||||
this.languageName = (languageName != null && !languageName.isEmpty()) ? languageName : this.languageID;
|
||||
this.version = (version != null) ? version : "1.0";
|
||||
this.helpLink = helpLink;
|
||||
}
|
||||
|
||||
protected void fromJSON(JSONObject installedObj) {
|
||||
|
|
|
|||
|
|
@ -23,14 +23,13 @@ public class LexicalModel extends LanguageResource implements Serializable {
|
|||
private String modelURL;
|
||||
|
||||
// JSON key
|
||||
public static String LM_MODEL_URL_KEY = "modelURL";
|
||||
private static String LM_MODEL_URL_KEY = "modelURL";
|
||||
|
||||
/**
|
||||
* Constructor using JSON Object from installed lexical models list
|
||||
* @param installedObj
|
||||
*/
|
||||
public LexicalModel(JSONObject installedObj) {
|
||||
super(installedObj);
|
||||
this.fromJSON(installedObj);
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +39,6 @@ public class LexicalModel extends LanguageResource implements Serializable {
|
|||
* @param fromCloud boolean - only really used to make a unique prototype
|
||||
*/
|
||||
public LexicalModel(JSONObject lexicalModelJSON, boolean fromCloud) {
|
||||
super(lexicalModelJSON, fromCloud);
|
||||
try {
|
||||
this.modelURL = lexicalModelJSON.optString("packageFilename", "");
|
||||
|
||||
|
|
@ -87,9 +85,10 @@ public class LexicalModel extends LanguageResource implements Serializable {
|
|||
String languageID, String languageName, String version,
|
||||
String helpLink,
|
||||
String modelURL) {
|
||||
super(packageID, lexicalModelID, lexicalModelName, languageID, languageName, version);
|
||||
// TODO: handle help links
|
||||
super(packageID, lexicalModelID, lexicalModelName, languageID, languageName,
|
||||
version, "");
|
||||
|
||||
this.helpLink = ""; // TODO: Handle help links
|
||||
this.modelURL = modelURL;
|
||||
}
|
||||
|
||||
|
|
@ -131,6 +130,7 @@ public class LexicalModel extends LanguageResource implements Serializable {
|
|||
}
|
||||
|
||||
protected void fromJSON(JSONObject installedObj) {
|
||||
super.fromJSON(installedObj);
|
||||
try {
|
||||
this.modelURL = installedObj.getString(LM_MODEL_URL_KEY);
|
||||
} catch (JSONException e) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue