This commit is contained in:
Nazar-Kutz 2020-07-14 11:02:02 +03:00
parent 7038311bae
commit 2377a089ab
4 changed files with 41 additions and 10 deletions

View file

@ -11,6 +11,7 @@
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="app_mode_go_cart">Go-cart</string>
<string name="app_mode_wheelchair_forward">Wheelchair forward</string>

View file

@ -15,6 +15,7 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -45,7 +46,8 @@ import java.util.Set;
import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH;
public class AdvancedEditPoiFragment extends BaseOsmAndFragment
implements EditPoiDialogFragment.OnFragmentActivatedListener {
implements EditPoiDialogFragment.OnFragmentActivatedListener,
EditPoiDialogFragment.OnSaveButtonClickListener {
private static final String TAG = "AdvancedEditPoiFragment";
private static final Log LOG = PlatformUtil.getLog(AdvancedEditPoiFragment.class);
@ -55,6 +57,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
private TextView nameTextView;
private TextView amenityTagTextView;
private TextView amenityTextView;
private EditText currentTagEditText;
@Override
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 {
private final LinearLayout linearLayout;
private final EditPoiData editPoiData;
@ -241,6 +251,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
}
}
} else {
currentTagEditText = tagEditText;
tagAdapter.getFilter().filter(tagEditText.getText());
}
}
@ -269,7 +280,6 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
initAutocompleteTextView(valueEditText, valueAdapter);
linearLayout.addView(convertView);
tagEditText.requestFocus();
}
public void setTagData(String[] tags) {

View file

@ -113,6 +113,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
private EditPoiViewPager viewPager;
private AutoCompleteTextView poiTypeEditText;
private OnSaveButtonClickListener onSaveButtonClickListener;
private OpenstreetmapUtil mOpenstreetmapUtil;
private TextInputLayout poiTypeTextInputLayout;
private View view;
@ -173,7 +174,13 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
@Override
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
@ -433,6 +440,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
}
private void trySave() {
if (onSaveButtonClickListener != null) {
onSaveButtonClickListener.onSaveButtonClick();
}
String tagWithExceedingValue = isTextLengthInRange();
if (!Algorithms.isEmpty(tagWithExceedingValue)){
ValueExceedLimitDialogFragment f = new ValueExceedLimitDialogFragment();
@ -996,4 +1006,8 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
public interface OnFragmentActivatedListener {
void onFragmentActivated();
}
public interface OnSaveButtonClickListener {
void onSaveButtonClick();
}
}

View file

@ -4,6 +4,7 @@ import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
@ -57,21 +58,26 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment {
}
});
builder.setPositiveButton(createNew ? R.string.next_proceed
: R.string.shared_string_save,
builder.setPositiveButton(createNew ? R.string.next_proceed : R.string.shared_string_save,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
boolean[] days = item.getDays();
boolean activeDaysAvailable = false;
for (int i = 0; i < 7; i++) {
days[(first + 5 + i) % 7] = dayToShow[i];
activeDaysAvailable = activeDaysAvailable || dayToShow[i];
}
if (createNew) {
OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true, 0)
.show(getFragmentManager(), "TimePickerDialogFragment");
if (activeDaysAvailable) {
if (createNew) {
OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true, 0)
.show(getFragmentManager(), "TimePickerDialogFragment");
} else {
((BasicEditPoiFragment) getParentFragment())
.setBasicOpeningHoursRule(item, positionToAdd);
}
} else {
((BasicEditPoiFragment) getParentFragment())
.setBasicOpeningHoursRule(item, positionToAdd);
Toast.makeText(getContext(), getString(R.string.set_working_days_to_continue), Toast.LENGTH_SHORT).show();
}
}