Merge branch 'r3.7' into searchRefactor

This commit is contained in:
vshcherb 2020-06-04 15:56:44 +02:00 committed by GitHub
commit 3ccb9bc037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 51 additions and 78 deletions

View file

@ -15,7 +15,6 @@
"Calle de las Eras (Uranización Los Corales), Navacerrada [[5, STREET, 0.310, 70.15 km]]"
],
"extra-results": [
"5, Calle Navacerrada (Urb. Las Suertes), Las Suertes [[4, HOUSE, 0.430, 60.50 km]]",
"50, Calle de Francisco Navacerrada, Salamanca [[4, HOUSE, 0.430, 26.37 km]]",
"52, Calle de Francisco Navacerrada, Salamanca [[4, HOUSE, 0.430, 26.36 km]]",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -26,9 +26,7 @@ import java.text.DecimalFormatSymbols;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import static net.osmand.data.PointDescription.getLocationOlcName;
@ -276,27 +274,13 @@ public class OsmAndFormatter {
}
}
public static Map<MetricsConstants, String> getDistanceData(OsmandApplication app, float meters) {
Map<MetricsConstants, String> results = new LinkedHashMap<>();
String kilometersAndMeters = getFormattedDistance(meters, app, true, MetricsConstants.KILOMETERS_AND_METERS);
String milesAndFeet = getFormattedDistance(meters, app, true, MetricsConstants.MILES_AND_FEET);
String milesAndMeters = getFormattedDistance(meters, app, true, MetricsConstants.MILES_AND_METERS);
String milesAndYards = getFormattedDistance(meters, app, true, MetricsConstants.MILES_AND_YARDS);
String nauticalMiles = getFormattedDistance(meters, app, true, MetricsConstants.NAUTICAL_MILES);
results.put(MetricsConstants.KILOMETERS_AND_METERS, kilometersAndMeters);
results.put(MetricsConstants.MILES_AND_FEET, milesAndFeet);
results.put(MetricsConstants.MILES_AND_METERS, milesAndMeters);
results.put(MetricsConstants.MILES_AND_YARDS, milesAndYards);
results.put(MetricsConstants.NAUTICAL_MILES, nauticalMiles);
return results;
}
public static String getFormattedAlt(double alt, OsmandApplication ctx) {
OsmandSettings settings = ctx.getSettings();
MetricsConstants mc = settings.METRIC_SYSTEM.get();
return getFormattedAlt(alt, ctx, mc);
}
public static String getFormattedAlt(double alt, OsmandApplication ctx, MetricsConstants mc) {
boolean useFeet = (mc == MetricsConstants.MILES_AND_FEET) || (mc == MetricsConstants.MILES_AND_YARDS);
if (!useFeet) {
return ((int) (alt + 0.5)) + " " + ctx.getString(R.string.m);

View file

@ -1990,7 +1990,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override
public void unlock() {
changeKeyguardFlags(true, false);
changeKeyguardFlags(true, true);
}
@Override

View file

@ -118,9 +118,11 @@ public class LockHelper implements SensorEventListener {
private void lock() {
releaseWakeLocks();
int unlockTime = turnScreenOnTime.get();
if (lockUIAdapter != null) {
if (!(useSystemScreenTimeout.get() && turnScreenOnPowerButton.get()) && unlockTime != 0) {
boolean useSystemTimeout = useSystemScreenTimeout.get();
boolean usePowerButton = useSystemTimeout && turnScreenOnPowerButton.get()
|| !useSystemTimeout && turnScreenOnTime.get() == 0 && turnScreenOnPowerButton.get();
if (!usePowerButton) {
lockUIAdapter.lock();
}
}

View file

@ -1316,7 +1316,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
int iconId = menu.getRightIconId();
int sizeId = menu.isBigRightIcon() ? R.dimen.context_menu_big_icon_size : R.dimen.standard_icon_size;
if (menu.getPointDescription().isFavorite() || menu.getPointDescription().isWpt()) {
sizeId = R.dimen.favorites_icon_size;
sizeId = R.dimen.favorites_my_places_icon_size;
}
int iconViewSize = getResources().getDimensionPixelSize(sizeId);
ViewGroup.LayoutParams params = iconView.getLayoutParams();

View file

@ -58,11 +58,13 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
public class AmenityMenuBuilder extends MenuBuilder {
@ -529,9 +531,16 @@ public class AmenityMenuBuilder extends MenuBuilder {
if ("ele".equals(key)) {
try {
float distance = Float.parseFloat(vl);
vl = OsmAndFormatter.getFormattedDistance(distance, app, true, metricSystem);
Map<MetricsConstants, String> distanceData = OsmAndFormatter.getDistanceData(app, distance);
collapsableView = getDistanceCollapsableView(new LinkedHashSet<>(distanceData.values()));
vl = OsmAndFormatter.getFormattedAlt(distance, app, metricSystem);
String collapsibleVal;
if (metricSystem == MetricsConstants.MILES_AND_FEET || metricSystem == MetricsConstants.MILES_AND_YARDS) {
collapsibleVal = OsmAndFormatter.getFormattedAlt(distance, app, MetricsConstants.KILOMETERS_AND_METERS);
} else {
collapsibleVal = OsmAndFormatter.getFormattedAlt(distance, app, MetricsConstants.MILES_AND_FEET);
}
Set<String> elevationData = new HashSet<>();
elevationData.add(collapsibleVal);
collapsableView = getDistanceCollapsableView(elevationData);
collapsable = true;
} catch (NumberFormatException ex) {
LOG.error(ex);

View file

@ -206,7 +206,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
private int getSmallIconId(String layer, int iconId) {
String iconName = view.getResources().getResourceEntryName(iconId);
return view.getResources().getIdentifier("map_" + iconName + "_" + layer + "_small"
return view.getResources().getIdentifier("ic_" + iconName + "_" + layer + "_small"
, "drawable", view.getContext().getPackageName());
}

View file

@ -11,9 +11,9 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.os.ConfigurationCompat;
import androidx.core.os.LocaleListCompat;
import androidx.fragment.app.FragmentActivity;
import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
@ -48,7 +48,6 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
private List<BottomSheetItemWithCompoundButton> languageItems;
private ArrayList<WikiLanguageItem> languages;
private CallbackWithObject<Boolean> languageChangedCallback;
private boolean isGlobalWikiPoiEnabled = false;
@Override
@ -56,6 +55,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
super.onCreate(savedInstanceState);
app = requiredMyApplication();
settings = app.getSettings();
appMode = settings.getApplicationMode();
initLanguagesData();
}
@ -192,8 +192,9 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
}
settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.setStringsListForProfile(appMode, localesForSaving);
settings.GLOBAL_WIKIPEDIA_POI_ENABLED.setModeValue(appMode, isGlobalWikiPoiEnabled);
if (languageChangedCallback != null) {
languageChangedCallback.processResult(true);
MapActivity ma = getMapActivity();
if (ma != null) {
WikipediaPoiMenu.updateWikipediaState(ma);
}
dismiss();
}
@ -227,12 +228,13 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
}
}
public void setAppMode(ApplicationMode appMode) {
this.appMode = appMode;
@Nullable
private MapActivity getMapActivity() {
FragmentActivity activity = getActivity();
if (activity instanceof MapActivity) {
return (MapActivity) activity;
}
public void setLanguageChangedCallback(CallbackWithObject<Boolean> languageChangedCallback) {
this.languageChangedCallback = languageChangedCallback;
return null;
}
private class WikiLanguageItem implements Comparable<WikiLanguageItem> {
@ -276,13 +278,9 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
}
public static void showInstance(@NonNull MapActivity mapActivity,
@NonNull ApplicationMode appMode,
boolean usedOnMap,
CallbackWithObject<Boolean> callback) {
boolean usedOnMap) {
SelectWikiLanguagesBottomSheet fragment = new SelectWikiLanguagesBottomSheet();
fragment.setAppMode(appMode);
fragment.setUsedOnMap(usedOnMap);
fragment.setLanguageChangedCallback(callback);
fragment.show(mapActivity.getSupportFragmentManager(), SelectWikiLanguagesBottomSheet.TAG);
}
}

View file

@ -38,14 +38,12 @@ public class WikipediaPoiMenu {
private MapActivity mapActivity;
private OsmandApplication app;
private OsmandSettings settings;
private ApplicationMode appMode;
private boolean nightMode;
public WikipediaPoiMenu(MapActivity mapActivity) {
this.mapActivity = mapActivity;
this.app = mapActivity.getMyApplication();
this.settings = app.getSettings();
this.appMode = settings.getApplicationMode();
this.nightMode = app.getDaynightHelper().isNightModeForMapControls();
}
@ -59,14 +57,6 @@ public class WikipediaPoiMenu {
adapter.setProfileDependent(true);
adapter.setNightMode(nightMode);
final CallbackWithObject<Boolean> callback = new CallbackWithObject<Boolean>() {
@Override
public boolean processResult(Boolean result) {
mapActivity.getDashboard().refreshContent(true);
return true;
}
};
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
@Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter,
@ -75,11 +65,11 @@ public class WikipediaPoiMenu {
app.runInUIThread(new Runnable() {
@Override
public void run() {
toggleWikipediaPoi(mapActivity, !enabled, callback);
toggleWikipediaPoi(mapActivity, !enabled, null);
}
});
} else if (itemId == languageActionStringId) {
showLanguagesDialog(mapActivity, appMode, true, callback);
SelectWikiLanguagesBottomSheet.showInstance(mapActivity, true);
}
return false;
}
@ -230,27 +220,16 @@ public class WikipediaPoiMenu {
return adapter;
}
private static void showLanguagesDialog(@NonNull final MapActivity mapActivity,
@NonNull final ApplicationMode appMode,
final boolean usedOnMap,
final CallbackWithObject<Boolean> callback) {
final OsmandApplication app = mapActivity.getMyApplication();
SelectWikiLanguagesBottomSheet.showInstance(mapActivity, appMode, usedOnMap,
new CallbackWithObject<Boolean>() {
@Override
public boolean processResult(Boolean result) {
if (result) {
public static void updateWikipediaState(MapActivity ma) {
final OsmandApplication app = ma.getMyApplication();
ApplicationMode appMode = app.getSettings().getApplicationMode();
Bundle wikiPoiSetting = getWikiPoiSettingsForProfile(app, appMode);
if (wikiPoiSetting != null) {
refreshWikipediaOnMap(mapActivity);
refreshWikipediaOnMap(ma);
} else {
toggleWikipediaPoi(mapActivity, false, callback);
toggleWikipediaPoi(ma, false, null);
}
}
return true;
}
});
}
public static String getTranslation(OsmandApplication app, String locale) {
String translation = app.getLangTranslation(locale);
@ -305,6 +284,8 @@ public class WikipediaPoiMenu {
}
if (callback != null) {
callback.processResult(enable);
} else {
mapActivity.getDashboard().refreshContent(true);
}
mapActivity.refreshMap();
}