1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

first experiments with colordict 3

This commit is contained in:
Nikolay Pultsin 2011-01-27 01:09:30 +00:00
parent 24c2fe7074
commit 3cb4674893
2 changed files with 41 additions and 10 deletions

View file

@ -37,14 +37,36 @@ public abstract class DictionaryUtil {
new LinkedHashMap<PackageInfo,Boolean>();
private static ZLStringOption ourDictionaryOption;
private interface ColorDict3 {
String ACTION = "colordict.intent.action.SEARCH";
String QUERY = "EXTRA_QUERY";
String HEIGHT = "EXTRA_HEIGHT";
String WIDTH = "EXTRA_WIDTH";
String GRAVITY = "EXTRA_GRAVITY";
String MARGIN_LEFT = "EXTRA_MARGIN_LEFT";
String MARGIN_TOP = "EXTRA_MARGIN_TOP";
String MARGIN_BOTTOM = "EXTRA_MARGIN_BOTTOM";
String MARGIN_RIGHT = "EXTRA_MARGIN_RIGHT";
}
private static Map<PackageInfo,Boolean> infos() {
if (ourDictionaryInfos.isEmpty()) {
ourDictionaryInfos.put(new PackageInfo(
"ColorDict", // Id
null, // Package
null, // Class
"ColorDict", // Title
ColorDict3.ACTION,
ColorDict3.QUERY,
"%s"
), false);
ourDictionaryInfos.put(new PackageInfo(
"ColorDict2", // Id
"com.socialnmobile.colordict", // Package
"com.socialnmobile.colordict.activity.Main", // Class
"ColorDict", // Title
"ColorDict Old Style", // Title
Intent.ACTION_SEARCH,
SearchManager.QUERY,
"%s"
), false);
ourDictionaryInfos.put(new PackageInfo(
@ -53,6 +75,7 @@ public abstract class DictionaryUtil {
"com.ngc.fora.ForaDictionary", // Class
"Fora Dictionary", // Title
Intent.ACTION_SEARCH,
SearchManager.QUERY,
"%s"
), false);
ourDictionaryInfos.put(new PackageInfo(
@ -61,6 +84,7 @@ public abstract class DictionaryUtil {
"org.freedictionary.MainActivity", // Class
"Free Dictionary . org", // Title
Intent.ACTION_VIEW,
null,
"%s"
), false);
ourDictionaryInfos.put(new PackageInfo(
@ -69,6 +93,7 @@ public abstract class DictionaryUtil {
"com.slovoed.noreg.english_german.deluxe.Start", // Class
"SlovoEd Deluxe German->English", // Title
Intent.ACTION_VIEW,
null,
"%s/808464950"
), true);
ourDictionaryInfos.put(new PackageInfo(
@ -77,6 +102,7 @@ public abstract class DictionaryUtil {
"com.slovoed.noreg.english_german.deluxe.Start", // Class
"SlovoEd Deluxe English->German", // Title
Intent.ACTION_VIEW,
null,
"%s/808464949"
), true);
}
@ -126,15 +152,18 @@ public abstract class DictionaryUtil {
}
public static Intent getDictionaryIntent(PackageInfo dictionaryInfo, String text) {
final Intent intent = new Intent(dictionaryInfo.IntentAction)
.setComponent(new ComponentName(
dictionaryInfo.PackageName,
dictionaryInfo.ClassName
))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
final Intent intent = new Intent(dictionaryInfo.IntentAction);
if (dictionaryInfo.PackageName != null) {
intent.setComponent(new ComponentName(
dictionaryInfo.PackageName, dictionaryInfo.ClassName
));
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
text = dictionaryInfo.IntentDataPattern.replace("%s", text);
if (Intent.ACTION_SEARCH.equals(dictionaryInfo.IntentAction)) {
return intent.putExtra(SearchManager.QUERY, text);
if (dictionaryInfo.IntentKey != null) {
intent.putExtra(ColorDict3.HEIGHT, 300);
intent.putExtra(ColorDict3.GRAVITY, android.view.Gravity.BOTTOM);
return intent.putExtra(dictionaryInfo.IntentKey, text);
} else {
return intent.setData(Uri.parse(text));
}