diff --git a/OsmAnd/res/layout/fragment_edit_poi.xml b/OsmAnd/res/layout/fragment_edit_poi.xml index 1e7b216d3f..8b842aee23 100644 --- a/OsmAnd/res/layout/fragment_edit_poi.xml +++ b/OsmAnd/res/layout/fragment_edit_poi.xml @@ -7,7 +7,7 @@ android:background="?attr/spinnerListBackground" android:clickable="true" android:orientation="vertical" - tools:context="net.osmand.plus.osmedit.EditPoiFragment"> + tools:context="net.osmand.plus.osmedit.EditPoiDialogFragment"> getLocalIndexData(LoadLocalIndexTask loadTask){ Map loadedMaps = app.getResourceManager().getIndexFileNames(); - List result = new ArrayList(); + List result = new ArrayList<>(); loadObfData(app.getAppPath(IndexConstants.MAPS_PATH), result, false, loadTask, loadedMaps); loadObfData(app.getAppPath(IndexConstants.ROADS_INDEX_DIR), result, false, loadTask, loadedMaps); @@ -220,12 +221,12 @@ public class LocalIndexHelper { @DrawableRes private int iconResource; - private LocalIndexType(@StringRes int resId, @DrawableRes int iconResource){ + LocalIndexType(@StringRes int resId, @DrawableRes int iconResource){ this.resId = resId; this.iconResource = iconResource; } - private LocalIndexType(@StringRes int resId){ + LocalIndexType(@StringRes int resId){ this.resId = resId; this.iconResource = R.drawable.ic_map; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java similarity index 96% rename from OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java rename to OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index d92a96d32b..d77d2d4149 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -41,10 +41,10 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -public class AdvancedDataFragment extends Fragment - implements EditPoiFragment.OnFragmentActivatedListener { - private static final String TAG = "AdvancedDataFragment"; - private static final Log LOG = PlatformUtil.getLog(AdvancedDataFragment.class); +public class AdvancedEditPoiFragment extends Fragment + implements EditPoiDialogFragment.OnFragmentActivatedListener { + private static final String TAG = "AdvancedEditPoiFragment"; + private static final Log LOG = PlatformUtil.getLog(AdvancedEditPoiFragment.class); private TagAdapterLinearLayoutHack mAdapter; private EditPoiData.TagsChangedListener mTagsChangedListener; @@ -134,8 +134,8 @@ public class AdvancedDataFragment extends Fragment super.onSaveInstanceState(outState); } - private EditPoiFragment getEditPoiFragment() { - return (EditPoiFragment) getParentFragment(); + private EditPoiDialogFragment getEditPoiFragment() { + return (EditPoiDialogFragment) getParentFragment(); } private EditPoiData getData() { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/BasicEditPoiFragment.java similarity index 97% rename from OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java rename to OsmAnd/src/net/osmand/plus/osmedit/BasicEditPoiFragment.java index affa4f162c..d98f37224a 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/BasicEditPoiFragment.java @@ -35,10 +35,9 @@ import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule; import org.apache.commons.logging.Log; -public class BasicDataFragment extends Fragment - implements EditPoiFragment.OnFragmentActivatedListener { - private static final String TAG = "BasicDataFragment"; - private static final Log LOG = PlatformUtil.getLog(BasicDataFragment.class); +public class BasicEditPoiFragment extends Fragment + implements EditPoiDialogFragment.OnFragmentActivatedListener { + private static final Log LOG = PlatformUtil.getLog(BasicEditPoiFragment.class); private static final String OPENING_HOURS = "opening_hours"; private EditText streetEditText; private EditText houseNumberEditText; @@ -119,6 +118,7 @@ public class BasicDataFragment extends Fragment mOpeningHoursAdapter = new OpeningHoursAdapter(new OpeningHoursParser.OpeningHours(), openHoursContainer, getData(), clockDrawable, deleteDrawable); } + onFragmentActivated(); return view; } @@ -163,8 +163,8 @@ public class BasicDataFragment extends Fragment } - private EditPoiFragment getEditPoiFragment() { - return (EditPoiFragment) getParentFragment(); + private EditPoiDialogFragment getEditPoiFragment() { + return (EditPoiDialogFragment) getParentFragment(); } private EditPoiData getData() { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java similarity index 96% rename from OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java rename to OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 246be98421..931b87876e 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -66,9 +66,9 @@ import java.text.MessageFormat; import java.util.LinkedHashMap; import java.util.Map; -public class EditPoiFragment extends DialogFragment { - public static final String TAG = "EditPoiFragment"; - private static final Log LOG = PlatformUtil.getLog(EditPoiFragment.class); +public class EditPoiDialogFragment extends DialogFragment { + public static final String TAG = "EditPoiDialogFragment"; + 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 = "key_amenity"; @@ -259,7 +259,7 @@ public class EditPoiFragment extends DialogFragment { @Override public void onClick(View v) { FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); - fragmentManager.beginTransaction().remove(EditPoiFragment.this).commit(); + fragmentManager.beginTransaction().remove(EditPoiDialogFragment.this).commit(); 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) { Node node = new Node(latitude, longitude, -1); Amenity amenity; @@ -365,13 +365,13 @@ public class EditPoiFragment extends DialogFragment { return createInstance(node, amenity); } - public static EditPoiFragment createInstance(Node node, Amenity amenity) { - EditPoiFragment editPoiFragment = new EditPoiFragment(); + public static EditPoiDialogFragment createInstance(Node node, Amenity amenity) { + EditPoiDialogFragment editPoiDialogFragment = new EditPoiDialogFragment(); Bundle args = new Bundle(); args.putSerializable(KEY_AMENITY_NODE, node); args.putSerializable(KEY_AMENITY, amenity); - editPoiFragment.setArguments(args); - return editPoiFragment; + editPoiDialogFragment.setArguments(args); + return editPoiDialogFragment; } public EditPoiData getEditPoiData() { @@ -500,8 +500,8 @@ public class EditPoiFragment extends DialogFragment { protected void onPostExecute(Node n) { if (n != null) { - EditPoiFragment fragment = - EditPoiFragment.createInstance(n, amenity); + EditPoiDialogFragment fragment = + EditPoiDialogFragment.createInstance(n, amenity); fragment.show(activity.getSupportFragmentManager(), TAG); } else { AccessibleToast.makeText(activity, @@ -513,8 +513,8 @@ public class EditPoiFragment extends DialogFragment { } public static class MyAdapter extends FragmentPagerAdapter { - private final Fragment[] fragments = new Fragment[]{new BasicDataFragment(), - new AdvancedDataFragment()}; + private final Fragment[] fragments = new Fragment[]{new BasicEditPoiFragment(), + new AdvancedEditPoiFragment()}; private final String[] titles; public MyAdapter(FragmentManager fm, String basicTitle, String extendedTitle) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 54c94651d1..d42a6bc8e6 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -28,7 +28,6 @@ import net.osmand.plus.activities.EnumAdapter; import net.osmand.plus.activities.EnumAdapter.IEnumWithResource; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.TabActivity; -import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.myplaces.AvailableGPXFragment; 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) { if (resId == R.string.context_menu_item_create_poi) { //getPoiActions(mapActivity).showCreateDialog(latitude, longitude); - EditPoiFragment editPoiFragment = - EditPoiFragment.createAddPoiInstance(latitude, longitude, + EditPoiDialogFragment editPoiDialogFragment = + EditPoiDialogFragment.createAddPoiInstance(latitude, longitude, mapActivity.getMyApplication()); - editPoiFragment.show(mapActivity.getSupportFragmentManager(), - EditPoiFragment.TAG); + editPoiDialogFragment.show(mapActivity.getSupportFragmentManager(), + EditPoiDialogFragment.TAG); } else if (resId == R.string.context_menu_item_open_bug) { if (osmBugsLayer == null) { registerLayers(mapActivity); } osmBugsLayer.openBug(latitude, longitude); } else if (resId == R.string.poi_context_menu_delete) { - new EditPoiFragment.ShowDeleteDialogAsyncTask(mapActivity) + new EditPoiDialogFragment.ShowDeleteDialogAsyncTask(mapActivity) .execute((Amenity) selectedObj); } else if (resId == R.string.poi_context_menu_modify) { - EditPoiFragment.showEditInstance((Amenity) selectedObj, mapActivity); + EditPoiDialogFragment.showEditInstance((Amenity) selectedObj, mapActivity); } return true; } @@ -265,7 +264,7 @@ public class OsmEditingPlugin extends OsmandPlugin { Private(R.string.gpxup_private); private final int resourceId; - private UploadVisibility(int resourceId) { + UploadVisibility(int resourceId) { this.resourceId = resourceId; } @@ -296,7 +295,7 @@ public class OsmEditingPlugin extends OsmandPlugin { } final EditText tags = (EditText) view.findViewById(R.id.TagsText); final Spinner visibility = ((Spinner) view.findViewById(R.id.Visibility)); - EnumAdapter adapter = new EnumAdapter(la, android.R.layout.simple_spinner_item, UploadVisibility.values()); + EnumAdapter adapter = new EnumAdapter<>(la, android.R.layout.simple_spinner_item, UploadVisibility.values()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); visibility.setAdapter(adapter); visibility.setSelection(0); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java index a2b15ec7a5..f4dee8ebdf 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java @@ -14,7 +14,7 @@ import net.osmand.osm.edit.Node; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; 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.OpenstreetmapUtil; import net.osmand.plus.osmedit.OsmEditingPlugin; @@ -40,7 +40,7 @@ public class DeletePoiDialogFragment extends DialogFragment { @Override public void onClick(DialogInterface dialog, int which) { Node node = (Node) args.getSerializable(KEY_AMENITY_NODE); - EditPoiFragment.commitNode(OsmPoint.Action.DELETE, node, + EditPoiDialogFragment.commitNode(OsmPoint.Action.DELETE, node, mOpenstreetmapUtil.getEntityInfo(), null, false, new Runnable() { @Override diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java index cafc2b2a00..2fb9b0bf71 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursDaysDialogFragment.java @@ -10,7 +10,7 @@ import android.text.format.DateFormat; import net.osmand.PlatformUtil; import net.osmand.plus.R; -import net.osmand.plus.osmedit.BasicDataFragment; +import net.osmand.plus.osmedit.BasicEditPoiFragment; import net.osmand.util.OpeningHoursParser; import org.apache.commons.logging.Log; @@ -69,7 +69,7 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment { OpeningHoursHoursDialogFragment.createInstance(item, positionToAdd, true) .show(getFragmentManager(), "TimePickerDialogFragment"); } else { - ((BasicDataFragment) getParentFragment()) + ((BasicEditPoiFragment) getParentFragment()) .setBasicOpeningHoursRule(item, positionToAdd); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursHoursDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursHoursDialogFragment.java index 36bf8f630c..5db6ae1a50 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursHoursDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/OpeningHoursHoursDialogFragment.java @@ -14,7 +14,7 @@ import android.widget.TextView; import android.widget.TimePicker; import net.osmand.plus.R; -import net.osmand.plus.osmedit.BasicDataFragment; +import net.osmand.plus.osmedit.BasicEditPoiFragment; import net.osmand.util.OpeningHoursParser; public class OpeningHoursHoursDialogFragment extends DialogFragment { @@ -63,7 +63,7 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment { } else { item.setEndTime(time); } - ((BasicDataFragment) getParentFragment()) + ((BasicEditPoiFragment) getParentFragment()) .setBasicOpeningHoursRule(item, positionToAdd); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java index d04ce7ba53..d69075340f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java @@ -11,9 +11,10 @@ import net.osmand.data.Amenity; import net.osmand.osm.MapPoiTypes; import net.osmand.osm.PoiType; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.osmedit.EditPoiFragment; +import net.osmand.plus.osmedit.EditPoiDialogFragment; import java.util.Map; +import java.util.Set; public class PoiSubTypeDialogFragment extends DialogFragment { 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 Map allTranslatedNames = poiTypes.getAllTranslatedNames(a.getType(), true); // (=^.^=) - final String[] subCats = allTranslatedNames.keySet().toArray(new String[0]); + Set strings = allTranslatedNames.keySet(); + final String[] subCats = strings.toArray(new String[strings.size()]); builder.setItems(subCats, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - ((EditPoiFragment) getParentFragment()).setSubCategory(subCats[which]); + ((EditPoiDialogFragment) getParentFragment()).setSubCategory(subCats[which]); dismiss(); } }); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java index 077329c2c3..3344d83f5e 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java @@ -11,7 +11,7 @@ import net.osmand.data.Amenity; import net.osmand.osm.MapPoiTypes; import net.osmand.osm.PoiCategory; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.osmedit.EditPoiFragment; +import net.osmand.plus.osmedit.EditPoiDialogFragment; import java.util.ArrayList; import java.util.List; @@ -45,7 +45,7 @@ public class PoiTypeDialogFragment extends DialogFragment { if (aType != amenity.getType()) { amenity.setType(aType); amenity.setSubType(""); //$NON-NLS-1$ - ((EditPoiFragment) getParentFragment()).updateType(amenity); + ((EditPoiDialogFragment) getParentFragment()).updateType(amenity); } dismiss(); }