aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/cgeo/geocaching/CacheListActivity.java9
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java45
2 files changed, 36 insertions, 18 deletions
diff --git a/main/src/cgeo/geocaching/CacheListActivity.java b/main/src/cgeo/geocaching/CacheListActivity.java
index d4d46fd..41e7cfb 100644
--- a/main/src/cgeo/geocaching/CacheListActivity.java
+++ b/main/src/cgeo/geocaching/CacheListActivity.java
@@ -56,8 +56,8 @@ import cgeo.geocaching.ui.WeakReferenceHandler;
import cgeo.geocaching.ui.dialog.Dialogs;
import cgeo.geocaching.utils.AngleUtils;
import cgeo.geocaching.utils.AsyncTaskWithProgress;
-import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.CalendarUtils;
+import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.Log;
import cgeo.geocaching.utils.RxUtils;
@@ -1395,12 +1395,7 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA
// apply filter settings (if there's a filter)
final SearchResult searchToUse = getFilteredSearch();
- final int count = searchToUse.getCount();
- String mapTitle = title;
- if (count > 0) {
- mapTitle = title + " [" + count + "]";
- }
- CGeoMap.startActivitySearch(this, searchToUse, mapTitle);
+ CGeoMap.startActivitySearch(this, searchToUse, title);
}
private void refreshCurrentList() {
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index ed938bd..38fe6bd 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -219,28 +219,34 @@ public class CGeoMap extends AbstractMap implements ViewFactory {
switch (what) {
case UPDATE_TITLE:
// set title
- final StringBuilder title = new StringBuilder();
-
if (map.mapMode == MapMode.LIVE && map.isLiveEnabled) {
- title.append(map.res.getString(R.string.map_live));
+ map.setTitle(map.res.getString(R.string.map_live));
} else {
- title.append(map.mapTitle);
+ map.setTitle(map.mapTitle);
}
+ // count caches in the sub title
map.countVisibleCaches();
- if (!map.caches.isEmpty() && !map.mapTitle.contains("[")) {
- title.append(" [").append(map.cachesCnt);
- if (map.cachesCnt != map.caches.size() && Settings.isDebug()) {
- title.append('/').append(map.caches.size());
+ final StringBuilder subtitle = new StringBuilder();
+ if (!map.caches.isEmpty()) {
+ final int totalCount = map.caches.size();
+
+ if (map.cachesCnt != totalCount && Settings.isDebug()) {
+ subtitle.append(map.cachesCnt).append('/').append(totalCount).append(map.res.getQuantityString(R.plurals.cache_counts, totalCount, totalCount));
+ }
+ else {
+ subtitle.append(map.res.getQuantityString(R.plurals.cache_counts, map.cachesCnt, map.cachesCnt));
}
- title.append(']');
}
if (Settings.isDebug() && map.lastSearchResult != null && StringUtils.isNotBlank(map.lastSearchResult.getUrl())) {
- title.append('[').append(map.lastSearchResult.getUrl()).append(']');
+ subtitle.append(" [").append(map.lastSearchResult.getUrl()).append(']');
+ }
+
+ if (subtitle.length() > 0) {
+ map.setSubtitle(subtitle.toString());
}
- map.setTitle(title.toString());
break;
case INVALIDATE_MAP:
map.mapView.repaintRequired(null);
@@ -267,10 +273,27 @@ public class CGeoMap extends AbstractMap implements ViewFactory {
}
}
+ private void setSubtitle(final String subtitle) {
+ /* Compatibility for the old Action Bar, only used by the maps activity at the moment */
+ final TextView titleView = ButterKnife.findById(activity, R.id.actionbar_title);
+ if (titleView != null) {
+ titleView.setText(titleView.getText().toString() + ' ' + subtitle);
+ }
+ if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)) {
+ setSubtitleIceCreamSandwich(subtitle);
+ }
+ }
+
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setTitleIceCreamSandwich(final String title) {
activity.getActionBar().setTitle(title);
}
+
+ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
+ private void setSubtitleIceCreamSandwich(final String subtitle) {
+ activity.getActionBar().setSubtitle(subtitle);
+ }
+
/** Updates the progress. */
private static final class ShowProgressHandler extends Handler {
private int counter = 0;