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

PackageInfo moved inside DictionaryUtil

This commit is contained in:
Nikolay Pultsin 2013-09-17 07:03:45 +04:00
parent 4f0c868da2
commit 70cfb8e13d
3 changed files with 30 additions and 50 deletions

View file

@ -53,6 +53,28 @@ public abstract class DictionaryUtil {
private static Map<PackageInfo,Integer> ourInfos =
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 {
@Override
public boolean dontCacheAttributeValues() {
@ -120,11 +142,11 @@ public abstract class DictionaryUtil {
}
private static class BitKnightsInfoReader extends ZLXMLReaderAdapter {
private final Context mContext;
private int mCounter;
private final Context myContext;
private int myCounter;
BitKnightsInfoReader(Context context) {
mContext = context;
myContext = context;
}
@Override
@ -136,7 +158,7 @@ public abstract class DictionaryUtil {
public boolean startElementHandler(String tag, ZLStringMap attributes) {
if ("dictionary".equals(tag)) {
final PackageInfo info = new PackageInfo(
"BK" + mCounter ++,
"BK" + myCounter ++,
attributes.getValue("package"),
"com.bitknights.dict.ShareTranslateActivity",
attributes.getValue("title"),
@ -144,7 +166,7 @@ public abstract class DictionaryUtil {
null,
"%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);
}
}

View file

@ -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;
}
}

View file

@ -26,12 +26,12 @@ import android.content.Context;
import org.geometerplus.zlibrary.core.options.ZLStringOption;
import org.geometerplus.zlibrary.core.resources.ZLResource;
import org.geometerplus.android.fbreader.PackageInfo;
import org.geometerplus.android.fbreader.DictionaryUtil;
class DictionaryPreference extends ZLStringListPreference {
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);
myOption = dictionaryOption;
@ -39,7 +39,7 @@ class DictionaryPreference extends ZLStringListPreference {
final String[] values = new String[infos.size()];
final String[] texts = new String[infos.size()];
int index = 0;
for (PackageInfo i : infos) {
for (DictionaryUtil.PackageInfo i : infos) {
values[index] = i.Id;
texts[index] = i.Title;
++index;