public void saveState(IMControlPanel controlPanel) { // save state of control panel itself StateBundle cpState = new StateBundle(mPreferences, PREFIX + ".", true); cpState.putInt("activeMethodIndex", controlPanel.getActiveMethodIndex()); cpState.commit(); // save state of all input methods for (InputMethod im : controlPanel.getInputMethods()) { StateBundle outState = new StateBundle(mPreferences, PREFIX + "." + im.getInputMethodName(), true); im.onSaveState(outState); outState.commit(); } }
public void restoreState(IMControlPanel controlPanel) { // restore state of control panel itself StateBundle cpState = new StateBundle(mPreferences, PREFIX + ".", false); int methodId = cpState.getInt("activeMethodIndex", 0); if (methodId != -1) { controlPanel.activateInputMethod(methodId); } // restore state of all input methods for (InputMethod im : controlPanel.getInputMethods()) { StateBundle savedState = new StateBundle(mPreferences, PREFIX + "." + im.getInputMethodName(), false); im.onRestoreState(savedState); } }