import android.preference.PreferenceManager;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.SearchView;
+import android.support.v7.widget.SearchView.OnQueryTextListener;
import android.text.ClipboardManager;
import android.text.Spannable;
import android.text.method.LinkMovementMethod;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Gravity;
import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView.BufferType;
import android.widget.Toast;
-import android.support.v4.view.MenuItemCompat;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.ActionBarActivity;
-import android.support.v7.widget.SearchView;
-import android.support.v7.widget.SearchView.OnQueryTextListener;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.MenuItem.OnMenuItemClickListener;
import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;
import com.hughes.android.dictionary.engine.Dictionary;
import com.hughes.android.dictionary.engine.EntrySource;
import com.hughes.android.dictionary.engine.HtmlEntry;
import com.hughes.android.dictionary.engine.Index;
import com.hughes.android.dictionary.engine.Index.IndexEntry;
-import com.hughes.android.dictionary.engine.Language;
import com.hughes.android.dictionary.engine.Language.LanguageResources;
import com.hughes.android.dictionary.engine.PairEntry;
import com.hughes.android.dictionary.engine.PairEntry.Pair;
volatile boolean ttsReady;
Typeface typeface;
- C.Theme theme = C.Theme.LIGHT;
+ DictionaryApplication.Theme theme = DictionaryApplication.Theme.LIGHT;
int textColorFg = Color.BLACK;
int fontSizeSp;
public DictionaryActivity() {
}
- public static Intent getLaunchIntent(final File dictFile, final String indexShortName,
+ public static Intent getLaunchIntent(Context c, final File dictFile, final String indexShortName,
final String searchToken) {
- final Intent intent = new Intent();
- intent.setClassName(DictionaryActivity.class.getPackage().getName(),
- DictionaryActivity.class.getName());
+ final Intent intent = new Intent(c, DictionaryActivity.class);
intent.putExtra(C.DICT_FILE, dictFile.getPath());
intent.putExtra(C.INDEX_SHORT_NAME, indexShortName);
intent.putExtra(C.SEARCH_TOKEN, searchToken);
// Don't auto-launch if this fails.
prefs.edit().remove(C.DICT_FILE).commit();
+ setContentView(R.layout.dictionary_activity);
application = (DictionaryApplication) getApplication();
theme = application.getSelectedTheme();
if (dictFilename == null)
{
Toast.makeText(this, getString(R.string.no_dict_file), Toast.LENGTH_LONG).show();
- startActivity(DictionaryManagerActivity.getLaunchIntent());
+ startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
finish();
return;
}
}
Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()),
Toast.LENGTH_LONG).show();
- startActivity(DictionaryManagerActivity.getLaunchIntent());
+ startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
finish();
return;
}
fontSizeSp = 14;
}
- setContentView(R.layout.dictionary_activity);
-
// ContextMenu.
registerForContextMenu(getListView());
final String name = getString(R.string.dictionaryManager);
button.setText(name);
final IntentLauncher intentLauncher = new IntentLauncher(listView.getContext(),
- DictionaryManagerActivity.getLaunchIntent()) {
+ DictionaryManagerActivity.getLaunchIntent(getApplicationContext())) {
@Override
protected void onGo() {
dialog.dismiss();
DictionaryActivity.this.finish();
- };
+ }
};
button.setOnClickListener(intentLauncher);
listView.addHeaderView(button);
final View button = application.createButton(parent.getContext(),
dictionaryInfo, indexInfo);
final IntentLauncher intentLauncher = new IntentLauncher(parent.getContext(),
- getLaunchIntent(
+ getLaunchIntent(getApplicationContext(),
application.getPath(dictionaryInfo.uncompressedFilename),
indexInfo.shortName, searchView.getQuery().toString())) {
@Override
protected void onGo() {
dialog.dismiss();
DictionaryActivity.this.finish();
- };
+ }
};
button.setOnClickListener(intentLauncher);
result.addView(button);
MenuItemCompat.setShowAsAction(dictionaryManager, MenuItem.SHOW_AS_ACTION_NEVER);
dictionaryManager.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(final MenuItem menuItem) {
- startActivity(DictionaryManagerActivity.getLaunchIntent());
+ startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
finish();
return false;
}
String html = HtmlEntry.htmlBody(htmlEntries, index.shortName);
// Log.d(LOG, "html=" + html);
startActivityForResult(
- HtmlDisplayActivity.getHtmlIntent(String.format(
+ HtmlDisplayActivity.getHtmlIntent(getApplicationContext(), String.format(
"<html><head></head><body>%s</body></html>", html),
htmlTextToHighlight, false),
0);