Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-08-28 15:34:45 +02:00
commit 21b65c3882
11 changed files with 227 additions and 103 deletions

View file

@ -32,6 +32,7 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="name"
android:textColor="@color/dashboard_black"
android:textSize="14sp"
osmand:typeface="@string/font_roboto_regular"/>
@ -46,6 +47,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textColor="@color/dashboard_black"
android:textSize="14sp"
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout>
@ -67,6 +69,7 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="amenity"
android:textColor="@color/dashboard_black"
android:textSize="14sp"
osmand:typeface="@string/font_roboto_regular"/>
@ -81,6 +84,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textColor="@color/dashboard_black"
android:textSize="14sp"
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout>
@ -93,12 +97,12 @@
android:orientation="vertical"
android:saveEnabled="false"/>
<include layout="@layout/poi_tag_list_item"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/addTagButton"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:text="Add tag"
android:textSize="@dimen/default_sub_text_size"
osmand:typeface="@string/font_roboto_medium"/>

View file

@ -93,9 +93,10 @@
android:layout_height="wrap_content"
android:layout_below="@id/descriptionEditText"
android:layout_marginLeft="16dp"
android:layout_marginTop="18dp"
android:text="Open hours"
android:textColor="@color/color_black"
osmand:typeface="@string/font_roboto_medium" />
osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout
android:id="@+id/openHoursContainer"
@ -104,6 +105,13 @@
android:layout_below="@id/openHoursTextView"
android:orientation="vertical"/>
<ImageView
android:id="@+id/openingHoursImageView"
style="@style/edit_poi_imageview_style"
android:layout_below="@id/openHoursContainer"
android:layout_marginTop="12dp"
tools:src="@drawable/ic_action_time"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/addOpeningHoursButton"
android:layout_width="wrap_content"
@ -117,6 +125,7 @@
<!--XXX due to bug in NestedScroolView-->
<Space
android:layout_width="match_parent"
android:layout_height="500dp"/>
android:layout_height="500dp"
tools:visibility="gone"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>

View file

@ -9,16 +9,15 @@
<ImageView
android:id="@+id/clockIconImageView"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_action_time"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginLeft="36dp"
android:layout_weight="1"
android:orientation="vertical">

View file

@ -4,55 +4,42 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="horizontal"
android:paddingTop="16dp">
<LinearLayout
android:layout_width="match_parent"
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
<EditText
android:id="@+id/tagEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
android:hint="Tag"/>
<EditText
android:id="@+id/tagEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Tag"/>
</android.support.design.widget.TextInputLayout>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
<EditText
android:id="@+id/valueEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
android:hint="Value"/>
<EditText
android:id="@+id/valueEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Value"/>
</android.support.design.widget.TextInputLayout>
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="@+id/deleteItemImageButton"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:src="@drawable/ic_action_close_dark"/>
</LinearLayout>
<View
android:id="@+id/buttonDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/descriptionEditText"
android:background="@color/divider_color"/>
<ImageButton
android:id="@+id/deleteItemImageButton"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:src="@drawable/ic_action_close_dark"/>
</LinearLayout>

View file

@ -10,6 +10,7 @@ import net.londatiga.android.ActionItem;
import net.londatiga.android.QuickAction;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.access.AccessibleToast;
import net.osmand.data.LatLon;
@ -58,8 +59,10 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.commons.logging.Log;
public class MapActivityActions implements DialogProvider {
private static final Log LOG = PlatformUtil.getLog(MapActivityActions.class);
public static final String KEY_LONGITUDE = "longitude";
public static final String KEY_LATITUDE = "latitude";
public static final String KEY_NAME = "name";
@ -283,7 +286,7 @@ public class MapActivityActions implements DialogProvider {
R.drawable.ic_action_fav_dark).reg();
LOG.debug("contextMenuPoint()");
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
getMyApplication().getAppCustomization().prepareLocationMenu(mapActivity, adapter);

View file

@ -49,23 +49,10 @@ public class AdvancedDataFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_edit_poi_advanced, container, false);
final EditText tagEditText = (EditText) view.findViewById(R.id.tagEditText);
final EditText valueEditText = (EditText) view.findViewById(R.id.valueEditText);
ImageButton deleteItemImageButton =
(ImageButton) view.findViewById(R.id.deleteItemImageButton);
deleteItemImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tagEditText.setText(null);
tagEditText.clearFocus();
valueEditText.setText(null);
valueEditText.clearFocus();
}
});
deleteDrawable = ((MapActivity)getActivity()).getMyApplication().getIconsCache()
.getPaintedContentIcon(R.drawable.ic_action_remove_dark, R.color.icon_color_light);
deleteItemImageButton.setImageDrawable(deleteDrawable);
.getPaintedContentIcon(R.drawable.ic_action_remove_dark,
getActivity().getResources().getColor(R.color.icon_color_light));
TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
TextView amenityTagTextView = (TextView) view.findViewById(R.id.amenityTagTextView);
TextView amenityTextView = (TextView) view.findViewById(R.id.amenityTextView);
@ -79,16 +66,7 @@ public class AdvancedDataFragment extends Fragment {
addTagButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String tag = String.valueOf(tagEditText.getText());
String value = String.valueOf(valueEditText.getText());
if (!TextUtils.isEmpty(tag) && !TextUtils.isEmpty(value)) {
mAdapter.addTag(new Tag(tag, value));
// setListViewHeightBasedOnChildren(editTagsLineaLayout);
tagEditText.setText(null);
tagEditText.clearFocus();
valueEditText.setText(null);
valueEditText.clearFocus();
}
mAdapter.addTag(new Tag("", ""));
}
});
return view;
@ -145,11 +123,10 @@ public class AdvancedDataFragment extends Fragment {
}
public void addTag(Tag tag) {
View view = getView(tag);
editPoiData.tags.add(tag);
if (mIsUserInput)
editPoiData.notifyDatasetChanged(mTagsChangedListener);
linearLayout.addView(view);
updateViews();
}
public void updateViews() {

View file

@ -65,6 +65,8 @@ public class BasicDataFragment extends Fragment {
webSiteImageView.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_world_globe_dark));
ImageView descriptionImageView = (ImageView) view.findViewById(R.id.descriptionImageView);
descriptionImageView.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_description));
ImageView openingHoursImageView = (ImageView) view.findViewById(R.id.openingHoursImageView);
openingHoursImageView.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_time));
streetEditText = (EditText) view.findViewById(R.id.streetEditText);
streetEditText.addTextChangedListener(new MyOnFocusChangeListener(getData(),

View file

@ -16,6 +16,7 @@ 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.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
@ -44,6 +45,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.osmedit.data.EditPoiData;
import net.osmand.plus.osmedit.data.Tag;
import net.osmand.plus.osmedit.dialogs.DeletePoiDialogFragment;
import net.osmand.plus.osmedit.dialogs.PoiSubTypeDialogFragment;
import net.osmand.plus.osmedit.dialogs.PoiTypeDialogFragment;
import net.osmand.util.Algorithms;
@ -73,7 +75,7 @@ public class EditPoiFragment extends Fragment {
private Node node;
private Map<String, PoiType> allTranslatedSubTypes;
public static final String POI_TYPE_TAG = "poi_type_tag";
private OpenstreetmapUtil openstreetmapUtil;
private OpenstreetmapUtil mOpenstreetmapUtil;
private TextInputLayout poiTypeTextInputLayout;
@Override
@ -83,17 +85,17 @@ public class EditPoiFragment extends Fragment {
// allTranslatedSubTypes = poiTypes.getAllTranslatedNames();
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
// editPoiData.isLocalEdit = true;
OsmEditingPlugin plugin = (OsmEditingPlugin) OsmandPlugin.getPlugin(OsmEditingPlugin.class);
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
// openstreetmapUtilToLoad = openstreetmapUtil;
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
// openstreetmapUtilToLoad = mOpenstreetmapUtil;
} else if (!settings.isInternetConnectionAvailable(true)) {
openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
// openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
} else {
isLocalEdit = false;
openstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
// openstreetmapUtilToLoad = openstreetmapUtil;
mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
// openstreetmapUtilToLoad = mOpenstreetmapUtil;
}
node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE);
@ -215,7 +217,7 @@ public class EditPoiFragment extends Fragment {
poiTypeEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(poiTypeEditText.getText().length() == 0 && editPoiData.amenity.getType() != null){
if (poiTypeEditText.getText().length() == 0 && editPoiData.amenity.getType() != null) {
DialogFragment dialogFragment =
PoiSubTypeDialogFragment.createInstance(editPoiData.amenity);
dialogFragment.show(getChildFragmentManager(), "PoiSubTypeDialogFragment");
@ -254,7 +256,7 @@ public class EditPoiFragment extends Fragment {
}
}
}
commitNode(action, node, openstreetmapUtil.getEntityInfo(),
commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(),
"",
false,//closeChange.isSelected(),
new Runnable() {
@ -286,7 +288,7 @@ public class EditPoiFragment extends Fragment {
.commit();
fragmentManager.popBackStack();
}
}, getActivity());
}, getActivity(), mOpenstreetmapUtil);
}
});
@ -337,13 +339,15 @@ public class EditPoiFragment extends Fragment {
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) {
// TODO: 8/28/15 Move to some king of helper class
public static void commitNode(final OsmPoint.Action action,
final Node n,
final EntityInfo info,
final String comment,
final boolean closeChangeSet,
final Runnable successAction,
final Activity activity,
final OpenstreetmapUtil openstreetmapUtil) {
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;
@ -409,12 +413,12 @@ public class EditPoiFragment extends Fragment {
}
public static void showEditInstance(final Amenity amenity, OsmandSettings settings,
final MapActivity mapActivity) {
final MapActivity mapActivity) {
final OpenstreetmapUtil openstreetmapUtilToLoad;
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
openstreetmapUtilToLoad = new OpenstreetmapLocalUtil(plugin, mapActivity);
} else if(!settings.isInternetConnectionAvailable(true)) {
} else if (!settings.isInternetConnectionAvailable(true)) {
openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(mapActivity);
} else {
openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(mapActivity);
@ -427,7 +431,7 @@ public class EditPoiFragment extends Fragment {
}
protected void onPostExecute(Node n) {
if(n != null){
if (n != null) {
EditPoiFragment fragment =
EditPoiFragment.createInstance(n, (Amenity) amenity);
mapActivity.getSupportFragmentManager().beginTransaction()
@ -437,7 +441,9 @@ public class EditPoiFragment extends Fragment {
mapActivity.getString(R.string.poi_error_poi_not_found),
Toast.LENGTH_SHORT).show();
}
};
}
;
}.execute(new Void[0]);
}
@ -445,6 +451,7 @@ public class EditPoiFragment extends Fragment {
public static class MyAdapter extends FragmentPagerAdapter {
private final String basicTitle;
private final String extendedTitle;
public MyAdapter(FragmentManager fm, String basicTitle, String extendedTitle) {
super(fm);
this.basicTitle = basicTitle;
@ -479,4 +486,35 @@ public class EditPoiFragment extends Fragment {
throw new IllegalArgumentException("Unexpected position");
}
}
// TODO: 8/28/15 Move to helper
public static class ShowDeleteDialogAsyncTask extends AsyncTask<Amenity, Void, Node> {
private final OpenstreetmapUtil openstreetmapUtil;
private final AppCompatActivity activity;
public ShowDeleteDialogAsyncTask(AppCompatActivity activity) {
this.activity = activity;
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
} else if (!settings.isInternetConnectionAvailable(true)) {
openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
} else {
openstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
}
}
protected Node doInBackground(Amenity[] params) {
return openstreetmapUtil.loadNode(params[0]);
};
protected void onPostExecute(Node n) {
if(n == null){
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show();
return;
}
DeletePoiDialogFragment.createInstance(n).show(activity.getSupportFragmentManager(),
"DeletePoiDialogFragment");
};
}
}

View file

@ -15,6 +15,7 @@ import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.plus.ContextMenuAdapter;
@ -35,6 +36,8 @@ import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.util.List;
@ -163,10 +166,12 @@ public class OsmEditingPlugin extends OsmandPlugin {
registerLayers(mapActivity);
}
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)
.execute((Amenity) selectedObj);
// TODO implement delete
// getPoiActions(mapActivity).showDeleteDialog((Amenity) selectedObj);
// } else if (resId == R.string.poi_context_menu_modify) {
}//} else if (resId == R.string.poi_context_menu_modify) {
// TODO implement edit
// getPoiActions(mapActivity).showEditDialog((Amenity) selectedObj);
// }

View file

@ -1,8 +1,13 @@
package net.osmand.plus.osmedit.data;
import net.osmand.PlatformUtil;
import org.apache.commons.logging.Log;
import java.io.Serializable;
public class Tag implements Serializable {
private static final Log LOG = PlatformUtil.getLog(Tag.class);
public String tag;
public String value;
@ -16,6 +21,7 @@ public class Tag implements Serializable {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Tag tag1 = (Tag) o;
LOG.debug("this=" + this + "; that=" + tag1);
return tag.equals(tag1.tag);
}

View file

@ -0,0 +1,94 @@
package net.osmand.plus.osmedit.dialogs;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.osm.edit.Node;
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.plus.osmedit.EditPoiFragment;
import net.osmand.plus.osmedit.OpenstreetmapLocalUtil;
import net.osmand.plus.osmedit.OpenstreetmapRemoteUtil;
import net.osmand.plus.osmedit.OpenstreetmapUtil;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.osmedit.OsmPoint;
/**
* Created by GaidamakUA on 8/28/15.
*/
public class DeletePoiDialogFragment extends DialogFragment {
private static final String KEY_AMENITY_NODE = "amenity_node";
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Activity activity = getActivity();
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
final OpenstreetmapUtil mOpenstreetmapUtil;
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
} else if (!settings.isInternetConnectionAvailable(true)) {
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
} else {
mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
}
final Bundle args = getArguments();
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.poi_remove_title);
LinearLayout ll = new LinearLayout(activity);
ll.setPadding(4, 2, 4, 0);
ll.setOrientation(LinearLayout.VERTICAL);
final EditText comment = new EditText(activity);
comment.setText(R.string.poi_remove_title);
ll.addView(comment);
final CheckBox closeChangeset;
closeChangeset = new CheckBox(activity);
closeChangeset.setText(R.string.close_changeset);
ll.addView(closeChangeset);
builder.setView(ll);
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Node n = (Node) args.getSerializable(KEY_AMENITY_NODE);
String c = comment.getText().toString();
EditPoiFragment.commitNode(OsmPoint.Action.DELETE, n, mOpenstreetmapUtil.getEntityInfo(), c,
closeChangeset == null ? false : closeChangeset.isSelected(), new Runnable() {
@Override
public void run() {
AccessibleToast.makeText(activity, R.string.poi_remove_success, Toast.LENGTH_LONG).show();
if (activity instanceof MapActivity) {
((MapActivity) activity).getMapView().refreshMap(true);
}
}
}, getActivity(), mOpenstreetmapUtil);
}
});
return builder.create();
}
public static DeletePoiDialogFragment createInstance(Node amenityNode) {
DeletePoiDialogFragment fragment = new DeletePoiDialogFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(KEY_AMENITY_NODE, amenityNode);
fragment.setArguments(bundle);
return fragment;
}
}