final String searchToken) {
final Intent intent = new Intent();
intent.setClassName(DictionaryActivity.class.getPackage().getName(),
DictionaryActivity.class.getName());
intent.putExtra(C.DICT_FILE, dictFile.getPath());
final String searchToken) {
final Intent intent = new Intent();
intent.setClassName(DictionaryActivity.class.getPackage().getName(),
DictionaryActivity.class.getName());
intent.putExtra(C.DICT_FILE, dictFile.getPath());
protected void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
Log.d(LOG, "onSaveInstanceState: " + searchView.getQuery().toString());
protected void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
Log.d(LOG, "onSaveInstanceState: " + searchView.getQuery().toString());
- protected void onRestoreInstanceState(final Bundle outState) {
- super.onRestoreInstanceState(outState);
- Log.d(LOG, "onRestoreInstanceState: " + outState.getString(C.SEARCH_TOKEN));
- onCreate(outState);
+ protected void onRestoreInstanceState(final Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ Log.d(LOG, "onRestoreInstanceState: " + savedInstanceState.getString(C.SEARCH_TOKEN));
+ onCreate(savedInstanceState);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Don't auto-launch if this fails.
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Don't auto-launch if this fails.
theme = application.getSelectedTheme();
textColorFg = getResources().getColor(theme.tokenRowFgColor);
theme = application.getSelectedTheme();
textColorFg = getResources().getColor(theme.tokenRowFgColor);
- Log.d(LOG, "DictSearch: from: " + from + " to " + to);
- List<DictionaryInfo> dicts = application.getUsableDicts();
+ Log.d(LOG, "DictSearch: from: " + from + " to " + to);
+ List<DictionaryInfo> dicts = application.getDictionariesOnDevice();
- indexIndex = intent.getIntExtra(C.INDEX_INDEX, 0);
- if (savedInstanceState != null) {
- indexIndex = savedInstanceState.getInt(C.INDEX_INDEX, indexIndex);
+ String targetIndex = intent.getStringExtra(C.INDEX_SHORT_NAME);
+ if (savedInstanceState != null && savedInstanceState.getString(C.INDEX_SHORT_NAME) != null) {
+ targetIndex = savedInstanceState.getString(C.INDEX_SHORT_NAME);
+ }
+ indexIndex = 0;
+ for (int i = 0; i < dictionary.indices.size(); ++i) {
+ if (dictionary.indices.get(i).shortName.equals(targetIndex)) {
+ indexIndex = i;
+ break;
+ }
}
indexIndex %= dictionary.indices.size();
Log.d(LOG, "Loading index " + indexIndex);
}
indexIndex %= dictionary.indices.size();
Log.d(LOG, "Loading index " + indexIndex);
setSearchText(text, true);
Log.d(LOG, "Trying to restore searchText=" + text);
setSearchText(text, true);
Log.d(LOG, "Trying to restore searchText=" + text);
- setDictionaryPrefs(this, dictFile, indexIndex, searchView.getQuery().toString());
+ setDictionaryPrefs(this, dictFile, index.shortName, searchView.getQuery().toString());
final SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(
context).edit();
prefs.putString(C.DICT_FILE, dictFile.getPath());
final SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(
context).edit();
prefs.putString(C.DICT_FILE, dictFile.getPath());
dialog.setContentView(R.layout.select_dictionary_dialog);
dialog.setTitle(R.string.selectDictionary);
dialog.setContentView(R.layout.select_dictionary_dialog);
dialog.setTitle(R.string.selectDictionary);
final Button button = new Button(listView.getContext());
final String name = getString(R.string.dictionaryManager);
button.setText(name);
final Button button = new Button(listView.getContext());
final String name = getString(R.string.dictionaryManager);
button.setText(name);
final IntentLauncher intentLauncher = new IntentLauncher(parent.getContext(),
getLaunchIntent(
application.getPath(dictionaryInfo.uncompressedFilename),
final IntentLauncher intentLauncher = new IntentLauncher(parent.getContext(),
getLaunchIntent(
application.getPath(dictionaryInfo.uncompressedFilename),
indexAdapter = new IndexAdapter(index);
setListAdapter(indexAdapter);
Log.d(LOG, "changingIndex, newLang=" + index.longName);
indexAdapter = new IndexAdapter(index);
setListAdapter(indexAdapter);
Log.d(LOG, "changingIndex, newLang=" + index.longName);
- setDictionaryPrefs(this, dictFile, indexIndex, searchView.getQuery().toString());
+ setDictionaryPrefs(this, dictFile, index.shortName, searchView.getQuery().toString());