This commit is contained in:
madwasp79 2019-06-03 16:10:59 +03:00
parent 3bf119b30b
commit c6a1f997ba
2 changed files with 20 additions and 14 deletions

View file

@ -3164,5 +3164,6 @@
<string name="run_full_osmand_header">Launch OsmAnd?</string>
<string name="routing_attr_avoid_sett_name">Avoid cobblestone and sett</string>
<string name="routing_attr_avoid_sett_description">Avoid cobblestone and sett</string>
<string name="quick_action_need_to_add_item_to_list">You need to add at least one Item to list in Quick Action\' Settings</string>
</resources>

View file

@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import net.osmand.util.Algorithms;
public class MapStyleAction extends SwitchableAction<String> {
@ -42,21 +43,26 @@ public class MapStyleAction extends SwitchableAction<String> {
@Override
public void execute(MapActivity activity) {
List<String> mapStyles = getFilteredStyles();
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
if (showBottomSheetStyles) {
showChooseDialog(activity.getSupportFragmentManager());
return;
}
String curStyle = activity.getMyApplication().getSettings().RENDERER.get();
int index = mapStyles.indexOf(curStyle);
String nextStyle = mapStyles.get(0);
if (!Algorithms.isEmpty(mapStyles)) {
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
if (showBottomSheetStyles) {
showChooseDialog(activity.getSupportFragmentManager());
return;
}
String curStyle = activity.getMyApplication().getSettings().RENDERER.get();
int index = mapStyles.indexOf(curStyle);
String nextStyle = mapStyles.get(0);
if (index >= 0 && index + 1 < mapStyles.size()) {
nextStyle = mapStyles.get(index + 1);
if (index >= 0 && index + 1 < mapStyles.size()) {
nextStyle = mapStyles.get(index + 1);
}
executeWithParams(activity, nextStyle);
} else {
Toast.makeText(activity, R.string.quick_action_need_to_add_item_to_list,
Toast.LENGTH_LONG).show();
}
executeWithParams(activity, nextStyle);
}
@Override
@ -181,9 +187,8 @@ public class MapStyleAction extends SwitchableAction<String> {
@Override
public boolean fillParams(View root, MapActivity activity) {
super.fillParams(root, activity);
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return true;
return super.fillParams(root, activity);
}
@Override