Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2012-09-12 00:00:52 +02:00
commit cd2b5c2349
25 changed files with 262 additions and 347 deletions

View file

@ -259,6 +259,13 @@
</target>
<target name="fix_apostrophe_issues">
<replace token="version='1.0'" value="version=&quot;1.0&quot;">
<fileset dir="res" includes="**/strings.xml"/>
</replace>
<replace token="encoding='utf-8'" value="encoding=&quot;utf-8&quot;">
<fileset dir="res" includes="**/strings.xml"/>
</replace>
<replaceregexp match="([^\\])'" replace="\1\\\\'" flags="-g" byline="off">
<fileset dir="res" includes="**/strings.xml"/>
</replaceregexp>

View file

@ -9,7 +9,7 @@
android:layout_marginLeft = "3dp" android:layout_marginTop ="3dp" android:layout_marginRight = "3dp"/>
</LinearLayout>
<ExpandableListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginTop="3dp" android:layout_marginRight="3dp" ></ExpandableListView>
<ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_marginLeft="3dp" android:layout_marginTop="3dp" android:layout_marginRight="3dp" ></ListView>
</LinearLayout>

View file

@ -2,6 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/showmod" android:title="@string/local_openstreetmap_show"></item>
<item android:id="@+id/deletemod" android:title="@string/local_openstreetmap_delete"></item>
<item android:id="@+id/uploadmods" android:title="@string/local_openstreetmap_upload"></item>
</menu>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/uploadmods" android:title="@string/local_openstreetmap_upload"></item>
</menu>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources><string name="live_monitoring_mode_off">Iniciar\n seguimiento en directo</string>
<string name="live_monitoring_mode_on">Parar\n seguimiento en directo</string>
<string name="layer_map_appearance">Configura pantalla…</string>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources><string name="tip_recent_changes_0_7_2_t">A 0.7.2 kiadás változásai: \n\t- Natív renderelő minden eszközre \n\t- Offline POI szerkesztés \n\t- Akadálymentesítés \n\t- Sok egyéb hibajavítás</string>
<string name="send_files_to_osm">GPX fájl küldése OSM-re?</string>
<string name="gpx_visibility_txt">Láthatóság</string>

View file

@ -1,5 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<resources><string name="use_fluorescent_overlays">Sovrapposizioni fluorescenti</string>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="use_fluorescent_overlays">Sovrapposizioni fluorescenti</string>
<string name="use_fluorescent_overlays_descr">Usa colori fluorescenti per mostrare tracce e percorsi</string>
<string name="offline_edition">Modifiche offline</string>
<string name="offline_edition_descr">Usa sempre la modifica offline</string>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="download_link_and_local_description">Загрузите или обновите локальные данные. \nЧтобы получить дополнительную информацию о карте, выделите ее в списке. Удерживайте карту, если вы хотите удалить или деактивировать. \nДанные на устройстве (%1$s свободно):</string>
<string name="unknown_from_location">Начальное местоположение еще не определено</string>
<string name="unknown_location">Местоположение еще не определено</string>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources><string name="tip_recent_changes_0_8_3_t">Zmeny vo verzii 0.8.3 :
\n\t* Vylepšená navigácia
\n\t* Voľba obídenia diaľnic

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<!--
Disclaimer :
@ -9,7 +9,6 @@
1. 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="show_warnings_title">Show alarms&#8230;</string>
<string name="show_warnings_descr">Show speed limits, speed cameras, speed bumps, and other warnings</string>
<string name="use_compass_navigation_descr">Use the compass when no heading is detected otherwise</string>

View file

@ -1215,8 +1215,7 @@ public class OsmandSettings {
//public final OsmandPreference<Boolean> USE_COMPASS_IN_NAVIGATION = new BooleanPreference("use_compass_navigation", true).makeProfile().cache();
public final CommonPreference<Boolean> USE_COMPASS_IN_NAVIGATION = new BooleanPreference("use_compass_navigation", true).makeProfile().cache();
{
//Issue 1346
USE_COMPASS_IN_NAVIGATION.setModeDefaultValue(ApplicationMode.CAR, false);
USE_COMPASS_IN_NAVIGATION.setModeDefaultValue(ApplicationMode.CAR, true);
}
// this value string is synchronized with settings_pref.xml preference name

View file

@ -884,7 +884,9 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
int currentMapRotation = settings.ROTATE_MAP.get();
if (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
if (location.hasBearing()) {
if(location.getBearing() != 0f) {
mapView.setRotate(-location.getBearing());
}
} else if (routingHelper.isFollowingMode() && settings.USE_COMPASS_IN_NAVIGATION.get()) {
if (previousSensorValue != 0 && Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -previousSensorValue)) > 15) {
if(now - lastTimeSensorRotation > 1500 && now - lastTimeSensorRotation < 15000) {

View file

@ -165,6 +165,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
// db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
// db.execSQL("DELETE FROM " + POINT_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
}
distance = 0;
return warnings;
}

View file

@ -125,7 +125,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements LockInfoCont
cat.addPreference(activity.createCheckBoxPreference(settings.SAVE_TRACK_TO_GPX, R.string.save_track_to_gpx,
R.string.save_track_to_gpx_descrp));
cat.addPreference(activity.createTimeListPreference(settings.SAVE_TRACK_INTERVAL, SECONDS,
MINUTES, 1, R.string.save_track_interval, R.string.save_track_interval_descr));
MINUTES, 1000, R.string.save_track_interval, R.string.save_track_interval_descr));
cat = new PreferenceCategory(activity);
cat.setTitle(R.string.live_monitoring);
@ -134,7 +134,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements LockInfoCont
cat.addPreference(activity.createCheckBoxPreference(settings.LIVE_MONITORING, R.string.live_monitoring,
R.string.live_monitoring_descr));
cat.addPreference(activity.createTimeListPreference(settings.LIVE_MONITORING_INTERVAL, SECONDS,
MINUTES, 1, R.string.live_monitoring_interval, R.string.live_monitoring_interval_descr));
MINUTES, 1000, R.string.live_monitoring_interval, R.string.live_monitoring_interval_descr));
cat = new PreferenceCategory(activity);
cat.setTitle(R.string.monitor_preferences);

View file

@ -4,33 +4,21 @@ package net.osmand.plus.osmedit;
import java.util.ArrayList;
import java.util.List;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.Node;
import net.osmand.plus.AmenityIndexRepositoryOdb;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import android.app.Activity;
import android.widget.Toast;
public abstract class AbstractOpenstreetmapUtil implements OpenstreetmapUtil {
@Override
public void updateNodeInIndexes(Activity ctx, OsmPoint.Action action, Node n, Node oldNode) {
final OsmandApplication app = (OsmandApplication) ctx.getApplication();
final AmenityIndexRepositoryOdb repo = app.getResourceManager().getUpdatablePoiDb();
ctx.runOnUiThread(new Runnable() {
@Override
public void run() {
if (repo == null) {
AccessibleToast.makeText(app, app.getString(R.string.update_poi_no_offline_poi_index), Toast.LENGTH_LONG).show();
} else {
AccessibleToast.makeText(app, app.getString(R.string.update_poi_does_not_change_indexes), Toast.LENGTH_LONG).show();
}
}
});
showMessageAfterCommit(ctx, app, repo);
if (repo == null) {
return;
@ -55,4 +43,8 @@ public abstract class AbstractOpenstreetmapUtil implements OpenstreetmapUtil {
}
}
}
protected void showMessageAfterCommit(Activity ctx, final OsmandApplication app, final AmenityIndexRepositoryOdb repo) {
}
}

View file

@ -2,11 +2,11 @@ package net.osmand.plus.osmedit;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.OsmAndFormatter;
import net.osmand.access.AccessibleToast;
@ -54,6 +54,7 @@ public class EditingPOIActivity implements DialogProvider {
private final MapActivity ctx;
private final OpenstreetmapUtil openstreetmapUtil;
private final OpenstreetmapUtil openstreetmapUtilToLoad;
private AutoCompleteTextView typeText;
private EditText nameText;
private Button typeButton;
@ -83,15 +84,21 @@ public class EditingPOIActivity implements DialogProvider {
this.ctx = uiContext;
settings = ((OsmandApplication) uiContext.getApplication()).getSettings();
if(settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)){
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
this.openstreetmapUtil = new OpenstreetmapLocalUtil(ctx);
if (settings.isInternetConnectionAvailable(true)) {
this.openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(ctx, ctx.getMapView());
} else {
this.openstreetmapUtilToLoad = openstreetmapUtil;
}
} else {
this.openstreetmapUtil = new OpenstreetmapRemoteUtil(ctx, ctx.getMapView());
this.openstreetmapUtilToLoad= openstreetmapUtil;
}
}
public void showEditDialog(Amenity editA){
Node n = openstreetmapUtil.loadNode(editA);
Node n = openstreetmapUtilToLoad.loadNode(editA);
if(n != null){
showPOIDialog(DIALOG_EDIT_POI, n, editA.getType(), editA.getSubType());
} else {
@ -166,9 +173,105 @@ public class EditingPOIActivity implements DialogProvider {
phoneText.setText(a.getPhone());
EditText websiteText = ((EditText)dlg.findViewById(R.id.Website));
websiteText.setText(a.getSite());
final TableLayout layout = ((TableLayout)dlg.findViewById(R.id.advancedModeTable));
layout.setVisibility(View.GONE);
updateType(a);
}
private void addTagValueRow(final Node n, final TableLayout layout, String tg, String vl) {
final TableRow newTagRow = new TableRow(ctx);
TableRow.LayoutParams tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
tlp.leftMargin = 5;
newTagRow.setLayoutParams(tlp);
final AutoCompleteTextView tag = new AutoCompleteTextView(ctx);
final AutoCompleteTextView value = new AutoCompleteTextView(ctx);
final Button delete = new Button(ctx);
tag.setLayoutParams(tlp);
if(tg != null) {
tag.setText(tg);
} else {
tag.setHint("Tag");
}
final Set<String> tagKeys = new TreeSet<String>();
for (OSMTagKey t : OSMTagKey.values()) {
if ((t != OSMTagKey.NAME) && (t != OSMTagKey.OPENING_HOURS) && (t != OSMTagKey.PHONE)
&& (t != OSMTagKey.WEBSITE)) {
tagKeys.add(t.getValue());
}
}
ArrayAdapter<Object> adapter = new ArrayAdapter<Object>(ctx, R.layout.list_textview, tagKeys.toArray());
tag.setAdapter(adapter);
tag.setThreshold(1);
tag.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Builder builder = new AlertDialog.Builder(ctx);
final String[] tags = tagKeys.toArray(new String[tagKeys.size()]);
builder.setItems(tags, new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tag.setText(tags[which]);
}
});
builder.create();
builder.show();
}
});
tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.FILL_PARENT);
tlp.leftMargin = 5;
tlp.rightMargin = 5;
tlp.width = 80;
value.setLayoutParams(tlp);
if(vl != null) {
value.setText(vl);
} else {
value.setHint("Value");
}
Set<String> subCategories = MapRenderingTypes.getDefault().getAmenityNameToType().keySet();
ArrayAdapter<Object> valueAdapter = new ArrayAdapter<Object>(ctx, R.layout.list_textview, subCategories.toArray());
value.setThreshold(1);
value.setAdapter(valueAdapter);
value.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
if ((newTagRow != null) && (tag != null) && (value != null) && (tag.getText() != null)
&& (value.getText() != null) && (!tag.getText().equals("")) && (!value.getText().equals(""))) {
n.putTag(tag.getText().toString(), value.getText().toString());
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
tlp.gravity = Gravity.CENTER;
tlp.rightMargin = 5;
delete.setLayoutParams(tlp);
delete.setText("X");
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
layout.removeView(newTagRow);
layout.invalidate();
n.removeTag(tag.getText().toString());
}
});
newTagRow.addView(tag);
newTagRow.addView(value);
newTagRow.addView(delete);
layout.addView(newTagRow);
layout.invalidate();
}
private Dialog createPOIDialog(final int dialogID, final Bundle args) {
final Dialog dlg = new Dialog(ctx);
dlg.setContentView(R.layout.editing_poi);
@ -248,12 +351,13 @@ public class EditingPOIActivity implements DialogProvider {
});
final Button advancedModeButton = ((Button)dlg.findViewById(R.id.advancedMode));
final Map<String, String> additionalTags = new HashMap<String, String>();
advancedModeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final TableLayout layout = ((TableLayout)dlg.findViewById(R.id.advancedModeTable));
TableLayout.LayoutParams tlParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
final Node n = (Node) args.getSerializable(KEY_AMENITY_NODE);
final TableLayout layout = ((TableLayout) dlg.findViewById(R.id.advancedModeTable));
TableLayout.LayoutParams tlParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(tlParams);
layout.setColumnStretchable(1, true);
layout.setVisibility((layout.getVisibility() == View.VISIBLE) ? View.GONE : View.VISIBLE);
@ -263,93 +367,23 @@ public class EditingPOIActivity implements DialogProvider {
addTag.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final TableRow newTagRow = new TableRow(ctx);
TableRow.LayoutParams tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
tlp.leftMargin = 5;
newTagRow.setLayoutParams(tlp);
final AutoCompleteTextView tag = new AutoCompleteTextView(ctx);
final AutoCompleteTextView value = new AutoCompleteTextView(ctx);
final Button delete = new Button(ctx);
tag.setLayoutParams(tlp);
tag.setHint("Tag");
final Set<String> tagKeys = new LinkedHashSet<String>();
for (OSMTagKey t : OSMTagKey.values()) {
if ((t != OSMTagKey.NAME) && (t != OSMTagKey.OPENING_HOURS) && (t != OSMTagKey.PHONE)
&& (t != OSMTagKey.WEBSITE)) {
tagKeys.add(t.getValue());
}
}
ArrayAdapter<Object> adapter = new ArrayAdapter<Object>(ctx, R.layout.list_textview, tagKeys.toArray());
tag.setAdapter(adapter);
tag.setThreshold(1);
tag.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Builder builder = new AlertDialog.Builder(ctx);
final String[] tags = tagKeys.toArray(new String[tagKeys.size()]);
builder.setItems(tags, new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tag.setText(tags[which]);
}
});
builder.create();
builder.show();
addTagValueRow(n, layout, null, null);
}
});
tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.FILL_PARENT);
tlp.leftMargin = 5;
tlp.rightMargin = 5;
tlp.width = 80;
value.setLayoutParams(tlp);
value.setHint("Value");
Set<String> subCategories = MapRenderingTypes.getDefault().getAmenityNameToType().keySet();
ArrayAdapter<Object> valueAdapter = new ArrayAdapter<Object>(ctx, R.layout.list_textview, subCategories.toArray());
value.setThreshold(1);
value.setAdapter(valueAdapter);
value.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
if ((newTagRow != null) && (tag != null) && (value != null) && (tag.getText() != null)
&& (value.getText() != null) && (!tag.getText().equals("")) && (!value.getText().equals(""))) {
additionalTags.put(tag.getText().toString(), value.getText().toString());
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
tlp.gravity = Gravity.CENTER;
tlp.rightMargin = 5;
delete.setLayoutParams(tlp);
delete.setText("X");
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
layout.removeView(newTagRow);
layout.invalidate();
additionalTags.remove(tag.getText().toString());
}
});
newTagRow.addView(tag);
newTagRow.addView(value);
newTagRow.addView(delete);
layout.addView(newTagRow);
layout.invalidate();
}
});
while (layout.getChildCount() > 0) {
layout.removeViewAt(0);
}
layout.requestLayout();
Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
for (String tg : n.getTagKeySet()) {
if (!tg.equals(OSMTagKey.NAME.getValue()) && !tg.equals(OSMTagKey.OPENING_HOURS.getValue())
&& !tg.equals(OSMTagKey.PHONE.getValue()) && !tg.equals(OSMTagKey.WEBSITE.getValue())) {
if(a == null || a.getType() == null || !a.getType().getDefaultTag().equals(tg)) {
addTagValueRow(n, layout, tg, n.getTag(tg));
}
}
}
}
});
@ -407,11 +441,6 @@ public class EditingPOIActivity implements DialogProvider {
if (phone.length() > 0 ){
n.putTag(OSMTagKey.PHONE.getValue(),phone);
}
if ((additionalTags != null) && (!additionalTags.isEmpty())) {
for (String tk : additionalTags.keySet()) {
n.putTag(tk, additionalTags.get(tk));
}
}
commitNode(action, n, openstreetmapUtil.getEntityInfo(), commentText.getText().toString(), new Runnable() {
@Override
public void run() {

View file

@ -2,21 +2,20 @@ package net.osmand.plus.osmedit;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.osmand.access.AccessibleToast;
import net.osmand.osm.EntityInfo;
import net.osmand.osm.Node;
import net.osmand.plus.AmenityIndexRepositoryOdb;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.activities.OsmandExpandableListActivity;
import net.osmand.plus.osmedit.OsmPoint.Action;
import android.app.Dialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
@ -28,12 +27,12 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
public class LocalOpenstreetmapActivity extends ListActivity {
/** dialogs **/
protected static final int DIALOG_PROGRESS_UPLOAD = 0;
@ -48,6 +47,10 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
private OsmBugsRemoteUtil remotebug;
protected OsmPoint[] toUpload;
private ArrayList<OsmPoint> dataPoints;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -56,18 +59,11 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
setContentView(R.layout.local_openstreetmap);
listAdapter = new LocalOpenstreetmapAdapter();
getExpandableListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
getListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
long packedPos = ((ExpandableListContextMenuInfo)menuInfo).packedPosition;
int group = ExpandableListView.getPackedPositionGroup(packedPos);
int child = ExpandableListView.getPackedPositionChild(packedPos);
MenuInflater inflater = getMenuInflater();
if (child >= 0 && group >= 0) {
inflater.inflate(R.menu.localosm_child, menu);
} else if (group >= 0) { //group menu
inflater.inflate(R.menu.localosm_group, menu);
}
}
});
setListAdapter(listAdapter);
@ -79,12 +75,9 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
remotebug = new OsmBugsRemoteUtil();
findViewById(R.id.UploadAllButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//NOTE, the order of upload is important, there can be more edits per one POI!!
toUpload = listAdapter.values().toArray(new OsmPoint[0]);
toUpload = dataPoints.toArray(new OsmPoint[0]);
showDialog(DIALOG_PROGRESS_UPLOAD);
}
});
@ -93,51 +86,59 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
@Override
protected void onResume() {
super.onResume();
listAdapter.clear();
dataPoints = new ArrayList<OsmPoint>();
List<OpenstreetmapPoint> l1 = dbpoi.getOpenstreetmapPoints();
List<OsmbugsPoint> l2 = dbbug.getOsmbugsPoints();
dataPoints.addAll(l1);
dataPoints.addAll(l2);
listAdapter.clear();
for (OpenstreetmapPoint p : l1) {
listAdapter.addOsmPoint(p);
listAdapter.add(p);
}
for (OsmbugsPoint p : l2) {
listAdapter.addOsmPoint(p);
listAdapter.add(p);
}
listAdapter.notifyDataSetChanged();
}
@Override
public boolean onContextItemSelected(MenuItem item) {
long packedPos = ((ExpandableListContextMenuInfo)item.getMenuInfo()).packedPosition;
int group = ExpandableListView.getPackedPositionGroup(packedPos);
int child = ExpandableListView.getPackedPositionChild(packedPos);
int pos = ((AdapterContextMenuInfo)item.getMenuInfo()).position;
int itemId = item.getItemId();
if(itemId == R.id.showmod) {
OsmandSettings settings = getMyApplication().getSettings();
OsmPoint info = (OsmPoint) listAdapter.getChild(group, child);
OsmPoint info = (OsmPoint) listAdapter.getItem(pos);
settings.setMapLocationToShow(info.getLatitude(), info.getLongitude(), settings.getLastKnownMapZoom());
MapActivity.launchMapActivityMoveToTop(LocalOpenstreetmapActivity.this);
return true;
} else if(itemId == R.id.deletemod) {
OsmPoint info = (OsmPoint) listAdapter.getChild(group, child);
OsmPoint info = (OsmPoint) listAdapter.getItem(pos);
if (info.getGroup() == OsmPoint.Group.POI) {
dbpoi.deletePOI((OpenstreetmapPoint) info);
if (info.getAction() == Action.CREATE) {
AmenityIndexRepositoryOdb repo = getMyApplication().getResourceManager().getUpdatablePoiDb();
repo.deleteAmenities(info.getId() << 1);
repo.clearCache();
}
} else if (info.getGroup() == OsmPoint.Group.BUG) {
dbbug.deleteAllBugModifications((OsmbugsPoint) info);
}
listAdapter.delete(info);
return true;
} else if(itemId == R.id.uploadmods) {
List<OsmPoint> list = listAdapter.data.get(listAdapter.category.get(group));
if (list != null) {
toUpload = list.toArray(new OsmPoint[] {});
} else if (itemId == R.id.uploadmods) {
toUpload = new OsmPoint[]{ listAdapter.getItem(pos)};
showDialog(DIALOG_PROGRESS_UPLOAD);
return true;
}
}
return super.onContextItemSelected(item);
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getApplication();
}
@Override
protected void onDestroy() {
super.onDestroy();
@ -209,10 +210,6 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
}
Node n;
if ((n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment())) != null) {
if (point.getId() != n.getId()) {
// change all category points...
listAdapter.categoryIdChanged(point.getId(), n.getId());
}
remotepoi.updateNodeInIndexes(LocalOpenstreetmapActivity.this, p.getAction(), n, p.getEntity());
dbpoi.deletePOI(p);
publishProgress(p);
@ -225,7 +222,7 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
} else if (p.getAction() == OsmPoint.Action.MODIFY) {
remotebug.addingComment(p.getId(), p.getText(), p.getAuthor());
} else if (p.getAction() == OsmPoint.Action.DELETE) {
remotebug.closingBug(p.getId());
remotebug.closingBug(p.getId(), p.getText(), p.getAuthor());
}
dbbug.deleteAllBugModifications(p);
publishProgress(p);
@ -268,68 +265,25 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
@Override
protected void onProgressUpdate(OsmPoint... points) {
listAdapter.delete(points[0]);
for(OsmPoint p : points) {
listAdapter.delete(p);
progress.incrementProgressBy(1);
}
}
}
protected class LocalOpenstreetmapAdapter extends OsmandBaseExpandableListAdapter {
Map<Long, List<OsmPoint>> data = new LinkedHashMap<Long, List<OsmPoint>>();
List<Long> category = new ArrayList<Long>();
protected class LocalOpenstreetmapAdapter extends ArrayAdapter<OsmPoint> {
public LocalOpenstreetmapAdapter() {
super(LocalOpenstreetmapActivity.this, net.osmand.plus.R.layout.local_openstreetmap_list_item);
}
public void categoryIdChanged(long oldID, long newID) {
int index = category.indexOf(oldID);
if (index != -1) {
category.set(index, newID);
List<OsmPoint> list = data.remove(oldID);
if (list != null) {
for (OsmPoint point : list) {
point.updateID(newID);
}
data.put(newID, list);
}
}
}
public void clear() {
data.clear();
category.clear();
notifyDataSetChanged();
}
public List<OsmPoint> values() {
List<OsmPoint> values = new ArrayList<OsmPoint>();
for (List<OsmPoint> v : data.values()) {
values.addAll(v);
}
return values;
}
public void delete(OsmPoint i) {
final AmenityIndexRepositoryOdb repo = getMyApplication().getResourceManager().getUpdatablePoiDb();
Long c = i.getId();
if(c != null){
List<OsmPoint> list = data.get(c);
list.remove(i);
if (list.isEmpty()) {
data.remove(c);
category.remove(c);
}
repo.deleteAmenities(i.getId() << 1);
// We need to re-insert the POI if it is a delete or modify
for (OsmPoint point : list) {
if (point.getGroup() == OsmPoint.Group.POI) {
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
remotepoi.updateNodeInIndexes(LocalOpenstreetmapActivity.this, p.getAction(), p.getEntity(), p.getEntity());
}
}
repo.clearCache();
}
dataPoints.remove(i);
remove(i);
listAdapter.notifyDataSetChanged();
}
@ -337,51 +291,20 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
notifyDataSetChanged();
}
public void addOsmPoint(OsmPoint info) {
int found = -1;
// search from end
for (int i = category.size() - 1; i >= 0; i--) {
Long cat = category.get(i);
if (cat.compareTo(info.getId()) == 0) {
found = i;
break;
}
}
if (found == -1) {
found = category.size();
category.add(info.getId());
}
if (!data.containsKey(category.get(found))) {
data.put(category.get(found), new ArrayList<OsmPoint>());
}
data.get(category.get(found)).add(info);
}
@Override
public OsmPoint getChild(int groupPosition, int childPosition) {
Long cat = category.get(groupPosition);
return data.get(cat).get(childPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
// it would be unusable to have 10000 local categories
return groupPosition * 10000 + childPosition;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
final OsmPoint child = (OsmPoint) getChild(groupPosition, childPosition);
final OsmPoint child = getItem(position);
if (v == null ) {
LayoutInflater inflater = getLayoutInflater();
v = inflater.inflate(net.osmand.plus.R.layout.local_openstreetmap_list_item, parent, false);
}
TextView viewName = ((TextView) v.findViewById(R.id.local_openstreetmap_name));
String idPrefix = (child.getGroup() == OsmPoint.Group.POI ? "POI " : "Bug ") + " id: " + child.getId();
if (child.getGroup() == OsmPoint.Group.POI)
viewName.setText("(" + ((OpenstreetmapPoint) child).getSubtype() + ") " + ((OpenstreetmapPoint) child).getName());
viewName.setText(idPrefix + " (" + ((OpenstreetmapPoint) child).getSubtype() + ") " + ((OpenstreetmapPoint) child).getName());
else if (child.getGroup() == OsmPoint.Group.BUG)
viewName.setText("(" + ((OsmbugsPoint) child).getAuthor() + ") " + ((OsmbugsPoint) child).getText());
viewName.setText(idPrefix + " (" + ((OsmbugsPoint) child).getAuthor() + ") " + ((OsmbugsPoint) child).getText());
if (child.getAction() == OsmPoint.Action.CREATE) {
viewName.setTextColor(getResources().getColor(R.color.osm_create));
} else if (child.getAction() == OsmPoint.Action.MODIFY) {
@ -393,61 +316,5 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
return v;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View v = convertView;
Long group = getGroup(groupPosition);
if (v == null) {
LayoutInflater inflater = getLayoutInflater();
v = inflater.inflate(net.osmand.plus.R.layout.local_openstreetmap_list_item_category, parent, false);
}
adjustIndicator(groupPosition, isExpanded, v);
StringBuilder t = new StringBuilder();
t.append(" id:").append(group);
t.append(" [").append(getChildrenCount(groupPosition));
if(getString(R.string.local_openstreetmap_items).length() > 0){
t.append(" ").append(getString(R.string.local_openstreetmap_items));
}
if(getString(R.string.local_openstreetmap_items).length() > 0){
t.append(" ").append(getString(R.string.local_openstreetmap_items));
}
t.append("]");
TextView nameView = ((TextView) v.findViewById(R.id.local_openstreetmap_category_name));
nameView.setText(t.toString());
return v;
}
@Override
public int getChildrenCount(int groupPosition) {
Long cat = category.get(groupPosition);
return data.get(cat).size();
}
@Override
public Long getGroup(int groupPosition) {
return category.get(groupPosition);
}
@Override
public int getGroupCount() {
return category.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
}

View file

@ -4,6 +4,7 @@ import java.util.Map;
import net.osmand.LogUtil;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.osm.EntityInfo;
@ -11,10 +12,15 @@ import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.MapUtils;
import net.osmand.osm.Node;
import net.osmand.osm.OSMSettings.OSMTagKey;
import net.osmand.plus.AmenityIndexRepositoryOdb;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import org.apache.commons.logging.Log;
import android.app.Activity;
import android.content.Context;
import android.widget.Toast;
public class OpenstreetmapLocalUtil extends AbstractOpenstreetmapUtil {
@ -25,10 +31,10 @@ public class OpenstreetmapLocalUtil extends AbstractOpenstreetmapUtil {
public final static Log log = LogUtil.getLog(OpenstreetmapLocalUtil.class);
public OpenstreetmapLocalUtil(Context uiContext){
public OpenstreetmapLocalUtil(Context uiContext) {
this.ctx = uiContext;
this.db = new OpenstreetmapsDbHelper(ctx);
this.nextid = Math.min(-2,db.getMinID());
this.nextid = Math.min(-2, db.getMinID());
}
@Override
@ -54,6 +60,21 @@ public class OpenstreetmapLocalUtil extends AbstractOpenstreetmapUtil {
return newNode;
}
@Override
protected void showMessageAfterCommit(Activity ctx, final OsmandApplication app, final AmenityIndexRepositoryOdb repo) {
ctx.runOnUiThread(new Runnable() {
@Override
public void run() {
if (repo == null) {
AccessibleToast.makeText(app, app.getString(R.string.update_poi_no_offline_poi_index), Toast.LENGTH_LONG).show();
} else {
AccessibleToast.makeText(app, app.getString(R.string.update_poi_does_not_change_indexes), Toast.LENGTH_LONG).show();
}
}
});
}
@Override
public Node loadNode(Amenity n) {
if(n.getId() % 2 == 1){

View file

@ -5,9 +5,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import com.ibm.icu.impl.locale.StringTokenIterator;
import com.ibm.icu.util.StringTokenizer;
import net.osmand.osm.Node;
import android.content.Context;
import android.database.Cursor;
@ -16,7 +13,7 @@ import android.database.sqlite.SQLiteOpenHelper;
public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 2;
private static final int DATABASE_VERSION = 4;
public static final String OPENSTREETMAP_DB_NAME = "openstreetmap"; //$NON-NLS-1$
private static final String OPENSTREETMAP_TABLE_NAME = "openstreetmaptable"; //$NON-NLS-1$
private static final String OPENSTREETMAP_COL_ID = "id"; //$NON-NLS-1$
@ -43,8 +40,8 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if(newVersion == 2) {
// db.execSQL("DROP TABLE " + OPENSTREETMAP_TABLE_NAME);
if(newVersion == 4) {
db.execSQL("DROP TABLE IF EXISTS " + OPENSTREETMAP_TABLE_NAME);
db.execSQL(OPENSTREETMAP_TABLE_CREATE);
}
}
@ -75,6 +72,8 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
return false;
}
public boolean deletePOI(OpenstreetmapPoint p) {
checkOpenstreetmapPoints();
SQLiteDatabase db = getWritableDatabase();
@ -86,6 +85,7 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
return false;
}
private List<OpenstreetmapPoint> checkOpenstreetmapPoints(){
SQLiteDatabase db = getWritableDatabase();
List<OpenstreetmapPoint> cachedOpenstreetmapPoints = new ArrayList<OpenstreetmapPoint>();

View file

@ -20,7 +20,6 @@ import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.R.drawable;
import net.osmand.plus.activities.DialogProvider;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
@ -399,7 +398,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
@Override
public void onClick(DialogInterface dialog, int which) {
OpenStreetBug bug = (OpenStreetBug) args.getSerializable(KEY_BUG);
boolean closed = osmbugsUtil.closingBug(bug.getId());
boolean closed = osmbugsUtil.closingBug(bug.getId(), "", ((OsmandApplication) OsmBugsLayer.this.activity.getApplication()).getSettings().USER_OSM_BUG_NAME.get());
if (closed) {
AccessibleToast.makeText(activity, activity.getString(R.string.osb_close_dialog_success), Toast.LENGTH_LONG).show();
clearCache();

View file

@ -1,14 +1,11 @@
package net.osmand.plus.osmedit;
import net.osmand.LogUtil;
import org.apache.commons.logging.Log;
import android.content.Context;
public class OsmBugsLocalUtil implements OsmBugsUtil {
private static final Log log = LogUtil.getLog(OsmBugsLocalUtil.class);
private final Context ctx;
private final OsmBugsDbHelper db;
@ -41,9 +38,11 @@ public class OsmBugsLocalUtil implements OsmBugsUtil {
}
@Override
public boolean closingBug(long id){
public boolean closingBug(long id, String text, String authorName){
OsmbugsPoint p = new OsmbugsPoint();
p.setId(id);
p.setAuthor(authorName);
p.setText(text);
p.setAction(OsmPoint.Action.DELETE);
return db.addOsmbugs(p);
}

View file

@ -41,10 +41,15 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
}
@Override
public boolean closingBug(long id){
public boolean closingBug(long id, String text, String authorName){
StringBuilder b = new StringBuilder();
b.append(SITE_API).append("closePOIexec?"); //$NON-NLS-1$
b.append("id=").append(id); //$NON-NLS-1$
if(text != null) {
b.append("&text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
}
b.append("&name=").append(URLEncoder.encode(authorName)); //$NON-NLS-1$
return editingPOI(b.toString(),"closing bug"); //$NON-NLS-1$
}

View file

@ -8,5 +8,5 @@ public interface OsmBugsUtil {
public boolean addingComment(long id, String text, String authorName);
public boolean closingBug(long id);
public boolean closingBug(long id, String text, String authorName);
}

View file

@ -187,14 +187,14 @@ public class LockInfoControl {
}
});
for(int i=0; i<secondsLength +minutesLength - 1; i++) {
if(i < secondsLength) {
if(v.value <= seconds[i] * 1000) {
for (int i = 0; i < secondsLength + minutesLength - 1; i++) {
if (i < secondsLength) {
if (v.value <= seconds[i] * 1000) {
sp.setProgress(i);
break;
}
} else {
if(v.value <= minutes[i - secondsLength] * 1000 * 60) {
if (v.value <= minutes[i - secondsLength] * 1000 * 60) {
sp.setProgress(i);
break;
}

View file

@ -467,7 +467,7 @@ public class RouteInfoControls {
boolean visible = false;
int locimminent = -1;
int[] loclanes = null;
if (routingHelper != null && routingHelper.isRouteCalculated()) {
if (routingHelper != null && routingHelper.isRouteCalculated() && view.getSettings().SHOW_LANES.get()) {
if (routingHelper.isFollowingMode()) {
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(new NextDirectionInfo(), false);
if(r != null && r.directionInfo != null && r.directionInfo.getTurnType() != null) {