commit
ada724f7f0
9 changed files with 150 additions and 43 deletions
|
@ -2,53 +2,46 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="?dialogPreferredPadding"
|
||||
android:paddingRight="?dialogPreferredPadding">
|
||||
|
||||
<TextView
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/osb_comment_dialog_message" />
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/osb_comment_dialog_message"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/message_field"
|
||||
android:minLines="1"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:inputType="textMultiLine" />
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textMultiLine"
|
||||
android:minLines="1"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_marginLeft="5dp"
|
||||
android:id="@+id/userNameEditTextLabel"
|
||||
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/userNameEditTextLabel"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/osb_comment_dialog_author" />
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/osb_comment_dialog_author"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/user_name_field"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:text="NoName" />
|
||||
android:layout_height="wrap_content"
|
||||
android:text="NoName"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/passwordEditTextLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/osb_author_dialog_password" />
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/osb_author_dialog_password"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password_field"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:inputType="textPassword" />
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="osn_modify_dialog_error">Exception occurred: note was not modified</string>
|
||||
<string name="osn_modify_dialog_title">Modify note</string>
|
||||
<string name="context_menu_item_modify_note">Modify OSM note</string>
|
||||
<string name="make_round_trip_descr">Add copy of start point as destination.</string>
|
||||
<string name="make_round_trip">Make round trip</string>
|
||||
<string name="shared_string_navigate">Navigate</string>
|
||||
|
|
|
@ -47,6 +47,19 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
|
|||
return cache;
|
||||
}
|
||||
|
||||
public boolean updateOsmBug(long id, String text) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null) {
|
||||
db.execSQL("UPDATE " + OSMBUGS_TABLE_NAME +
|
||||
" SET " + OSMBUGS_COL_TEXT + " = ? " +
|
||||
"WHERE " + OSMBUGS_COL_ID + " = ?", new Object[]{text, id});
|
||||
checkOsmbugsPoints(db);
|
||||
db.close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addOsmbugs(OsmNotesPoint p) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null) {
|
||||
|
|
|
@ -304,19 +304,24 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
return bugs;
|
||||
}
|
||||
|
||||
|
||||
private void asyncActionTask(final OpenStreetNote bug, final String text, final Action action) {
|
||||
private void asyncActionTask(final OpenStreetNote bug, final OsmNotesPoint point, final String text, final Action action) {
|
||||
AsyncTask<Void, Void, OsmBugResult> task = new AsyncTask<Void, Void, OsmBugResult>() {
|
||||
private OsmBugsUtil osmbugsUtil;
|
||||
|
||||
@Override
|
||||
protected OsmBugResult doInBackground(Void... params) {
|
||||
osmbugsUtil = getOsmbugsUtil(bug);
|
||||
OsmNotesPoint pnt = new OsmNotesPoint();
|
||||
pnt.setId(bug.getId());
|
||||
pnt.setLatitude(bug.getLatitude());
|
||||
pnt.setLongitude(bug.getLongitude());
|
||||
return osmbugsUtil.commit(pnt, text, action);
|
||||
if (bug != null) {
|
||||
osmbugsUtil = getOsmbugsUtil(bug);
|
||||
OsmNotesPoint pnt = new OsmNotesPoint();
|
||||
pnt.setId(bug.getId());
|
||||
pnt.setLatitude(bug.getLatitude());
|
||||
pnt.setLongitude(bug.getLongitude());
|
||||
return osmbugsUtil.commit(pnt, text, action);
|
||||
} else if (point != null) {
|
||||
osmbugsUtil = local;
|
||||
return osmbugsUtil.modify(point, text);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(OsmBugResult obj) {
|
||||
|
@ -351,6 +356,9 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
} else if (action == Action.CREATE) {
|
||||
r = R.string.osn_add_dialog_error;
|
||||
openBug(bug.getLatitude(), bug.getLongitude(), text);
|
||||
} else if (action == null) {
|
||||
r = R.string.osn_modify_dialog_error;
|
||||
modifyBug(point);
|
||||
} else {
|
||||
commentBug(bug, text);
|
||||
}
|
||||
|
@ -374,11 +382,10 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
bug.setLatitude(latitude);
|
||||
bug.setLongitude(longitude);
|
||||
|
||||
if (autofill) asyncActionTask(bug, message, Action.CREATE);
|
||||
if (autofill) asyncActionTask(bug, null, message, Action.CREATE);
|
||||
else showBugDialog(bug, Action.CREATE, message);
|
||||
}
|
||||
|
||||
|
||||
public void closeBug(final OpenStreetNote bug, String txt) {
|
||||
showBugDialog(bug, Action.DELETE, txt);
|
||||
}
|
||||
|
@ -391,6 +398,15 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
showBugDialog(bug, Action.MODIFY, txt);
|
||||
}
|
||||
|
||||
public void modifyBug(final OsmNotesPoint point) {
|
||||
showBugDialog(point);
|
||||
}
|
||||
|
||||
private void showBugDialog(final OsmNotesPoint point) {
|
||||
String text = point.getText();
|
||||
createBugDialog(true, text, R.string.osn_modify_dialog_title, null, null, point);
|
||||
}
|
||||
|
||||
private void showBugDialog(final OpenStreetNote bug, final Action action, String text) {
|
||||
int title;
|
||||
if (action == Action.DELETE) {
|
||||
|
@ -406,6 +422,10 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
OsmBugsUtil util = getOsmbugsUtil(bug);
|
||||
final boolean offline = util instanceof OsmBugsLocalUtil;
|
||||
|
||||
createBugDialog(offline, text, title, action, bug, null);
|
||||
}
|
||||
|
||||
private void createBugDialog(final boolean offline, String text, int posButtonTitleRes, final Action action, final OpenStreetNote bug, final OsmNotesPoint point) {
|
||||
@SuppressLint("InflateParams")
|
||||
final View view = LayoutInflater.from(activity).inflate(R.layout.open_bug, null);
|
||||
if (offline) {
|
||||
|
@ -425,13 +445,15 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(R.string.shared_string_commit);
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(title, new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton(posButtonTitleRes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String text = offline ? getMessageText(view) : getTextAndUpdateUserPwd(view);
|
||||
activity.getContextMenu().close();
|
||||
if (bug != null) {
|
||||
String text = offline ? getMessageText(view) : getTextAndUpdateUserPwd(view);
|
||||
activity.getContextMenu().close();
|
||||
asyncActionTask(bug, text, action);
|
||||
asyncActionTask(bug, null, text, action);
|
||||
} else if (point != null) {
|
||||
asyncActionTask(null, point, text, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -32,7 +32,18 @@ public class OsmBugsLocalUtil implements OsmBugsUtil {
|
|||
}
|
||||
return wrap(point, db.addOsmbugs(point));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OsmBugResult modify(OsmNotesPoint point, String text) {
|
||||
OsmNotesPoint pnt = new OsmNotesPoint();
|
||||
pnt.setId(point.getId());
|
||||
pnt.setLatitude(point.getLatitude());
|
||||
pnt.setLongitude(point.getLongitude());
|
||||
pnt.setText(text);
|
||||
point = pnt;
|
||||
return wrap(point, db.updateOsmBug(point.getId(), text));
|
||||
}
|
||||
|
||||
private OsmBugResult wrap(OsmNotesPoint p, boolean success) {
|
||||
OsmBugResult s = new OsmBugResult();
|
||||
s.local = p;
|
||||
|
|
|
@ -61,6 +61,11 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
|
|||
return commit(point, text, action, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmBugResult modify(OsmNotesPoint bug, String text) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public OsmBugResult commit(OsmNotesPoint point, String text, Action action, boolean anonymous) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
String msg = "";
|
||||
|
|
|
@ -10,5 +10,7 @@ public interface OsmBugsUtil {
|
|||
}
|
||||
|
||||
public OsmBugResult commit(OsmNotesPoint bug, String text, Action action);
|
||||
|
||||
OsmBugResult modify(OsmNotesPoint bug, String text);
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import net.osmand.util.Algorithms;
|
|||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class OsmEditingPlugin extends OsmandPlugin {
|
||||
|
@ -181,6 +182,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
EditPoiDialogFragment.TAG);
|
||||
} else if (resId == R.string.context_menu_item_open_note) {
|
||||
openOsmNote(mapActivity, latitude, longitude);
|
||||
} else if (resId == R.string.context_menu_item_modify_note) {
|
||||
modifyOsmNote(mapActivity, (OsmNotesPoint) selectedObj);
|
||||
} else if (resId == R.string.poi_context_menu_delete) {
|
||||
new EditPoiDialogFragment.ShowDeleteDialogAsyncTask(mapActivity)
|
||||
.execute((Amenity) selectedObj);
|
||||
|
@ -220,9 +223,15 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
.setListener(listener)
|
||||
.createItem());
|
||||
}
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_open_note, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_bug_dark)
|
||||
.setListener(listener).createItem());
|
||||
if (selectedObj instanceof OsmNotesPoint) {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_modify_note, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_edit_dark)
|
||||
.setListener(listener).createItem());
|
||||
} else {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_open_note, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_bug_dark)
|
||||
.setListener(listener).createItem());
|
||||
}
|
||||
}
|
||||
|
||||
public void openOsmNote(MapActivity mapActivity, double latitude, double longitude) {
|
||||
|
@ -239,6 +248,13 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
osmBugsLayer.openBug(latitude, longitude, message, autofill);
|
||||
}
|
||||
|
||||
public void modifyOsmNote(MapActivity mapActivity, OsmNotesPoint point) {
|
||||
if (osmBugsLayer == null) {
|
||||
registerLayers(mapActivity);
|
||||
}
|
||||
osmBugsLayer.modifyBug(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMyPlacesTab(FavoritesActivity favoritesActivity, List<TabActivity.TabItem> mTabs, Intent intent) {
|
||||
if (getDBPOI().getOpenstreetmapPoints().size() > 0 || getDBBug().getOsmbugsPoints().size() > 0) {
|
||||
|
|
|
@ -24,11 +24,13 @@ import android.widget.AdapterView;
|
|||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -46,6 +48,7 @@ import net.osmand.plus.myplaces.FavoritesActivity;
|
|||
import net.osmand.plus.osmedit.OsmPoint.Action;
|
||||
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
|
||||
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.PoiUploaderType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
|
@ -351,6 +354,33 @@ public class OsmEditsFragment extends OsmAndListFragment
|
|||
|
||||
}
|
||||
|
||||
private void showBugDialog(final OsmNotesPoint point) {
|
||||
final View view = LayoutInflater.from(getActivity()).inflate(R.layout.open_bug, null);
|
||||
view.findViewById(R.id.user_name_field).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.userNameEditTextLabel).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.password_field).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.passwordEditTextLabel).setVisibility(View.GONE);
|
||||
String text = point.getText();
|
||||
if (!Algorithms.isEmpty(text)) {
|
||||
((EditText) view.findViewById(R.id.message_field)).setText(text);
|
||||
}
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(R.string.shared_string_commit);
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(R.string.osn_modify_dialog_title, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String text = ((EditText) view.findViewById(R.id.message_field)).getText().toString();
|
||||
plugin.getDBBug().updateOsmBug(point.getId(), text);
|
||||
point.setText(text);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
public static void getOsmEditView(View v, OsmPoint child, OsmandApplication app) {
|
||||
TextView viewName = ((TextView) v.findViewById(R.id.name));
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
|
@ -503,6 +533,18 @@ public class OsmEditsFragment extends OsmAndListFragment
|
|||
}
|
||||
});
|
||||
}
|
||||
if (info instanceof OsmNotesPoint) {
|
||||
item = optionsMenu.getMenu().add(R.string.context_menu_item_modify_note)
|
||||
.setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_action_edit_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
showBugDialog((OsmNotesPoint) info);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
item = optionsMenu.getMenu().add(R.string.shared_string_delete).
|
||||
setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_action_delete_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
|
|
Loading…
Reference in a new issue