1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-06 03:50:19 +02:00

separate class for Lingvo

This commit is contained in:
Nikolay Pultsin 2015-06-12 16:06:33 +01:00
parent 7772bf7edd
commit c6c5e1588f
3 changed files with 64 additions and 23 deletions

View file

@ -50,7 +50,6 @@
action="com.abbyy.mobile.lingvo.intent.action.TRANSLATE"
dataKey="com.abbyy.mobile.lingvo.intent.extra.TEXT"
role="dictionary"
supportsTargetLanguage="true"
/>
<dictionary
id="Lingo Quiz Lite"

View file

@ -32,10 +32,8 @@ import android.net.Uri;
import android.os.Looper;
import android.os.Parcelable;
import android.util.DisplayMetrics;
import android.util.Xml;
import android.view.View;
import com.abbyy.mobile.lingvo.api.MinicardContract;
import com.paragon.dictionary.fbreader.OpenDictionaryFlyout;
import com.paragon.open.dictionary.api.Dictionary;
import com.paragon.open.dictionary.api.OpenDictionaryAPI;
@ -122,8 +120,8 @@ public abstract class DictionaryUtil {
}
private static class PlainPackageInfo extends PackageInfo {
PlainPackageInfo(String id, String title, boolean supportsTargetLanguageSetting) {
super(id, title, supportsTargetLanguageSetting);
PlainPackageInfo(String id, String title) {
super(id, title, false);
}
@Override
@ -131,17 +129,7 @@ public abstract class DictionaryUtil {
final Intent intent = getDictionaryIntent(text);
try {
final String id = getId();
if ("ABBYY Lingvo".equals(id)) {
intent.putExtra(MinicardContract.EXTRA_GRAVITY, frameMetrics.Gravity);
intent.putExtra(MinicardContract.EXTRA_HEIGHT, frameMetrics.Height);
intent.putExtra(MinicardContract.EXTRA_FORCE_LEMMATIZATION, true);
intent.putExtra(MinicardContract.EXTRA_TRANSLATE_VARIANTS, true);
intent.putExtra(MinicardContract.EXTRA_LIGHT_THEME, true);
final String targetLanguage = TargetLanguageOption.getValue();
if (!Language.ANY_CODE.equals(targetLanguage)) {
intent.putExtra(MinicardContract.EXTRA_LANGUAGE_TO, targetLanguage);
}
} else if ("ColorDict".equals(id)) {
if ("ColorDict".equals(id)) {
intent.putExtra(ColorDict3.HEIGHT, frameMetrics.Height);
intent.putExtra(ColorDict3.GRAVITY, frameMetrics.Gravity);
final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
@ -201,12 +189,10 @@ public abstract class DictionaryUtil {
final PackageInfo info;
if ("dictan".equals(id)) {
info = new Dictan(id, title);
} else if ("ABBYY Lingvo".equals(id)) {
info = new Lingvo(id, title);
} else {
info = new PlainPackageInfo(
id,
title,
"true".equals(attributes.getValue("supportsTargetLanguage"))
);
info = new PlainPackageInfo(id, title);
}
for (int i = attributes.getLength() - 1; i >= 0; --i) {
info.put(attributes.getLocalName(i), attributes.getValue(i));
@ -231,8 +217,7 @@ public abstract class DictionaryUtil {
final PackageInfo info = new PlainPackageInfo(
"BK" + myCounter ++,
attributes.getValue("title"),
false
attributes.getValue("title")
);
for (int i = attributes.getLength() - 1; i >= 0; --i) {
info.put(attributes.getLocalName(i), attributes.getValue(i));

View file

@ -0,0 +1,57 @@
/*
* Copyright (C) 2010-2015 FBReader.ORG Limited <contact@fbreader.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
package org.geometerplus.android.fbreader.dict;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import com.abbyy.mobile.lingvo.api.MinicardContract;
import org.geometerplus.zlibrary.core.language.Language;
import org.geometerplus.android.fbreader.FBReader;
final class Lingvo extends DictionaryUtil.PackageInfo {
Lingvo(String id, String title) {
super(id, title, true);
}
@Override
void open(String text, Runnable outliner, FBReader fbreader, DictionaryUtil.PopupFrameMetric frameMetrics) {
final Intent intent = getDictionaryIntent(text);
intent.putExtra(MinicardContract.EXTRA_GRAVITY, frameMetrics.Gravity);
intent.putExtra(MinicardContract.EXTRA_HEIGHT, frameMetrics.Height);
intent.putExtra(MinicardContract.EXTRA_FORCE_LEMMATIZATION, true);
intent.putExtra(MinicardContract.EXTRA_TRANSLATE_VARIANTS, true);
intent.putExtra(MinicardContract.EXTRA_LIGHT_THEME, true);
final String targetLanguage = DictionaryUtil.TargetLanguageOption.getValue();
if (!Language.ANY_CODE.equals(targetLanguage)) {
intent.putExtra(MinicardContract.EXTRA_LANGUAGE_TO, targetLanguage);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
try {
fbreader.startActivity(intent);
fbreader.overridePendingTransition(0, 0);
} catch (ActivityNotFoundException e) {
DictionaryUtil.installDictionaryIfNotInstalled(fbreader, this);
}
}
}