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: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>
<TextView

View file

@ -520,7 +520,7 @@ public class FavouritesDbHelper {
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) {
FavoriteGroup gr = flatGroups.get(group.name);
group.color = color;
@ -535,6 +535,13 @@ public class FavouritesDbHelper {
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();
}

View file

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

View file

@ -218,7 +218,8 @@ public class MapActivityLayers {
if (g.showCurrentTrack) {
if (!settings.SAVE_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 {
g.path = getString(R.string.show_current_gpx_title);
}