mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
first experiments with colordict 3
This commit is contained in:
parent
24c2fe7074
commit
3cb4674893
2 changed files with 41 additions and 10 deletions
|
@ -37,14 +37,36 @@ public abstract class DictionaryUtil {
|
||||||
new LinkedHashMap<PackageInfo,Boolean>();
|
new LinkedHashMap<PackageInfo,Boolean>();
|
||||||
private static ZLStringOption ourDictionaryOption;
|
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() {
|
private static Map<PackageInfo,Boolean> infos() {
|
||||||
if (ourDictionaryInfos.isEmpty()) {
|
if (ourDictionaryInfos.isEmpty()) {
|
||||||
ourDictionaryInfos.put(new PackageInfo(
|
ourDictionaryInfos.put(new PackageInfo(
|
||||||
"ColorDict", // Id
|
"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", // Package
|
||||||
"com.socialnmobile.colordict.activity.Main", // Class
|
"com.socialnmobile.colordict.activity.Main", // Class
|
||||||
"ColorDict", // Title
|
"ColorDict Old Style", // Title
|
||||||
Intent.ACTION_SEARCH,
|
Intent.ACTION_SEARCH,
|
||||||
|
SearchManager.QUERY,
|
||||||
"%s"
|
"%s"
|
||||||
), false);
|
), false);
|
||||||
ourDictionaryInfos.put(new PackageInfo(
|
ourDictionaryInfos.put(new PackageInfo(
|
||||||
|
@ -53,6 +75,7 @@ public abstract class DictionaryUtil {
|
||||||
"com.ngc.fora.ForaDictionary", // Class
|
"com.ngc.fora.ForaDictionary", // Class
|
||||||
"Fora Dictionary", // Title
|
"Fora Dictionary", // Title
|
||||||
Intent.ACTION_SEARCH,
|
Intent.ACTION_SEARCH,
|
||||||
|
SearchManager.QUERY,
|
||||||
"%s"
|
"%s"
|
||||||
), false);
|
), false);
|
||||||
ourDictionaryInfos.put(new PackageInfo(
|
ourDictionaryInfos.put(new PackageInfo(
|
||||||
|
@ -61,6 +84,7 @@ public abstract class DictionaryUtil {
|
||||||
"org.freedictionary.MainActivity", // Class
|
"org.freedictionary.MainActivity", // Class
|
||||||
"Free Dictionary . org", // Title
|
"Free Dictionary . org", // Title
|
||||||
Intent.ACTION_VIEW,
|
Intent.ACTION_VIEW,
|
||||||
|
null,
|
||||||
"%s"
|
"%s"
|
||||||
), false);
|
), false);
|
||||||
ourDictionaryInfos.put(new PackageInfo(
|
ourDictionaryInfos.put(new PackageInfo(
|
||||||
|
@ -69,6 +93,7 @@ public abstract class DictionaryUtil {
|
||||||
"com.slovoed.noreg.english_german.deluxe.Start", // Class
|
"com.slovoed.noreg.english_german.deluxe.Start", // Class
|
||||||
"SlovoEd Deluxe German->English", // Title
|
"SlovoEd Deluxe German->English", // Title
|
||||||
Intent.ACTION_VIEW,
|
Intent.ACTION_VIEW,
|
||||||
|
null,
|
||||||
"%s/808464950"
|
"%s/808464950"
|
||||||
), true);
|
), true);
|
||||||
ourDictionaryInfos.put(new PackageInfo(
|
ourDictionaryInfos.put(new PackageInfo(
|
||||||
|
@ -77,6 +102,7 @@ public abstract class DictionaryUtil {
|
||||||
"com.slovoed.noreg.english_german.deluxe.Start", // Class
|
"com.slovoed.noreg.english_german.deluxe.Start", // Class
|
||||||
"SlovoEd Deluxe English->German", // Title
|
"SlovoEd Deluxe English->German", // Title
|
||||||
Intent.ACTION_VIEW,
|
Intent.ACTION_VIEW,
|
||||||
|
null,
|
||||||
"%s/808464949"
|
"%s/808464949"
|
||||||
), true);
|
), true);
|
||||||
}
|
}
|
||||||
|
@ -126,15 +152,18 @@ public abstract class DictionaryUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Intent getDictionaryIntent(PackageInfo dictionaryInfo, String text) {
|
public static Intent getDictionaryIntent(PackageInfo dictionaryInfo, String text) {
|
||||||
final Intent intent = new Intent(dictionaryInfo.IntentAction)
|
final Intent intent = new Intent(dictionaryInfo.IntentAction);
|
||||||
.setComponent(new ComponentName(
|
if (dictionaryInfo.PackageName != null) {
|
||||||
dictionaryInfo.PackageName,
|
intent.setComponent(new ComponentName(
|
||||||
dictionaryInfo.ClassName
|
dictionaryInfo.PackageName, dictionaryInfo.ClassName
|
||||||
))
|
));
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
}
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
text = dictionaryInfo.IntentDataPattern.replace("%s", text);
|
text = dictionaryInfo.IntentDataPattern.replace("%s", text);
|
||||||
if (Intent.ACTION_SEARCH.equals(dictionaryInfo.IntentAction)) {
|
if (dictionaryInfo.IntentKey != null) {
|
||||||
return intent.putExtra(SearchManager.QUERY, text);
|
intent.putExtra(ColorDict3.HEIGHT, 300);
|
||||||
|
intent.putExtra(ColorDict3.GRAVITY, android.view.Gravity.BOTTOM);
|
||||||
|
return intent.putExtra(dictionaryInfo.IntentKey, text);
|
||||||
} else {
|
} else {
|
||||||
return intent.setData(Uri.parse(text));
|
return intent.setData(Uri.parse(text));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,15 +26,17 @@ public class PackageInfo {
|
||||||
public final String Title;
|
public final String Title;
|
||||||
|
|
||||||
public final String IntentAction;
|
public final String IntentAction;
|
||||||
|
public final String IntentKey;
|
||||||
public final String IntentDataPattern;
|
public final String IntentDataPattern;
|
||||||
|
|
||||||
PackageInfo(String id, String packageName, String className, String title, String intentAction, String intentDataPattern) {
|
PackageInfo(String id, String packageName, String className, String title, String intentAction, String intentKey, String intentDataPattern) {
|
||||||
Id = id;
|
Id = id;
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
ClassName = className;
|
ClassName = className;
|
||||||
Title = title;
|
Title = title;
|
||||||
|
|
||||||
IntentAction = intentAction;
|
IntentAction = intentAction;
|
||||||
|
IntentKey = intentKey;
|
||||||
IntentDataPattern = intentDataPattern;
|
IntentDataPattern = intentDataPattern;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue