Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
93dcac82e3
4 changed files with 69 additions and 25 deletions
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
|
||||
|
@ -201,7 +202,9 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:stretchColumns="1"
|
||||
android:visibility="gone" >
|
||||
android:visibility="gone"
|
||||
tools:layout_height="25dp"
|
||||
tools:visibility="visible">
|
||||
</TableLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
android:layout_marginRight="16dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<EditText
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/tagEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
|
@ -29,6 +35,8 @@ import org.apache.commons.logging.Log;
|
|||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class AdvancedDataFragment extends Fragment {
|
||||
private static final String TAG = "AdvancedDataFragment";
|
||||
|
@ -99,6 +107,14 @@ public class AdvancedDataFragment extends Fragment {
|
|||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private EditPoiFragment getEditPoiFragment() {
|
||||
return (EditPoiFragment) getParentFragment();
|
||||
}
|
||||
|
||||
private EditPoiData getData() {
|
||||
return getEditPoiFragment().getEditPoiData();
|
||||
}
|
||||
|
||||
public class TagAdapterLinearLayoutHack {
|
||||
private final LinearLayout linearLayout;
|
||||
private final EditPoiData editPoiData;
|
||||
|
@ -131,7 +147,6 @@ public class AdvancedDataFragment extends Fragment {
|
|||
|
||||
public void updateViews() {
|
||||
linearLayout.removeAllViews();
|
||||
Iterator<Tag> iterator = editPoiData.tags.iterator();
|
||||
for (Tag tag : editPoiData.tags) {
|
||||
if (tag.tag.equals(OSMSettings.OSMTagKey.NAME.getValue())) {
|
||||
nameTextView.setText(tag.value);
|
||||
|
@ -155,7 +170,8 @@ public class AdvancedDataFragment extends Fragment {
|
|||
private View getView(final Tag tag) {
|
||||
final View convertView = LayoutInflater.from(linearLayout.getContext())
|
||||
.inflate(R.layout.poi_tag_list_item, null, false);
|
||||
final EditText tagEditText = (EditText) convertView.findViewById(R.id.tagEditText);
|
||||
final AutoCompleteTextView tagEditText =
|
||||
(AutoCompleteTextView) convertView.findViewById(R.id.tagEditText);
|
||||
tagEditText.setText(tag.tag);
|
||||
final EditText valueEditText = (EditText) convertView.findViewById(R.id.valueEditText);
|
||||
ImageButton deleteItemImageButton =
|
||||
|
@ -193,6 +209,35 @@ public class AdvancedDataFragment extends Fragment {
|
|||
editPoiData.notifyDatasetChanged(mTagsChangedListener);
|
||||
}
|
||||
});
|
||||
final Set<String> tagKeys = new TreeSet<String>();
|
||||
for (OSMSettings.OSMTagKey t : OSMSettings.OSMTagKey.values()) {
|
||||
if ((t != OSMSettings.OSMTagKey.NAME) && (t != OSMSettings.OSMTagKey.OPENING_HOURS) && (t != OSMSettings.OSMTagKey.PHONE)
|
||||
&& (t != OSMSettings.OSMTagKey.WEBSITE)) {
|
||||
tagKeys.add(t.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<Object> adapter = new ArrayAdapter<Object>(linearLayout.getContext(),
|
||||
R.layout.list_textview, tagKeys.toArray());
|
||||
tagEditText.setAdapter(adapter);
|
||||
tagEditText.setThreshold(1);
|
||||
tagEditText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO: 8/29/15 Rewrite as dialog fragment
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
final String[] tags = tagKeys.toArray(new String[tagKeys.size()]);
|
||||
builder.setItems(tags, new Dialog.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
tagEditText.setText(tags[which]);
|
||||
}
|
||||
|
||||
});
|
||||
builder.create();
|
||||
builder.show();
|
||||
}
|
||||
});
|
||||
valueEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
@ -214,12 +259,4 @@ public class AdvancedDataFragment extends Fragment {
|
|||
return convertView;
|
||||
}
|
||||
}
|
||||
|
||||
private EditPoiFragment getEditPoiFragment() {
|
||||
return (EditPoiFragment) getParentFragment();
|
||||
}
|
||||
|
||||
private EditPoiData getData() {
|
||||
return getEditPoiFragment().getEditPoiData();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,13 @@ import java.util.List;
|
|||
|
||||
|
||||
public class OsmEditingPlugin extends OsmandPlugin {
|
||||
private static final Log LOG = PlatformUtil.getLog(OsmEditingPlugin.class);
|
||||
private static final String ID = "osm.editing";
|
||||
private OsmandSettings settings;
|
||||
private OsmandApplication app;
|
||||
OpenstreetmapsDbHelper dbpoi;
|
||||
OsmBugsDbHelper dbbug;
|
||||
private EditingPOIDialogProvider poiActions;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
|
@ -136,12 +138,12 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
return SettingsOsmEditingActivity.class;
|
||||
}
|
||||
|
||||
// public EditingPOIDialogProvider getPoiActions(MapActivity activity) {
|
||||
// if (poiActions == null) {
|
||||
// poiActions = new EditingPOIDialogProvider(activity, this);
|
||||
// }
|
||||
// return poiActions;
|
||||
// }
|
||||
public EditingPOIDialogProvider getPoiActions(MapActivity activity) {
|
||||
if (poiActions == null) {
|
||||
poiActions = new EditingPOIDialogProvider(activity, this);
|
||||
}
|
||||
return poiActions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMapContextMenuActions(final MapActivity mapActivity,
|
||||
|
@ -152,6 +154,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
|
||||
LOG.debug("onContextMenuClick()");
|
||||
if (resId == R.string.context_menu_item_create_poi) {
|
||||
//getPoiActions(mapActivity).showCreateDialog(latitude, longitude);
|
||||
EditPoiFragment editPoiFragment =
|
||||
|
@ -167,14 +170,15 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
}
|
||||
osmBugsLayer.openBug(latitude, longitude);
|
||||
} else if (resId == R.string.poi_context_menu_delete) {
|
||||
new EditPoiFragment.ShowDeleteDialogAsyncTask(mapActivity)
|
||||
.execute((Amenity) selectedObj);
|
||||
LOG.debug("delete poi");
|
||||
// new EditPoiFragment.ShowDeleteDialogAsyncTask(mapActivity)
|
||||
// .execute((Amenity) selectedObj);
|
||||
// TODO implement delete
|
||||
// getPoiActions(mapActivity).showDeleteDialog((Amenity) selectedObj);
|
||||
}//} else if (resId == R.string.poi_context_menu_modify) {
|
||||
getPoiActions(mapActivity).showDeleteDialog((Amenity) selectedObj);
|
||||
} else if (resId == R.string.poi_context_menu_modify) {
|
||||
// TODO implement edit
|
||||
// getPoiActions(mapActivity).showEditDialog((Amenity) selectedObj);
|
||||
// }
|
||||
getPoiActions(mapActivity).showEditDialog((Amenity) selectedObj);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue