Issue Fix - Quick Action: Incorrect position when creating "My places" point #6508

Day/Night mode QA refactoring.
This commit is contained in:
madwasp79 2019-03-14 18:09:26 +02:00
parent f4a96eb194
commit 77cfcf6feb
3 changed files with 21 additions and 25 deletions

View file

@ -10,7 +10,7 @@
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
Thx - Hardy
-->
--> <string name="shared_string_mode">mode</string>
<string name="public_transport_warning_descr_blog">Learn more about how OsmAnd calculates routes in our blog.</string>
<string name="public_transport_warning_title">Public transport routes are now in the beta testing phase, so errors and inaccuracies may occur.</string>
<string name="add_intermediate">Add intermediate point</string>

View file

@ -7,6 +7,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.DayNightMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction;
@ -25,14 +26,8 @@ public class DayNightModeAction extends QuickAction {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.NIGHT);
break;
}
case NIGHT: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
}
case AUTO: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
}
case NIGHT:
case AUTO:
case SENSOR: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
@ -44,7 +39,6 @@ public class DayNightModeAction extends QuickAction {
public void drawUI(ViewGroup parent, MapActivity activity) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_with_text, parent, false);
((TextView) view.findViewById(R.id.text))
.setText(R.string.quick_action_switch_day_night_descr);
@ -53,24 +47,20 @@ public class DayNightModeAction extends QuickAction {
@Override
public int getIconRes(Context context) {
if(context instanceof MapActivity) {
switch (((MapActivity) context).getMyApplication().getSettings().DAYNIGHT_MODE.get()) {
case NIGHT: {
if (context instanceof MapActivity
&& ((MapActivity) context).getMyApplication().getSettings().DAYNIGHT_MODE.get() == DayNightMode.DAY) {
return R.drawable.ic_action_map_night;
}
case AUTO: {
return R.drawable.ic_action_map_sunst;
}
case SENSOR: {
return R.drawable.ic_action_map_light_sensor;
}
}
}
return R.drawable.ic_action_map_day;
}
@Override
public String getActionText(OsmandApplication application) {
return application.getSettings().DAYNIGHT_MODE.get().toHumanString(application) + " Mode";
if (application.getSettings().DAYNIGHT_MODE.get() == DayNightMode.DAY) {
return DayNightMode.NIGHT.toHumanString(application) + " " + application.getString(R.string.shared_string_mode);
} else {
return DayNightMode.DAY.toHumanString(application) + " " + application.getString(R.string.shared_string_mode);
}
}
}

View file

@ -44,6 +44,7 @@ import net.osmand.plus.quickaction.QuickActionsWidget;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import net.osmand.plus.quickaction.actions.DayNightModeAction;
import static net.osmand.plus.views.ContextMenuLayer.VIBRATE_SHORT;
@ -420,8 +421,13 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
@Override
public void onActionSelected(QuickAction action) {
if (action instanceof DayNightModeAction) {
setLayerState(false);
QuickActionFactory.produceAction(action).execute(mapActivity);
} else {
QuickActionFactory.produceAction(action).execute(mapActivity);
setLayerState(false);
}
}
public PointF getMovableCenterPoint(RotatedTileBox tb) {