Show GPX on map dialog fix

This commit is contained in:
GaidamakUA 2015-09-11 17:15:52 +03:00
parent 7765383d85
commit beca2f9522
4 changed files with 49 additions and 19 deletions

View file

@ -6,6 +6,21 @@
android:paddingRight="7dp" android:paddingRight="7dp"
android:stretchColumns="1"> android:stretchColumns="1">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/favourites_edit_dialog_name" />
<EditText
android:id="@+id/nameEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
</TableRow>
<TableRow> <TableRow>
<TextView <TextView

View file

@ -520,7 +520,7 @@ public class FavouritesDbHelper {
return null; return null;
} }
public void editFavouriteGroup(FavoriteGroup group, int color, boolean visible) { public void editFavouriteGroup(FavoriteGroup group, String newName, int color, boolean visible) {
if(color != 0 && group.color != color) { if(color != 0 && group.color != color) {
FavoriteGroup gr = flatGroups.get(group.name); FavoriteGroup gr = flatGroups.get(group.name);
group.color = color; group.color = color;
@ -535,6 +535,13 @@ public class FavouritesDbHelper {
p.setVisible(visible); p.setVisible(visible);
} }
} }
if (!group.name.equals(newName)) {
FavoriteGroup gr = flatGroups.get(group.name);
group.name = newName;
for(FavouritePoint p : gr.points) {
p.setCategory(newName);
}
}
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
} }

View file

@ -493,31 +493,38 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
protected void openChangeGroupDialog(final FavoriteGroup group) { protected void openChangeGroupDialog(final FavoriteGroup group) {
Builder bld = new AlertDialog.Builder(getActivity()); Builder builder = new AlertDialog.Builder(getActivity());
View favEdit = getActivity().getLayoutInflater().inflate(R.layout.fav_group_edit, null); View view = getActivity().getLayoutInflater().inflate(R.layout.fav_group_edit, null);
final TIntArrayList list = new TIntArrayList();
final Spinner colorSpinner = (Spinner) favEdit.findViewById(R.id.ColorSpinner); final EditText nameEditText = (EditText) view.findViewById(R.id.nameEditText);
final int intColor = group.color == 0? getResources().getColor(R.color.color_favorite) : group.color; nameEditText.setText(group.name);
ColorDialogs.setupColorSpinner(getActivity(), intColor, colorSpinner, list);
final CheckBox checkBox = (CheckBox) view.findViewById(R.id.Visibility);
final CheckBox checkBox = (CheckBox) favEdit.findViewById(R.id.Visibility);
checkBox.setChecked(group.visible); checkBox.setChecked(group.visible);
bld.setTitle(R.string.edit_group);
bld.setView(favEdit); final Spinner colorSpinner = (Spinner) view.findViewById(R.id.ColorSpinner);
bld.setNegativeButton(R.string.shared_string_cancel, null); final TIntArrayList list = new TIntArrayList();
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { final int intColor = group.color == 0? getResources().getColor(R.color.color_favorite) : group.color;
ColorDialogs.setupColorSpinner(getActivity(), intColor, colorSpinner, list);
builder.setTitle(R.string.edit_group);
builder.setView(view);
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
int clr = list.get(colorSpinner.getSelectedItemPosition()); int clr = list.get(colorSpinner.getSelectedItemPosition());
if(clr != intColor || group.visible != checkBox.isChecked()) { String name = nameEditText.getText().toString();
getMyApplication().getFavorites().editFavouriteGroup(group, clr, checkBox.isChecked()); if (clr != intColor || group.visible != checkBox.isChecked()) {
getMyApplication().getFavorites().editFavouriteGroup(group, name, clr,
checkBox.isChecked());
favouritesAdapter.notifyDataSetInvalidated(); favouritesAdapter.notifyDataSetInvalidated();
} }
} }
}); });
bld.show(); builder.show();
} }

View file

@ -218,7 +218,8 @@ public class MapActivityLayers {
if (g.showCurrentTrack) { if (g.showCurrentTrack) {
if (!settings.SAVE_TRACK_TO_GPX.get() && ! if (!settings.SAVE_TRACK_TO_GPX.get() && !
settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) { settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
AccessibleToast.makeText(activity, R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_LONG).show(); AccessibleToast.makeText(activity,
R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_LONG).show();
} else { } else {
g.path = getString(R.string.show_current_gpx_title); g.path = getString(R.string.show_current_gpx_title);
} }