- Fix Tab : SHow all notes / All tracks

- Search coordinates show full cordinates
- Search coordinates On Resume don't restore coordinates to let user enter lat & lon separately
- Fix SHOW LAT/LON Doesn't save to History
This commit is contained in:
Victor Shcherb 2015-06-02 00:15:56 +02:00
parent 0e3d3c9104
commit e666da21b1
20 changed files with 95 additions and 88 deletions

View file

@ -49,7 +49,7 @@
android:id="@+id/LatitudeEdit" android:id="@+id/LatitudeEdit"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:inputType="phone"></EditText> android:inputType="numberSigned|numberDecimal|time"></EditText>
</TableRow> </TableRow>
<TableRow android:layout_width="fill_parent" android:id="@+id/lon_row"> <TableRow android:layout_width="fill_parent" android:id="@+id/lon_row">
@ -67,7 +67,7 @@
android:id="@+id/LongitudeEdit" android:id="@+id/LongitudeEdit"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:inputType="phone"></EditText> android:inputType="numberSigned|numberDecimal|time"></EditText>
</TableRow> </TableRow>
<TableRow android:layout_width="fill_parent" android:id="@+id/northing_row"> <TableRow android:layout_width="fill_parent" android:id="@+id/northing_row">
@ -84,7 +84,7 @@
android:id="@+id/NorthingEdit" android:id="@+id/NorthingEdit"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:inputType="phone"></EditText> android:inputType="numberSigned|numberDecimal|time"></EditText>
</TableRow> </TableRow>
<TableRow android:layout_width="fill_parent" android:id="@+id/easting_row"> <TableRow android:layout_width="fill_parent" android:id="@+id/easting_row">
@ -102,7 +102,7 @@
android:id="@+id/EastingEdit" android:id="@+id/EastingEdit"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:inputType="phone"></EditText> android:inputType="numberSigned|numberDecimal|time"></EditText>
</TableRow> </TableRow>
<TableRow android:layout_width="fill_parent" android:id="@+id/zone_row"> <TableRow android:layout_width="fill_parent" android:id="@+id/zone_row">

View file

@ -19,6 +19,8 @@ public class PointDescription {
private String type = ""; private String type = "";
private String name = ""; private String name = "";
private String typeName; private String typeName;
private double lat = 0;
private double lon = 0;
public static final String POINT_TYPE_FAVORITE = "favorite"; public static final String POINT_TYPE_FAVORITE = "favorite";
public static final String POINT_TYPE_WPT = "wpt"; public static final String POINT_TYPE_WPT = "wpt";
@ -37,6 +39,12 @@ public class PointDescription {
public static final PointDescription LOCATION_POINT = new PointDescription(POINT_TYPE_LOCATION, ""); public static final PointDescription LOCATION_POINT = new PointDescription(POINT_TYPE_LOCATION, "");
public PointDescription(double lat, double lon) {
this(POINT_TYPE_LOCATION, "");
this.lat = lat;
this.lon = lon;
}
public PointDescription(String type, String name) { public PointDescription(String type, String name) {
this.type = type; this.type = type;
this.name = name; this.name = name;
@ -54,6 +62,14 @@ public class PointDescription {
} }
} }
public void setLat(double lat) {
this.lat = lat;
}
public void setLon(double lon) {
this.lon = lon;
}
public void setTypeName(String typeName){ public void setTypeName(String typeName){
this.typeName = typeName; this.typeName = typeName;
} }
@ -72,7 +88,7 @@ public class PointDescription {
} }
@NonNull @NonNull
public String getSimpleName(Context ctx, double lat, double lon, boolean addTypeName) { public String getSimpleName(Context ctx, boolean addTypeName) {
if (isLocation()) { if (isLocation()) {
return getLocationName(ctx, lat, lon, true).replace('\n', ' '); return getLocationName(ctx, lat, lon, true).replace('\n', ' ');
} }
@ -86,7 +102,7 @@ public class PointDescription {
return name; return name;
} }
public String getFullPlainName(Context ctx, double lat, double lon) { public String getFullPlainName(Context ctx) {
if (isLocation()) { if (isLocation()) {
return getLocationName(ctx, lat, lon, false); return getLocationName(ctx, lat, lon, false);
} else { } else {
@ -167,6 +183,8 @@ public class PointDescription {
result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((typeName == null) ? 0 : typeName.hashCode()); result = prime * result + ((typeName == null) ? 0 : typeName.hashCode());
result = prime * result + ((lat == 0) ? 0 : new Double(lat).hashCode());
result = prime * result + ((lon == 0) ? 0 : new Double(lon).hashCode());
return result; return result;
} }
@ -179,6 +197,8 @@ public class PointDescription {
PointDescription other = (PointDescription) obj; PointDescription other = (PointDescription) obj;
if (Algorithms.objectEquals(other.name, name) if (Algorithms.objectEquals(other.name, name)
&& Algorithms.objectEquals(other.type, type) && Algorithms.objectEquals(other.type, type)
&& Algorithms.objectEquals(other.lat, lat)
&& Algorithms.objectEquals(other.lon, lon)
&& Algorithms.objectEquals(other.typeName, typeName)) { && Algorithms.objectEquals(other.typeName, typeName)) {
return true; return true;
} }
@ -188,7 +208,7 @@ public class PointDescription {
public static String getSimpleName(LocationPoint o, Context ctx) { public static String getSimpleName(LocationPoint o, Context ctx) {
PointDescription pd = o.getPointDescription(ctx); PointDescription pd = o.getPointDescription(ctx);
return pd.getSimpleName(ctx, o.getLatitude(), o.getLongitude(), true); return pd.getSimpleName(ctx, true);
// return o.getPointDescription(ctx).getFullPlainName(ctx, o.getLatitude(), o.getLongitude()); // return o.getPointDescription(ctx).getFullPlainName(ctx, o.getLatitude(), o.getLongitude());
} }
@ -203,20 +223,25 @@ public class PointDescription {
return tp + "#" + p.name; return tp + "#" + p.name;
} }
public static PointDescription deserializeFromString(String s) { public static PointDescription deserializeFromString(String s, LatLon l) {
PointDescription pd = null;
if (s != null && s.length() > 0) { if (s != null && s.length() > 0) {
int in = s.indexOf('#'); int in = s.indexOf('#');
if (in >= 0) { if (in >= 0) {
String nm = s.substring(in + 1).trim(); String nm = s.substring(in + 1).trim();
String tp = s.substring(0, in); String tp = s.substring(0, in);
if(tp.contains(".")) { if(tp.contains(".")) {
return new PointDescription(tp.substring(0, tp.indexOf('.')), tp.substring(tp.indexOf('.') + 1), nm); pd = new PointDescription(tp.substring(0, tp.indexOf('.')), tp.substring(tp.indexOf('.') + 1), nm);
} else { } else {
return new PointDescription(tp, nm); pd = new PointDescription(tp, nm);
} }
} }
} }
return null; if(pd != null && pd.isLocation() && l != null) {
pd.setLat(l.getLatitude());
pd.setLon(l.getLongitude());
}
return pd;
} }

View file

@ -1322,10 +1322,10 @@ public class OsmandSettings {
return new LatLon(lat, lon); return new LatLon(lat, lon);
} }
public PointDescription getAndClearMapLabelToShow(){ public PointDescription getAndClearMapLabelToShow(LatLon l){
String label = settingsAPI.getString(globalPreferences,MAP_LABEL_TO_SHOW, null); String label = settingsAPI.getString(globalPreferences,MAP_LABEL_TO_SHOW, null);
settingsAPI.edit(globalPreferences).remove(MAP_LABEL_TO_SHOW).commit(); settingsAPI.edit(globalPreferences).remove(MAP_LABEL_TO_SHOW).commit();
return PointDescription.deserializeFromString(label); return PointDescription.deserializeFromString(label, l);
} }
private Object objectToShow; private Object objectToShow;
@ -1414,12 +1414,12 @@ public class OsmandSettings {
public PointDescription getStartPointDescription() { public PointDescription getStartPointDescription() {
return return
PointDescription.deserializeFromString(settingsAPI.getString(globalPreferences, START_POINT_DESCRIPTION, "")); PointDescription.deserializeFromString(settingsAPI.getString(globalPreferences, START_POINT_DESCRIPTION, ""), getPointToStart());
} }
public PointDescription getPointNavigateDescription() { public PointDescription getPointNavigateDescription() {
return return
PointDescription.deserializeFromString(settingsAPI.getString(globalPreferences, POINT_NAVIGATE_DESCRIPTION, "")); PointDescription.deserializeFromString(settingsAPI.getString(globalPreferences, POINT_NAVIGATE_DESCRIPTION, ""), getPointToNavigate());
} }

View file

@ -102,7 +102,7 @@ public class TargetPointsHelper {
List<LatLon> ips = settings.getIntermediatePoints(); List<LatLon> ips = settings.getIntermediatePoints();
List<String> desc = settings.getIntermediatePointDescriptions(ips.size()); List<String> desc = settings.getIntermediatePointDescriptions(ips.size());
for(int i = 0; i < ips.size(); i++) { for(int i = 0; i < ips.size(); i++) {
intermediatePoints.add(new TargetPoint(ips.get(i), PointDescription.deserializeFromString(desc.get(i)), i)); intermediatePoints.add(new TargetPoint(ips.get(i), PointDescription.deserializeFromString(desc.get(i), ips.get(i)), i));
} }
} }

View file

@ -460,7 +460,7 @@ public class MapActivity extends AccessibleActivity {
public void readLocationToShow() { public void readLocationToShow() {
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude()); LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
LatLon latLonToShow = settings.getAndClearMapLocationToShow(); LatLon latLonToShow = settings.getAndClearMapLocationToShow();
PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(); PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow);
Object toShow = settings.getAndClearObjectToShow(); Object toShow = settings.getAndClearObjectToShow();
int status = settings.isRouteToPointNavigateAndClear(); int status = settings.isRouteToPointNavigateAndClear();
if (status != 0) { if (status != 0) {
@ -480,7 +480,7 @@ public class MapActivity extends AccessibleActivity {
if (mapLabelToShow != null) { if (mapLabelToShow != null) {
mapLayers.getContextMenuLayer().setSelectedObject(toShow); mapLayers.getContextMenuLayer().setSelectedObject(toShow);
mapLayers.getContextMenuLayer().setLocation(latLonToShow, mapLayers.getContextMenuLayer().setLocation(latLonToShow,
mapLabelToShow.getFullPlainName(this, latLonToShow.getLatitude(), latLonToShow.getLongitude())); mapLabelToShow.getFullPlainName(this));
} }
if (!latLonToShow.equals(cur)) { if (!latLonToShow.equals(cur)) {
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(),

View file

@ -11,6 +11,7 @@ import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.dialogs.FavoriteDialogs; import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
@ -178,26 +179,19 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
//Hardy: onResume() code is needed so that search origin is properly reflected in tab contents when origin has been changed on one tab, then tab is changed to another one.
location = null;
OsmandApplication app = (OsmandApplication) getActivity().getApplication(); OsmandApplication app = (OsmandApplication) getActivity().getApplication();
//Intent intent = getSherlockActivity().getIntent();
//if (intent != null) { LatLon loc = null;
// if (intent.hasExtra(SearchActivity.SEARCH_LAT) && intent.hasExtra(SearchActivity.SEARCH_LON)) { if (getActivity() instanceof SearchActivity) {
// double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0); loc = ((SearchActivity) getActivity()).getSearchPoint();
// double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
// if (lat != 0 || lon != 0) {
// location = new LatLon(lat, lon);
// }
// }
//}
if (location == null && getActivity() instanceof SearchActivity) {
location = ((SearchActivity) getActivity()).getSearchPoint();
} }
if (location == null) { if (loc == null) {
location = app.getSettings().getLastKnownMapLocation(); loc = app.getSettings().getLastKnownMapLocation();
}
if(!Algorithms.objectEquals(loc, location)) {
location = loc;
locationUpdate(location);
} }
locationUpdate(location);
} }
@Override @Override
@ -385,19 +379,20 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi
LatLon loc = parseLocation(); LatLon loc = parseLocation();
double lat = loc.getLatitude(); double lat = loc.getLatitude();
double lon = loc.getLongitude(); double lon = loc.getLongitude();
PointDescription pd = new PointDescription(lat, lon);
if(mode == ADD_TO_FAVORITE) { if(mode == ADD_TO_FAVORITE) {
Bundle b = new Bundle(); Bundle b = new Bundle();
Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b); Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b);
dlg.show(); dlg.show();
FavoriteDialogs.prepareAddFavouriteDialog(getActivity(), dlg, b, lat, lon, PointDescription.LOCATION_POINT); FavoriteDialogs.prepareAddFavouriteDialog(getActivity(), dlg, b, lat, lon, pd);
} else if (mode == NAVIGATE_TO) { } else if (mode == NAVIGATE_TO) {
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), lat, lon, PointDescription.LOCATION_POINT); DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), lat, lon, pd);
} else if (mode == ADD_WAYPOINT) { } else if (mode == ADD_WAYPOINT) {
DirectionsDialogs.addWaypointDialogAndLaunchMap(getActivity(), lat, lon, PointDescription.LOCATION_POINT); DirectionsDialogs.addWaypointDialogAndLaunchMap(getActivity(), lat, lon, pd);
} else if (mode == SHOW_ON_MAP){ } else if (mode == SHOW_ON_MAP){
OsmandApplication app = (OsmandApplication) getActivity().getApplication(); OsmandApplication app = (OsmandApplication) getActivity().getApplication();
app.getSettings().setMapLocationToShow(lat, lon, Math.max(12, app.getSettings().getLastKnownMapZoom()), app.getSettings().setMapLocationToShow(lat, lon, Math.max(12, app.getSettings().getLastKnownMapZoom()),
PointDescription.LOCATION_POINT); pd);
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
} }

View file

@ -14,14 +14,16 @@ import android.support.v4.view.ViewPager;
public class TabActivity extends ActionBarProgressActivity { public class TabActivity extends ActionBarProgressActivity {
public TabItem getTabIndicator(int resId, Class<?> fragment){ public TabItem getTabIndicator(int resId, Class<?> fragment){
return new TabItem(getString(resId), fragment); return new TabItem(resId, getString(resId), fragment);
} }
public static class TabItem { public static class TabItem {
public final CharSequence mTitle; public final CharSequence mTitle;
public final Class<?> fragment; public final Class<?> fragment;
public final int resId;
public TabItem(CharSequence mTitle, Class<?> fragment) { public TabItem(int resId, CharSequence mTitle, Class<?> fragment) {
this.resId = resId;
this.mTitle = mTitle; this.mTitle = mTitle;
this.fragment = fragment; this.fragment = fragment;
} }

View file

@ -168,7 +168,7 @@ public class GeoIntentActivity extends OsmandListActivity {
} else { } else {
distanceLabel.setText(""); //$NON-NLS-1$ distanceLabel.setText(""); //$NON-NLS-1$
} }
label.setText(getString(model).getFullPlainName(getApplication(), 0, 0)); label.setText(getString(model).getFullPlainName(getApplication()));
return row; return row;
} }
} }

View file

@ -253,7 +253,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
} }
distanceText.setText(distance); distanceText.setText(distance);
PointDescription pd = historyEntry.getName(); PointDescription pd = historyEntry.getName();
nameText.setText(pd.getSimpleName(activity, historyEntry.getLat(), historyEntry.getLon(), false), BufferType.SPANNABLE); nameText.setText(pd.getSimpleName(activity, false), BufferType.SPANNABLE);
ImageView icon = ((ImageView) row.findViewById(R.id.icon)); ImageView icon = ((ImageView) row.findViewById(R.id.icon));
if (historyEntry.getName().isAddress()) { if (historyEntry.getName().isAddress()) {

View file

@ -83,6 +83,7 @@ import android.widget.Toast;
public class AudioVideoNotesPlugin extends OsmandPlugin { public class AudioVideoNotesPlugin extends OsmandPlugin {
public static final int NOTES_TAB = R.string.notes;
public static final String ID = "osmand.audionotes"; public static final String ID = "osmand.audionotes";
public static final String THREEGP_EXTENSION = "3gp"; public static final String THREEGP_EXTENSION = "3gp";
public static final String MPEG4_EXTENSION = "mp4"; public static final String MPEG4_EXTENSION = "mp4";
@ -994,9 +995,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
@Override @Override
public void addMyPlacesTab(FavoritesActivity favoritesActivity, List<TabItem> mTabs, Intent intent) { public void addMyPlacesTab(FavoritesActivity favoritesActivity, List<TabItem> mTabs, Intent intent) {
if (getAllRecordings().size() > 0) { if (getAllRecordings().size() > 0) {
mTabs.add(favoritesActivity.getTabIndicator(R.string.notes, NotesFragment.class)); mTabs.add(favoritesActivity.getTabIndicator(NOTES_TAB, NotesFragment.class));
if (intent != null && "AUDIO".equals(intent.getStringExtra("TAB"))) { if (intent != null && "AUDIO".equals(intent.getStringExtra("TAB"))) {
app.getSettings().FAVORITES_TAB.set(FavoritesActivity.NOTES_TAB); app.getSettings().FAVORITES_TAB.set(NOTES_TAB);
} }
} }
} }

View file

@ -38,7 +38,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() { (view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
startFavoritesActivity(FavoritesActivity.NOTES_TAB); startFavoritesActivity(AudioVideoNotesPlugin.NOTES_TAB);
} }
}); });
return view; return view;

View file

@ -39,7 +39,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() { (view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
startFavoritesActivity(FavoritesActivity.FAVORITES_TAB); startFavoritesActivity(FavoritesActivity.FAV_TAB);
} }
}); });
return view; return view;

View file

@ -99,9 +99,12 @@ public class DownloadActivity extends BaseDownloadActivity {
ViewPager viewPager = (ViewPager) findViewById(R.id.pager); ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs); PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
mTabs.add(new TabActivity.TabItem(getString(R.string.download_tab_local), LocalIndexesFragment.class)); mTabs.add(new TabActivity.TabItem(R.string.download_tab_local,
mTabs.add(new TabActivity.TabItem(getString(R.string.download_tab_downloads), DownloadIndexFragment.class)); getString(R.string.download_tab_local), LocalIndexesFragment.class));
mTabs.add(new TabActivity.TabItem(getString(R.string.download_tab_updates), UpdatesIndexFragment.class)); mTabs.add(new TabActivity.TabItem(R.string.download_tab_downloads,
getString(R.string.download_tab_downloads), DownloadIndexFragment.class));
mTabs.add(new TabActivity.TabItem(R.string.download_tab_updates,
getString(R.string.download_tab_updates), UpdatesIndexFragment.class));
viewPager.setAdapter(new TabActivity.OsmandFragmentPagerAdapter(getSupportFragmentManager(), mTabs)); viewPager.setAdapter(new TabActivity.OsmandFragmentPagerAdapter(getSupportFragmentManager(), mTabs));
mSlidingTabLayout.setViewPager(viewPager); mSlidingTabLayout.setViewPager(viewPager);

View file

@ -3,12 +3,12 @@ package net.osmand.plus.helpers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -416,22 +416,22 @@ public class SearchHistoryHelper {
"SELECT " + HISTORY_COL_NAME + ", " + HISTORY_COL_LAT + "," + HISTORY_COL_LON +", " + "SELECT " + HISTORY_COL_NAME + ", " + HISTORY_COL_LAT + "," + HISTORY_COL_LON +", " +
HISTORY_COL_TIME + ", " + HISTORY_COL_FREQ_INTERVALS + ", " + HISTORY_COL_FREQ_VALUES + HISTORY_COL_TIME + ", " + HISTORY_COL_FREQ_INTERVALS + ", " + HISTORY_COL_FREQ_VALUES +
" FROM " + HISTORY_TABLE_NAME , null); //$NON-NLS-1$//$NON-NLS-2$ " FROM " + HISTORY_TABLE_NAME , null); //$NON-NLS-1$//$NON-NLS-2$
Map<String, HistoryEntry> st = new TreeMap<String, HistoryEntry>(); Map<PointDescription, HistoryEntry> st = new HashMap<PointDescription, HistoryEntry>();
if (query.moveToFirst()) { if (query.moveToFirst()) {
boolean reinsert = false; boolean reinsert = false;
do { do {
String name = query.getString(0); String name = query.getString(0);
PointDescription p = PointDescription.deserializeFromString(name, new LatLon(query.getDouble(1), query.getDouble(2)));
HistoryEntry e = new HistoryEntry(query.getDouble(1), query.getDouble(2), HistoryEntry e = new HistoryEntry(query.getDouble(1), query.getDouble(2),
PointDescription.deserializeFromString(name)); p);
long time = query.getLong(3); long time = query.getLong(3);
e.setLastAccessTime(time); e.setLastAccessTime(time);
e.setFrequency(query.getString(4), query.getString(5)); e.setFrequency(query.getString(4), query.getString(5));
if(st.containsKey(name) || st.containsKey(e.getSerializedName()) if(st.containsKey(p)) {
|| !Algorithms.objectEquals(name, e.getSerializedName())) {
reinsert = true; reinsert = true;
} }
entries.add(e); entries.add(e);
st.put(e.getSerializedName(), e); st.put(p, e);
} while (query.moveToNext()); } while (query.moveToNext());
if(reinsert) { if(reinsert) {
System.err.println("Reinsert all values"); System.err.println("Reinsert all values");

View file

@ -15,7 +15,6 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.FavoritesTreeFragment; import net.osmand.plus.activities.FavoritesTreeFragment;
import net.osmand.plus.activities.TabActivity; import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.views.controls.PagerSlidingTabStrip; import net.osmand.plus.views.controls.PagerSlidingTabStrip;
import android.app.Activity; import android.app.Activity;
@ -24,12 +23,10 @@ import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.widget.SearchView; import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan; import android.text.style.ImageSpan;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
/** /**
@ -39,12 +36,9 @@ public class FavoritesActivity extends TabActivity {
// private static final String FAVOURITES_INFO = "FAVOURITES_INFO"; // private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
private static final String TRACKS = "TRACKS"; private static final String TRACKS = "TRACKS";
public static final int GPX_TAB = R.string.shared_string_my_tracks;
public static final int FAV_TAB = R.string.shared_string_my_favorites;
// private static final String SELECTED_TRACK = "SELECTED_TRACK"; // private static final String SELECTED_TRACK = "SELECTED_TRACK";
public static int FAVORITES_TAB = 0;
public static int GPX_TAB = 1;
public static int SELECTED_GPX_TAB = 2;
public static int NOTES_TAB = 3;
public static int OSM_EDITS_TAB = 4;
public static String TAB_PARAM = "TAB_PARAM"; public static String TAB_PARAM = "TAB_PARAM";
protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>(); protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
@ -79,25 +73,15 @@ public class FavoritesActivity extends TabActivity {
mTabs.add(getTabIndicator(R.string.shared_string_my_tracks, AvailableGPXFragment.class)); mTabs.add(getTabIndicator(R.string.shared_string_my_tracks, AvailableGPXFragment.class));
} }
OsmandPlugin.addMyPlacesTabPlugins(this, mTabs, getIntent()); OsmandPlugin.addMyPlacesTabPlugins(this, mTabs, getIntent());
Integer tabId = settings.FAVORITES_TAB.get();
Integer tab = settings.FAVORITES_TAB.get(); int tab = 0;
if (tab == NOTES_TAB) { for(int i = 0; i < mTabs.size(); i++) {
if (OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null){ if(mTabs.get(i).resId == tabId) {
tab = mTabs.size() - 2; tab = i;
} else {
tab = mTabs.size() - 1;
} }
} else if (tab == OSM_EDITS_TAB) {
tab = mTabs.size() - 1;
} }
setViewPagerAdapter(mViewPager, mTabs); setViewPagerAdapter(mViewPager, mTabs);
mSlidingTabLayout.setViewPager(mViewPager); mSlidingTabLayout.setViewPager(mViewPager);
if (tab > mTabs.size() - 1){
tab = 0;
}
mViewPager.setCurrentItem(tab); mViewPager.setCurrentItem(tab);
// setupHomeButton(); // setupHomeButton();
} }

View file

@ -46,7 +46,7 @@ public class DashOsmEditsFragment extends DashBaseFragment implements OsmEditsUp
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() { (view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
startFavoritesActivity(FavoritesActivity.OSM_EDITS_TAB); startFavoritesActivity(R.string.osm_edits);
} }
}); });

View file

@ -155,7 +155,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
if (dbpoi.getOpenstreetmapPoints().size() > 0 || dbbug.getOsmbugsPoints().size() > 0){ if (dbpoi.getOpenstreetmapPoints().size() > 0 || dbbug.getOsmbugsPoints().size() > 0){
mTabs.add(favoritesActivity.getTabIndicator(R.string.osm_edits, OsmEditsFragment.class)); mTabs.add(favoritesActivity.getTabIndicator(R.string.osm_edits, OsmEditsFragment.class));
if (intent != null && "OSM".equals(intent.getStringExtra("TAB"))) { if (intent != null && "OSM".equals(intent.getStringExtra("TAB"))) {
app.getSettings().FAVORITES_TAB.set(FavoritesActivity.OSM_EDITS_TAB); app.getSettings().FAVORITES_TAB.set(R.string.osm_edits);
} }
} }
} }

View file

@ -46,7 +46,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
final Intent favorites = new Intent(SettingsOsmEditingActivity.this, final Intent favorites = new Intent(SettingsOsmEditingActivity.this,
appCustomization.getFavoritesActivity()); appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.OSM_EDITS_TAB); getMyApplication().getSettings().FAVORITES_TAB.set(R.string.osm_edits);
startActivity(favorites); startActivity(favorites);
return true; return true;
} }

View file

@ -179,7 +179,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
latLon = loc; latLon = loc;
if(latLon != null){ if(latLon != null){
if(description == null){ if(description == null){
description = PointDescription.LOCATION_POINT.getFullPlainName(activity, loc.getLatitude(), loc.getLongitude()); description = new PointDescription(loc.getLatitude(), loc.getLongitude()).getFullPlainName(activity);
} }
textView.setText(Html.fromHtml(description.replace("\n", "<br/>"))); textView.setText(Html.fromHtml(description.replace("\n", "<br/>")));
} else { } else {
@ -321,9 +321,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
} }
if(name) { if(name) {
PointDescription nm = e.getValue().getObjectName(e.getKey()); PointDescription nm = e.getValue().getObjectName(e.getKey());
LatLon ll = e.getValue().getObjectLocation(e.getKey()); description.append(nm.getFullPlainName(activity));
description.append(nm.getFullPlainName(activity, ll == null? 0 : ll.getLatitude(), ll == null? 0
: ll.getLongitude()));
} else { } else {
description.append(e.getValue().getObjectDescription(e.getKey())); description.append(e.getValue().getObjectDescription(e.getKey()));
} }

View file

@ -205,8 +205,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
@Override @Override
public String getObjectDescription(Object o) { public String getObjectDescription(Object o) {
if (o instanceof TargetPoint) { if (o instanceof TargetPoint) {
return ((TargetPoint) o).getPointDescription(view.getContext()).getFullPlainName(view.getContext(), return ((TargetPoint) o).getPointDescription(view.getContext()).getFullPlainName(view.getContext());
((TargetPoint) o).getLatitude(), ((TargetPoint) o).getLongitude());
} }
return null; return null;
} }