mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
NEW: Support for SlovoEd English German Deluxe dictionary added.
This commit is contained in:
parent
6607f5139d
commit
dd109d8c3f
3 changed files with 46 additions and 13 deletions
|
@ -28,6 +28,7 @@ import android.content.ActivityNotFoundException;
|
|||
import android.content.ComponentName;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
@ -44,12 +45,30 @@ public abstract class DictionaryUtil {
|
|||
ourDictionaryInfos.add(new PackageInfo(
|
||||
"com.socialnmobile.colordict",
|
||||
"com.socialnmobile.colordict.activity.Main",
|
||||
"ColorDict"
|
||||
"ColorDict",
|
||||
null,
|
||||
true
|
||||
));
|
||||
ourDictionaryInfos.add(new PackageInfo(
|
||||
"com.ngc.fora",
|
||||
"com.ngc.fora.ForaDictionary",
|
||||
"Fora Dictionary"
|
||||
"Fora Dictionary",
|
||||
null,
|
||||
true
|
||||
));
|
||||
ourDictionaryInfos.add(new PackageInfo(
|
||||
"com.slovoed.noreg.english_german.deluxe",
|
||||
"com.slovoed.noreg.english_german.deluxe.Start",
|
||||
"SlovoEd Deluxe German->English",
|
||||
"/808464950",
|
||||
false
|
||||
));
|
||||
ourDictionaryInfos.add(new PackageInfo(
|
||||
"com.slovoed.noreg.english_german.deluxe",
|
||||
"com.slovoed.noreg.english_german.deluxe.Start",
|
||||
"SlovoEd Deluxe English->German",
|
||||
"/808464949",
|
||||
false
|
||||
));
|
||||
}
|
||||
return ourDictionaryInfos;
|
||||
|
@ -58,15 +77,15 @@ public abstract class DictionaryUtil {
|
|||
public static ZLStringOption dictionaryOption() {
|
||||
if (ourDictionaryOption == null) {
|
||||
ourDictionaryOption =
|
||||
new ZLStringOption("Dictionary", "Class", dictionaryInfos().get(0).ClassName);
|
||||
new ZLStringOption("Dictionary", "Title", dictionaryInfos().get(0).Title);
|
||||
}
|
||||
return ourDictionaryOption;
|
||||
}
|
||||
|
||||
private static PackageInfo getCurrentDictionaryInfo() {
|
||||
final String className = dictionaryOption().getValue();
|
||||
final String title = dictionaryOption().getValue();
|
||||
for (PackageInfo info : dictionaryInfos()) {
|
||||
if (info.ClassName.equals(className)) {
|
||||
if (info.Title.equals(title)) {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
@ -75,12 +94,22 @@ public abstract class DictionaryUtil {
|
|||
|
||||
public static Intent getDictionaryIntent(String text) {
|
||||
final PackageInfo dictionaryInfo = getCurrentDictionaryInfo();
|
||||
if (dictionaryInfo.UseSearchIntend) {
|
||||
return new Intent(Intent.ACTION_SEARCH)
|
||||
.setComponent(new ComponentName(
|
||||
dictionaryInfo.PackageName,
|
||||
dictionaryInfo.ClassName
|
||||
))
|
||||
.putExtra(SearchManager.QUERY, text);
|
||||
} else {
|
||||
return new Intent(Intent.ACTION_VIEW)
|
||||
.setComponent(new ComponentName(
|
||||
dictionaryInfo.PackageName,
|
||||
dictionaryInfo.ClassName
|
||||
))
|
||||
.setData(Uri.parse(text + dictionaryInfo.Argument))
|
||||
.addFlags(0x14000000);
|
||||
}
|
||||
}
|
||||
|
||||
public static void openWordInDictionary(Activity activity, String text) {
|
||||
|
|
|
@ -23,10 +23,14 @@ public class PackageInfo {
|
|||
public final String PackageName;
|
||||
public final String ClassName;
|
||||
public final String Title;
|
||||
public final String Argument;
|
||||
public final boolean UseSearchIntend;
|
||||
|
||||
PackageInfo(String packageName, String className, String title) {
|
||||
PackageInfo(String packageName, String className, String title, String argument, boolean useSearchIntend) {
|
||||
PackageName = packageName;
|
||||
ClassName = className;
|
||||
Title = title;
|
||||
Argument = argument;
|
||||
UseSearchIntend = useSearchIntend;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class DictionaryPreference extends ZLStringListPreference {
|
|||
final String[] texts = new String[infos.size()];
|
||||
int index = 0;
|
||||
for (PackageInfo i : infos) {
|
||||
values[index] = i.ClassName;
|
||||
values[index] = i.Title;
|
||||
texts[index] = i.Title;
|
||||
++index;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue