Fix #6589
This commit is contained in:
parent
7038311bae
commit
2377a089ab
4 changed files with 41 additions and 10 deletions
|
@ -11,6 +11,7 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="set_working_days_to_continue">You need to set working days to continue</string>
|
||||||
<string name="osm_edit_closed_note">Closed OSM Note</string>
|
<string name="osm_edit_closed_note">Closed OSM Note</string>
|
||||||
<string name="app_mode_go_cart">Go-cart</string>
|
<string name="app_mode_go_cart">Go-cart</string>
|
||||||
<string name="app_mode_wheelchair_forward">Wheelchair forward</string>
|
<string name="app_mode_wheelchair_forward">Wheelchair forward</string>
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -45,7 +46,8 @@ import java.util.Set;
|
||||||
import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH;
|
import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH;
|
||||||
|
|
||||||
public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
||||||
implements EditPoiDialogFragment.OnFragmentActivatedListener {
|
implements EditPoiDialogFragment.OnFragmentActivatedListener,
|
||||||
|
EditPoiDialogFragment.OnSaveButtonClickListener {
|
||||||
private static final String TAG = "AdvancedEditPoiFragment";
|
private static final String TAG = "AdvancedEditPoiFragment";
|
||||||
private static final Log LOG = PlatformUtil.getLog(AdvancedEditPoiFragment.class);
|
private static final Log LOG = PlatformUtil.getLog(AdvancedEditPoiFragment.class);
|
||||||
|
|
||||||
|
@ -55,6 +57,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
||||||
private TextView nameTextView;
|
private TextView nameTextView;
|
||||||
private TextView amenityTagTextView;
|
private TextView amenityTagTextView;
|
||||||
private TextView amenityTextView;
|
private TextView amenityTextView;
|
||||||
|
private EditText currentTagEditText;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -165,6 +168,13 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveButtonClick() {
|
||||||
|
if (currentTagEditText != null) {
|
||||||
|
currentTagEditText.clearFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class TagAdapterLinearLayoutHack {
|
public class TagAdapterLinearLayoutHack {
|
||||||
private final LinearLayout linearLayout;
|
private final LinearLayout linearLayout;
|
||||||
private final EditPoiData editPoiData;
|
private final EditPoiData editPoiData;
|
||||||
|
@ -241,6 +251,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
currentTagEditText = tagEditText;
|
||||||
tagAdapter.getFilter().filter(tagEditText.getText());
|
tagAdapter.getFilter().filter(tagEditText.getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +280,6 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
||||||
initAutocompleteTextView(valueEditText, valueAdapter);
|
initAutocompleteTextView(valueEditText, valueAdapter);
|
||||||
|
|
||||||
linearLayout.addView(convertView);
|
linearLayout.addView(convertView);
|
||||||
tagEditText.requestFocus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTagData(String[] tags) {
|
public void setTagData(String[] tags) {
|
||||||
|
|
|
@ -113,6 +113,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
private EditPoiViewPager viewPager;
|
private EditPoiViewPager viewPager;
|
||||||
private AutoCompleteTextView poiTypeEditText;
|
private AutoCompleteTextView poiTypeEditText;
|
||||||
|
|
||||||
|
private OnSaveButtonClickListener onSaveButtonClickListener;
|
||||||
private OpenstreetmapUtil mOpenstreetmapUtil;
|
private OpenstreetmapUtil mOpenstreetmapUtil;
|
||||||
private TextInputLayout poiTypeTextInputLayout;
|
private TextInputLayout poiTypeTextInputLayout;
|
||||||
private View view;
|
private View view;
|
||||||
|
@ -173,7 +174,13 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int i) {
|
public void onPageSelected(int i) {
|
||||||
((OnFragmentActivatedListener) pagerAdapter.getItem(i)).onFragmentActivated();
|
Fragment pageFragment = pagerAdapter.getItem(i);
|
||||||
|
((OnFragmentActivatedListener) pageFragment).onFragmentActivated();
|
||||||
|
if (pageFragment instanceof OnSaveButtonClickListener) {
|
||||||
|
onSaveButtonClickListener = (OnSaveButtonClickListener) pageFragment;
|
||||||
|
} else {
|
||||||
|
onSaveButtonClickListener = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -433,6 +440,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trySave() {
|
private void trySave() {
|
||||||
|
if (onSaveButtonClickListener != null) {
|
||||||
|
onSaveButtonClickListener.onSaveButtonClick();
|
||||||
|
}
|
||||||
String tagWithExceedingValue = isTextLengthInRange();
|
String tagWithExceedingValue = isTextLengthInRange();
|
||||||
if (!Algorithms.isEmpty(tagWithExceedingValue)){
|
if (!Algorithms.isEmpty(tagWithExceedingValue)){
|
||||||
ValueExceedLimitDialogFragment f = new ValueExceedLimitDialogFragment();
|
ValueExceedLimitDialogFragment f = new ValueExceedLimitDialogFragment();
|
||||||
|
@ -996,4 +1006,8 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
public interface OnFragmentActivatedListener {
|
public interface OnFragmentActivatedListener {
|
||||||
void onFragmentActivated();
|
void onFragmentActivated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnSaveButtonClickListener {
|
||||||
|
void onSaveButtonClick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
@ -57,21 +58,26 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
builder.setPositiveButton(createNew ? R.string.next_proceed
|
builder.setPositiveButton(createNew ? R.string.next_proceed : R.string.shared_string_save,
|
||||||
: 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) {
|
||||||
boolean[] days = item.getDays();
|
boolean[] days = item.getDays();
|
||||||
|
boolean activeDaysAvailable = false;
|
||||||
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];
|
||||||
|
activeDaysAvailable = activeDaysAvailable || dayToShow[i];
|
||||||
}
|
}
|
||||||
if (createNew) {
|
if (activeDaysAvailable) {
|
||||||
OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true, 0)
|
if (createNew) {
|
||||||
.show(getFragmentManager(), "TimePickerDialogFragment");
|
OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true, 0)
|
||||||
|
.show(getFragmentManager(), "TimePickerDialogFragment");
|
||||||
|
} else {
|
||||||
|
((BasicEditPoiFragment) getParentFragment())
|
||||||
|
.setBasicOpeningHoursRule(item, positionToAdd);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
((BasicEditPoiFragment) getParentFragment())
|
Toast.makeText(getContext(), getString(R.string.set_working_days_to_continue), Toast.LENGTH_SHORT).show();
|
||||||
.setBasicOpeningHoursRule(item, positionToAdd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue