Renamed Edit Poi Class to more appropriate names.

This commit is contained in:
GaidamakUA 2015-10-26 12:50:41 +02:00
parent 0063091275
commit 429284992e
11 changed files with 64 additions and 63 deletions

View file

@ -7,7 +7,7 @@
android:background="?attr/spinnerListBackground" android:background="?attr/spinnerListBackground"
android:clickable="true" android:clickable="true"
android:orientation="vertical" android:orientation="vertical"
tools:context="net.osmand.plus.osmedit.EditPoiFragment"> tools:context="net.osmand.plus.osmedit.EditPoiDialogFragment">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"

View file

@ -1,14 +1,10 @@
package net.osmand.plus.activities; package net.osmand.plus.activities;
import java.io.File; import android.content.Context;
import java.text.ParseException; import android.os.Build;
import java.util.ArrayList; import android.support.annotation.DrawableRes;
import java.util.Arrays; import android.support.annotation.StringRes;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.map.ITileSource; import net.osmand.map.ITileSource;
@ -19,10 +15,15 @@ import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.download.ui.LocalIndexesFragment.LoadLocalIndexTask; import net.osmand.plus.download.ui.LocalIndexesFragment.LoadLocalIndexTask;
import net.osmand.plus.voice.MediaCommandPlayerImpl; import net.osmand.plus.voice.MediaCommandPlayerImpl;
import net.osmand.plus.voice.TTSCommandPlayerImpl; import net.osmand.plus.voice.TTSCommandPlayerImpl;
import android.content.Context;
import android.os.Build; import java.io.File;
import android.support.annotation.DrawableRes; import java.text.ParseException;
import android.support.annotation.StringRes; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
public class LocalIndexHelper { public class LocalIndexHelper {
@ -89,7 +90,7 @@ public class LocalIndexHelper {
public List<LocalIndexInfo> getLocalIndexData(LoadLocalIndexTask loadTask){ public List<LocalIndexInfo> getLocalIndexData(LoadLocalIndexTask loadTask){
Map<String, String> loadedMaps = app.getResourceManager().getIndexFileNames(); Map<String, String> loadedMaps = app.getResourceManager().getIndexFileNames();
List<LocalIndexInfo> result = new ArrayList<LocalIndexInfo>(); List<LocalIndexInfo> result = new ArrayList<>();
loadObfData(app.getAppPath(IndexConstants.MAPS_PATH), result, false, loadTask, loadedMaps); loadObfData(app.getAppPath(IndexConstants.MAPS_PATH), result, false, loadTask, loadedMaps);
loadObfData(app.getAppPath(IndexConstants.ROADS_INDEX_DIR), result, false, loadTask, loadedMaps); loadObfData(app.getAppPath(IndexConstants.ROADS_INDEX_DIR), result, false, loadTask, loadedMaps);
@ -211,8 +212,8 @@ public class LocalIndexHelper {
TILES_DATA(R.string.local_indexes_cat_tile), TILES_DATA(R.string.local_indexes_cat_tile),
SRTM_DATA(R.string.local_indexes_cat_srtm, R.drawable.ic_plugin_srtm), SRTM_DATA(R.string.local_indexes_cat_srtm, R.drawable.ic_plugin_srtm),
WIKI_DATA(R.string.local_indexes_cat_wiki, R.drawable.ic_plugin_wikipedia), WIKI_DATA(R.string.local_indexes_cat_wiki, R.drawable.ic_plugin_wikipedia),
TTS_VOICE_DATA(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up); TTS_VOICE_DATA(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up),
VOICE_DATA(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up), VOICE_DATA(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up);
// AV_DATA(R.string.local_indexes_cat_av);; // AV_DATA(R.string.local_indexes_cat_av);;
@StringRes @StringRes
@ -220,12 +221,12 @@ public class LocalIndexHelper {
@DrawableRes @DrawableRes
private int iconResource; private int iconResource;
private LocalIndexType(@StringRes int resId, @DrawableRes int iconResource){ LocalIndexType(@StringRes int resId, @DrawableRes int iconResource){
this.resId = resId; this.resId = resId;
this.iconResource = iconResource; this.iconResource = iconResource;
} }
private LocalIndexType(@StringRes int resId){ LocalIndexType(@StringRes int resId){
this.resId = resId; this.resId = resId;
this.iconResource = R.drawable.ic_map; this.iconResource = R.drawable.ic_map;
} }

View file

@ -41,10 +41,10 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
public class AdvancedDataFragment extends Fragment public class AdvancedEditPoiFragment extends Fragment
implements EditPoiFragment.OnFragmentActivatedListener { implements EditPoiDialogFragment.OnFragmentActivatedListener {
private static final String TAG = "AdvancedDataFragment"; private static final String TAG = "AdvancedEditPoiFragment";
private static final Log LOG = PlatformUtil.getLog(AdvancedDataFragment.class); private static final Log LOG = PlatformUtil.getLog(AdvancedEditPoiFragment.class);
private TagAdapterLinearLayoutHack mAdapter; private TagAdapterLinearLayoutHack mAdapter;
private EditPoiData.TagsChangedListener mTagsChangedListener; private EditPoiData.TagsChangedListener mTagsChangedListener;
@ -134,8 +134,8 @@ public class AdvancedDataFragment extends Fragment
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
private EditPoiFragment getEditPoiFragment() { private EditPoiDialogFragment getEditPoiFragment() {
return (EditPoiFragment) getParentFragment(); return (EditPoiDialogFragment) getParentFragment();
} }
private EditPoiData getData() { private EditPoiData getData() {

View file

@ -35,10 +35,9 @@ import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
public class BasicDataFragment extends Fragment public class BasicEditPoiFragment extends Fragment
implements EditPoiFragment.OnFragmentActivatedListener { implements EditPoiDialogFragment.OnFragmentActivatedListener {
private static final String TAG = "BasicDataFragment"; private static final Log LOG = PlatformUtil.getLog(BasicEditPoiFragment.class);
private static final Log LOG = PlatformUtil.getLog(BasicDataFragment.class);
private static final String OPENING_HOURS = "opening_hours"; private static final String OPENING_HOURS = "opening_hours";
private EditText streetEditText; private EditText streetEditText;
private EditText houseNumberEditText; private EditText houseNumberEditText;
@ -163,8 +162,8 @@ public class BasicDataFragment extends Fragment
} }
private EditPoiFragment getEditPoiFragment() { private EditPoiDialogFragment getEditPoiFragment() {
return (EditPoiFragment) getParentFragment(); return (EditPoiDialogFragment) getParentFragment();
} }
private EditPoiData getData() { private EditPoiData getData() {

View file

@ -66,9 +66,9 @@ import java.text.MessageFormat;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
public class EditPoiFragment extends DialogFragment { public class EditPoiDialogFragment extends DialogFragment {
public static final String TAG = "EditPoiFragment"; public static final String TAG = "EditPoiDialogFragment";
private static final Log LOG = PlatformUtil.getLog(EditPoiFragment.class); private static final Log LOG = PlatformUtil.getLog(EditPoiDialogFragment.class);
private static final String KEY_AMENITY_NODE = "key_amenity_node"; private static final String KEY_AMENITY_NODE = "key_amenity_node";
private static final String KEY_AMENITY = "key_amenity"; private static final String KEY_AMENITY = "key_amenity";
@ -259,7 +259,7 @@ public class EditPoiFragment extends DialogFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
fragmentManager.beginTransaction().remove(EditPoiFragment.this).commit(); fragmentManager.beginTransaction().remove(EditPoiDialogFragment.this).commit();
fragmentManager.popBackStack(); fragmentManager.popBackStack();
} }
}); });
@ -354,7 +354,7 @@ public class EditPoiFragment extends DialogFragment {
} }
public static EditPoiFragment createAddPoiInstance(double latitude, double longitude, public static EditPoiDialogFragment createAddPoiInstance(double latitude, double longitude,
OsmandApplication application) { OsmandApplication application) {
Node node = new Node(latitude, longitude, -1); Node node = new Node(latitude, longitude, -1);
Amenity amenity; Amenity amenity;
@ -365,13 +365,13 @@ public class EditPoiFragment extends DialogFragment {
return createInstance(node, amenity); return createInstance(node, amenity);
} }
public static EditPoiFragment createInstance(Node node, Amenity amenity) { public static EditPoiDialogFragment createInstance(Node node, Amenity amenity) {
EditPoiFragment editPoiFragment = new EditPoiFragment(); EditPoiDialogFragment editPoiDialogFragment = new EditPoiDialogFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putSerializable(KEY_AMENITY_NODE, node); args.putSerializable(KEY_AMENITY_NODE, node);
args.putSerializable(KEY_AMENITY, amenity); args.putSerializable(KEY_AMENITY, amenity);
editPoiFragment.setArguments(args); editPoiDialogFragment.setArguments(args);
return editPoiFragment; return editPoiDialogFragment;
} }
public EditPoiData getEditPoiData() { public EditPoiData getEditPoiData() {
@ -500,8 +500,8 @@ public class EditPoiFragment extends DialogFragment {
protected void onPostExecute(Node n) { protected void onPostExecute(Node n) {
if (n != null) { if (n != null) {
EditPoiFragment fragment = EditPoiDialogFragment fragment =
EditPoiFragment.createInstance(n, amenity); EditPoiDialogFragment.createInstance(n, amenity);
fragment.show(activity.getSupportFragmentManager(), TAG); fragment.show(activity.getSupportFragmentManager(), TAG);
} else { } else {
AccessibleToast.makeText(activity, AccessibleToast.makeText(activity,
@ -513,8 +513,8 @@ public class EditPoiFragment extends DialogFragment {
} }
public static class MyAdapter extends FragmentPagerAdapter { public static class MyAdapter extends FragmentPagerAdapter {
private final Fragment[] fragments = new Fragment[]{new BasicDataFragment(), private final Fragment[] fragments = new Fragment[]{new BasicEditPoiFragment(),
new AdvancedDataFragment()}; new AdvancedEditPoiFragment()};
private final String[] titles; private final String[] titles;
public MyAdapter(FragmentManager fm, String basicTitle, String extendedTitle) { public MyAdapter(FragmentManager fm, String basicTitle, String extendedTitle) {

View file

@ -28,7 +28,6 @@ import net.osmand.plus.activities.EnumAdapter;
import net.osmand.plus.activities.EnumAdapter.IEnumWithResource; import net.osmand.plus.activities.EnumAdapter.IEnumWithResource;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TabActivity; import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.myplaces.AvailableGPXFragment; import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo; import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
@ -156,21 +155,21 @@ public class OsmEditingPlugin extends OsmandPlugin {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_create_poi) { if (resId == R.string.context_menu_item_create_poi) {
//getPoiActions(mapActivity).showCreateDialog(latitude, longitude); //getPoiActions(mapActivity).showCreateDialog(latitude, longitude);
EditPoiFragment editPoiFragment = EditPoiDialogFragment editPoiDialogFragment =
EditPoiFragment.createAddPoiInstance(latitude, longitude, EditPoiDialogFragment.createAddPoiInstance(latitude, longitude,
mapActivity.getMyApplication()); mapActivity.getMyApplication());
editPoiFragment.show(mapActivity.getSupportFragmentManager(), editPoiDialogFragment.show(mapActivity.getSupportFragmentManager(),
EditPoiFragment.TAG); EditPoiDialogFragment.TAG);
} else if (resId == R.string.context_menu_item_open_bug) { } else if (resId == R.string.context_menu_item_open_bug) {
if (osmBugsLayer == null) { if (osmBugsLayer == null) {
registerLayers(mapActivity); registerLayers(mapActivity);
} }
osmBugsLayer.openBug(latitude, longitude); osmBugsLayer.openBug(latitude, longitude);
} else if (resId == R.string.poi_context_menu_delete) { } else if (resId == R.string.poi_context_menu_delete) {
new EditPoiFragment.ShowDeleteDialogAsyncTask(mapActivity) new EditPoiDialogFragment.ShowDeleteDialogAsyncTask(mapActivity)
.execute((Amenity) selectedObj); .execute((Amenity) selectedObj);
} else if (resId == R.string.poi_context_menu_modify) { } else if (resId == R.string.poi_context_menu_modify) {
EditPoiFragment.showEditInstance((Amenity) selectedObj, mapActivity); EditPoiDialogFragment.showEditInstance((Amenity) selectedObj, mapActivity);
} }
return true; return true;
} }
@ -265,7 +264,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
Private(R.string.gpxup_private); Private(R.string.gpxup_private);
private final int resourceId; private final int resourceId;
private UploadVisibility(int resourceId) { UploadVisibility(int resourceId) {
this.resourceId = resourceId; this.resourceId = resourceId;
} }
@ -296,7 +295,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
} }
final EditText tags = (EditText) view.findViewById(R.id.TagsText); final EditText tags = (EditText) view.findViewById(R.id.TagsText);
final Spinner visibility = ((Spinner) view.findViewById(R.id.Visibility)); final Spinner visibility = ((Spinner) view.findViewById(R.id.Visibility));
EnumAdapter<UploadVisibility> adapter = new EnumAdapter<UploadVisibility>(la, android.R.layout.simple_spinner_item, UploadVisibility.values()); EnumAdapter<UploadVisibility> adapter = new EnumAdapter<>(la, android.R.layout.simple_spinner_item, UploadVisibility.values());
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
visibility.setAdapter(adapter); visibility.setAdapter(adapter);
visibility.setSelection(0); visibility.setSelection(0);

View file

@ -14,7 +14,7 @@ import net.osmand.osm.edit.Node;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.osmedit.EditPoiFragment; import net.osmand.plus.osmedit.EditPoiDialogFragment;
import net.osmand.plus.osmedit.OpenstreetmapLocalUtil; import net.osmand.plus.osmedit.OpenstreetmapLocalUtil;
import net.osmand.plus.osmedit.OpenstreetmapUtil; import net.osmand.plus.osmedit.OpenstreetmapUtil;
import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin;
@ -40,7 +40,7 @@ public class DeletePoiDialogFragment extends DialogFragment {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Node node = (Node) args.getSerializable(KEY_AMENITY_NODE); Node node = (Node) args.getSerializable(KEY_AMENITY_NODE);
EditPoiFragment.commitNode(OsmPoint.Action.DELETE, node, EditPoiDialogFragment.commitNode(OsmPoint.Action.DELETE, node,
mOpenstreetmapUtil.getEntityInfo(), null, false, mOpenstreetmapUtil.getEntityInfo(), null, false,
new Runnable() { new Runnable() {
@Override @Override

View file

@ -10,7 +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.plus.osmedit.BasicEditPoiFragment;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -69,7 +69,7 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment {
OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true) OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true)
.show(getFragmentManager(), "TimePickerDialogFragment"); .show(getFragmentManager(), "TimePickerDialogFragment");
} else { } else {
((BasicDataFragment) getParentFragment()) ((BasicEditPoiFragment) getParentFragment())
.setBasicOpeningHoursRule(item, positionToAdd); .setBasicOpeningHoursRule(item, positionToAdd);
} }
} }

View file

@ -14,7 +14,7 @@ import android.widget.TextView;
import android.widget.TimePicker; import android.widget.TimePicker;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.osmedit.BasicDataFragment; import net.osmand.plus.osmedit.BasicEditPoiFragment;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
public class OpeningHoursHoursDialogFragment extends DialogFragment { public class OpeningHoursHoursDialogFragment extends DialogFragment {
@ -63,7 +63,7 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment {
} else { } else {
item.setEndTime(time); item.setEndTime(time);
} }
((BasicDataFragment) getParentFragment()) ((BasicEditPoiFragment) getParentFragment())
.setBasicOpeningHoursRule(item, positionToAdd); .setBasicOpeningHoursRule(item, positionToAdd);
} }
} }

View file

@ -11,9 +11,10 @@ import net.osmand.data.Amenity;
import net.osmand.osm.MapPoiTypes; import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.osmedit.EditPoiFragment; import net.osmand.plus.osmedit.EditPoiDialogFragment;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class PoiSubTypeDialogFragment extends DialogFragment { public class PoiSubTypeDialogFragment extends DialogFragment {
private static final String KEY_AMENITY = "amenity"; private static final String KEY_AMENITY = "amenity";
@ -26,11 +27,12 @@ public class PoiSubTypeDialogFragment extends DialogFragment {
final Amenity a = (Amenity) getArguments().getSerializable(KEY_AMENITY); final Amenity a = (Amenity) getArguments().getSerializable(KEY_AMENITY);
final Map<String, PoiType> allTranslatedNames = poiTypes.getAllTranslatedNames(a.getType(), true); final Map<String, PoiType> allTranslatedNames = poiTypes.getAllTranslatedNames(a.getType(), true);
// (=^.^=) // (=^.^=)
final String[] subCats = allTranslatedNames.keySet().toArray(new String[0]); Set<String> strings = allTranslatedNames.keySet();
final String[] subCats = strings.toArray(new String[strings.size()]);
builder.setItems(subCats, new DialogInterface.OnClickListener() { builder.setItems(subCats, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
((EditPoiFragment) getParentFragment()).setSubCategory(subCats[which]); ((EditPoiDialogFragment) getParentFragment()).setSubCategory(subCats[which]);
dismiss(); dismiss();
} }
}); });

View file

@ -11,7 +11,7 @@ import net.osmand.data.Amenity;
import net.osmand.osm.MapPoiTypes; import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiCategory;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.osmedit.EditPoiFragment; import net.osmand.plus.osmedit.EditPoiDialogFragment;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -45,7 +45,7 @@ public class PoiTypeDialogFragment extends DialogFragment {
if (aType != amenity.getType()) { if (aType != amenity.getType()) {
amenity.setType(aType); amenity.setType(aType);
amenity.setSubType(""); //$NON-NLS-1$ amenity.setSubType(""); //$NON-NLS-1$
((EditPoiFragment) getParentFragment()).updateType(amenity); ((EditPoiDialogFragment) getParentFragment()).updateType(amenity);
} }
dismiss(); dismiss();
} }