quick action params check
This commit is contained in:
parent
2e486cf9ca
commit
dc31eda502
3 changed files with 43 additions and 27 deletions
|
@ -2519,4 +2519,5 @@ If you need help with OsmAnd application, please contact our support team: suppo
|
|||
<string name="quick_action_sh_poi_discrp">You can add few POI categories to display on the map.</string>
|
||||
<string name="quic_action_map_style_doscrp">Tap on the action button will toggle the map style, from the list order.</string>
|
||||
<string name="quick_action_map_style_action">Add map style</string>
|
||||
<string name="quick_action_empty_param_error">Parameters should not be empty</string>
|
||||
</resources>
|
||||
|
|
|
@ -19,6 +19,7 @@ import android.view.ViewGroup;
|
|||
import android.view.Window;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
|
@ -191,40 +192,44 @@ public class CreateEditActionDialog extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
action.fillParams(((ViewGroup) root.findViewById(R.id.container)).getChildAt(0), (MapActivity) getActivity());
|
||||
if (action.fillParams(((ViewGroup) root.findViewById(R.id.container)).getChildAt(0), (MapActivity) getActivity())) {
|
||||
|
||||
if (quickActionRegistry.isNameUnique(action, getContext())) {
|
||||
if (quickActionRegistry.isNameUnique(action, getContext())) {
|
||||
|
||||
if (isNew) quickActionRegistry.addQuickAction(action);
|
||||
else quickActionRegistry.updateQuickAction(action);
|
||||
if (isNew) quickActionRegistry.addQuickAction(action);
|
||||
else quickActionRegistry.updateQuickAction(action);
|
||||
|
||||
quickActionRegistry.notifyUpdates();
|
||||
quickActionRegistry.notifyUpdates();
|
||||
|
||||
dismiss();
|
||||
dismiss();
|
||||
|
||||
} else {
|
||||
|
||||
action = quickActionRegistry.generateUniqueName(action, getContext());
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(R.string.quick_action_duplicate);
|
||||
builder.setMessage(getString(R.string.quick_action_duplicates, action.getName(getContext())));
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
if (isNew) quickActionRegistry.addQuickAction(action);
|
||||
else quickActionRegistry.updateQuickAction(action);
|
||||
|
||||
quickActionRegistry.notifyUpdates();
|
||||
|
||||
CreateEditActionDialog.this.dismiss();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
|
||||
((EditText) root.findViewById(R.id.name)).setText(action.getName(getContext()));
|
||||
}
|
||||
} else {
|
||||
|
||||
action = quickActionRegistry.generateUniqueName(action, getContext());
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(R.string.quick_action_duplicate);
|
||||
builder.setMessage(getString(R.string.quick_action_duplicates, action.getName(getContext())));
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
if (isNew) quickActionRegistry.addQuickAction(action);
|
||||
else quickActionRegistry.updateQuickAction(action);
|
||||
|
||||
quickActionRegistry.notifyUpdates();
|
||||
|
||||
CreateEditActionDialog.this.dismiss();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
|
||||
((EditText) root.findViewById(R.id.name)).setText(action.getName(getContext()));
|
||||
Toast.makeText(getContext(), R.string.quick_action_empty_param_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -787,6 +787,11 @@ public class QuickActionFactory {
|
|||
builder.setSkipPaintingWithoutColor(true);
|
||||
adapter.addItem(builder.createItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fillParams(View root, MapActivity activity) {
|
||||
return !getParams().isEmpty() && (getParams().get(KEY_FILTERS) != null || !getParams().get(KEY_FILTERS).isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
public static class GPXAction extends QuickAction {
|
||||
|
@ -1518,5 +1523,10 @@ public class QuickActionFactory {
|
|||
|
||||
return styles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fillParams(View root, MapActivity activity) {
|
||||
return !getParams().isEmpty() && (getParams().get(KEY_STYLES) != null || !getParams().get(KEY_STYLES).isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue