mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-20 08:50:25 +00:00
LatinIME: Properly refresh summary
* onResume() of AppearanceSettingsFragment gets called before onPause() of CustomInputStyleSettingsFragment * Instead, save after each modification so the lifecycle doesn't matter Change-Id: If5c5df8b589c08df61eea2643c217e9665a01002
This commit is contained in:
parent
0834f408ef
commit
8acf5b5464
1 changed files with 19 additions and 12 deletions
|
@ -188,7 +188,8 @@ public final class CustomInputStyleSettingsFragment extends PreferenceFragment
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (findDuplicatedSubtype(subtype) == null) {
|
if (findDuplicatedSubtype(subtype) == null) {
|
||||||
mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
|
final InputMethodSubtype[] subTypes = saveAndGetSubTypes();
|
||||||
|
mRichImm.setAdditionalInputMethodSubtypes(subTypes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +206,8 @@ public final class CustomInputStyleSettingsFragment extends PreferenceFragment
|
||||||
mIsAddingNewSubtype = false;
|
mIsAddingNewSubtype = false;
|
||||||
final InputMethodSubtype subtype = stylePref.getSubtype();
|
final InputMethodSubtype subtype = stylePref.getSubtype();
|
||||||
if (findDuplicatedSubtype(subtype) == null) {
|
if (findDuplicatedSubtype(subtype) == null) {
|
||||||
mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
|
final InputMethodSubtype[] subTypes = saveAndGetSubTypes();
|
||||||
|
mRichImm.setAdditionalInputMethodSubtypes(subTypes);
|
||||||
mSubtypePreferenceKeyForSubtypeEnabler = stylePref.getKey();
|
mSubtypePreferenceKeyForSubtypeEnabler = stylePref.getKey();
|
||||||
mSubtypeEnablerNotificationDialog = createDialog();
|
mSubtypeEnablerNotificationDialog = createDialog();
|
||||||
mSubtypeEnablerNotificationDialog.show();
|
mSubtypeEnablerNotificationDialog.show();
|
||||||
|
@ -299,16 +301,7 @@ public final class CustomInputStyleSettingsFragment extends PreferenceFragment
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
final String oldSubtypes = Settings.readPrefAdditionalSubtypes(mPrefs, getResources());
|
final InputMethodSubtype[] subtypes = saveAndGetSubTypes();
|
||||||
final InputMethodSubtype[] subtypes = getSubtypes();
|
|
||||||
final String prefSubtypes = AdditionalSubtypeUtils.createPrefSubtypes(subtypes);
|
|
||||||
if (DEBUG_CUSTOM_INPUT_STYLES) {
|
|
||||||
Log.i(TAG, "Save custom input styles: " + prefSubtypes);
|
|
||||||
}
|
|
||||||
if (prefSubtypes.equals(oldSubtypes)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Settings.writePrefAdditionalSubtypes(mPrefs, prefSubtypes);
|
|
||||||
mRichImm.setAdditionalInputMethodSubtypes(subtypes);
|
mRichImm.setAdditionalInputMethodSubtypes(subtypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,4 +328,18 @@ public final class CustomInputStyleSettingsFragment extends PreferenceFragment
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private InputMethodSubtype[] saveAndGetSubTypes() {
|
||||||
|
final String oldSubtypes = Settings.readPrefAdditionalSubtypes(mPrefs, getResources());
|
||||||
|
final InputMethodSubtype[] subtypes = getSubtypes();
|
||||||
|
final String prefSubtypes = AdditionalSubtypeUtils.createPrefSubtypes(subtypes);
|
||||||
|
if (DEBUG_CUSTOM_INPUT_STYLES) {
|
||||||
|
Log.i(TAG, "Save custom input styles: " + prefSubtypes);
|
||||||
|
}
|
||||||
|
if (prefSubtypes.equals(oldSubtypes)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Settings.writePrefAdditionalSubtypes(mPrefs, prefSubtypes);
|
||||||
|
return subtypes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue