Remove client context interface
This commit is contained in:
parent
e316c81d6f
commit
607ddc17b7
8 changed files with 22 additions and 45 deletions
|
@ -6,6 +6,9 @@ import org.apache.commons.logging.Log;
|
|||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import android.util.Xml;
|
||||
|
||||
/**
|
||||
* That class is replacing of standard LogFactory due to
|
||||
|
@ -22,7 +25,6 @@ import org.xmlpull.v1.XmlPullParserFactory;
|
|||
*/
|
||||
public class PlatformUtil {
|
||||
public static String TAG = "net.osmand"; //$NON-NLS-1$
|
||||
public static boolean AVIAN_LIBRARY = false;
|
||||
private static class OsmandLogImplementation implements Log {
|
||||
|
||||
private final String fullName;
|
||||
|
@ -159,7 +161,12 @@ public class PlatformUtil {
|
|||
}
|
||||
|
||||
public static XmlPullParser newXMLPullParser() throws XmlPullParserException {
|
||||
return XmlPullParserFactory.newInstance().newPullParser();
|
||||
// return XmlPullParserFactory.newInstance().newPullParser();
|
||||
return Xml.newPullParser();
|
||||
}
|
||||
|
||||
public static XmlSerializer newSerializer() {
|
||||
return Xml.newSerializer();
|
||||
}
|
||||
|
||||
public static net.osmand.Collator primaryCollator(){
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class GPXUtilities {
|
||||
public final static Log log = PlatformUtil.getLog(GPXUtilities.class);
|
||||
|
||||
|
@ -179,7 +181,7 @@ public class GPXUtilities {
|
|||
SimpleDateFormat format = new SimpleDateFormat(GPX_TIME_FORMAT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
output = new FileOutputStream(fout);
|
||||
XmlSerializer serializer = ctx.getInternalAPI().newSerializer();
|
||||
XmlSerializer serializer = PlatformUtil.newSerializer();
|
||||
serializer.setOutput(output, "UTF-8"); //$NON-NLS-1$
|
||||
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); //$NON-NLS-1$
|
||||
serializer.startDocument("UTF-8", true); //$NON-NLS-1$
|
||||
|
@ -332,7 +334,7 @@ public class GPXUtilities {
|
|||
return text;
|
||||
}
|
||||
|
||||
public static GPXFile loadGPXFile(ClientContext ctx, File f) {
|
||||
public static GPXFile loadGPXFile(Context ctx, File f) {
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(f);
|
||||
|
@ -355,12 +357,12 @@ public class GPXUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static GPXFile loadGPXFile(ClientContext ctx, InputStream f) {
|
||||
public static GPXFile loadGPXFile(Context ctx, InputStream f) {
|
||||
GPXFile res = new GPXFile();
|
||||
SimpleDateFormat format = new SimpleDateFormat(GPX_TIME_FORMAT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
try {
|
||||
XmlPullParser parser = ctx.getInternalAPI().newPullParser();
|
||||
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||
parser.setInput(getUTF8Reader(f)); //$NON-NLS-1$
|
||||
Stack<GPXExtensions> parserState = new Stack<GPXExtensions>();
|
||||
boolean extensionReadMode = false;
|
||||
|
|
|
@ -64,7 +64,7 @@ public class NameFinderPoiFilter extends PoiFilter {
|
|||
log.info(urlq);
|
||||
URL url = new URL(urlq); //$NON-NLS-1$
|
||||
InputStream stream = url.openStream();
|
||||
XmlPullParser parser = application.getInternalAPI().newPullParser();
|
||||
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||
parser.setInput(stream, "UTF-8"); //$NON-NLS-1$
|
||||
int eventType;
|
||||
int namedDepth= 0;
|
||||
|
|
|
@ -50,7 +50,7 @@ public class SpecialPhrases {
|
|||
* @param lang the language to use
|
||||
* @throws IOException when reading the text file failed
|
||||
*/
|
||||
public static void setLanguage(ClientContext ctx, OsmandSettings settings) throws IOException {
|
||||
public static void setLanguage(OsmandApplication ctx, OsmandSettings settings) throws IOException {
|
||||
String lang = getPreferredLanguage(settings).getLanguage();
|
||||
m = new HashMap<String, String>();
|
||||
// The InputStream opens the resourceId and sends it to the buffer
|
||||
|
@ -58,10 +58,10 @@ public class SpecialPhrases {
|
|||
BufferedReader br = null;
|
||||
try {
|
||||
try {
|
||||
is = ctx.getInternalAPI().openAsset("specialphrases/specialphrases_" + lang + ".txt");
|
||||
is = ctx.getAssets().open("specialphrases/specialphrases_" + lang + ".txt");
|
||||
} catch (IOException ex) {
|
||||
// second try: default to English, if this fails, the error is thrown outside
|
||||
is = ctx.getInternalAPI().openAsset("specialphrases/specialphrases_en.txt");
|
||||
is = ctx.getAssets().open("specialphrases/specialphrases_en.txt");
|
||||
}
|
||||
br = new BufferedReader(new InputStreamReader(is));
|
||||
String readLine = null;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.access;
|
||||
|
||||
import android.content.Context;
|
||||
import net.osmand.plus.ClientContext;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
|
@ -14,7 +15,7 @@ public enum RelativeDirectionStyle {
|
|||
this.key = key;
|
||||
}
|
||||
|
||||
public String toHumanString(ClientContext ctx) {
|
||||
public String toHumanString(Context ctx) {
|
||||
return ctx.getString(key);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,13 @@
|
|||
package net.osmand.plus.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.plus.PoiFilter;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
public interface InternalOsmAndAPI {
|
||||
|
||||
public XmlSerializer newSerializer();
|
||||
|
||||
public XmlPullParser newPullParser();
|
||||
|
||||
public InputStream openAsset(String name) throws IOException;
|
||||
|
||||
public List<Amenity> searchAmenities(PoiFilter filter,
|
||||
double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
|
||||
double lat, double lon, ResultMatcher<Amenity> matcher);
|
||||
|
|
|
@ -4,22 +4,16 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.NativeLibrary;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.PoiFilter;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Build;
|
||||
import android.util.Xml;
|
||||
|
||||
public class InternalOsmAndAPIImpl implements InternalOsmAndAPI {
|
||||
|
@ -30,21 +24,6 @@ public class InternalOsmAndAPIImpl implements InternalOsmAndAPI {
|
|||
this.app = app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlSerializer newSerializer() {
|
||||
return Xml.newSerializer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlPullParser newPullParser() {
|
||||
return Xml.newPullParser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream openAsset(String name) throws IOException {
|
||||
return app.getAssets().open(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Amenity> searchAmenities(PoiFilter filter, double topLatitude, double leftLongitude, double bottomLatitude,
|
||||
|
|
|
@ -385,7 +385,7 @@ public class GpxUiHelper {
|
|||
GPXFile r = currentFile;
|
||||
for(String fname : filename) {
|
||||
final File f = new File(dir, fname);
|
||||
GPXFile res = GPXUtilities.loadGPXFile((ClientContext) activity.getApplication(), f);
|
||||
GPXFile res = GPXUtilities.loadGPXFile(activity.getApplication(), f);
|
||||
GPXUtilities.mergeGPXFileInto(res, r);
|
||||
r = res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue