Merge pull request #7788 from osmandapp/Fix_7606

Fix #7606
This commit is contained in:
max-klaus 2019-10-30 13:31:39 +03:00 committed by GitHub
commit 62b546c64e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View file

@ -27,7 +27,7 @@
android:layout_weight="1" android:layout_weight="1"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="@string/layer_poi" android:text="@string/layer_poi"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/> android:textSize="@dimen/default_list_text_size"/>
<android.support.v7.widget.AppCompatImageView <android.support.v7.widget.AppCompatImageView

View file

@ -93,17 +93,12 @@ public class MapActivityLayers {
private QuickActionRegistry quickActionRegistry; private QuickActionRegistry quickActionRegistry;
private MeasurementToolLayer measurementToolLayer; private MeasurementToolLayer measurementToolLayer;
private boolean nightMode;
private int themeRes;
private StateChangedListener<Integer> transparencyListener; private StateChangedListener<Integer> transparencyListener;
public MapActivityLayers(MapActivity activity) { public MapActivityLayers(MapActivity activity) {
this.activity = activity; this.activity = activity;
this.mapWidgetRegistry = new MapWidgetRegistry(activity.getMyApplication()); this.mapWidgetRegistry = new MapWidgetRegistry(activity.getMyApplication());
this.quickActionRegistry = new QuickActionRegistry(activity.getMyApplication().getSettings()); 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() { public QuickActionRegistry getQuickActionRegistry() {
@ -272,7 +267,7 @@ public class MapActivityLayers {
return true; return true;
} }
}; };
return GpxUiHelper.selectGPXFiles(files, activity, callbackWithObject, themeRes); return GpxUiHelper.selectGPXFiles(files, activity, callbackWithObject, getThemeRes(getApplication()));
} }
@ -289,8 +284,8 @@ public class MapActivityLayers {
} }
list.add(poiFilters.getCustomPOIFilter()); list.add(poiFilters.getCustomPOIFilter());
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !nightMode); final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !isNightMode(app));
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes)); AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(app)));
final ListView listView = new ListView(activity); final ListView listView = new ListView(activity);
listView.setDivider(null); listView.setDivider(null);
listView.setClickable(true); listView.setClickable(true);
@ -367,8 +362,8 @@ public class MapActivityLayers {
addFilterToList(adapter, list, f, false); addFilterToList(adapter, list, f, false);
} }
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !nightMode); final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !isNightMode(app));
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes)); AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(app)));
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() { builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@ -583,6 +578,16 @@ public class MapActivityLayers {
} }
} }
private boolean isNightMode(OsmandApplication app) {
if (app == null) {
return false;
}
return app.getDaynightHelper().isNightModeForMapControls();
}
private int getThemeRes(OsmandApplication app) {
return isNightMode(app) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
}
private String getString(int resId) { private String getString(int resId) {
return activity.getString(resId); return activity.getString(resId);