mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
PackageInfo moved inside DictionaryUtil
This commit is contained in:
parent
4f0c868da2
commit
70cfb8e13d
3 changed files with 30 additions and 50 deletions
|
@ -53,6 +53,28 @@ public abstract class DictionaryUtil {
|
||||||
private static Map<PackageInfo,Integer> ourInfos =
|
private static Map<PackageInfo,Integer> ourInfos =
|
||||||
Collections.synchronizedMap(new LinkedHashMap<PackageInfo,Integer>());
|
Collections.synchronizedMap(new LinkedHashMap<PackageInfo,Integer>());
|
||||||
|
|
||||||
|
public static class PackageInfo {
|
||||||
|
public final String Id;
|
||||||
|
public final String PackageName;
|
||||||
|
public final String ClassName;
|
||||||
|
public final String Title;
|
||||||
|
|
||||||
|
public final String IntentAction;
|
||||||
|
public final String IntentKey;
|
||||||
|
public final String IntentDataPattern;
|
||||||
|
|
||||||
|
PackageInfo(String id, String packageName, String className, String title, String intentAction, String intentKey, String intentDataPattern) {
|
||||||
|
Id = id;
|
||||||
|
PackageName = packageName;
|
||||||
|
ClassName = className;
|
||||||
|
Title = title;
|
||||||
|
|
||||||
|
IntentAction = intentAction;
|
||||||
|
IntentKey = intentKey;
|
||||||
|
IntentDataPattern = intentDataPattern;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class InfoReader extends ZLXMLReaderAdapter {
|
private static class InfoReader extends ZLXMLReaderAdapter {
|
||||||
@Override
|
@Override
|
||||||
public boolean dontCacheAttributeValues() {
|
public boolean dontCacheAttributeValues() {
|
||||||
|
@ -120,11 +142,11 @@ public abstract class DictionaryUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BitKnightsInfoReader extends ZLXMLReaderAdapter {
|
private static class BitKnightsInfoReader extends ZLXMLReaderAdapter {
|
||||||
private final Context mContext;
|
private final Context myContext;
|
||||||
private int mCounter;
|
private int myCounter;
|
||||||
|
|
||||||
BitKnightsInfoReader(Context context) {
|
BitKnightsInfoReader(Context context) {
|
||||||
mContext = context;
|
myContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,7 +158,7 @@ public abstract class DictionaryUtil {
|
||||||
public boolean startElementHandler(String tag, ZLStringMap attributes) {
|
public boolean startElementHandler(String tag, ZLStringMap attributes) {
|
||||||
if ("dictionary".equals(tag)) {
|
if ("dictionary".equals(tag)) {
|
||||||
final PackageInfo info = new PackageInfo(
|
final PackageInfo info = new PackageInfo(
|
||||||
"BK" + mCounter ++,
|
"BK" + myCounter ++,
|
||||||
attributes.getValue("package"),
|
attributes.getValue("package"),
|
||||||
"com.bitknights.dict.ShareTranslateActivity",
|
"com.bitknights.dict.ShareTranslateActivity",
|
||||||
attributes.getValue("title"),
|
attributes.getValue("title"),
|
||||||
|
@ -144,7 +166,7 @@ public abstract class DictionaryUtil {
|
||||||
null,
|
null,
|
||||||
"%s"
|
"%s"
|
||||||
);
|
);
|
||||||
if (PackageUtil.canBeStarted(mContext, getDictionaryIntent(info, "test"), false)) {
|
if (PackageUtil.canBeStarted(myContext, getDictionaryIntent(info, "test"), false)) {
|
||||||
ourInfos.put(info, FLAG_SHOW_AS_DICTIONARY | FLAG_INSTALLED_ONLY);
|
ourInfos.put(info, FLAG_SHOW_AS_DICTIONARY | FLAG_INSTALLED_ONLY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2010-2013 Geometer Plus <contact@geometerplus.com>
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
public class PackageInfo {
|
|
||||||
public final String Id;
|
|
||||||
public final String PackageName;
|
|
||||||
public final String ClassName;
|
|
||||||
public final String Title;
|
|
||||||
|
|
||||||
public final String IntentAction;
|
|
||||||
public final String IntentKey;
|
|
||||||
public final String IntentDataPattern;
|
|
||||||
|
|
||||||
PackageInfo(String id, String packageName, String className, String title, String intentAction, String intentKey, String intentDataPattern) {
|
|
||||||
Id = id;
|
|
||||||
PackageName = packageName;
|
|
||||||
ClassName = className;
|
|
||||||
Title = title;
|
|
||||||
|
|
||||||
IntentAction = intentAction;
|
|
||||||
IntentKey = intentKey;
|
|
||||||
IntentDataPattern = intentDataPattern;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,12 +26,12 @@ import android.content.Context;
|
||||||
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
import org.geometerplus.android.fbreader.PackageInfo;
|
import org.geometerplus.android.fbreader.DictionaryUtil;
|
||||||
|
|
||||||
class DictionaryPreference extends ZLStringListPreference {
|
class DictionaryPreference extends ZLStringListPreference {
|
||||||
private final ZLStringOption myOption;
|
private final ZLStringOption myOption;
|
||||||
|
|
||||||
DictionaryPreference(Context context, ZLResource resource, String resourceKey, ZLStringOption dictionaryOption, List<PackageInfo> infos) {
|
DictionaryPreference(Context context, ZLResource resource, String resourceKey, ZLStringOption dictionaryOption, List<DictionaryUtil.PackageInfo> infos) {
|
||||||
super(context, resource, resourceKey);
|
super(context, resource, resourceKey);
|
||||||
|
|
||||||
myOption = dictionaryOption;
|
myOption = dictionaryOption;
|
||||||
|
@ -39,7 +39,7 @@ class DictionaryPreference extends ZLStringListPreference {
|
||||||
final String[] values = new String[infos.size()];
|
final String[] values = new String[infos.size()];
|
||||||
final String[] texts = new String[infos.size()];
|
final String[] texts = new String[infos.size()];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (PackageInfo i : infos) {
|
for (DictionaryUtil.PackageInfo i : infos) {
|
||||||
values[index] = i.Id;
|
values[index] = i.Id;
|
||||||
texts[index] = i.Title;
|
texts[index] = i.Title;
|
||||||
++index;
|
++index;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue