Logic fix

This commit is contained in:
madwasp79 2019-03-18 10:27:20 +02:00
parent bc94d1a4c7
commit ac50aef203

View file

@ -21,17 +21,10 @@ public class DayNightModeAction extends QuickAction {
@Override @Override
public void execute(MapActivity activity) { public void execute(MapActivity activity) {
switch (activity.getMyApplication().getSettings().DAYNIGHT_MODE.get()){ if (activity.getMyApplication().getDaynightHelper().isNightMode()) {
case DAY: { activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.NIGHT); } else {
break; activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.NIGHT);
}
case NIGHT:
case AUTO:
case SENSOR: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
}
} }
} }
@ -47,18 +40,20 @@ public class DayNightModeAction extends QuickAction {
@Override @Override
public int getIconRes(Context context) { public int getIconRes(Context context) {
if (context instanceof MapActivity if (context instanceof MapActivity
&& !((MapActivity) context).getMyApplication().getDaynightHelper().isNightMode()) { && ((MapActivity) context).getMyApplication().getDaynightHelper().isNightMode()) {
return R.drawable.ic_action_map_night; return R.drawable.ic_action_map_day;
} }
return R.drawable.ic_action_map_day; return R.drawable.ic_action_map_night;
} }
@Override @Override
public String getActionText(OsmandApplication application) { public String getActionText(OsmandApplication application) {
if (!application.getDaynightHelper().isNightMode()) { if (application.getDaynightHelper().isNightMode()) {
return String.format(application.getString(R.string.quick_action_day_night_mode), DayNightMode.NIGHT.toHumanString(application)); return String.format(application.getString(R.string.quick_action_day_night_mode),
DayNightMode.DAY.toHumanString(application));
} else { } else {
return String.format(application.getString(R.string.quick_action_day_night_mode), DayNightMode.DAY.toHumanString(application)); return String.format(application.getString(R.string.quick_action_day_night_mode),
DayNightMode.NIGHT.toHumanString(application));
} }
} }
} }