diff --git a/OsmAnd-java/build.gradle b/OsmAnd-java/build.gradle index a2f264f236..7df79e528e 100644 --- a/OsmAnd-java/build.gradle +++ b/OsmAnd-java/build.gradle @@ -82,18 +82,17 @@ dependencies { testImplementation 'junit:junit:4.12' testImplementation 'com.google.code.gson:gson:2.8.2' testImplementation 'org.hamcrest:hamcrest-core:1.3' - - implementation group: 'commons-logging', name: 'commons-logging', version: '1.2' - implementation group: 'org.json', name: 'json', version: '20171018' + implementation 'commons-logging:commons-logging:1.2' + implementation 'org.json:json:20171018' implementation 'it.unibo.alice.tuprolog:tuprolog:3.2.1' implementation 'org.beanshell:bsh-core:2.0b4' implementation 'org.apache.commons:commons-compress:1.17' implementation 'com.moparisthebest:junidecode:0.1.1' implementation 'com.vividsolutions:jts-core:1.14.0' - implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' +// implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' implementation 'net.sf.kxml:kxml2:2.1.8' - - - implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation files('libs/kuromoji-core-1.0-SNAPSHOT.jar') + implementation files('libs/kuromoji-ipadic-1.0-SNAPSHOT.jar') } diff --git a/OsmAnd-java/libs/kuromoji-core-1.0-SNAPSHOT.jar b/OsmAnd-java/libs/kuromoji-core-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000..7b850bbb90 Binary files /dev/null and b/OsmAnd-java/libs/kuromoji-core-1.0-SNAPSHOT.jar differ diff --git a/OsmAnd-java/libs/kuromoji-ipadic-1.0-SNAPSHOT.jar b/OsmAnd-java/libs/kuromoji-ipadic-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000..23f8a89eb4 Binary files /dev/null and b/OsmAnd-java/libs/kuromoji-ipadic-1.0-SNAPSHOT.jar differ diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapAddressReaderAdapter.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapAddressReaderAdapter.java index 09f3442dfe..b99bd972e1 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapAddressReaderAdapter.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapAddressReaderAdapter.java @@ -152,7 +152,7 @@ public class BinaryMapAddressReaderAdapter { switch (tag) { case 0: if (region.enName == null || region.enName.length() == 0) { - region.enName = region.name == null ? "" : TransliterationHelper.getInstance().transliterateText(region.name); + region.enName = region.name == null ? "" : TransliterationHelper.getInstance().transliterate(region.name); } return; case OsmandOdb.OsmAndAddressIndex.NAME_FIELD_NUMBER: diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java index 65290641f8..66fe0fa5ad 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java @@ -435,7 +435,7 @@ public class BinaryMapTransportReaderAdapter { dataObject.setEnName(stringTable.get(dataObject.getEnName(false).charAt(0))); } if(dataObject.getName().length() > 0 && dataObject.getName("en").length() == 0){ - dataObject.setEnName(TransliterationHelper.getInstance().transliterateText(dataObject.getName())); + dataObject.setEnName(TransliterationHelper.getInstance().transliterate(dataObject.getName())); } if(dataObject.getOperator() != null && dataObject.getOperator().length() > 0){ dataObject.setOperator(stringTable.get(dataObject.getOperator().charAt(0))); @@ -547,7 +547,7 @@ public class BinaryMapTransportReaderAdapter { case 0: dataObject.setReferencesToRoutes(req.cacheTypes.toArray()); if(dataObject.getName("en").length() == 0){ - dataObject.setEnName(TransliterationHelper.getInstance().transliterateText(dataObject.getName())); + dataObject.setEnName(TransliterationHelper.getInstance().transliterate(dataObject.getName())); } return dataObject; case OsmandOdb.TransportStop.ROUTES_FIELD_NUMBER : @@ -611,7 +611,7 @@ public class BinaryMapTransportReaderAdapter { switch (tag) { case 0: if (dataObject.getName("en").length() == 0) { - dataObject.setEnName(TransliterationHelper.getInstance().transliterateText(dataObject.getName())); + dataObject.setEnName(TransliterationHelper.getInstance().transliterate(dataObject.getName())); } if (x != 0 || y != 0) { dataObject.setLocation(BinaryMapIndexReader.TRANSPORT_STOP_ZOOM, x, y); diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java index e7e14046f7..85af1b2cf8 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java @@ -261,7 +261,7 @@ public class RouteDataObject { } String nmDef = names.get(region.nameTypeRule); if(transliterate && nmDef != null && nmDef.length() > 0) { - return TransliterationHelper.getInstance().transliterateText(nmDef); + return TransliterationHelper.getInstance().transliterate(nmDef); } return nmDef; } @@ -295,7 +295,7 @@ public class RouteDataObject { } String refDefault = names.get(region.refTypeRule); if(transliterate && refDefault != null && refDefault.length() > 0) { - return TransliterationHelper.getInstance().transliterateText(refDefault); + return TransliterationHelper.getInstance().transliterate(refDefault); } return refDefault; } @@ -358,13 +358,13 @@ public class RouteDataObject { int k = kt[i]; if(region.routeEncodingRules.size() > k) { if(!Algorithms.isEmpty(lang) && destinationTagLangFB.equals(region.routeEncodingRules.get(k).getTag())) { - return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterateText(names.get(k)) : names.get(k)); + return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterate(names.get(k)) : names.get(k)); } if(destinationTagFB.equals(region.routeEncodingRules.get(k).getTag())) { - return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterateText(names.get(k)) : names.get(k)); + return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterate(names.get(k)) : names.get(k)); } if(!Algorithms.isEmpty(lang) && destinationTagLang.equals(region.routeEncodingRules.get(k).getTag())) { - return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterateText(names.get(k)) : names.get(k)); + return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterate(names.get(k)) : names.get(k)); } if(destinationTagDefault.equals(region.routeEncodingRules.get(k).getTag())) { destinationDefault = names.get(k); @@ -372,7 +372,7 @@ public class RouteDataObject { } } if(destinationDefault != null) { - return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterateText(destinationDefault) : destinationDefault); + return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterate(destinationDefault) : destinationDefault); } } return "".equals(destRef) ? null : destRef; diff --git a/OsmAnd-java/src/main/java/net/osmand/data/MapObject.java b/OsmAnd-java/src/main/java/net/osmand/data/MapObject.java index d7132963f0..f326d02a6c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/MapObject.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/MapObject.java @@ -184,7 +184,7 @@ public abstract class MapObject implements Comparable { return nm; } if (transliterate) { - return TransliterationHelper.getInstance().transliterateText(getName()); + return TransliterationHelper.getInstance().transliterate(getName()); // return Junidecode.unidecode(getName()); } } @@ -197,7 +197,7 @@ public abstract class MapObject implements Comparable { if (!Algorithms.isEmpty(enName)) { return this.enName; } else if (!Algorithms.isEmpty(getName()) && transliterate) { - return TransliterationHelper.getInstance().transliterateText(getName()); + return TransliterationHelper.getInstance().transliterate(getName()); // return Junidecode.unidecode(getName()); } return ""; //$NON-NLS-1$ diff --git a/OsmAnd-java/src/main/java/net/osmand/util/TransliterationHelper.java b/OsmAnd-java/src/main/java/net/osmand/util/TransliterationHelper.java index cba5b26fe6..76ecab9ebc 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/TransliterationHelper.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/TransliterationHelper.java @@ -19,11 +19,12 @@ public class TransliterationHelper { private static String country = DEFAULT; - private Tokenizer tokenizer; + private static Tokenizer tokenizer; - private Map katakanaMap = new HashMap<>(); + private static Map katakanaMap = new HashMap<>(); - private TransliterationHelper(){} + private TransliterationHelper() { + } static { try { @@ -45,8 +46,8 @@ public class TransliterationHelper { return country; } - public String transliterateText(String text) { - if(tokenizer==null){ + public static String transliterate(String text) { + if (tokenizer == null) { tokenizer = new Tokenizer(); } switch (country) { @@ -58,12 +59,11 @@ public class TransliterationHelper { return text; } - private String japanese2Romaji(String input) { + private static String japanese2Romaji(String text) { boolean capitalizeWords = true; - - List tokens = tokenizer.tokenize(input); + List tokens = tokenizer.tokenize(text); StringBuilder builder = new StringBuilder(); if (katakanaMap.isEmpty()) { @@ -94,8 +94,7 @@ public class TransliterationHelper { builder.append(romaji.substring(1)); } else { if (token.getSurface() - .equals(token.getPronunciation())) - { + .equals(token.getPronunciation())) { romaji = romaji.toUpperCase(); } builder.append(romaji); @@ -107,7 +106,7 @@ public class TransliterationHelper { return builder.toString(); } - private String convertKanaToRomaji(String s) { + private static String convertKanaToRomaji(String s) { StringBuilder t = new StringBuilder(); for (int i = 0; i < s.length(); i++) { if (i <= s.length() - 2) { @@ -132,7 +131,7 @@ public class TransliterationHelper { return t.toString(); } - private void initKanaMap(){ + private static void initKanaMap() { katakanaMap.put("ア", "a"); katakanaMap.put("イ", "i"); katakanaMap.put("ウ", "u"); diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index c54ad3c9ac..8d65a120ae 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -373,59 +373,50 @@ task appStart(type: Exec) { project.logger.warn("Analytics enabled for free version: $analytics") dependencies { - implementation project(path: ':OsmAnd-java', configuration: 'android') - if (analytics) { - implementation 'com.google.firebase:firebase-core:12.0.1' - implementation 'com.google.firebase:firebase-messaging:12.0.1' - implementation 'com.google.firebase:firebase-iid:12.0.1' - implementation 'com.google.firebase:firebase-config:12.0.1' - implementation 'com.facebook.android:facebook-android-sdk:4.31.0' - } - implementation 'com.android.support:multidex:1.0.1' - implementation 'com.android.support:gridlayout-v7:27.1.1' - implementation 'com.android.support:cardview-v7:27.1.1' - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support:design:27.1.1' - implementation 'com.android.support:customtabs:27.1.1' - implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs') - - implementation group: 'commons-logging', name: 'commons-logging', version: '1.2' - implementation 'commons-codec:commons-codec:1.11' - implementation 'it.unibo.alice.tuprolog:tuprolog:3.2.1' - implementation 'org.beanshell:bsh-core:2.0b4' - implementation 'org.apache.commons:commons-compress:1.17' - implementation 'com.moparisthebest:junidecode:0.1.1' - implementation 'org.immutables:gson:2.5.0' - implementation 'com.vividsolutions:jts-core:1.14.0' - - implementation 'com.squareup.picasso:picasso:2.71828' - // JS core - implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9' - - - - -// size restrictions -// implementation 'com.ibm.icu:icu4j:50.1' -// implementation 'net.sf.trove4j:trove4j:3.0.3' - - qtcoreImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs') - qtcoredebugImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs') - - legacyImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" - qtcoredebugImplementation "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" - qtcoredebugImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" - qtcoreImplementation "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar" - qtcoreImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" - implementation ("com.getkeepsafe.taptargetview:taptargetview:1.12.0"){ - exclude group: 'com.android.support' - } - implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1' - implementation ("com.github.HITGIF:TextFieldBoxes:1.3.5"){ - exclude group: 'com.android.support' - } - - implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' + implementation project(path: ':OsmAnd-java', configuration: 'android') + if (analytics) { + implementation 'com.google.firebase:firebase-core:12.0.1' + implementation 'com.google.firebase:firebase-messaging:12.0.1' + implementation 'com.google.firebase:firebase-iid:12.0.1' + implementation 'com.google.firebase:firebase-config:12.0.1' + implementation 'com.facebook.android:facebook-android-sdk:4.31.0' + } + implementation 'com.android.support:multidex:1.0.1' + implementation 'com.android.support:gridlayout-v7:27.1.1' + implementation 'com.android.support:cardview-v7:27.1.1' + implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:design:27.1.1' + implementation 'com.android.support:customtabs:27.1.1' + implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs') + implementation 'commons-logging:commons-logging:1.2' + implementation 'commons-codec:commons-codec:1.11' + implementation 'it.unibo.alice.tuprolog:tuprolog:3.2.1' + implementation 'org.beanshell:bsh-core:2.0b4' + implementation 'org.apache.commons:commons-compress:1.17' + implementation 'com.moparisthebest:junidecode:0.1.1' + implementation 'org.immutables:gson:2.5.0' + implementation 'com.vividsolutions:jts-core:1.14.0' + implementation 'com.squareup.picasso:picasso:2.71828' + // JS core + implementation 'org.mozilla:rhino:1.7.9' + // size restrictions + // implementation 'com.ibm.icu:icu4j:50.1' + // implementation 'net.sf.trove4j:trove4j:3.0.3' + qtcoreImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs') + qtcoredebugImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs') + legacyImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" + qtcoredebugImplementation "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" + qtcoredebugImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" + qtcoreImplementation "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar" + qtcoreImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" + implementation('com.getkeepsafe.taptargetview:taptargetview:1.12.0') { + exclude group: 'com.android.support' + } + implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1' + implementation('com.github.HITGIF:TextFieldBoxes:1.3.5') { + exclude group: 'com.android.support' + } + implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' } if(analytics) { println "Apply GMS plugin" diff --git a/OsmAnd/src/net/osmand/plus/poi/NominatimPoiFilter.java b/OsmAnd/src/net/osmand/plus/poi/NominatimPoiFilter.java index 258dc3b593..4831b8a16d 100644 --- a/OsmAnd/src/net/osmand/plus/poi/NominatimPoiFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/NominatimPoiFilter.java @@ -137,7 +137,7 @@ public class NominatimPoiFilter extends PoiUIFilter { a.setId(Long.parseLong(parser.getAttributeValue("", "place_id"))); //$NON-NLS-1$ //$NON-NLS-2$ String name = parser.getAttributeValue("", "display_name"); //$NON-NLS-1$//$NON-NLS-2$ a.setName(name); - a.setEnName(TransliterationHelper.getInstance().transliterateText(getName())); + a.setEnName(TransliterationHelper.getInstance().transliterate(getName())); a.setSubType(parser.getAttributeValue("", "type")); //$NON-NLS-1$//$NON-NLS-2$ PoiType pt = poiTypes.getPoiTypeByKey(a.getSubType()); a.setType(pt != null ? pt.getCategory() : poiTypes.getOtherPoiCategory()); @@ -153,7 +153,7 @@ public class NominatimPoiFilter extends PoiUIFilter { String name = parser.getText(); if (name != null) { a.setName(name); - a.setEnName(TransliterationHelper.getInstance().transliterateText(getName())); + a.setEnName(TransliterationHelper.getInstance().transliterate(getName())); } } } diff --git a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java index 25ac423808..4ad4990e95 100644 --- a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java @@ -241,7 +241,7 @@ public class TextRenderer { TextDrawInfo text = rc.textToDraw.get(i); if (text.text != null && text.text.length() > 0) { if (preferredLocale.length() > 0) { - text.text = TransliterationHelper.getInstance().transliterateText(text.text); + text.text = TransliterationHelper.getInstance().transliterate(text.text); } diff --git a/gradle.properties b/gradle.properties index 3bb8ab935d..5230a4c9b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m -# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit