diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 19335faa05..795e9e9997 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,8 @@
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
-->
+ Nothing to download, please check internet connection.
+ Nothing was found. If you can\'t find your region, you can make it yourself (see http://osmand.net).
No GPX files selected. In order to select press and hold on available track.
Unselect
Select to show
@@ -983,7 +985,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
Do you want to interrupt file downloading?
Thank you for using OsmAnd. For many features of this application you need some regional offline data which you can download via \'Settings\' → \'Manage map files\'. Afterwards you will be able to view maps, locate addresses, look up POIs, and find public transportation.
Basemap is required for proper application functioning and was selected to download.
- Nothing was found. If you can\'t find your region, you can make it yourself (see http://osmand.net).
Online and tile maps
Offline maps (vector)
Download and manage offline map files stored on your device
diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
index 7715b30861..791cc1db12 100644
--- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
+++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
@@ -2,7 +2,9 @@ package net.osmand.plus;
import java.io.File;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
@@ -30,7 +32,7 @@ public class GpxSelectionHelper {
// new BooleanPreference("show_current_gpx_track", false).makeGlobal().cache();
private List selectedGPXFiles = new java.util.concurrent.CopyOnWriteArrayList();
private SavingTrackHelper savingTrackHelper;
- private Runnable uiListener;
+ private Map, Runnable> uiListeners = new LinkedHashMap, Runnable>();
public GpxSelectionHelper(OsmandApplication osmandApplication) {
this.app = osmandApplication;
@@ -353,15 +355,20 @@ public class GpxSelectionHelper {
saveCurrentSelections();
}
- public void setUiListener(Runnable r) {
- this.uiListener = r;
+ public void setUiListener(Class> key, Runnable listener) {
+ if(listener == null) {
+ uiListeners.remove(key);
+ } else {
+ uiListeners.put(key, listener);
+ }
}
- public Runnable getUiListener() {
- return uiListener;
+ public void runUiListeners() {
+ for(Runnable r : uiListeners.values()) {
+ r.run();
+ }
}
-
public static class SelectedGpxFile {
public boolean notShowNavigationDialog = false;
@@ -545,5 +552,4 @@ public class GpxSelectionHelper {
}
-
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java
index ad196e8684..69c76af025 100644
--- a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java
@@ -400,10 +400,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
resId == R.string.local_index_select_gpx_file) {
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, resId == R.string.local_index_select_gpx_file, true);
listAdapter.notifyDataSetChanged();
- Runnable r = selectedGpxHelper.getUiListener();
- if(r != null) {
- r.run();
- }
+ selectedGpxHelper.runUiListeners();
} else if (resId == R.string.local_index_mi_delete) {
Builder confirm = new AlertDialog.Builder(getActivity());
confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
@@ -498,6 +495,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onPreExecute() {
getSherlockActivity().setSupportProgressBarIndeterminateVisibility(true);
+ listAdapter.clear();
}
@Override
@@ -917,10 +915,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onPostExecute(String result) {
- Runnable r = selectedGpxHelper.getUiListener();
- if(r != null) {
- r.run();
- }
+ selectedGpxHelper.runUiListeners();
getSherlockActivity().setProgressBarIndeterminateVisibility(false);
if(showOnMap && toShow != null) {
getMyApplication().getSettings().setMapLocationToShow(toShow.lat, toShow.lon,
diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java
index 0c75b99f91..792cf41556 100644
--- a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java
@@ -6,6 +6,7 @@ package net.osmand.plus.activities;
import java.io.File;
import java.util.ArrayList;
+import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@@ -20,7 +21,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TabHost;
+import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
+import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Window;
@@ -34,6 +37,8 @@ public class FavouritesActivity extends SherlockFragmentActivity {
private static final String TRACKS = "TRACKS";
private static final String SELECTED_TRACK = "SELECTED_TRACK";
private TabsAdapter mTabsAdapter;
+ private TabSpec selectedTrack;
+ private TabHost tabHost;
@Override
@@ -67,7 +72,7 @@ public class FavouritesActivity extends SherlockFragmentActivity {
getSupportFragmentManager().beginTransaction().add(R.id.layout, new FavouritesTreeFragment()).commit();
} else {
setContentView(R.layout.tab_content);
- TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
+ tabHost = (TabHost) findViewById(android.R.id.tabhost);
tabHost.setup();
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
@@ -78,12 +83,45 @@ public class FavouritesActivity extends SherlockFragmentActivity {
FavouritesTreeFragment.class, null);
mTabsAdapter.addTab(tabHost.newTabSpec(TRACKS).setIndicator(getString(R.string.my_tracks)),
AvailableGPXFragment.class, null);
- mTabsAdapter.addTab(tabHost.newTabSpec(SELECTED_TRACK).setIndicator(getString(R.string.selected_track)),
+ selectedTrack = mTabsAdapter.addTab(tabHost.newTabSpec(SELECTED_TRACK).setIndicator(getString(R.string.selected_track)),
SelectedGPXFragment.class, null);
tabHost.setCurrentTab(tab);
+ updateSelectedTracks();
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ ((OsmandApplication) getApplication()).getSelectedGpxHelper().setUiListener(FavouritesActivity.class,new Runnable() {
+
+ @Override
+ public void run() {
+ updateSelectedTracks();
+ }
+ });
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ ((OsmandApplication) getApplication()).getSelectedGpxHelper().setUiListener(FavouritesActivity.class, null);
+ }
+
+ public void updateSelectedTracks() {
+ if (selectedTrack != null) {
+ GpxSelectionHelper gpx = ((OsmandApplication) getApplication()).getSelectedGpxHelper();
+ String vl = getString(R.string.selected_track);
+ if (gpx.isShowingAnyGpxFiles()) {
+ vl += " (" + gpx.getSelectedGPXFiles().size()
+ + ")";
+ }
+ try {
+ ((TextView)tabHost.getTabWidget().getChildAt(2).findViewById(android.R.id.title)).setText(vl);
+ } catch (Exception e) {
+ }
+ mTabsAdapter.notifyDataSetChanged();
}
-
-
}
@@ -157,7 +195,7 @@ public class FavouritesActivity extends SherlockFragmentActivity {
mViewPager.setOnPageChangeListener(this);
}
- public void addTab(TabHost.TabSpec tabSpec, Class> clss, Bundle args) {
+ public TabSpec addTab(TabHost.TabSpec tabSpec, Class> clss, Bundle args) {
tabSpec.setContent(new DummyTabFactory(mContext));
String tag = tabSpec.getTag();
@@ -165,6 +203,7 @@ public class FavouritesActivity extends SherlockFragmentActivity {
mTabs.add(info);
mTabHost.addTab(tabSpec);
notifyDataSetChanged();
+ return tabSpec;
}
@@ -210,3 +249,4 @@ public class FavouritesActivity extends SherlockFragmentActivity {
}
}
+
diff --git a/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java b/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java
index d9ad3d3dec..387ecd16e4 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java
@@ -83,7 +83,8 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
setAdapter(adapter);
}
adapter.setDisplayGroups(selectedGpxHelper.getDisplayGroups());
- selectedGpxHelper.setUiListener(new Runnable() {
+ selectedGpxHelper.setUiListener(SelectedGPXFragment.class,
+ new Runnable() {
@Override
public void run() {
@@ -95,7 +96,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
@Override
public void onPause() {
super.onPause();
- selectedGpxHelper.setUiListener(null);
+ selectedGpxHelper.setUiListener(SelectedGPXFragment.class, null);
}
@Override
@@ -274,8 +275,8 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
public void onClick(DialogInterface dialog, int which) {
if(!vis.isChecked()) {
getMyApplication().getSelectedGpxHelper().selectGpxFile(model.getGpx(), false, false);
-
SelectedGPXFragment.this.adapter.setDisplayGroups(selectedGpxHelper.getDisplayGroups());
+ getMyApplication().getSelectedGpxHelper().runUiListeners();
} else {
updateSplit(model, distanceSplit, timeSplit, sp.getSelectedItemPosition() );
}
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java
index 81de5bdbfe..55c55c6422 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java
@@ -167,6 +167,8 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem
Collection items = (Collection) results.values;
if (items != null && !items.isEmpty()) {
list.addAll(IndexItemCategory.categorizeIndexItems(downloadActivity.getMyApplication(), items));
+ } else if(DownloadIndexAdapter.this.indexFiles.isEmpty()){
+ list.add(new IndexItemCategory(downloadActivity.getResources().getString(R.string.no_index_file_to_download), 1));
} else {
list.add(new IndexItemCategory(downloadActivity.getResources().getString(R.string.select_index_file_to_download), 1));
}
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
index adf1c5eb72..2d03652175 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
@@ -42,7 +42,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
public OsmandMonitoringPlugin(OsmandApplication app) {
this.app = app;
liveMonitoringHelper = new LiveMonitoringHelper(app);
- ApplicationMode.regWidget("monitoring", (ApplicationMode[])null);
+ ApplicationMode.regWidget("monitoring", ApplicationMode.DEFAULT);
}
@Override