Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7dffa77028
3 changed files with 56 additions and 25 deletions
|
@ -25,6 +25,7 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.osmedit.data.EditPoiData;
|
import net.osmand.plus.osmedit.data.EditPoiData;
|
||||||
import net.osmand.plus.osmedit.data.Tag;
|
import net.osmand.plus.osmedit.data.Tag;
|
||||||
import net.osmand.plus.osmedit.dialogs.OpeningHoursDaysDialogFragment;
|
import net.osmand.plus.osmedit.dialogs.OpeningHoursDaysDialogFragment;
|
||||||
|
import net.osmand.plus.osmedit.dialogs.OpeningHoursHoursDialogFragment;
|
||||||
import net.osmand.util.OpeningHoursParser;
|
import net.osmand.util.OpeningHoursParser;
|
||||||
import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
|
import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
|
||||||
|
|
||||||
|
@ -95,7 +96,8 @@ public class BasicDataFragment extends Fragment {
|
||||||
LinearLayout openHoursContainer = (LinearLayout) view.findViewById(R.id.openHoursContainer);
|
LinearLayout openHoursContainer = (LinearLayout) view.findViewById(R.id.openHoursContainer);
|
||||||
Drawable clockDrawable = iconsCache.getContentIcon(R.drawable.ic_action_time);
|
Drawable clockDrawable = iconsCache.getContentIcon(R.drawable.ic_action_time);
|
||||||
Drawable deleteDrawable = iconsCache
|
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)) {
|
if (savedInstanceState != null && savedInstanceState.containsKey(OPENING_HOURS)) {
|
||||||
mOpeningHoursAdapter = new OpeningHoursAdapter(
|
mOpeningHoursAdapter = new OpeningHoursAdapter(
|
||||||
(OpeningHoursParser.OpeningHours) savedInstanceState.getSerializable(OPENING_HOURS),
|
(OpeningHoursParser.OpeningHours) savedInstanceState.getSerializable(OPENING_HOURS),
|
||||||
|
@ -554,7 +556,7 @@ public class BasicDataFragment extends Fragment {
|
||||||
closingTextView.setText(formatTime(enHour, enTime));
|
closingTextView.setText(formatTime(enHour, enTime));
|
||||||
timeContainer.setVisibility(View.VISIBLE);
|
timeContainer.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
view.setOnClickListener(new View.OnClickListener() {
|
daysTextView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
OpeningHoursDaysDialogFragment fragment =
|
OpeningHoursDaysDialogFragment fragment =
|
||||||
|
@ -562,6 +564,22 @@ public class BasicDataFragment extends Fragment {
|
||||||
fragment.show(getChildFragmentManager(), "OpenTimeDialogFragment");
|
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) {
|
} else if (openingHours.getRules().get(position) instanceof UnparseableRule) {
|
||||||
daysTextView.setText(openingHours.getRules().get(position).toRuleString(false));
|
daysTextView.setText(openingHours.getRules().get(position).toRuleString(false));
|
||||||
timeContainer.setVisibility(View.GONE);
|
timeContainer.setVisibility(View.GONE);
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.text.format.DateFormat;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.osmedit.BasicDataFragment;
|
||||||
import net.osmand.util.OpeningHoursParser;
|
import net.osmand.util.OpeningHoursParser;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -30,7 +31,7 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
|
||||||
boolean add = positionToAdd > -1;
|
final boolean createNew = positionToAdd == -1;
|
||||||
Calendar inst = Calendar.getInstance();
|
Calendar inst = Calendar.getInstance();
|
||||||
final int first = inst.getFirstDayOfWeek();
|
final int first = inst.getFirstDayOfWeek();
|
||||||
final boolean[] dayToShow = new boolean[7];
|
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() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -63,9 +65,13 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment {
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
days[(first + 5 + i) % 7] = dayToShow[i];
|
days[(first + 5 + i) % 7] = dayToShow[i];
|
||||||
}
|
}
|
||||||
|
if (createNew) {
|
||||||
OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true)
|
OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true)
|
||||||
.show(getFragmentManager(), "TimePickerDialogFragment");
|
.show(getFragmentManager(), "TimePickerDialogFragment");
|
||||||
|
} else {
|
||||||
|
((BasicDataFragment) getParentFragment())
|
||||||
|
.setBasicOpeningHoursRule(item, positionToAdd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment {
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
final boolean isStart = args.getBoolean(IS_START);
|
final boolean isStart = args.getBoolean(IS_START);
|
||||||
final int positionToAdd = args.getInt(POSITION_TO_ADD);
|
final int positionToAdd = args.getInt(POSITION_TO_ADD);
|
||||||
|
final boolean createNew = positionToAdd == -1;
|
||||||
final OpeningHoursParser.BasicOpeningHourRule item = (OpeningHoursParser.BasicOpeningHourRule)
|
final OpeningHoursParser.BasicOpeningHourRule item = (OpeningHoursParser.BasicOpeningHourRule)
|
||||||
args.getSerializable(BASIC_OPENING_HOUR_RULE);
|
args.getSerializable(BASIC_OPENING_HOUR_RULE);
|
||||||
AlertDialog.Builder builder =
|
AlertDialog.Builder builder =
|
||||||
|
@ -43,24 +44,30 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment {
|
||||||
timePicker.setCurrentMinute(minute);
|
timePicker.setCurrentMinute(minute);
|
||||||
|
|
||||||
builder.setView(timePicker)
|
builder.setView(timePicker)
|
||||||
.setPositiveButton(R.string.next_proceed, new DialogInterface.OnClickListener() {
|
.setPositiveButton(isStart && createNew ? R.string.next_proceed
|
||||||
@Override
|
: R.string.shared_string_save,
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
new DialogInterface.OnClickListener() {
|
||||||
int minute = timePicker.getCurrentMinute();
|
@Override
|
||||||
int hourOfDay = timePicker.getCurrentHour();
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int time = minute + hourOfDay * 60;
|
int minute = timePicker.getCurrentMinute();
|
||||||
if (isStart) {
|
int hourOfDay = timePicker.getCurrentHour();
|
||||||
item.setStartTime(time);
|
int time = minute + hourOfDay * 60;
|
||||||
OpeningHoursHoursDialogFragment
|
if (isStart && createNew) {
|
||||||
.createInstance(item, positionToAdd, false)
|
item.setStartTime(time);
|
||||||
.show(getFragmentManager(), "TimePickerDialogFragment");
|
OpeningHoursHoursDialogFragment
|
||||||
} else {
|
.createInstance(item, positionToAdd, false)
|
||||||
item.setEndTime(time);
|
.show(getFragmentManager(), "TimePickerDialogFragment");
|
||||||
((BasicDataFragment) getParentFragment())
|
} else {
|
||||||
.setBasicOpeningHoursRule(item, positionToAdd);
|
if (isStart) {
|
||||||
}
|
item.setStartTime(time);
|
||||||
}
|
} else {
|
||||||
})
|
item.setEndTime(time);
|
||||||
|
}
|
||||||
|
((BasicDataFragment) getParentFragment())
|
||||||
|
.setBasicOpeningHoursRule(item, positionToAdd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
.setNegativeButton(R.string.shared_string_cancel, null);
|
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
|
||||||
int paddingInDp = 18;
|
int paddingInDp = 18;
|
||||||
|
|
Loading…
Reference in a new issue