aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormax-klaus <53395422+max-klaus@users.noreply.github.com>2019-10-18 20:24:30 +0300
committerGitHub <noreply@github.com>2019-10-18 20:24:30 +0300
commit6b31bf45cba74b9edd904b1bdaa92fafaa144cdd (patch)
treec615261371b42624ac65ee4ade23ed72079ef17f
parentab74acd2c99bfeb87d3012d45312031d885052dc (diff)
parent9d50cf4f15d063cffb32023f5d9daa1533383899 (diff)
downloadOsmand-6b31bf45cba74b9edd904b1bdaa92fafaa144cdd.tar.gz
Merge pull request #7699 from osmandapp/Fix_7606
Fix #7606
-rw-r--r--OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java4
-rw-r--r--OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java17
-rw-r--r--OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java81
-rw-r--r--OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java27
-rw-r--r--OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java2
-rw-r--r--OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java2
-rw-r--r--OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java2
7 files changed, 78 insertions, 57 deletions
diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java
index a5ed402e78..0fee27c79f 100644
--- a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java
+++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java
@@ -16,6 +16,7 @@ import android.widget.Toast;
import net.osmand.CallbackWithObject;
import net.osmand.GPXUtilities;
import net.osmand.Location;
+import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
@@ -78,6 +79,7 @@ public class OsmAndLocationSimulation {
public void onClick(DialogInterface dialog, int which) {
boolean gpxNavigation = radioGPX.isChecked();
if (gpxNavigation) {
+ boolean nightMode = ma instanceof MapActivity ? app.getDaynightHelper().isNightModeForMapControls() : !app.getSettings().isLightContent();
GpxUiHelper.selectGPXFile(ma, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
@Override
public boolean processResult(GPXUtilities.GPXFile[] result) {
@@ -88,7 +90,7 @@ public class OsmAndLocationSimulation {
}
return true;
}
- });
+ }, nightMode);
} else {
List<Location> currentRoute = app.getRoutingHelper().getCurrentCalculatedRoute();
if (currentRoute.isEmpty()) {
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
index 71849b7298..e64769f88a 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
@@ -5,6 +5,7 @@ import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
+import android.support.v7.view.ContextThemeWrapper;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
@@ -91,6 +92,9 @@ public class MapActivityLayers {
private MapWidgetRegistry mapWidgetRegistry;
private QuickActionRegistry quickActionRegistry;
private MeasurementToolLayer measurementToolLayer;
+
+ private boolean nightMode;
+ private int themeRes;
private StateChangedListener<Integer> transparencyListener;
@@ -98,6 +102,8 @@ public class MapActivityLayers {
this.activity = activity;
this.mapWidgetRegistry = new MapWidgetRegistry(activity.getMyApplication());
this.quickActionRegistry = new QuickActionRegistry(activity.getMyApplication().getSettings());
+ this.nightMode = activity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
+ this.themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
}
public QuickActionRegistry getQuickActionRegistry() {
@@ -266,7 +272,7 @@ public class MapActivityLayers {
return true;
}
};
- return GpxUiHelper.selectGPXFiles(files, activity, callbackWithObject);
+ return GpxUiHelper.selectGPXFiles(files, activity, callbackWithObject, themeRes);
}
@@ -283,8 +289,8 @@ public class MapActivityLayers {
}
list.add(poiFilters.getCustomPOIFilter());
- final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
- AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !nightMode);
+ AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
final ListView listView = new ListView(activity);
listView.setDivider(null);
listView.setClickable(true);
@@ -361,9 +367,8 @@ public class MapActivityLayers {
addFilterToList(adapter, list, f, false);
}
- final ArrayAdapter<ContextMenuItem> listAdapter =
- adapter.createListAdapter(activity, app.getSettings().isLightContent());
- AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !nightMode);
+ AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
index 4f8cc4bb93..8b1d2a47fe 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
@@ -9,6 +9,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
+import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.AppCompatCheckedTextView;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
@@ -114,6 +115,8 @@ public class ConfigureMapMenu {
public ContextMenuAdapter createListAdapter(final MapActivity ma) {
OsmandApplication app = ma.getMyApplication();
+ boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
+ int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
ContextMenuAdapter adapter = new ContextMenuAdapter();
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
adapter.addItem(new ContextMenuItem.ItemBuilder()
@@ -138,8 +141,8 @@ public class ConfigureMapMenu {
}
}
}
- createLayersItems(customRules, adapter, ma);
- createRenderingAttributeItems(customRules, adapter, ma);
+ createLayersItems(customRules, adapter, ma, themeRes);
+ createRenderingAttributeItems(customRules, adapter, ma, themeRes, nightMode);
return adapter;
}
@@ -284,7 +287,7 @@ public class ConfigureMapMenu {
}
}
- private void createLayersItems(List<RenderingRuleProperty> customRules, ContextMenuAdapter adapter, final MapActivity activity) {
+ private void createLayersItems(List<RenderingRuleProperty> customRules, ContextMenuAdapter adapter, final MapActivity activity, final int themeRes) {
final OsmandApplication app = activity.getMyApplication();
final OsmandSettings settings = app.getSettings();
LayerMenuListener l = new LayerMenuListener(activity, adapter);
@@ -398,7 +401,7 @@ public class ConfigureMapMenu {
}
private void showTransportDialog(final ArrayAdapter<ContextMenuItem> ad, final int pos) {
- final AlertDialog.Builder b = new AlertDialog.Builder(activity);
+ final AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
b.setTitle(activity.getString(R.string.rendering_category_transport));
final int[] iconIds = new int[transportPrefs.size()];
@@ -425,7 +428,7 @@ public class ConfigureMapMenu {
}
}
- adapter = new ArrayAdapter<CharSequence>(activity, R.layout.popup_list_item_icon24_and_menu, R.id.title, vals) {
+ adapter = new ArrayAdapter<CharSequence>(new ContextThemeWrapper(activity, themeRes), R.layout.popup_list_item_icon24_and_menu, R.id.title, vals) {
@NonNull
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
@@ -545,7 +548,8 @@ public class ConfigureMapMenu {
}
private void createRenderingAttributeItems(List<RenderingRuleProperty> customRules,
- final ContextMenuAdapter adapter, final MapActivity activity) {
+ final ContextMenuAdapter adapter, final MapActivity activity,
+ final int themeRes, final boolean nightMode) {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity)
.setId(MAP_RENDERING_CATEGORY_ID)
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
@@ -570,7 +574,7 @@ public class ConfigureMapMenu {
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId,
final int pos, boolean isChecked, int[] viewCoordinates) {
final OsmandMapTileView view = activity.getMapView();
- AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
+ AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
bld.setTitle(R.string.daynight);
final String[] items = new String[OsmandSettings.DayNightMode.values().length];
for (int i = 0; i < items.length; i++) {
@@ -608,7 +612,7 @@ public class ConfigureMapMenu {
final int pos, boolean isChecked, int[] viewCoordinates) {
final OsmandMapTileView view = activity.getMapView();
final OsmandSettings.OsmandPreference<Float> mapDensity = view.getSettings().MAP_DENSITY;
- final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
+ AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
int p = (int) (mapDensity.get() * 100);
final TIntArrayList tlist = new TIntArrayList(new int[]{25, 33, 50, 75, 100, 125, 150, 200, 300, 400});
final List<String> values = new ArrayList<>();
@@ -658,7 +662,7 @@ public class ConfigureMapMenu {
}).createItem());
ContextMenuItem props;
- props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR, ROAD_STYLE_ID);
+ props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR, ROAD_STYLE_ID, themeRes);
if (props != null) {
adapter.addItem(props);
}
@@ -671,7 +675,7 @@ public class ConfigureMapMenu {
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId,
final int pos, boolean isChecked, int[] viewCoordinates) {
final OsmandMapTileView view = activity.getMapView();
- AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
+ AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
// test old descr as title
b.setTitle(R.string.text_size);
final Float[] txtValues = new Float[]{0.75f, 1f, 1.25f, 1.5f, 2f, 3f};
@@ -711,7 +715,7 @@ public class ConfigureMapMenu {
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId,
final int pos, boolean isChecked, int[] viewCoordinates) {
final OsmandMapTileView view = activity.getMapView();
- final AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
+ AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
b.setTitle(activity.getString(R.string.map_locale));
@@ -735,7 +739,7 @@ public class ConfigureMapMenu {
}
};
- final ArrayAdapter<CharSequence> singleChoiceAdapter = new ArrayAdapter<CharSequence>(activity, R.layout.single_choice_switch_item, R.id.text1, txtValues) {
+ final ArrayAdapter<CharSequence> singleChoiceAdapter = new ArrayAdapter<CharSequence>(new ContextThemeWrapper(view.getContext(), themeRes), R.layout.single_choice_switch_item, R.id.text1, txtValues) {
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
@@ -794,17 +798,17 @@ public class ConfigureMapMenu {
}).createItem());
props = createProperties(customRules, null, R.string.rendering_category_transport, R.drawable.ic_action_bus_dark,
- "transport", null, adapter, activity, true, TRANSPORT_RENDERING_ID);
+ "transport", null, adapter, activity, true, TRANSPORT_RENDERING_ID, themeRes, nightMode);
if (props != null) {
adapter.addItem(props);
}
props = createProperties(customRules, null, R.string.rendering_category_details, R.drawable.ic_action_layers_dark,
- "details", null, adapter, activity, true, DETAILS_ID);
+ "details", null, adapter, activity, true, DETAILS_ID, themeRes, nightMode);
if (props != null) {
adapter.addItem(props);
}
props = createProperties(customRules, null, R.string.rendering_category_hide, R.drawable.ic_action_hide,
- "hide", null, adapter, activity, true, HIDE_ID);
+ "hide", null, adapter, activity, true, HIDE_ID, themeRes, nightMode);
if (props != null) {
adapter.addItem(props);
}
@@ -816,7 +820,7 @@ public class ConfigureMapMenu {
}
}
props = createProperties(customRules, customRulesIncluded, R.string.rendering_category_routes, R.drawable.ic_action_map_routes,
- "routes", null, adapter, activity, true, ROUTES_ID);
+ "routes", null, adapter, activity, true, ROUTES_ID, themeRes, nightMode);
if (props != null) {
adapter.addItem(props);
}
@@ -824,7 +828,7 @@ public class ConfigureMapMenu {
if (getCustomRenderingPropertiesSize(customRules) > 0) {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.rendering_category_others, activity)
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
- createCustomRenderingProperties(adapter, activity, customRules);
+ createCustomRenderingProperties(adapter, activity, customRules, themeRes);
}
}
@@ -879,7 +883,9 @@ public class ConfigureMapMenu {
final ContextMenuAdapter adapter,
final MapActivity activity,
final boolean useDescription,
- final String id) {
+ final String id,
+ final int themeRes,
+ final boolean nightMode) {
final List<RenderingRuleProperty> ps = new ArrayList<>();
final List<OsmandSettings.CommonPreference<Boolean>> prefs = new ArrayList<>();
@@ -928,7 +934,7 @@ public class ConfigureMapMenu {
activity.getMapLayers().updateLayers(activity.getMapView());
} else {
showPreferencesDialog(adapter, a, pos, activity, activity.getString(strId), ps, prefs,
- useDescription, defaultSettings, true, customRulesIncluded);
+ useDescription, defaultSettings, true, customRulesIncluded, themeRes, nightMode);
}
return false;
}
@@ -968,7 +974,7 @@ public class ConfigureMapMenu {
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> a, View view, int itemId,
int pos) {
showPreferencesDialog(adapter, a, pos, activity, activity.getString(strId), ps, prefs,
- useDescription, defaultSettings, false, customRulesIncluded);
+ useDescription, defaultSettings, false, customRulesIncluded, themeRes, nightMode);
return false;
}
});
@@ -1010,9 +1016,11 @@ public class ConfigureMapMenu {
final boolean useDescription,
ListStringPreference defaultSettings,
boolean useDefault,
- final List<RenderingRuleProperty> customRulesIncluded) {
+ final List<RenderingRuleProperty> customRulesIncluded,
+ final int themeRes,
+ final boolean nightMode) {
- AlertDialog.Builder bld = new AlertDialog.Builder(activity);
+ AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
boolean[] checkedItems = new boolean[prefs.size()];
final boolean[] tempPrefs = new boolean[prefs.size()];
for (int i = 0; i < prefs.size(); i++) {
@@ -1095,8 +1103,7 @@ public class ConfigureMapMenu {
final OsmandSettings.CommonPreference<String> pref = activity.getMyApplication().getSettings()
.getCustomRenderProperty(p.getAttrName());
- LayoutInflater inflater = activity.getLayoutInflater();
- View spinnerView = inflater.inflate(R.layout.spinner_rule_layout, null);
+ View spinnerView = View.inflate(new ContextThemeWrapper(activity, themeRes), R.layout.spinner_rule_layout, null);
TextView title = (TextView) spinnerView.findViewById(R.id.title);
final Spinner spinner = (Spinner) spinnerView.findViewById(R.id.spinner);
TextView description = (TextView) spinnerView.findViewById(R.id.description);
@@ -1125,7 +1132,7 @@ public class ConfigureMapMenu {
p.getPossibleValues()[j]);
}
- StringSpinnerArrayAdapter arrayAdapter = new StringSpinnerArrayAdapter(activity);
+ StringSpinnerArrayAdapter arrayAdapter = new StringSpinnerArrayAdapter(activity, nightMode);
for (String val : possibleValuesString) {
arrayAdapter.add(val);
}
@@ -1189,10 +1196,10 @@ public class ConfigureMapMenu {
}
private void createCustomRenderingProperties(final ContextMenuAdapter adapter, final MapActivity activity,
- List<RenderingRuleProperty> customRules) {
+ List<RenderingRuleProperty> customRules, final int themeRes) {
for (final RenderingRuleProperty p : customRules) {
if (isPropertyAccepted(p)) {
- adapter.addItem(createRenderingProperty(adapter, activity, 0, p, CUSTOM_RENDERING_ITEMS_ID_SCHEME + p.getName()));
+ adapter.addItem(createRenderingProperty(adapter, activity, 0, p, CUSTOM_RENDERING_ITEMS_ID_SCHEME + p.getName(), themeRes));
}
}
}
@@ -1209,17 +1216,19 @@ public class ConfigureMapMenu {
private ContextMenuItem createRenderingProperty(final List<RenderingRuleProperty> customRules,
final ContextMenuAdapter adapter, final MapActivity activity,
- @DrawableRes final int icon, final String attrName, String id) {
+ @DrawableRes final int icon, final String attrName, String id,
+ final int themeRes) {
for (final RenderingRuleProperty p : customRules) {
if (p.getAttrName().equals(attrName)) {
- return createRenderingProperty(adapter, activity, icon, p, id);
+ return createRenderingProperty(adapter, activity, icon, p, id, themeRes);
}
}
return null;
}
private ContextMenuItem createRenderingProperty(final ContextMenuAdapter adapter, final MapActivity activity,
- @DrawableRes final int icon, final RenderingRuleProperty p, final String id) {
+ @DrawableRes final int icon, final RenderingRuleProperty p, final String id,
+ final int themeRes) {
final OsmandMapTileView view = activity.getMapView();
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(),
p.getName());
@@ -1259,7 +1268,7 @@ public class ConfigureMapMenu {
@Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad,
final int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
- AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
+ AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
// test old descr as title
b.setTitle(propertyDescr);
@@ -1310,13 +1319,13 @@ public class ConfigureMapMenu {
private class StringSpinnerArrayAdapter extends ArrayAdapter<String> {
- private boolean lightTheme;
+ private boolean nightMode;
- public StringSpinnerArrayAdapter(Context context) {
+ public StringSpinnerArrayAdapter(Context context, boolean nightMode) {
super(context, android.R.layout.simple_spinner_item);
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
OsmandApplication app = (OsmandApplication )getContext().getApplicationContext();
- lightTheme = app.getSettings().isLightContent();
+ this.nightMode = nightMode;
}
@Override
@@ -1325,7 +1334,7 @@ public class ConfigureMapMenu {
String text = getItem(position);
label.setText(text);
- label.setTextColor(!lightTheme ?
+ label.setTextColor(nightMode ?
ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_dark) : ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_light));
return label;
}
@@ -1336,7 +1345,7 @@ public class ConfigureMapMenu {
String text = getItem(position);
label.setText(text);
- label.setTextColor(!lightTheme ?
+ label.setTextColor(nightMode ?
ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_dark) : ContextCompat.getColorStateList(getContext(), R.color.text_color_primary_light));
return label;
diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
index 5350a4b1ad..4f1a852cfd 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
@@ -23,6 +23,7 @@ import android.support.v7.widget.SwitchCompat;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.util.TypedValue;
+import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
@@ -219,7 +220,8 @@ public class GpxUiHelper {
}
public static AlertDialog selectGPXFiles(List<String> selectedGpxList, final Activity activity,
- final CallbackWithObject<GPXFile[]> callbackWithObject) {
+ final CallbackWithObject<GPXFile[]> callbackWithObject,
+ int dialogThemeRes) {
OsmandApplication app = (OsmandApplication) activity.getApplication();
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
final List<GPXInfo> allGpxList = getSortedGPXFilesInfo(dir, selectedGpxList, false);
@@ -229,11 +231,13 @@ public class GpxUiHelper {
allGpxList.add(0, new GPXInfo(activity.getString(R.string.show_current_gpx_title), 0, 0));
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(allGpxList, selectedGpxList, true);
- return createDialog(activity, true, true, true, callbackWithObject, allGpxList, adapter);
+ return createDialog(activity, true, true, true, callbackWithObject, allGpxList, adapter, dialogThemeRes);
}
public static AlertDialog selectGPXFile(final Activity activity,
- final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject<GPXFile[]> callbackWithObject) {
+ final boolean showCurrentGpx, final boolean multipleChoice,
+ final CallbackWithObject<GPXFile[]> callbackWithObject, boolean nightMode) {
+ int dialogThemeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
OsmandApplication app = (OsmandApplication) activity.getApplication();
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
final List<GPXInfo> list = getSortedGPXFilesInfo(dir, null, false);
@@ -246,7 +250,7 @@ public class GpxUiHelper {
}
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(list, null, showCurrentGpx);
- return createDialog(activity, showCurrentGpx, multipleChoice, false, callbackWithObject, list, adapter);
+ return createDialog(activity, showCurrentGpx, multipleChoice, false, callbackWithObject, list, adapter, dialogThemeRes);
}
return null;
}
@@ -439,11 +443,12 @@ public class GpxUiHelper {
final boolean showAppearanceSetting,
final CallbackWithObject<GPXFile[]> callbackWithObject,
final List<GPXInfo> list,
- final ContextMenuAdapter adapter) {
+ final ContextMenuAdapter adapter,
+ final int themeRes) {
final OsmandApplication app = (OsmandApplication) activity.getApplication();
final DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(activity);
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
- AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
final int layout = R.layout.gpx_track_item;
final Map<String, String> gpxAppearanceParams = new HashMap<>();
@@ -479,7 +484,7 @@ public class GpxUiHelper {
View v = convertView;
boolean checkLayout = getItemViewType(position) == 0;
if (v == null) {
- v = activity.getLayoutInflater().inflate(layout, null);
+ v = View.inflate(new ContextThemeWrapper(activity, themeRes), layout, null);
}
if (dataItems == null) {
@@ -546,7 +551,7 @@ public class GpxUiHelper {
if (trackWidthProp == null || trackColorProp == null) {
builder.setTitle(R.string.show_gpx);
} else {
- final View apprTitleView = activity.getLayoutInflater().inflate(R.layout.select_gpx_appearance_title, null);
+ final View apprTitleView = View.inflate(new ContextThemeWrapper(activity, themeRes), R.layout.select_gpx_appearance_title, null);
final OsmandSettings.CommonPreference<String> prefWidth
= app.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR);
@@ -558,14 +563,14 @@ public class GpxUiHelper {
apprTitleView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- final ListPopupWindow popup = new ListPopupWindow(activity);
+ final ListPopupWindow popup = new ListPopupWindow(new ContextThemeWrapper(activity, themeRes));
popup.setAnchorView(apprTitleView);
popup.setContentWidth(AndroidUtils.dpToPx(activity, 200f));
popup.setModal(true);
popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(activity, -48f));
popup.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f));
- final GpxAppearanceAdapter gpxApprAdapter = new GpxAppearanceAdapter(activity,
+ final GpxAppearanceAdapter gpxApprAdapter = new GpxAppearanceAdapter(new ContextThemeWrapper(activity, themeRes),
gpxAppearanceParams.containsKey(CURRENT_TRACK_COLOR_ATTR) ? gpxAppearanceParams.get(CURRENT_TRACK_COLOR_ATTR) : prefColor.get(),
GpxAppearanceAdapter.GpxAppearanceAdapterType.TRACK_WIDTH_COLOR);
popup.setAdapter(gpxApprAdapter);
@@ -669,7 +674,7 @@ public class GpxUiHelper {
if (position == 0 && showCurrentGpx && item.getSelected()) {
OsmandMonitoringPlugin monitoringPlugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
if (monitoringPlugin == null) {
- AlertDialog.Builder confirm = new AlertDialog.Builder(activity);
+ AlertDialog.Builder confirm = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
confirm.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java
index 44b9a1aa32..7f0826304e 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java
@@ -376,7 +376,7 @@ public class RoutePreferencesMenu {
mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange();
return true;
}
- });
+ }, app.getDaynightHelper().isNightModeForMapControls());
}
private void updateSpinnerItems(final TextView gpxSpinner) {
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
index 8590bb43a4..d356fc0c82 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
@@ -885,7 +885,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
}
};
- return GpxUiHelper.selectGPXFile(mapActivity, false, false, callbackWithObject);
+ return GpxUiHelper.selectGPXFile(mapActivity, false, false, callbackWithObject, nightMode);
}
private void applyMovePointMode() {
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
index dbe9633c44..3b11ca88a4 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
@@ -412,7 +412,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
routingHelper.recalculateRouteDueToSettingsChange();
return true;
}
- });
+ }, nightMode);
}
private void showOptionsMenu(final TextView gpxSpinner) {