Fix osm warnings

This commit is contained in:
Victor Shcherb 2013-07-18 01:37:58 +02:00
parent 18a3179df9
commit f829365f14
3 changed files with 28 additions and 8 deletions

View file

@ -15,6 +15,12 @@
<EditText android:id="@+id/AuthorName" android:layout_marginLeft="5dp" android:layout_marginRight="5dp"
android:layout_height="wrap_content" android:text="NoName"></EditText>
</TableRow>
<TableRow>
<TextView android:id="@+id/TextView" android:layout_marginLeft="5dp"
android:layout_height="wrap_content" android:text="@string/osb_author_dialog_password"></TextView>
<EditText android:id="@+id/Password" android:layout_marginLeft="5dp" android:layout_marginRight="5dp"
android:layout_height="wrap_content" android:text="" android:inputType="textPassword"></EditText>
</TableRow>

View file

@ -9,6 +9,7 @@
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="osb_author_or_password_not_specified">Please specify OSM user and password in Settings</string>
<string name="clear_intermediate_points">Clear intermediate points</string>
<string name="keep_intermediate_points">Keep intermediate points</string>
<string name="new_directions_point_dialog">You already have intermediate points set.</string>
@ -1479,6 +1480,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="osb_add_dialog_title">Enter bug text</string>
<string name="osb_add_dialog_success">Bug successfully created</string>
<string name="osb_add_dialog_error">Exception occured: bug was not created</string>
<string name="osb_author_dialog_password">OSM password (optional)</string>
<string name="osb_comment_menu_item">Add comment</string>
<string name="osb_comment_dialog_message">Message</string>
<string name="osb_comment_dialog_author">Author name</string>

View file

@ -375,16 +375,14 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
builder.setTitle(R.string.osb_add_dialog_title);
builder.setView(openBug);
builder.setNegativeButton(R.string.default_buttons_cancel, null);
((EditText)view.findViewById(R.id.Password)).setText(((OsmandApplication) activity.getApplication()).getSettings().USER_PASSWORD.get());
((EditText)view.findViewById(R.id.AuthorName)).setText(((OsmandApplication) activity.getApplication()).getSettings().USER_NAME.get());
builder.setPositiveButton(R.string.default_buttons_add, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final double latitude = args.getDouble(KEY_LATITUDE);
final double longitude = args.getDouble(KEY_LONGITUDE);
final String text = ((EditText)openBug.findViewById(R.id.BugMessage)).getText().toString();
final String author = ((EditText)openBug.findViewById(R.id.AuthorName)).getText().toString();
// do not set name as author it is ridiculous in that case
((OsmandApplication) activity.getApplication()).getSettings().USER_NAME.set(author);
final String text = getTextAndUpdateUserPwd(openBug);
createNewBugAsync(latitude, longitude, text);
}
@ -447,20 +445,28 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
final View view = activity.getLayoutInflater().inflate(R.layout.open_bug, null);
builder.setView(view);
((EditText)view.findViewById(R.id.AuthorName)).setText(((OsmandApplication) activity.getApplication()).getSettings().USER_NAME.get());
((EditText)view.findViewById(R.id.Password)).setText(((OsmandApplication) activity.getApplication()).getSettings().USER_PASSWORD.get());
builder.setNegativeButton(R.string.default_buttons_cancel, null);
builder.setPositiveButton(R.string.osb_comment_dialog_add_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
OpenStreetNote bug = (OpenStreetNote) args.getSerializable(KEY_BUG);
String text = ((EditText)view.findViewById(R.id.BugMessage)).getText().toString();
String author = ((EditText)view.findViewById(R.id.AuthorName)).getText().toString();
((OsmandApplication) OsmBugsLayer.this.activity.getApplication()).getSettings().USER_NAME.set(author);
String text = getTextAndUpdateUserPwd(view);
addingCommentAsync(bug, text);
}
});
return builder.create();
}
private String getTextAndUpdateUserPwd(final View view) {
String text = ((EditText)view.findViewById(R.id.BugMessage)).getText().toString();
String author = ((EditText)view.findViewById(R.id.AuthorName)).getText().toString();
String pwd = ((EditText)view.findViewById(R.id.Password)).getText().toString();
((OsmandApplication) OsmBugsLayer.this.activity.getApplication()).getSettings().USER_NAME.set(author);
((OsmandApplication) OsmBugsLayer.this.activity.getApplication()).getSettings().USER_PASSWORD.set(pwd);
return text;
}
public void refreshMap(){
if (view != null && view.getLayers().contains(OsmBugsLayer.this)) {
view.refreshMap();
@ -480,6 +486,12 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
@Override
public void onClick(DialogInterface dialog, int which) {
OpenStreetNote bug = (OpenStreetNote) args.getSerializable(KEY_BUG);
String us = activity.getMyApplication().getSettings().USER_NAME.get();
String pwd = activity.getMyApplication().getSettings().USER_PASSWORD.get();
if(us.length() == 0 || pwd.length() == 0) {
AccessibleToast.makeText(activity, activity.getString(R.string.osb_author_or_password_not_specified),
Toast.LENGTH_SHORT).show();
}
closingAsync(bug, "");
}
});