Minor fixes

This commit is contained in:
Vitaliy 2020-11-23 03:27:09 +02:00
parent bb0099d17a
commit 9056c7e97b
5 changed files with 15 additions and 17 deletions

View file

@ -329,7 +329,7 @@ public class RouteDataObject {
public String getDestinationName(String lang, boolean transliterate, boolean direction){ public String getDestinationName(String lang, boolean transliterate, boolean direction){
//Issue #3289: Treat destination:ref like a destination, not like a ref //Issue #3289: Treat destination:ref like a destination, not like a ref
String destRef = ((getDestinationRef(direction) == null) || getDestinationRef(direction).equals(getRef(lang, transliterate, direction))) ? "" : getDestinationRef(direction); String destRef = ((getDestinationRef(direction) == null) || getDestinationRef(direction).equals(getRef(lang, transliterate, direction))) ? "" : getDestinationRef(direction);
String destRef1 = (destRef != null && destRef.isEmpty()) ? "" : destRef + ", "; String destRef1 = Algorithms.isEmpty(destRef) ? "" : destRef + ", ";
if(names != null) { if(names != null) {
int[] kt = names.keys(); int[] kt = names.keys();
@ -373,7 +373,7 @@ public class RouteDataObject {
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault); return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault);
} }
} }
return destRef != null && destRef.isEmpty() ? null : destRef; return Algorithms.isEmpty(destRef) ? null : destRef;
} }
public int getPoint31XTile(int i) { public int getPoint31XTile(int i) {

View file

@ -412,8 +412,8 @@ public class OsmandApplication extends MultiDexApplication {
if (defaultLocale == null) { if (defaultLocale == null) {
defaultLocale = Locale.getDefault(); defaultLocale = Locale.getDefault();
} }
if (lang != null && !lang.isEmpty()) { if (!Algorithms.isEmpty(lang)) {
if (country != null && !country.isEmpty()) { if (!Algorithms.isEmpty(country)) {
preferredLocale = new Locale(lang, country); preferredLocale = new Locale(lang, country);
} else { } else {
preferredLocale = new Locale(lang); preferredLocale = new Locale(lang);
@ -421,9 +421,9 @@ public class OsmandApplication extends MultiDexApplication {
} }
Locale selectedLocale = null; Locale selectedLocale = null;
if (lang != null && !lang.isEmpty() && !config.locale.equals(preferredLocale)) { if (!Algorithms.isEmpty(lang) && !config.locale.equals(preferredLocale)) {
selectedLocale = preferredLocale; selectedLocale = preferredLocale;
} else if (lang != null && lang.isEmpty() && defaultLocale != null && Locale.getDefault() != defaultLocale) { } else if (Algorithms.isEmpty(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) {
selectedLocale = defaultLocale; selectedLocale = defaultLocale;
preferredLocale = null; preferredLocale = null;
} }
@ -812,12 +812,12 @@ public class OsmandApplication extends MultiDexApplication {
if (preferredLocale != null) { if (preferredLocale != null) {
Configuration config = context.getResources().getConfiguration(); Configuration config = context.getResources().getConfiguration();
String lang = preferredLocale.getLanguage(); String lang = preferredLocale.getLanguage();
if (!lang.isEmpty() && !config.locale.getLanguage().equals(lang)) { if (!Algorithms.isEmpty(lang) && !config.locale.getLanguage().equals(lang)) {
preferredLocale = new Locale(lang); preferredLocale = new Locale(lang);
Locale.setDefault(preferredLocale); Locale.setDefault(preferredLocale);
config.locale = preferredLocale; config.locale = preferredLocale;
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
} else if(lang.isEmpty() && defaultLocale != null && Locale.getDefault() != defaultLocale) { } else if (Algorithms.isEmpty(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) {
Locale.setDefault(defaultLocale); Locale.setDefault(defaultLocale);
config.locale = defaultLocale; config.locale = defaultLocale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());

View file

@ -210,10 +210,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
// save file // save file
for (final Map.Entry<String, GPXFile> entry : data.entrySet()) { for (final Map.Entry<String, GPXFile> entry : data.entrySet()) {
final String f = entry.getKey(); final String f = entry.getKey();
GPXFile gpx = entry.getValue();
log.debug("Filename: " + f); log.debug("Filename: " + f);
File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT); File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT);
if (!entry.getValue().isEmpty()) { if (!gpx.isEmpty()) {
WptPt pt = entry.getValue().findPointToShow(); WptPt pt = gpx.findPointToShow();
String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$ String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$
Integer trackStorageDirectory = ctx.getSettings().TRACK_STORAGE_DIRECTORY.get(); Integer trackStorageDirectory = ctx.getSettings().TRACK_STORAGE_DIRECTORY.get();
if (!OsmandSettings.REC_DIRECTORY.equals(trackStorageDirectory)) { if (!OsmandSettings.REC_DIRECTORY.equals(trackStorageDirectory)) {
@ -236,13 +237,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
} }
} }
Exception warn = GPXUtilities.writeGpxFile(fout, entry.getValue()); Exception warn = GPXUtilities.writeGpxFile(fout, gpx);
if (warn != null) { if (warn != null) {
warnings.add(warn.getMessage()); warnings.add(warn.getMessage());
return new SaveGpxResult(warnings, new ArrayList<String>()); return new SaveGpxResult(warnings, new ArrayList<String>());
} }
GPXFile gpx = entry.getValue();
GPXTrackAnalysis analysis = gpx.getAnalysis(fout.lastModified()); GPXTrackAnalysis analysis = gpx.getAnalysis(fout.lastModified());
GpxDataItem item = new GpxDataItem(fout, analysis); GpxDataItem item = new GpxDataItem(fout, analysis);
ctx.getGpxDbHelper().add(item); ctx.getGpxDbHelper().add(item);

View file

@ -513,10 +513,9 @@ public class ImportHelper {
private File getFileToSave(final String fileName, final File importDir, final WptPt pt) { private File getFileToSave(final String fileName, final File importDir, final WptPt pt) {
final StringBuilder builder = new StringBuilder(fileName); final StringBuilder builder = new StringBuilder(fileName);
if (fileName != null && fileName.isEmpty()) { if (Algorithms.isEmpty(fileName)) {
builder.append("import_").append(new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time))).append(GPX_FILE_EXT); //$NON-NLS-1$ builder.append("import_").append(new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time))).append(GPX_FILE_EXT); //$NON-NLS-1$
} } else if (fileName.endsWith(KML_SUFFIX)) {
if (fileName.endsWith(KML_SUFFIX)) {
builder.replace(builder.length() - KML_SUFFIX.length(), builder.length(), GPX_FILE_EXT); builder.replace(builder.length() - KML_SUFFIX.length(), builder.length(), GPX_FILE_EXT);
} else if (fileName.endsWith(KMZ_SUFFIX)) { } else if (fileName.endsWith(KMZ_SUFFIX)) {
builder.replace(builder.length() - KMZ_SUFFIX.length(), builder.length(), GPX_FILE_EXT); builder.replace(builder.length() - KMZ_SUFFIX.length(), builder.length(), GPX_FILE_EXT);

View file

@ -427,7 +427,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
f.setArguments(args); f.setArguments(args);
f.show(getChildFragmentManager(), "exceedDialog"); f.show(getChildFragmentManager(), "exceedDialog");
} else if (TextUtils.isEmpty(poiTypeEditText.getText())) { } else if (TextUtils.isEmpty(poiTypeEditText.getText())) {
new HashSet<>(editPoiData.getTagValues().keySet());
if (Algorithms.isEmpty(editPoiData.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()))) { if (Algorithms.isEmpty(editPoiData.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()))) {
SaveExtraValidationDialogFragment f = new SaveExtraValidationDialogFragment(); SaveExtraValidationDialogFragment f = new SaveExtraValidationDialogFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();