Merge pull request #7809 from osmandapp/Fix_7606

Support night theme for Overlay / Underlay (Fix #7606)
This commit is contained in:
max-klaus 2019-10-31 14:04:41 +03:00 committed by GitHub
commit d1d785e336
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View file

@ -462,7 +462,7 @@ public class MapActivityLayers {
final List<Entry<String, String>> entriesMapList = new ArrayList<>(entriesMap.entrySet());
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(getApplication())));
String selectedTileSourceKey = settings.MAP_TILE_SOURCES.get();

View file

@ -6,6 +6,7 @@ import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
@ -31,6 +32,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandSettings.LayerTransparencySeekbarMode;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version;
import net.osmand.plus.activities.DownloadTilesDialog;
import net.osmand.plus.activities.MapActivity;
@ -186,7 +188,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
final OsmandSettings settings = app.getSettings();
Map<String, String> entriesMap = settings.getTileSourceEntries();
final ArrayList<String> keys = new ArrayList<>(entriesMap.keySet());
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(activity, app)));
final String[] items = new String[entriesMap.size() + 1];
int i = 0;
for (String it : entriesMap.values()) {
@ -423,7 +425,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
Toast.makeText(activity, R.string.shared_string_io_error, Toast.LENGTH_SHORT).show();
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(activity, app)));
String[] names = new String[downloaded.size()];
for (int i = 0; i < names.length; i++) {
names[i] = downloaded.get(i).getName();
@ -477,8 +479,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
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(activity);
View view = activity.getLayoutInflater().inflate(R.layout.editing_tile_source, null);
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);
final EditText name = (EditText) view.findViewById(R.id.Name);
final Spinner existing = (Spinner) view.findViewById(R.id.TileSourceSpinner);
final EditText urlToLoad = (EditText) view.findViewById(R.id.URLToLoad);
@ -610,6 +612,17 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
}
private static boolean isNightMode(Activity activity, OsmandApplication app) {
if (activity == null || app == null) {
return false;
}
return activity 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;
}
public enum RasterMapType {
OVERLAY,
UNDERLAY