mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
different options for 'dictionary' and 'translator'
This commit is contained in:
parent
5df9f5fd9a
commit
48913e6404
23 changed files with 217 additions and 117 deletions
|
@ -165,6 +165,17 @@ public abstract class DictionaryUtil {
|
|||
}
|
||||
|
||||
public static void openTextInDictionary(Activity activity, String text, boolean singleWord, int selectionTop, int selectionBottom) {
|
||||
if (singleWord) {
|
||||
int start = 0;
|
||||
int end = text.length();
|
||||
for (; start < end && !Character.isLetterOrDigit(text.charAt(start)); ++start);
|
||||
for (; start < end && !Character.isLetterOrDigit(text.charAt(end - 1)); --end);
|
||||
if (start == end) {
|
||||
return;
|
||||
}
|
||||
text = text.substring(start, end);
|
||||
}
|
||||
|
||||
final PackageInfo info = getCurrentDictionaryInfo(singleWord);
|
||||
final Intent intent = getDictionaryIntent(info, text);
|
||||
try {
|
||||
|
@ -190,17 +201,8 @@ public abstract class DictionaryUtil {
|
|||
}
|
||||
|
||||
public static void openWordInDictionary(Activity activity, ZLTextWord word, ZLTextRegion region) {
|
||||
final String text = word.toString();
|
||||
int start = 0;
|
||||
int end = text.length();
|
||||
for (; start < end && !Character.isLetterOrDigit(text.charAt(start)); ++start);
|
||||
for (; start < end && !Character.isLetterOrDigit(text.charAt(end - 1)); --end);
|
||||
if (start == end) {
|
||||
return;
|
||||
}
|
||||
|
||||
openTextInDictionary(
|
||||
activity, text.substring(start, end), true, region.getTop(), region.getBottom()
|
||||
activity, word.toString(), true, region.getTop(), region.getBottom()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue