mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
fix(oem/fv/android): Refresh menu on install
This commit is contained in:
parent
2b7d10718b
commit
8aadea6086
2 changed files with 14 additions and 9 deletions
|
|
@ -57,6 +57,7 @@ public final class FVKeyboardSettingsActivity extends AppCompatActivity {
|
|||
private String associatedLexicalModel = "";
|
||||
private String lgCode;
|
||||
private static RelativeLayout checkModelLayout = null;
|
||||
private static Intent intent = null;
|
||||
private static Bundle bundle = null;
|
||||
private static ListView listView = null;
|
||||
private String lgName;
|
||||
|
|
@ -121,7 +122,8 @@ public final class FVKeyboardSettingsActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.fv_keyboard_settings_list_layout);
|
||||
|
||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||
bundle = getIntent().getExtras();
|
||||
intent = getIntent();
|
||||
bundle = intent.getExtras();
|
||||
}
|
||||
if (bundle == null) {
|
||||
// Should never actually happen.
|
||||
|
|
@ -182,8 +184,7 @@ public final class FVKeyboardSettingsActivity extends AppCompatActivity {
|
|||
});
|
||||
|
||||
// The following two layouts/toggles will need to link with these objects.
|
||||
Context appContext = this.getApplicationContext();
|
||||
prefs = appContext.getSharedPreferences(appContext.getString(R.string.kma_prefs_name), Context.MODE_PRIVATE);
|
||||
prefs = context.getSharedPreferences(context.getString(R.string.kma_prefs_name), Context.MODE_PRIVATE);
|
||||
boolean mayPredict = prefs.getBoolean(KMManager.getLanguagePredictionPreferenceKey(lgCode), false);
|
||||
boolean mayCorrect = prefs.getBoolean(KMManager.getLanguageCorrectionPreferenceKey(lgCode), false);
|
||||
|
||||
|
|
@ -382,7 +383,9 @@ public final class FVKeyboardSettingsActivity extends AppCompatActivity {
|
|||
|
||||
public static void restartActivity() {
|
||||
if (context != null) {
|
||||
((Activity)context).recreate();
|
||||
// Not using Activity.recreate() because we need to recalculate the items
|
||||
((Activity)context).finish();
|
||||
((Activity)context).startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import io.sentry.android.core.SentryAndroid;
|
|||
|
||||
import com.tavultesoft.kmea.*;
|
||||
import com.tavultesoft.kmea.data.Keyboard;
|
||||
import com.tavultesoft.kmea.util.BCP47;
|
||||
import com.tavultesoft.kmea.util.DownloadFileUtils;
|
||||
import com.tavultesoft.kmea.KeyboardEventHandler.OnKeyboardDownloadEventListener;
|
||||
|
||||
|
|
@ -250,7 +251,7 @@ public class MainActivity extends AppCompatActivity implements OnKeyboardDownloa
|
|||
|
||||
@Override
|
||||
public void onLexicalModelInstalled(List<Map<String, String>> lexicalModelsInstalled) {
|
||||
String langId = (KMManager.getCurrentKeyboardInfo(this) != null) ?
|
||||
String keyboardLangId = (KMManager.getCurrentKeyboardInfo(this) != null) ?
|
||||
KMManager.getCurrentKeyboardInfo(this).getLanguageID() :
|
||||
KMManager.KMDefault_LanguageID;
|
||||
boolean matchingModel = false;
|
||||
|
|
@ -260,21 +261,22 @@ public class MainActivity extends AppCompatActivity implements OnKeyboardDownloa
|
|||
|
||||
for(int i=0; i<lexicalModelsInstalled.size(); i++) {
|
||||
HashMap<String, String>lexicalModelInfo = new HashMap<>(lexicalModelsInstalled.get(i));
|
||||
if(lexicalModelInfo.get(KMManager.KMKey_LanguageID).equals(langId)) {
|
||||
String lexicalModelLangId = lexicalModelInfo.get(KMManager.KMKey_LanguageID);
|
||||
if(BCP47.languageEquals(keyboardLangId, lexicalModelLangId)) {
|
||||
matchingModel = true;
|
||||
}
|
||||
KMManager.addLexicalModel(this, lexicalModelInfo);
|
||||
|
||||
// Enable predictions and corrections toggles
|
||||
editor.putBoolean(KMManager.getLanguagePredictionPreferenceKey(lexicalModelInfo.get(KMManager.KMKey_LanguageID)), true);
|
||||
editor.putBoolean(KMManager.getLanguageCorrectionPreferenceKey(lexicalModelInfo.get(KMManager.KMKey_LanguageID)), true);
|
||||
editor.putBoolean(KMManager.getLanguagePredictionPreferenceKey(lexicalModelLangId), true);
|
||||
editor.putBoolean(KMManager.getLanguageCorrectionPreferenceKey(lexicalModelLangId), true);
|
||||
}
|
||||
editor.commit();
|
||||
|
||||
// We're on the main thread, so if the active keyboard's language code matches,
|
||||
// let's register the associated lexical model.
|
||||
if(matchingModel) {
|
||||
KMManager.registerAssociatedLexicalModel(langId);
|
||||
KMManager.registerAssociatedLexicalModel(keyboardLangId);
|
||||
}
|
||||
|
||||
// Launch/refresh FV Keyboard Settings menu
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue