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);
}
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(LOG, "onCreate:" + this);
super.onCreate(savedInstanceState);
}
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(LOG, "onCreate:" + this);
super.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(null);
- 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;
+ }
Log.d(LOG, "Loading index " + indexIndex);
index = dictionary.indices.get(indexIndex);
setListAdapter(new IndexAdapter(index));
Log.d(LOG, "Loading index " + indexIndex);
index = dictionary.indices.get(indexIndex);
setListAdapter(new IndexAdapter(index));
saveOnlyFirstSubentry = prefs.getBoolean(getString(R.string.saveOnlyFirstSubentryKey),
false);
clickOpensContextMenu = prefs.getBoolean(getString(R.string.clickOpensContextMenuKey),
saveOnlyFirstSubentry = prefs.getBoolean(getString(R.string.saveOnlyFirstSubentryKey),
false);
clickOpensContextMenu = prefs.getBoolean(getString(R.string.clickOpensContextMenuKey),
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());
searchView = new SearchView(getSupportActionBar().getThemedContext());
searchView.setIconifiedByDefault(false);
searchView = new SearchView(getSupportActionBar().getThemedContext());
searchView.setIconifiedByDefault(false);
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 LinearLayout result = new LinearLayout(parent.getContext());
for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) {
final LinearLayout result = new LinearLayout(parent.getContext());
for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) {
final IntentLauncher intentLauncher = new IntentLauncher(parent.getContext(),
getLaunchIntent(
application.getPath(dictionaryInfo.uncompressedFilename),
final IntentLauncher intentLauncher = new IntentLauncher(parent.getContext(),
getLaunchIntent(
application.getPath(dictionaryInfo.uncompressedFilename),
layoutParams.weight = 1.0f;
nameView.setLayoutParams(layoutParams);
result.addView(nameView);
layoutParams.weight = 1.0f;
nameView.setLayoutParams(layoutParams);
result.addView(nameView);
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());