Fix raster map menu crash

This commit is contained in:
max-klaus 2020-06-11 15:14:56 +03:00
parent 5b97a0b4aa
commit 19e5db7b0a

View file

@ -1,6 +1,7 @@
package net.osmand.plus.rastermaps;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@ -52,6 +53,7 @@ import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -128,8 +130,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
};
// mapView.addLayer(overlayLayer, 0.7f);
settings.MAP_OVERLAY_TRANSPARENCY.addListener(overlayLayerListener);
}
@Override
@ -138,8 +138,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
public void updateMapLayers(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap,
final MapActivityLayers layers) {
public void updateMapLayers(OsmandMapTileView mapView,
CommonPreference<String> settingsToWarnAboutMap,
MapActivityLayers layers) {
if (overlayLayer == null) {
createLayers();
}
@ -169,7 +170,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
public void updateLayer(OsmandMapTileView mapView, OsmandSettings settings,
MapTileLayer layer, CommonPreference<String> preference, float layerOrder, boolean warnWhenSelected) {
MapTileLayer layer, CommonPreference<String> preference,
float layerOrder, boolean warnWhenSelected) {
ITileSource overlay = settings.getTileSourceByName(preference.get(), warnWhenSelected);
if (!Algorithms.objectEquals(overlay, layer.getMap())) {
if (overlay == null) {
@ -186,21 +188,21 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
@NonNull final CommonPreference<String> mapPref,
@NonNull final CommonPreference<String> exMapPref,
boolean force,
@NonNull final MapActivity activity,
@NonNull final MapActivity mapActivity,
@Nullable final OnMapSelectedCallback callback) {
final MapActivityLayers layers = activity.getMapLayers();
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
if (!force && exMapPref.get() != null) {
mapPref.set(exMapPref.get());
if (callback != null) {
callback.onMapSelected(false);
}
updateMapLayers(mapView, mapPref, layers);
updateMapLayers(mapView, mapPref, mapActivity.getMapLayers());
return;
}
final OsmandSettings settings = app.getSettings();
OsmandSettings settings = app.getSettings();
Map<String, String> entriesMap = settings.getTileSourceEntries();
final ArrayList<String> keys = new ArrayList<>(entriesMap.keySet());
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(activity, app)));
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(mapActivity, getThemeRes(mapActivity)));
final String[] items = new String[entriesMap.size() + 1];
int i = 0;
for (String it : entriesMap.values()) {
@ -211,13 +213,24 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MapActivity activity = mapActivityRef.get();
if (activity == null || activity.isFinishing()) {
return;
}
if (which == items.length - 1) {
installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
TileSourceTemplate template = null;
int count = 0;
boolean cancel = false;
@Override
public boolean publish(TileSourceTemplate object) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity == null || mapActivity.isFinishing()) {
cancel = true;
return false;
}
OsmandMapTileView mapView = mapActivity.getMapView();
if (object == null) {
if (count == 1) {
mapPref.set(template.getName());
@ -225,9 +238,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
if (callback != null) {
callback.onMapSelected(false);
}
updateMapLayers(mapView, mapPref, layers);
updateMapLayers(mapView, mapPref, mapActivity.getMapLayers());
} else {
selectMapOverlayLayer(mapView, mapPref, exMapPref, false, activity, null);
selectMapOverlayLayer(mapView, mapPref, exMapPref, false, mapActivity, null);
}
} else {
count++;
@ -238,7 +251,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
@Override
public boolean isCancelled() {
return false;
return cancel;
}
});
} else {
@ -247,7 +260,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
if (callback != null) {
callback.onMapSelected(false);
}
updateMapLayers(mapView, mapPref, layers);
updateMapLayers(mapActivity.getMapView(), mapPref, activity.getMapLayers());
}
dialog.dismiss();
}
@ -266,43 +279,52 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
@Override
public void registerLayerContextMenuActions(final OsmandMapTileView mapView,
public void registerLayerContextMenuActions(OsmandMapTileView mapView,
ContextMenuAdapter adapter,
final MapActivity mapActivity) {
MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() {
@Override
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) {
int[] viewCoordinates = AndroidUtils.getCenterViewCoordinates(view);
if (itemId == R.string.layer_overlay) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP, viewCoordinates);
return false;
} else if (itemId == R.string.layer_underlay) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.UNDERLAY_MAP, viewCoordinates);
return false;
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null && !mapActivity.isFinishing()) {
int[] viewCoordinates = AndroidUtils.getCenterViewCoordinates(view);
if (itemId == R.string.layer_overlay) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP, viewCoordinates);
return false;
} else if (itemId == R.string.layer_underlay) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.UNDERLAY_MAP, viewCoordinates);
return false;
}
}
return true;
}
@Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity == null || mapActivity.isFinishing()) {
return false;
}
if (itemId == R.string.layer_overlay) {
toggleUnderlayState(mapActivity, RasterMapType.OVERLAY,
new OnMapSelectedCallback() {
@Override
public void onMapSelected(boolean canceled) {
ContextMenuItem item = adapter.getItem(pos);
String overlayMapDescr = settings.MAP_OVERLAY.get();
boolean hasOverlayDescription = overlayMapDescr != null;
overlayMapDescr = hasOverlayDescription ? overlayMapDescr
: mapActivity.getString(R.string.shared_string_none);
item.setDescription(overlayMapDescr);
item.setSelected(hasOverlayDescription);
item.setColorRes(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null && !mapActivity.isFinishing()) {
ContextMenuItem item = adapter.getItem(pos);
if (item != null) {
String overlayMapDescr = mapActivity.getMyApplication().getSettings().MAP_OVERLAY.get();
boolean hasOverlayDescription = overlayMapDescr != null;
overlayMapDescr = hasOverlayDescription ? overlayMapDescr
: mapActivity.getString(R.string.shared_string_none);
item.setDescription(overlayMapDescr);
item.setSelected(hasOverlayDescription);
item.setColorRes(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
}
}
});
return false;
@ -311,24 +333,29 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
new OnMapSelectedCallback() {
@Override
public void onMapSelected(boolean canceled) {
ContextMenuItem item = adapter.getItem(pos);
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null && !mapActivity.isFinishing()) {
ContextMenuItem item = adapter.getItem(pos);
if (item != null) {
String underlayMapDescr = settings.MAP_UNDERLAY.get();
String underlayMapDescr = settings.MAP_UNDERLAY.get();
boolean hasUnderlayDescription = underlayMapDescr != null;
underlayMapDescr = hasUnderlayDescription
? underlayMapDescr
: mapActivity.getString(R.string.shared_string_none);
boolean hasUnderlayDescription = underlayMapDescr != null;
underlayMapDescr = hasUnderlayDescription ? underlayMapDescr
: mapActivity.getString(R.string.shared_string_none);
item.setDescription(underlayMapDescr);
item.setSelected(hasUnderlayDescription);
item.setColorRes(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
item.setDescription(underlayMapDescr);
item.setSelected(hasUnderlayDescription);
item.setColorRes(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
adapter.notifyDataSetChanged();
final CommonPreference<Boolean> hidePolygonsPref =
mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
hidePolygonsPref.set(hasUnderlayDescription);
RasterMapMenu.refreshMapComplete(mapActivity);
final CommonPreference<Boolean> hidePolygonsPref =
mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
hidePolygonsPref.set(hasUnderlayDescription);
RasterMapMenu.refreshMapComplete(mapActivity);
}
}
}
});
return false;
@ -381,18 +408,23 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
@Override
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter,
Object selectedObj) {
final OsmandMapTileView mapView = mapActivity.getMapView();
if (mapView.getMainLayer() instanceof MapTileLayer) {
public void registerMapContextMenuActions(MapActivity mapActivity,
final double latitude, final double longitude,
ContextMenuAdapter adapter, Object selectedObj) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
if (mapActivity.getMapView().getMainLayer() instanceof MapTileLayer) {
ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int resId, int pos, boolean isChecked, int[] viewCoordinates) {
if (resId == R.string.context_menu_item_update_map) {
mapActivity.getMapActions().reloadTile(mapView.getZoom(), latitude, longitude);
} else if (resId == R.string.shared_string_download_map) {
DownloadTilesDialog dlg = new DownloadTilesDialog(mapActivity, (OsmandApplication) mapActivity.getApplication(), mapView);
dlg.openDialog();
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null && !mapActivity.isFinishing()) {
OsmandMapTileView mapView = mapActivity.getMapView();
if (resId == R.string.context_menu_item_update_map) {
mapActivity.getMapActions().reloadTile(mapView.getZoom(), latitude, longitude);
} else if (resId == R.string.shared_string_download_map) {
DownloadTilesDialog dlg = new DownloadTilesDialog(mapActivity, (OsmandApplication) mapActivity.getApplication(), mapView);
dlg.openDialog();
}
}
return true;
}
@ -412,10 +444,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
}
public static void installMapLayers(final Activity activity, final ResultMatcher<TileSourceTemplate> result) {
public static void installMapLayers(Activity activity, final ResultMatcher<TileSourceTemplate> result) {
final WeakReference<Activity> activityRef = new WeakReference<>(activity);
final OsmandApplication app = (OsmandApplication) activity.getApplication();
final OsmandSettings settings = app.getSettings();
final Map<String, String> entriesMap = settings.getTileSourceEntries();
OsmandSettings settings = app.getSettings();
if (!settings.isInternetConnectionAvailable(true)) {
Toast.makeText(activity, R.string.internet_not_available, Toast.LENGTH_LONG).show();
return;
@ -427,27 +459,36 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
protected void onPostExecute(final java.util.List<TileSourceTemplate> downloaded) {
Activity activity = activityRef.get();
if (activity == null || activity.isFinishing()) {
return;
}
OsmandApplication app = (OsmandApplication) activity.getApplication();
if (downloaded == null || downloaded.isEmpty()) {
Toast.makeText(activity, R.string.shared_string_io_error, Toast.LENGTH_SHORT).show();
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(activity, app)));
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(activity)));
String[] names = new String[downloaded.size()];
for (int i = 0; i < names.length; i++) {
names[i] = downloaded.get(i).getName();
}
final boolean[] selected = new boolean[downloaded.size()];
boolean nightMode = isNightMode(activity, app);
int themeResId = getThemeRes(activity, app);
boolean nightMode = isNightMode(activity);
int themeResId = getThemeRes(activity);
int selectedProfileColor = ContextCompat.getColor(app, app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode));
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createMultiChoiceAdapter(names, nightMode, selected, app,
selectedProfileColor, themeResId, new View.OnClickListener() {
@Override
public void onClick(View v) {
int which = (int) v.getTag();
selected[which] = !selected[which];
if (entriesMap.containsKey(downloaded.get(which).getName()) && selected[which]) {
Toast.makeText(activity, R.string.tile_source_already_installed, Toast.LENGTH_SHORT).show();
Activity activity = activityRef.get();
if (activity != null && !activity.isFinishing()) {
Map<String, String> entriesMap = ((OsmandApplication)activity.getApplication()).getSettings().getTileSourceEntries();
int which = (int) v.getTag();
selected[which] = !selected[which];
if (entriesMap.containsKey(downloaded.get(which).getName()) && selected[which]) {
Toast.makeText(activity, R.string.tile_source_already_installed, Toast.LENGTH_SHORT).show();
}
}
}
}
@ -458,22 +499,26 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
List<TileSourceTemplate> toInstall = new ArrayList<>();
for (int i = 0; i < selected.length; i++) {
if (selected[i]) {
toInstall.add(downloaded.get(i));
}
}
for (TileSourceTemplate ts : toInstall) {
if (settings.installTileSource(ts)) {
if (result != null) {
result.publish(ts);
Activity activity = activityRef.get();
if (activity != null && !activity.isFinishing()) {
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
List<TileSourceTemplate> toInstall = new ArrayList<>();
for (int i = 0; i < selected.length; i++) {
if (selected[i]) {
toInstall.add(downloaded.get(i));
}
}
}
// at the end publish null to show end of process
if (!toInstall.isEmpty() && result != null) {
result.publish(null);
for (TileSourceTemplate ts : toInstall) {
if (settings.installTileSource(ts)) {
if (result != null) {
result.publish(ts);
}
}
}
// at the end publish null to show end of process
if (!toInstall.isEmpty() && result != null) {
result.publish(null);
}
}
}
});
@ -483,19 +528,20 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public static void defineNewEditLayer(final Activity activity, final ResultMatcher<TileSourceTemplate> resultMatcher, final String editedLayerName) {
final OsmandApplication app = (OsmandApplication) activity.getApplication();
final OsmandSettings settings = app.getSettings();
final Map<String, String> entriesMap = settings.getTileSourceEntries(true);
public static void defineNewEditLayer(Activity activity, final ResultMatcher<TileSourceTemplate> resultMatcher, final String editedLayerName) {
final WeakReference<Activity> activityRef = new WeakReference<>(activity);
OsmandApplication app = (OsmandApplication) activity.getApplication();
OsmandSettings settings = app.getSettings();
Map<String, String> entriesMap = settings.getTileSourceEntries(true);
final SQLiteTileSource[] sqLiteTileSource = new SQLiteTileSource[1];
boolean nightMode = isNightMode(activity, app);
boolean nightMode = isNightMode(activity);
final int dp8 = AndroidUtils.dpToPx(app, 8f);
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
TileSourceTemplate ts = new TileSourceTemplate("NewMapnik", "http://mapnik.osmand.net/{0}/{1}/{2}.png",
"png", 17, 5, 256, 16, 32000);
final TileSourceTemplate[] result = new TileSourceTemplate[]{ts};
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(activity, app)));
View view = UiUtilities.getInflater(activity, isNightMode(activity, app)).inflate(R.layout.editing_tile_source, null);
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(activity)));
View view = UiUtilities.getInflater(activity, isNightMode(activity)).inflate(R.layout.editing_tile_source, null);
final EditText name = (EditText) view.findViewById(R.id.Name);
final Spinner existing = (Spinner) view.findViewById(R.id.TileSourceSpinner);
final TextView existingHint = (TextView) view.findViewById(R.id.TileSourceHint);
@ -539,10 +585,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
template.setExpirationTimeMinutes(sqLiteTileSource[0].getExpirationTimeMinutes());
template.setEllipticYTile(sqLiteTileSource[0].isEllipticYTile());
}
if (template != null) {
result[0] = template.copy();
updateTileSourceEditView(result[0], name, urlToLoad, minZoom, maxZoom, expire, elliptic);
}
result[0] = template.copy();
updateTileSourceEditView(result[0], name, urlToLoad, minZoom, maxZoom, expire, elliptic);
existingHint.setVisibility(View.GONE);
existing.setVisibility(View.GONE);
}
@ -551,13 +595,12 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position > 0) {
Activity activity = activityRef.get();
if (activity != null && !activity.isFinishing() && position > 0) {
File f = ((OsmandApplication) activity.getApplication()).getAppPath(IndexConstants.TILES_INDEX_DIR + templates.get(position));
TileSourceTemplate template = TileSourceManager.createTileSourceTemplate(f);
if (template != null) {
result[0] = template.copy();
updateTileSourceEditView(result[0], name, urlToLoad, minZoom, maxZoom, expire, elliptic);
}
result[0] = template.copy();
updateTileSourceEditView(result[0], name, urlToLoad, minZoom, maxZoom, expire, elliptic);
}
}
@ -571,29 +614,33 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
@Override
public void onClick(DialogInterface dialog, int which) {
TileSourceTemplate r = result[0];
try {
r.setName(name.getText().toString());
r.setExpirationTimeMinutes(expire.getText().length() == 0 ? -1 :
Integer.parseInt(expire.getText().toString()));
r.setMinZoom(Integer.parseInt(minZoom.getText().toString()));
r.setMaxZoom(Integer.parseInt(maxZoom.getText().toString()));
r.setEllipticYTile(elliptic.isChecked());
r.setUrlToLoad(urlToLoad.getText().toString().equals("") ? null : urlToLoad.getText().toString().replace("{$x}", "{1}")
.replace("{$y}", "{2}").replace("{$z}", "{0}"));
if (sqLiteTileSource[0] != null) {
sqLiteTileSource[0].updateFromTileSourceTemplate(r);
} else {
if (r.getName().length() > 0) {
if (settings.installTileSource(r)) {
Toast.makeText(activity, activity.getString(R.string.edit_tilesource_successfully, r.getName()),
Toast.LENGTH_SHORT).show();
resultMatcher.publish(r);
Activity activity = activityRef.get();
if (activity != null && !activity.isFinishing()) {
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
TileSourceTemplate r = result[0];
try {
r.setName(name.getText().toString());
r.setExpirationTimeMinutes(expire.getText().length() == 0 ? -1 :
Integer.parseInt(expire.getText().toString()));
r.setMinZoom(Integer.parseInt(minZoom.getText().toString()));
r.setMaxZoom(Integer.parseInt(maxZoom.getText().toString()));
r.setEllipticYTile(elliptic.isChecked());
r.setUrlToLoad(urlToLoad.getText().toString().equals("") ? null : urlToLoad.getText().toString().replace("{$x}", "{1}")
.replace("{$y}", "{2}").replace("{$z}", "{0}"));
if (sqLiteTileSource[0] != null) {
sqLiteTileSource[0].updateFromTileSourceTemplate(r);
} else {
if (r.getName().length() > 0) {
if (settings.installTileSource(r)) {
Toast.makeText(activity, activity.getString(R.string.edit_tilesource_successfully, r.getName()),
Toast.LENGTH_SHORT).show();
resultMatcher.publish(r);
}
}
}
} catch (RuntimeException e) {
Toast.makeText(activity, e.getMessage(), Toast.LENGTH_SHORT).show();
}
} catch (RuntimeException e) {
Toast.makeText(activity, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
@ -601,8 +648,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
bld.show();
}
private static void updateTileSourceEditView(TileSourceTemplate ts, EditText name, final EditText urlToLoad, final EditText minZoom,
final EditText maxZoom, EditText expire, final CheckBox elliptic) {
private static void updateTileSourceEditView(TileSourceTemplate ts, EditText name, EditText urlToLoad, EditText minZoom,
EditText maxZoom, EditText expire, CheckBox elliptic) {
minZoom.setText(String.valueOf(ts.getMinimumZoomSupported()));
maxZoom.setText(String.valueOf(ts.getMaximumZoomSupported()));
name.setText(ts.getName());
@ -626,7 +673,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
OsmandMapTileView mapView = mapActivity.getMapView();
CommonPreference<String> mapTypePreference;
CommonPreference<String> exMapTypePreference;
OsmandSettings.CommonPreference<Integer> mapTransparencyPreference;
//boolean isMapSelected;
MapTileLayer layer;
@ -663,15 +709,16 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
}
private static boolean isNightMode(Activity activity, OsmandApplication app) {
if (activity == null || app == null) {
private static boolean isNightMode(Context context) {
if (context == null) {
return false;
}
return activity instanceof MapActivity ? app.getDaynightHelper().isNightModeForMapControls() : !app.getSettings().isLightContent();
OsmandApplication app = (OsmandApplication) context.getApplicationContext();
return context instanceof MapActivity ? app.getDaynightHelper().isNightModeForMapControls() : !app.getSettings().isLightContent();
}
private static int getThemeRes(Activity activity, OsmandApplication app) {
return isNightMode(activity, app) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
private static int getThemeRes(Context context) {
return isNightMode(context) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
}
public enum RasterMapType {