fix(oem/fv/android): Toggle predictions when dictionary installed

This commit is contained in:
Darcy Wong 2022-03-09 12:02:56 +07:00
parent 738b3cc08a
commit e138ca382e
2 changed files with 11 additions and 2 deletions

View file

@ -182,8 +182,8 @@ 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);
boolean mayPredict = prefs.getBoolean(KMManager.getLanguagePredictionPreferenceKey(lgCode), true);
boolean mayCorrect = prefs.getBoolean(KMManager.getLanguageCorrectionPreferenceKey(lgCode), true);
boolean mayPredict = prefs.getBoolean(KMManager.getLanguagePredictionPreferenceKey(lgCode), false);
boolean mayCorrect = prefs.getBoolean(KMManager.getLanguageCorrectionPreferenceKey(lgCode), false);
layout = (RelativeLayout)findViewById(R.id.corrections_toggle);

View file

@ -2,6 +2,7 @@ package com.firstvoices.keyboards;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@ -254,13 +255,21 @@ public class MainActivity extends AppCompatActivity implements OnKeyboardDownloa
KMManager.KMDefault_LanguageID;
boolean matchingModel = false;
SharedPreferences prefs = context.getSharedPreferences(context.getString(R.string.kma_prefs_name), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
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)) {
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.commit();
// We're on the main thread, so if the active keyboard's language code matches,
// let's register the associated lexical model.