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);
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;
}
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();
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
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);
MenuItemCompat.setShowAsAction(about, MenuItem.SHOW_AS_ACTION_NEVER);
about.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(final MenuItem menuItem) {
- final Intent intent = new Intent().setClassName(AboutActivity.class
- .getPackage().getName(), AboutActivity.class.getCanonicalName());
+ final Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
context.startActivity(intent);
return false;
}
MenuItemCompat.setShowAsAction(help, MenuItem.SHOW_AS_ACTION_NEVER);
help.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(final MenuItem menuItem) {
- context.startActivity(HtmlDisplayActivity.getHelpLaunchIntent());
+ context.startActivity(HtmlDisplayActivity.getHelpLaunchIntent(getApplicationContext()));
return false;
}
});
preferences.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(final MenuItem menuItem) {
PreferenceActivity.prefsMightHaveChanged = true;
- final Intent intent = new Intent().setClassName(PreferenceActivity.class
- .getPackage().getName(), PreferenceActivity.class.getCanonicalName());
+ final Intent intent = new Intent(getApplicationContext(), PreferenceActivity.class);
context.startActivity(intent);
return false;
}
}
};
- public static Intent getLaunchIntent() {
- final Intent intent = new Intent();
- intent.setClassName(DictionaryManagerActivity.class.getPackage().getName(),
- DictionaryManagerActivity.class.getName());
+ public static Intent getLaunchIntent(Context c) {
+ final Intent intent = new Intent(c, DictionaryManagerActivity.class);
intent.putExtra(C.CAN_AUTO_LAUNCH_DICT, false);
return intent;
}
if (!prefs.getString(C.THANKS_FOR_UPDATING_VERSION, "").equals(
thanksForUpdatingLatestVersion)) {
blockAutoLaunch = true;
- startActivity(HtmlDisplayActivity.getWhatsNewLaunchIntent());
+ startActivity(HtmlDisplayActivity.getWhatsNewLaunchIntent(getApplicationContext()));
prefs.edit().putString(C.THANKS_FOR_UPDATING_VERSION, thanksForUpdatingLatestVersion)
.commit();
}
prefs.contains(C.DICT_FILE) &&
prefs.contains(C.INDEX_SHORT_NAME)) {
Log.d(LOG, "Skipping DictionaryManager, going straight to dictionary.");
- startActivity(DictionaryActivity.getLaunchIntent(
+ startActivity(DictionaryActivity.getLaunchIntent(getApplicationContext(),
new File(prefs.getString(C.DICT_FILE, "")),
prefs.getString(C.INDEX_SHORT_NAME, ""),
prefs.getString(C.SEARCH_TOKEN, "")));
if (canLaunch) {
button.setOnClickListener(
new IntentLauncher(buttons.getContext(),
- DictionaryActivity.getLaunchIntent(
+ DictionaryActivity.getLaunchIntent(getApplicationContext(),
application.getPath(dictionaryInfo.uncompressedFilename),
indexInfo.shortName, "")));
if (canLaunch) {
row.setClickable(true);
row.setOnClickListener(new IntentLauncher(parent.getContext(),
- DictionaryActivity.getLaunchIntent(
+ DictionaryActivity.getLaunchIntent(getApplicationContext(),
application.getPath(dictionaryInfo.uncompressedFilename),
dictionaryInfo.indexInfos.get(0).shortName, "")));
row.setFocusable(true);
\r
package com.hughes.android.dictionary;\r
\r
+import android.content.Context;\r
import android.content.Intent;\r
import android.os.Bundle;\r
import android.support.v7.app.ActionBar;\r
static final String TEXT_TO_HIGHLIGHT = "textToHighlight";\r
static final String SHOW_OK_BUTTON = "showOKButton";\r
\r
- public static Intent getHelpLaunchIntent() {\r
- final Intent intent = new Intent();\r
- intent.setClassName(HtmlDisplayActivity.class.getPackage().getName(),\r
- HtmlDisplayActivity.class.getName());\r
+ public static Intent getHelpLaunchIntent(Context c) {\r
+ final Intent intent = new Intent(c, HtmlDisplayActivity.class);\r
intent.putExtra(HTML_RES, R.raw.help);\r
return intent;\r
}\r
\r
- public static Intent getWhatsNewLaunchIntent() {\r
- final Intent intent = new Intent();\r
- intent.setClassName(HtmlDisplayActivity.class.getPackage().getName(),\r
- HtmlDisplayActivity.class.getName());\r
+ public static Intent getWhatsNewLaunchIntent(Context c) {\r
+ final Intent intent = new Intent(c, HtmlDisplayActivity.class);\r
intent.putExtra(HTML_RES, R.raw.whats_new);\r
return intent;\r
}\r
\r
- public static Intent getHtmlIntent(final String html, final String textToHighlight,\r
+ public static Intent getHtmlIntent(Context c, final String html, final String textToHighlight,\r
final boolean showOkButton) {\r
- final Intent intent = new Intent();\r
- intent.setClassName(HtmlDisplayActivity.class.getPackage().getName(),\r
- HtmlDisplayActivity.class.getName());\r
+ final Intent intent = new Intent(c, HtmlDisplayActivity.class);\r
intent.putExtra(HTML, html);\r
intent.putExtra(TEXT_TO_HIGHLIGHT, textToHighlight);\r
intent.putExtra(SHOW_OK_BUTTON, showOkButton);\r