diff --git a/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java index 3a79a9c06c..6322109aa5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java @@ -25,6 +25,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.osmedit.data.EditPoiData; import net.osmand.plus.osmedit.data.Tag; import net.osmand.plus.osmedit.dialogs.OpeningHoursDaysDialogFragment; +import net.osmand.plus.osmedit.dialogs.OpeningHoursHoursDialogFragment; import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule; @@ -95,7 +96,8 @@ public class BasicDataFragment extends Fragment { LinearLayout openHoursContainer = (LinearLayout) view.findViewById(R.id.openHoursContainer); Drawable clockDrawable = iconsCache.getContentIcon(R.drawable.ic_action_time); Drawable deleteDrawable = iconsCache - .getPaintedContentIcon(R.drawable.ic_action_remove_dark, R.color.icon_color_light); + .getPaintedContentIcon(R.drawable.ic_action_remove_dark, + getActivity().getResources().getColor(R.color.icon_color_light)); if (savedInstanceState != null && savedInstanceState.containsKey(OPENING_HOURS)) { mOpeningHoursAdapter = new OpeningHoursAdapter( (OpeningHoursParser.OpeningHours) savedInstanceState.getSerializable(OPENING_HOURS), @@ -554,7 +556,7 @@ public class BasicDataFragment extends Fragment { closingTextView.setText(formatTime(enHour, enTime)); timeContainer.setVisibility(View.VISIBLE); - view.setOnClickListener(new View.OnClickListener() { + daysTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { OpeningHoursDaysDialogFragment fragment = @@ -562,6 +564,22 @@ public class BasicDataFragment extends Fragment { fragment.show(getChildFragmentManager(), "OpenTimeDialogFragment"); } }); + openingTextView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + OpeningHoursHoursDialogFragment fragment = + OpeningHoursHoursDialogFragment.createInstance(rule, position, true); + fragment.show(getChildFragmentManager(), "OpeningHoursHoursDialogFragment"); + } + }); + closingTextView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + OpeningHoursHoursDialogFragment fragment = + OpeningHoursHoursDialogFragment.createInstance(rule, position, false); + fragment.show(getChildFragmentManager(), "OpeningHoursHoursDialogFragment"); + } + }); } else if (openingHours.getRules().get(position) instanceof UnparseableRule) { daysTextView.setText(openingHours.getRules().get(position).toRuleString(false)); timeContainer.setVisibility(View.GONE); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java index db134d2056..b02b47c65d 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java @@ -10,6 +10,7 @@ import android.text.format.DateFormat; import net.osmand.PlatformUtil; import net.osmand.plus.R; +import net.osmand.plus.osmedit.BasicDataFragment; import net.osmand.util.OpeningHoursParser; import org.apache.commons.logging.Log; @@ -30,7 +31,7 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - boolean add = positionToAdd > -1; + final boolean createNew = positionToAdd == -1; Calendar inst = Calendar.getInstance(); final int first = inst.getFirstDayOfWeek(); final boolean[] dayToShow = new boolean[7]; @@ -55,7 +56,8 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment { } }); - builder.setPositiveButton(getActivity().getString(R.string.next_proceed), + builder.setPositiveButton(createNew ? R.string.next_proceed + : R.string.shared_string_save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -63,9 +65,13 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment { for (int i = 0; i < 7; i++) { days[(first + 5 + i) % 7] = dayToShow[i]; } - - OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true) - .show(getFragmentManager(), "TimePickerDialogFragment"); + if (createNew) { + OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true) + .show(getFragmentManager(), "TimePickerDialogFragment"); + } else { + ((BasicDataFragment) getParentFragment()) + .setBasicOpeningHoursRule(item, positionToAdd); + } } }); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursHoursDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursHoursDialogFragment.java index df0b416e96..1248321048 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursHoursDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursHoursDialogFragment.java @@ -28,6 +28,7 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment { Bundle args = getArguments(); final boolean isStart = args.getBoolean(IS_START); final int positionToAdd = args.getInt(POSITION_TO_ADD); + final boolean createNew = positionToAdd == -1; final OpeningHoursParser.BasicOpeningHourRule item = (OpeningHoursParser.BasicOpeningHourRule) args.getSerializable(BASIC_OPENING_HOUR_RULE); AlertDialog.Builder builder = @@ -43,24 +44,30 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment { timePicker.setCurrentMinute(minute); builder.setView(timePicker) - .setPositiveButton(R.string.next_proceed, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - int minute = timePicker.getCurrentMinute(); - int hourOfDay = timePicker.getCurrentHour(); - int time = minute + hourOfDay * 60; - if (isStart) { - item.setStartTime(time); - OpeningHoursHoursDialogFragment - .createInstance(item, positionToAdd, false) - .show(getFragmentManager(), "TimePickerDialogFragment"); - } else { - item.setEndTime(time); - ((BasicDataFragment) getParentFragment()) - .setBasicOpeningHoursRule(item, positionToAdd); - } - } - }) + .setPositiveButton(isStart && createNew ? R.string.next_proceed + : R.string.shared_string_save, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + int minute = timePicker.getCurrentMinute(); + int hourOfDay = timePicker.getCurrentHour(); + int time = minute + hourOfDay * 60; + if (isStart && createNew) { + item.setStartTime(time); + OpeningHoursHoursDialogFragment + .createInstance(item, positionToAdd, false) + .show(getFragmentManager(), "TimePickerDialogFragment"); + } else { + if (isStart) { + item.setStartTime(time); + } else { + item.setEndTime(time); + } + ((BasicDataFragment) getParentFragment()) + .setBasicOpeningHoursRule(item, positionToAdd); + } + } + }) .setNegativeButton(R.string.shared_string_cancel, null); int paddingInDp = 18;