Start refactoring help links

This commit is contained in:
Darcy Wong 2019-09-05 16:23:58 +07:00
parent 6c4a610071
commit 028d247110
9 changed files with 24 additions and 6 deletions

View file

@ -111,12 +111,17 @@ final class KMKeyboardPickerAdapter extends NestedAdapter<Keyboard, Dataset.Keyb
i.putExtra(KMManager.KMKey_KeyboardID, keyboardID);
i.putExtra(KMManager.KMKey_LanguageID, kbInfo.get(KMManager.KMKey_LanguageID));
i.putExtra(KMManager.KMKey_KeyboardName, kbInfo.get(KMManager.KMKey_KeyboardName));
i.putExtra(KMManager.KMKey_KeyboardVersion, KMManager.getLatestKeyboardFileVersion(this.getContext(), packageID, keyboardID));
String keyboardVersion = KMManager.getLatestKeyboardFileVersion(this.getContext(), packageID, keyboardID);
i.putExtra(KMManager.KMKey_KeyboardVersion, keyboardVersion);
boolean isCustom = kbInfo.get(KMManager.KMKey_CustomKeyboard).equals("Y") ? true : false;
i.putExtra(KMManager.KMKey_CustomKeyboard, isCustom);
String customHelpLink = kbInfo.get(KMManager.KMKey_CustomHelpLink);
if (customHelpLink != null)
if (customHelpLink != null) {
i.putExtra(KMManager.KMKey_CustomHelpLink, customHelpLink);
} else {
i.putExtra(KMManager.KMKey_HelpLink,
String.format("https://help.keyman.com/keyboard/%s/%s/", keyboardID, keyboardVersion));
}
KeyboardInfoActivity.titleFont = listFont;
this.getContext().startActivity(i);
}

View file

@ -120,6 +120,7 @@ public final class KMManager {
public static final String KMKey_LanguageID = "langId";
public static final String KMKey_LanguageName = "langName";
public static final String KMKey_KeyboardCount = "kbCount";
public static final String KMKey_HelpLink = "helpLink";
public static final String KMKey_Icon = "icon";
public static final String KMKey_KeyboardID = "kbId";
public static final String KMKey_KeyboardName = "kbName";

View file

@ -79,6 +79,7 @@ public final class KeyboardInfoActivity extends AppCompatActivity {
// Display keyboard help link
hashMap = new HashMap<String, String>();
final String helpUrlStr = getIntent().getStringExtra(KMManager.KMKey_HelpLink);
final String customHelpLink = getIntent().getStringExtra(KMManager.KMKey_CustomHelpLink);
// Check if app declared FileProvider
String icon = String.valueOf(R.drawable.ic_arrow_forward);
@ -140,7 +141,6 @@ public final class KeyboardInfoActivity extends AppCompatActivity {
startActivity(i);
}
} else {
String helpUrlStr = String.format("http://help.keyman.com/keyboard/%s/%s/", kbID, kbVersion);
i.setData(Uri.parse(helpUrlStr));
startActivity(i);
}

View file

@ -84,6 +84,7 @@ public final class KeyboardSettingsActivity extends AppCompatActivity {
// Display keyboard help link
hashMap = new HashMap<String, String>();
final String helpUrlStr = getIntent().getStringExtra(KMManager.KMKey_HelpLink);
final String customHelpLink = getIntent().getStringExtra(KMManager.KMKey_CustomHelpLink);
// Check if app declared FileProvider
String icon = String.valueOf(R.drawable.ic_arrow_forward);
@ -159,7 +160,6 @@ public final class KeyboardSettingsActivity extends AppCompatActivity {
startActivity(i);
}
} else {
String helpUrlStr = String.format("http://help.keyman.com/keyboard/%s/%s/", kbID, kbVersion);
i.setData(Uri.parse(helpUrlStr));
startActivity(i);
}

View file

@ -208,12 +208,17 @@ public final class LanguageSettingsActivity extends AppCompatActivity {
intent.putExtra(KMManager.KMKey_LanguageID, kbInfo.get(KMManager.KMKey_LanguageID));
intent.putExtra(KMManager.KMKey_LanguageName, kbInfo.get(KMManager.KMKey_LanguageName));
intent.putExtra(KMManager.KMKey_KeyboardName, kbInfo.get(KMManager.KMKey_KeyboardName));
intent.putExtra(KMManager.KMKey_KeyboardVersion, KMManager.getLatestKeyboardFileVersion(context, packageID, keyboardID));
String keyboardVersion = KMManager.getLatestKeyboardFileVersion(context, packageID, keyboardID);
intent.putExtra(KMManager.KMKey_KeyboardVersion, keyboardVersion);
boolean isCustom = MapCompat.getOrDefault(kbInfo, KMManager.KMKey_CustomKeyboard, "N").equals("Y") ? true : false;
intent.putExtra(KMManager.KMKey_CustomKeyboard, isCustom);
String customHelpLink = kbInfo.get(KMManager.KMKey_CustomHelpLink);
if (customHelpLink != null)
if (customHelpLink != null) {
intent.putExtra(KMManager.KMKey_CustomHelpLink, customHelpLink);
} else {
intent.putExtra(KMManager.KMKey_HelpLink,
String.format("https://help.keyman.com/keyboard/%s/%s/", keyboardID, keyboardVersion));
}
startActivity(intent);
}
});

View file

@ -390,6 +390,8 @@ public class CloudRepository {
hashMap.put(KMManager.KMKey_KeyboardVersion, kbVersion);
hashMap.put(KMManager.KMKey_CustomKeyboard, isCustom);
hashMap.put(KMManager.KMKey_Font, kbFont);
hashMap.put(KMManager.KMKey_HelpLink,
String.format("https://help.keyman.com/keyboard/%s/%s/", kbID, kbVersion));
// if (keyboardModifiedDates.get(kbID) == null) {
// keyboardModifiedDates.put(kbID, keyboardJSON.getString(KMManager.KMKey_KeyboardModified));

View file

@ -51,6 +51,8 @@ public class Keyboard implements Serializable, LanguageResource {
return this.map.get(KMManager.KMKey_PackageID);
}
public String getHelp() { return this.map.get(KMManager.KMKey_HelpLink); }
public Bundle buildDownloadBundle() {
Bundle bundle = new Bundle();
bundle.putString(KMKeyboardDownloaderActivity.ARG_PKG_ID, getPackage());

View file

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

View file

@ -52,6 +52,8 @@ public class LexicalModel implements Serializable, LanguageResource {
return this.map.get(KMManager.KMKey_PackageID);
}
public String getHelp() { return this.map.get(KMManager.KMKey_HelpLink); }
public Bundle buildDownloadBundle() {
Bundle bundle = new Bundle();