diff --git a/OsmAnd/res/layout/fragment_edit_poi.xml b/OsmAnd/res/layout/fragment_edit_poi.xml
index 758e8d6387..4973836569 100644
--- a/OsmAnd/res/layout/fragment_edit_poi.xml
+++ b/OsmAnd/res/layout/fragment_edit_poi.xml
@@ -1,140 +1,91 @@
-
-
+ android:layout_height="wrap_content"
+ android:theme="@style/OsmandLightTheme.DarkActionbar">
-
+
+
+
+ app:layout_scrollFlags="scroll">
-
-
-
-
+ android:layout_marginLeft="72dp"
+ android:layout_marginRight="16dp"
+ android:layout_marginTop="16dp">
-
+ android:hint="Name"
+ android:text="@string/lorem_ipsum"/>
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:layout_marginLeft="72dp"
+ app:layout_scrollFlags="scroll">
-
+
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
+
diff --git a/OsmAnd/res/layout/fragment_edit_poi_advanced.xml b/OsmAnd/res/layout/fragment_edit_poi_advanced.xml
index 4320b68a32..be12353f94 100644
--- a/OsmAnd/res/layout/fragment_edit_poi_advanced.xml
+++ b/OsmAnd/res/layout/fragment_edit_poi_advanced.xml
@@ -2,7 +2,8 @@
+ android:layout_height="match_parent"
+ android:background="@color/dashboard_background">
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/fragment_edit_poi_normal.xml b/OsmAnd/res/layout/fragment_edit_poi_normal.xml
index 11c1982236..9b4415c9cd 100644
--- a/OsmAnd/res/layout/fragment_edit_poi_normal.xml
+++ b/OsmAnd/res/layout/fragment_edit_poi_normal.xml
@@ -3,16 +3,26 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:background="@color/dashboard_background">
+
+
@@ -82,13 +92,33 @@
android:layout_below="@id/webSiteEditText"
android:hint="Description"
android:inputType="textMultiLine"/>
-
+
+
+ android:layout_alignParentRight="true"
+ android:layout_below="@id/buttonDivider"
+ tools:text="Save"
+ android:textColor="@color/dashboard_general_button_text_light"/>
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index 8b89251afd..704e506dc0 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -45,7 +45,6 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.IntermediatePointsDialog;
import net.osmand.plus.activities.MapActivity;
-import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
@@ -58,13 +57,9 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.monitoring.DashTrackFragment;
-import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.osmedit.DashOsmEditsFragment;
-import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.osmo.DashOsMoFragment;
-import net.osmand.plus.osmo.OsMoPlugin;
import net.osmand.plus.parkingpoint.DashParkingFragment;
-import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.OsmandMapTileView;
@@ -92,32 +87,22 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
private static final DashFragmentData.ShouldShowFunction chooseAppDirShouldShow = new ChooseAppDirShouldShow();
private static final DashFragmentData[] fragmentsData = new DashFragmentData[]{
- new DashFragmentData(DashRateUsFragment.TAG, DashRateUsFragment.class, "Rate us",
- rateUsShouldShow, new CanNotHideFunction()),
- new DashFragmentData(DashFirstTimeFragment.TAG, DashFirstTimeFragment.class, "First time",
- firstTimeShouldShow, new CanNotHideFunction()),
- new DashFragmentData(DashChooseAppDirFragment.TAG, DashChooseAppDirFragment.class, "Choose app dir",
- chooseAppDirShouldShow, new CanNotHideFunction()),
- new DashFragmentData(DashErrorFragment.TAG, DashErrorFragment.class, "Error",
- errorShouldShow, new CanNotHideFunction()),
+ new DashFragmentData(DashRateUsFragment.TAG, DashRateUsFragment.class, "Rate us", rateUsShouldShow, true),
+ new DashFragmentData(DashFirstTimeFragment.TAG, DashFirstTimeFragment.class, "First time", firstTimeShouldShow, true),
+ new DashFragmentData(DashChooseAppDirFragment.TAG, DashChooseAppDirFragment.class, "Choose app dir", chooseAppDirShouldShow, true),
+ new DashFragmentData(DashErrorFragment.TAG, DashErrorFragment.class, "Error", errorShouldShow, true),
new DashFragmentData(DashNavigationFragment.TAG, DashNavigationFragment.class, "Navigation", defaultShouldShow),
- new DashFragmentData(DashParkingFragment.TAG, DashParkingFragment.class, "Parking",
- defaultShouldShow, new CanHideIfPluginEnabled(ParkingPositionPlugin.class)),
+ new DashFragmentData(DashParkingFragment.TAG, DashParkingFragment.class, "Parking", defaultShouldShow),
new DashFragmentData(DashWaypointsFragment.TAG, DashWaypointsFragment.class, "Waypoints", defaultShouldShow),
new DashFragmentData(DashSearchFragment.TAG, DashSearchFragment.class, "Search", defaultShouldShow),
new DashFragmentData(DashRecentsFragment.TAG, DashRecentsFragment.class, "Recent places", defaultShouldShow),
new DashFragmentData(DashFavoritesFragment.TAG, DashFavoritesFragment.class, "Favourites", defaultShouldShow),
- new DashFragmentData(DashAudioVideoNotesFragment.TAG, DashAudioVideoNotesFragment.class, "Notes",
- defaultShouldShow, new CanHideIfPluginEnabled(AudioVideoNotesPlugin.class)),
- new DashFragmentData(DashTrackFragment.TAG, DashTrackFragment.class, "Track",
- defaultShouldShow, new CanHideIfPluginEnabled(OsmandMonitoringPlugin.class)),
- new DashFragmentData(DashOsMoFragment.TAG, DashOsMoFragment.class, "OsMo",
- defaultShouldShow, new CanHideIfPluginEnabled(OsMoPlugin.class)),
- new DashFragmentData(DashOsmEditsFragment.TAG, DashOsmEditsFragment.class, "OsmEdits",
- defaultShouldShow, new CanHideIfPluginEnabled(OsmEditingPlugin.class)),
+ new DashFragmentData(DashAudioVideoNotesFragment.TAG, DashAudioVideoNotesFragment.class, "Notes", defaultShouldShow),
+ new DashFragmentData(DashTrackFragment.TAG, DashTrackFragment.class, "Track", defaultShouldShow),
+ new DashFragmentData(DashOsMoFragment.TAG, DashOsMoFragment.class, "OsMo", defaultShouldShow),
+ new DashFragmentData(DashOsmEditsFragment.TAG, DashOsmEditsFragment.class, "OsmEdits", defaultShouldShow),
new DashFragmentData(DashPluginsFragment.TAG, DashPluginsFragment.class, "Plugins", defaultShouldShow),
- new DashFragmentData(DashSimulateFragment.TAG, DashSimulateFragment.class, "Simulate",
- simulateShouldShow, new CanHideIfPluginEnabled(OsmandDevelopmentPlugin.class)),
+ new DashFragmentData(DashSimulateFragment.TAG, DashSimulateFragment.class, "Simulate", simulateShouldShow),
};
private MapActivity mapActivity;
@@ -1001,24 +986,4 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
&& super.shouldShow(settings, activity, tag);
}
}
-
- private static class CanNotHideFunction implements DashFragmentData.CanHideFunction {
- @Override
- public boolean canHide() {
- return false;
- }
- }
-
- private static class CanHideIfPluginEnabled implements DashFragmentData.CanHideFunction {
- private final Class extends OsmandPlugin> pluginClass;
-
- public CanHideIfPluginEnabled(Class extends OsmandPlugin> pluginClass) {
- this.pluginClass = pluginClass;
- }
-
- @Override
- public boolean canHide() {
- return OsmandPlugin.getEnabledPlugin(pluginClass) != null;
- }
- }
}
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashFragmentData.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashFragmentData.java
index 7964d671a7..84224b332f 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashFragmentData.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashFragmentData.java
@@ -9,16 +9,16 @@ public final class DashFragmentData {
public final Class extends DashBaseFragment> fragmentClass;
public final String title;
public final ShouldShowFunction shouldShowFunction;
- public final CanHideFunction canHideFunction;
+ public final boolean customDeletionLogic;
public DashFragmentData(String tag, Class extends DashBaseFragment> fragmentClass,
String title, ShouldShowFunction shouldShowFunction,
- CanHideFunction canHideFunction) {
+ boolean customDeletionLogic) {
this.tag = tag;
this.fragmentClass = fragmentClass;
this.title = title;
this.shouldShowFunction = shouldShowFunction;
- this.canHideFunction = canHideFunction;
+ this.customDeletionLogic = customDeletionLogic;
}
public DashFragmentData(String tag, Class extends DashBaseFragment> fragmentClass,
@@ -27,14 +27,10 @@ public final class DashFragmentData {
this.fragmentClass = fragmentClass;
this.title = title;
this.shouldShowFunction = shouldShowFunction;
- this.canHideFunction = null;
+ customDeletionLogic = false;
}
public interface ShouldShowFunction {
boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag);
}
-
- public interface CanHideFunction {
- boolean canHide();
- }
}
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java
index a93700ed9b..7df0fc7d90 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java
@@ -34,8 +34,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
mapActivity = (MapActivity) activity;
ArrayList fragmentsList = new ArrayList<>();
for(DashFragmentData fragmentData : mapActivity.getDashboard().getFragmentsData()) {
- if (fragmentData.canHideFunction == null || fragmentData.canHideFunction.canHide())
- fragmentsList.add(fragmentData);
+ if (!fragmentData.customDeletionLogic) fragmentsList.add(fragmentData);
}
fragmentsData = fragmentsList.toArray(new DashFragmentData[fragmentsList.size()]);
}
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java
index d57aea49d4..24a789fbc2 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java
@@ -3,9 +3,9 @@ package net.osmand.plus.osmedit;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
-import android.text.Editable;
+import android.support.v4.view.ViewPager;
import android.text.TextUtils;
-import android.text.TextWatcher;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -17,14 +17,10 @@ import android.widget.LinearLayout;
import net.osmand.plus.R;
import net.osmand.plus.osmedit.EditPoiFragment.Tag;
-import java.util.Iterator;
-
public class AdvancedDataFragment extends Fragment {
private static final String TAG = "AdvancedDataFragment";
private TagAdapterLinearLayoutHack mAdapter;
- private EditPoiFragment.EditPoiData.TagsChangedListener mTagsChangedListener;
- private boolean mIsUserInput = true;
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
@@ -52,6 +48,8 @@ public class AdvancedDataFragment extends Fragment {
});
LinearLayout editTagsLineaLayout =
(LinearLayout) view.findViewById(R.id.editTagsList);
+ Log.v(TAG, "arguments=" + savedInstanceState + "; ll=" + editTagsLineaLayout);
+ Log.v(TAG, "not restored");
mAdapter = new TagAdapterLinearLayoutHack(editTagsLineaLayout, getData());
// setListViewHeightBasedOnChildren(editTagsLineaLayout);
Button addTagButton = (Button) view.findViewById(R.id.addTagButton);
@@ -78,29 +76,29 @@ public class AdvancedDataFragment extends Fragment {
super.onResume();
// TODO read more about lifecycle
mAdapter.updateViews();
- mTagsChangedListener = new EditPoiFragment.EditPoiData.TagsChangedListener() {
+ getEditPoiFragment().addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
- public void onTagsChanged() {
- mIsUserInput = false;
- mAdapter.updateViews();
- mIsUserInput = true;
+ public void onPageScrolled(int i, float v, int i1) {
}
- };
- getData().addListener(mTagsChangedListener);
- }
- @Override
- public void onPause() {
- super.onPause();
- getData().deleteListener(mTagsChangedListener);
+ @Override
+ public void onPageSelected(int i) {
+ if (i == 1) mAdapter.updateViews();
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int i) {
+ }
+ });
}
@Override
public void onSaveInstanceState(Bundle outState) {
+ Log.v(TAG, "onSaveInstanceState(" + "outState=" + outState + ")");
super.onSaveInstanceState(outState);
}
- public class TagAdapterLinearLayoutHack {
+ public static class TagAdapterLinearLayoutHack {
private final LinearLayout linearLayout;
private final EditPoiFragment.EditPoiData editPoiData;
@@ -113,79 +111,41 @@ public class AdvancedDataFragment extends Fragment {
public void addTag(Tag tag) {
View view = getView(tag);
editPoiData.tags.add(tag);
- if (mIsUserInput)
- editPoiData.notifyDatasetChanged(mTagsChangedListener);
EditText valueEditText = (EditText) view.findViewById(R.id.valueEditText);
+ Log.v(TAG, "valueEditText text=" + valueEditText.getText());
linearLayout.addView(view);
}
public void updateViews() {
linearLayout.removeAllViews();
- Iterator iterator = editPoiData.tags.iterator();
- while (iterator.hasNext()) {
- iterator.next();
- }
+ Log.v(TAG, "editPoiData.tags=" + editPoiData.tags);
for (Tag tag : editPoiData.tags) {
+ Log.v(TAG, "tag=" + tag);
View view = getView(tag);
EditText valueEditText = (EditText) view.findViewById(R.id.valueEditText);
+ Log.v(TAG, "valueEditText text=" + valueEditText.getText());
linearLayout.addView(view);
}
}
private View getView(final Tag tag) {
+ Log.v(TAG, "getView(" + "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);
- tagEditText.setText(tag.tag);
- final EditText valueEditText = (EditText) convertView.findViewById(R.id.valueEditText);
+ EditText tagEditText = (EditText) convertView.findViewById(R.id.tagEditText);
+ EditText valueEditText = (EditText) convertView.findViewById(R.id.valueEditText);
ImageButton deleteItemImageButton =
(ImageButton) convertView.findViewById(R.id.deleteItemImageButton);
+ tagEditText.setText(tag.tag);
valueEditText.setText(tag.value);
deleteItemImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
linearLayout.removeView((View) v.getParent());
editPoiData.tags.remove(tag);
- if (mIsUserInput)
- editPoiData.notifyDatasetChanged(mTagsChangedListener);
- }
- });
- tagEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- editPoiData.tags.remove(tag);
- tag.tag = tagEditText.getText().toString();
- editPoiData.tags.add(tag);
- if (mIsUserInput)
- editPoiData.notifyDatasetChanged(mTagsChangedListener);
- }
- });
- valueEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- editPoiData.tags.remove(tag);
- tag.value = valueEditText.getText().toString();
- editPoiData.tags.add(tag);
- if (mIsUserInput)
- editPoiData.notifyDatasetChanged(mTagsChangedListener);
}
});
+ Log.v(TAG, "convertView=" + convertView);
return convertView;
}
}
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java
index 4d0638c618..1f47085ba6 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java
@@ -2,61 +2,28 @@ package net.osmand.plus.osmedit;
import android.annotation.TargetApi;
import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
-import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.Button;
-import android.widget.EditText;
import android.widget.ImageButton;
-import android.widget.Toast;
-import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
-import net.osmand.osm.MapPoiTypes;
-import net.osmand.osm.PoiCategory;
-import net.osmand.osm.PoiType;
-import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.Node;
-import net.osmand.osm.edit.OSMSettings;
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
-import net.osmand.plus.activities.MapActivity;
-import net.osmand.util.Algorithms;
import java.io.Serializable;
-import java.text.MessageFormat;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
public class EditPoiFragment extends Fragment {
public static final String TAG = "EditPoiFragment";
@@ -67,43 +34,27 @@ public class EditPoiFragment extends Fragment {
private final EditPoiData editPoiData = new EditPoiData();
private ViewPager viewPager;
- private boolean isLocalEdit;
- private boolean mIsUserInput = true;
- private EditText poiNameEditText;
- private EditPoiData.TagsChangedListener mTagsChangedListener;
- private AutoCompleteTextView poiTypeEditText;
- private Node node;
- private Map allTranslatedSubTypes;
- private String poiTypeTag;
- private Amenity amenity;
- private OpenstreetmapUtil openstreetmapUtil;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
// poiTypes = ((OsmandApplication) activity.getApplication()).getPoiTypes();
// allTranslatedSubTypes = poiTypes.getAllTranslatedNames();
- OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
+// OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
// editPoiData.isLocalEdit = true;
- OsmEditingPlugin plugin = (OsmEditingPlugin) OsmandPlugin.getPlugin(OsmEditingPlugin.class);
- if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
- openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
+// if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
+// openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
// openstreetmapUtilToLoad = openstreetmapUtil;
- } else if (!settings.isInternetConnectionAvailable(true)) {
- openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
+// } else if(!settings.isInternetConnectionAvailable(true)) {
+// openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
// openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
- } else {
- isLocalEdit = false;
- openstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
+// } else {
+// editPoiData.isLocalEdit = false;
+// openstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
// openstreetmapUtilToLoad = openstreetmapUtil;
- }
+// }
- node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE);
- allTranslatedSubTypes = ((OsmandApplication) activity.getApplication()).getPoiTypes()
- .getAllTranslatedNames();
- // TODO implement normal name
- poiTypeTag = "amenity";
- amenity = (Amenity) getArguments().getSerializable(KEY_AMENITY);
+// editPoiData.node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE);
// editPoiData.tags = new LinkedHashSet<>();
}
@@ -163,190 +114,21 @@ public class EditPoiFragment extends Fragment {
Uri.parse("https://wiki.openstreetmap.org/wiki/Map_Features")));
}
});
- ImageButton poiTypeButton = (ImageButton) view.findViewById(R.id.poiTypeButton);
- poiTypeButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- DialogFragment fragment = PoiTypeDialogFragment.createInstance(amenity);
- fragment.show(getChildFragmentManager(), "PoiTypeDialogFragment");
- }
- });
-
- poiNameEditText = (EditText) view.findViewById(R.id.poiNameEditText);
- poiNameEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- final Tag tag = new Tag(OSMSettings.OSMTagKey.NAME.getValue(), s.toString());
- if (mIsUserInput) {
- getEditPoiData().tags.remove(tag);
- getEditPoiData().tags.add(tag);
- getEditPoiData().notifyDatasetChanged(mTagsChangedListener);
- }
- }
- });
- poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText);
- poiTypeEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- final Tag tag = new Tag(poiTypeTag, s.toString());
- if (mIsUserInput) {
- getEditPoiData().tags.remove(tag);
- getEditPoiData().tags.add(tag);
- getEditPoiData().notifyDatasetChanged(mTagsChangedListener);
- }
- }
- });
- poiTypeEditText.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if(poiTypeEditText.getText().length() == 0 && amenity.getType() != null){
- DialogFragment dialogFragment = PoiSubTypeDialogFragment.createInstance(amenity);
- dialogFragment.show(getChildFragmentManager(), "PoiSubTypeDialogFragment");
- }
- }
- });
-
- Button saveButton = (Button) view.findViewById(R.id.saveButton);
- int saveButtonTextId = isLocalEdit ? R.string.shared_string_save :
- R.string.default_buttons_commit;
- saveButton.setText(saveButtonTextId);
- saveButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO implement saving
- OsmPoint.Action action = node.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
- String description = "";
- for (Tag tag : editPoiData.tags) {
- if (tag.tag.equals(poiTypeTag)) {
- if (allTranslatedSubTypes.get(tag.value) != null) {
- PoiType pt = allTranslatedSubTypes.get(tag.value);
- node.putTag(pt.getOsmTag(), pt.getOsmValue());
- if (pt.getOsmTag2() != null) {
- node.putTag(pt.getOsmTag2(), pt.getOsmValue2());
- }
- } else {
- node.putTag(amenity.getType().getDefaultTag(), tag.value);
- }
- } else if (tag.tag.equals(OSMSettings.OSMTagKey.DESCRIPTION.getValue())) {
- description = tag.value;
- } else {
- if (tag.value.length() > 0) {
- node.putTag(tag.tag, tag.value);
- } else {
- node.removeTag(tag.tag);
- }
- }
- }
- commitNode(action, node, openstreetmapUtil.getEntityInfo(),
- "",
- false,//closeChange.isSelected(),
- new Runnable() {
- @Override
- public void run() {
- if (isLocalEdit) {
- AccessibleToast.makeText(
- getActivity(), R.string.osm_changes_added_to_local_edits,
- Toast.LENGTH_LONG).show();
- } else {
- final String message = node.getId() == -1 ? getResources().getString(R.string.poi_action_add)
- : getResources().getString(R.string.poi_action_change);
-
- AccessibleToast.makeText(
- getActivity(),
- MessageFormat.format(
- getResources().getString(
- R.string.poi_action_succeded_template), message),
- Toast.LENGTH_LONG).show();
- }
- if (getActivity() instanceof MapActivity) {
- ((MapActivity) getActivity()).getMapView().refreshMap(true);
- }
- FragmentManager fragmentManager =
- getActivity().getSupportFragmentManager();
- fragmentManager.beginTransaction().remove(EditPoiFragment.this)
- .commit();
- fragmentManager.popBackStack();
- }
- }, getActivity());
-
- }
- });
- Button cancelButton = (Button) view.findViewById(R.id.cancelButton);
- cancelButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
- fragmentManager.beginTransaction().remove(EditPoiFragment.this).commit();
- fragmentManager.popBackStack();
- }
- });
return view;
}
- @Override
- public void onResume() {
- super.onResume();
- mTagsChangedListener = new EditPoiFragment.EditPoiData.TagsChangedListener() {
- @Override
- public void onTagsChanged() {
- Log.v(TAG, "onTagsChanged(" + ")");
- mIsUserInput = false;
- String poiName = null;
- String poiType = null;
- for (Tag tag : editPoiData.tags) {
- // TODO replace with constants
- if (tag.tag.equals(OSMSettings.OSMTagKey.NAME.getValue())) poiName = tag.value;
- if (tag.tag.equals(poiTypeTag)) poiType = tag.value;
- }
- poiNameEditText.setText(poiName);
- poiTypeEditText.setText(poiType);
- mIsUserInput = true;
- }
- };
- editPoiData.addListener(mTagsChangedListener);
- }
-
- @Override
- public void onPause() {
- super.onPause();
- editPoiData.deleteListener(mTagsChangedListener);
- }
-
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putSerializable(TAGS_LIST, editPoiData.tags);
super.onSaveInstanceState(outState);
}
- public static EditPoiFragment createAddPoiInstance(double latitude, double longitude,
- OsmandApplication application) {
- Node node = new Node(latitude, longitude, -1);
- Amenity amenity;
- amenity = new Amenity();
- amenity.setType(application.getPoiTypes().getOtherPoiCategory());
- amenity.setSubType("");
- amenity.setAdditionalInfo(OSMSettings.OSMTagKey.OPENING_HOURS.getValue(), "");
- return createInstance(node, amenity);
+ public void addOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
+ viewPager.addOnPageChangeListener(listener);
}
- public static EditPoiFragment createInstance(Node node, Amenity amenity) {
+ public EditPoiFragment createInstance(Node node, Amenity amenity) {
EditPoiFragment editPoiFragment = new EditPoiFragment();
Bundle args = new Bundle();
args.putSerializable(KEY_AMENITY_NODE, node);
@@ -359,78 +141,8 @@ public class EditPoiFragment extends Fragment {
return editPoiData;
}
- public void setSubCategory(String subCategory) {
- poiTypeEditText.setText(subCategory);
- }
-
- public void commitNode(final OsmPoint.Action action,
- final Node n,
- final EntityInfo info,
- final String comment,
- final boolean closeChangeSet,
- final Runnable successAction,
- final Activity activity) {
- if (info == null && OsmPoint.Action.CREATE != action) {
- AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_info_not_loaded), Toast.LENGTH_LONG).show();
- return;
- }
- new AsyncTask() {
- ProgressDialog progress;
-
- @Override
- protected void onPreExecute() {
- progress = ProgressDialog.show(activity, activity.getString(R.string.uploading), activity.getString(R.string.uploading_data));
- super.onPreExecute();
- }
-
- @Override
- protected Node doInBackground(Void... params) {
- Node node = openstreetmapUtil.commitNodeImpl(action, n, info, comment, closeChangeSet);
- return node;
- }
-
- @Override
- protected void onPostExecute(Node result) {
- progress.dismiss();
- if (result != null) {
- successAction.run();
- }
- }
-
- ;
- }.execute();
- }
-
- private void updateType(Amenity amenity) {
- // TODO implement
- Log.v(TAG, "updateType(" + "amenity=" + amenity + ")");
- poiTypeEditText.setText(amenity.getSubType());
-
- final Map subCategories = new LinkedHashMap<>();
- for (Map.Entry s : allTranslatedSubTypes.entrySet()) {
- if (!subCategories.containsKey(s.getKey())) {
- subCategories.put(Algorithms.capitalizeFirstLetterAndLowercase(s.getKey()), s.getValue());
- }
- }
-
- final ArrayAdapter