diff --git a/OsmAnd-java/src/net/osmand/map/ITileSource.java b/OsmAnd-java/src/net/osmand/map/ITileSource.java
index 1711f8453e..a51b5bdeeb 100644
--- a/OsmAnd-java/src/net/osmand/map/ITileSource.java
+++ b/OsmAnd-java/src/net/osmand/map/ITileSource.java
@@ -30,6 +30,6 @@ public interface ITileSource {
public String getReferer();
- public void clearTiles(String path);
+ public void deleteTiles(String path);
}
diff --git a/OsmAnd-java/src/net/osmand/map/TileSourceManager.java b/OsmAnd-java/src/net/osmand/map/TileSourceManager.java
index 95ef7fe3e5..4a0bcbc5cf 100644
--- a/OsmAnd-java/src/net/osmand/map/TileSourceManager.java
+++ b/OsmAnd-java/src/net/osmand/map/TileSourceManager.java
@@ -1,5 +1,13 @@
package net.osmand.map;
+import net.osmand.PlatformUtil;
+import net.osmand.osm.io.NetworkUtils;
+import net.osmand.util.Algorithms;
+
+import org.apache.commons.logging.Log;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
@@ -18,15 +26,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import net.osmand.PlatformUtil;
-import net.osmand.osm.io.NetworkUtils;
-import net.osmand.util.Algorithms;
-
-import org.apache.commons.logging.Log;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-
import bsh.Interpreter;
@@ -278,7 +277,7 @@ public class TileSourceManager {
@Override
- public void clearTiles(String path) {
+ public void deleteTiles(String path) {
File pf = new File(path);
File[] list = pf.listFiles();
if(list != null) {
diff --git a/OsmAnd/res/layout/fragment_mapillary_filters.xml b/OsmAnd/res/layout/fragment_mapillary_filters.xml
index d121a43e1e..01a207c612 100644
--- a/OsmAnd/res/layout/fragment_mapillary_filters.xml
+++ b/OsmAnd/res/layout/fragment_mapillary_filters.xml
@@ -20,8 +20,7 @@
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
- android:layout_marginLeft="16dp"
- android:layout_marginStart="16dp"
+ android:layout_margin="16dp"
tools:src="@drawable/ic_action_gabout_dark" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 2c5d0a34a7..eed69b3495 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,9 @@
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
-->
+ Reload
+ Reload tiles if you want see latest data.
+ Tile cache
Wrong user name!
To
From
@@ -17,7 +20,7 @@
Type user name
View images added by a certain user.
Username
- You can filter images by the name of the user or by the date.
+ You can filter images by the name of the user or by the date, filter apply only for close zoom.
Two point ruler
Radius ruler
Permissions
diff --git a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java
index acf0dafce3..93ac107f5c 100644
--- a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java
+++ b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java
@@ -1,12 +1,9 @@
package net.osmand.plus;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.List;
+import android.database.sqlite.SQLiteDiskIOException;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.widget.Toast;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
@@ -20,11 +17,15 @@ import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.List;
+
import bsh.Interpreter;
-import android.database.sqlite.SQLiteDiskIOException;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.widget.Toast;
public class SQLiteTileSource implements ITileSource {
@@ -416,7 +417,7 @@ public class SQLiteTileSource implements ITileSource {
@Override
- public void clearTiles(String path) {
+ public void deleteTiles(String path) {
SQLiteConnection db = getDatabase();
if (db == null || db.isReadOnly() || onlyReadonlyAvailable) {
return;
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index d9f5d03b66..72bb2f61f9 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -1,6 +1,7 @@
package net.osmand.plus.dashboard;
import android.annotation.SuppressLint;
+import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
@@ -20,6 +21,7 @@ import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
+import android.view.inputmethod.InputMethodManager;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@@ -1337,6 +1339,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private void backPressed() {
if (previousVisibleType != visibleType && previousVisibleType != null) {
+ if (visibleType == DashboardType.MAPILLARY) {
+ hideKeyboard();
+ }
visibleType = null;
setDashboardVisibility(true, previousVisibleType);
} else {
@@ -1344,6 +1349,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
+ private void hideKeyboard() {
+ View currentFocus = mapActivity.getCurrentFocus();
+ if (currentFocus != null) {
+ InputMethodManager imm = (InputMethodManager) mapActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
+ }
+ }
+
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java
index 08b2f025b7..b7f1900df3 100644
--- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java
@@ -3,7 +3,6 @@ package net.osmand.plus.download.ui;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@@ -483,7 +482,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
} else if (operation == CLEAR_TILES_OPERATION) {
ITileSource src = (ITileSource) info.getAttachedObject();
if(src != null) {
- src.clearTiles(info.getPathToData());
+ src.deleteTiles(info.getPathToData());
}
}
total++;
diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java
index fa9e666fd6..f6977bbe1b 100644
--- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java
@@ -2,6 +2,7 @@ package net.osmand.plus.mapillary;
import android.app.DatePickerDialog;
+import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
@@ -10,20 +11,27 @@ import android.support.v7.widget.AppCompatTextView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.ContextThemeWrapper;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
+import android.widget.TextView;
+import net.osmand.map.TileSourceManager;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
+import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.views.controls.DelayAutoCompleteTextView;
import java.text.DateFormat;
@@ -56,12 +64,6 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
final View toggleRow = view.findViewById(R.id.toggle_row);
- toggleRow.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- showOrHideMapillaryLayers(settings, plugin, mapActivity);
- }
- });
final boolean selected = settings.SHOW_MAPILLARY.get();
final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled;
int toggleIconColorId;
@@ -81,7 +83,27 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
- showOrHideMapillaryLayers(settings, plugin, mapActivity);
+ settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
+ plugin.updateLayers(mapActivity.getMapView(), mapActivity);
+ mapActivity.getDashboard().refreshContent(true);
+ }
+ });
+ toggleRow.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ toggle.setChecked(!toggle.isChecked());
+ }
+ });
+
+
+ final Button reloadTile = (Button) view.findViewById(R.id.button_reload_tile);
+ reloadTile.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ ResourceManager manager = getMyApplication().getResourceManager();
+ manager.clearCacheAndTiles(TileSourceManager.getMapillaryVectorSource());
+ manager.clearCacheAndTiles(TileSourceManager.getMapillaryRasterSource());
+ mapActivity.refreshMap();
}
});
@@ -89,6 +111,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
final int colorRes = nightMode ? R.color.color_white : R.color.icon_color;
((AppCompatImageView) view.findViewById(R.id.mapillary_filters_user_icon)).setImageDrawable(getIcon(R.drawable.ic_action_user, colorRes));
((AppCompatImageView) view.findViewById(R.id.mapillary_filters_date_icon)).setImageDrawable(getIcon(R.drawable.ic_action_data, colorRes));
+ ((AppCompatImageView) view.findViewById(R.id.mapillary_filters_tile_cache_icon)).setImageDrawable(getIcon(R.drawable.ic_layer_top_dark, colorRes));
final DelayAutoCompleteTextView textView = (DelayAutoCompleteTextView) view.findViewById(R.id.auto_complete_text_view);
@@ -98,6 +121,24 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
textView.setText(selectedUsername);
textView.setSelection(selectedUsername.length());
}
+ textView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
+ hideKeyboard();
+ mapActivity.getDashboard().refreshContent(true);
+ }
+ });
+ textView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
+ if (id == EditorInfo.IME_ACTION_DONE) {
+ hideKeyboard();
+ mapActivity.getDashboard().refreshContent(true);
+ return true;
+ }
+ return false;
+ }
+ });
textView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -107,7 +148,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
view.findViewById(R.id.warning_linear_layout).setVisibility(View.GONE);
- if (charSequence.length() > 0 ||
+ if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") ||
settings.MAPILLARY_FILTER_TO_DATE.get() != 0 ||
settings.MAPILLARY_FILTER_FROM_DATE.get() != 0) {
changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true);
@@ -137,6 +178,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
dateFromEt.setText(dateFormat.format(from.getTime()));
settings.MAPILLARY_FILTER_FROM_DATE.set(from.getTimeInMillis());
changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true);
+ mapActivity.getDashboard().refreshContent(true);
}
};
dateFromEt.setOnClickListener(new View.OnClickListener() {
@@ -163,6 +205,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
dateToEt.setText(dateFormat.format(to.getTime()));
settings.MAPILLARY_FILTER_TO_DATE.set(to.getTimeInMillis());
changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true);
+ mapActivity.getDashboard().refreshContent(true);
}
};
dateToEt.setOnClickListener(new View.OnClickListener() {
@@ -201,15 +244,17 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || !dateFrom.equals("") || !dateTo.equals("")) {
settings.USE_MAPILLARY_FILTER.set(true);
}
- if (!username.equals("") && settings.MAPILLARY_FILTER_USERNAME.get().equals("")) {
- view.findViewById(R.id.warning_linear_layout).setVisibility(View.VISIBLE);
- }
if (dateFrom.equals("")) {
settings.MAPILLARY_FILTER_FROM_DATE.set(0L);
}
if (dateTo.equals("")) {
settings.MAPILLARY_FILTER_TO_DATE.set(0L);
}
+ if (!username.equals("") && settings.MAPILLARY_FILTER_USERNAME.get().equals("")) {
+ view.findViewById(R.id.warning_linear_layout).setVisibility(View.VISIBLE);
+ } else {
+ mapActivity.getDashboard().hideDashboard();
+ }
changeButtonState(apply, .5f, false);
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
@@ -239,10 +284,12 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
return view;
}
- private void showOrHideMapillaryLayers(OsmandSettings settings, MapillaryPlugin plugin, MapActivity mapActivity) {
- settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
- plugin.updateLayers(mapActivity.getMapView(), mapActivity);
- mapActivity.getDashboard().refreshContent(true);
+ private void hideKeyboard() {
+ View currentFocus = getActivity().getCurrentFocus();
+ if (currentFocus != null) {
+ InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
+ }
}
private void changeButtonState(Button button, float alpha, boolean enabled) {
diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java
index efe1a43476..26fa4599c1 100644
--- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java
+++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java
@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.res.AssetManager;
import android.database.sqlite.SQLiteException;
import android.os.HandlerThread;
+import android.support.annotation.NonNull;
import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.view.WindowManager;
@@ -336,6 +337,13 @@ public class ResourceManager {
return cache != null && cache.getTileForMapSync(file, map, x, y, zoom, loadFromInternetIfNeeded) != null;
}
+ public void clearCacheAndTiles(@NonNull ITileSource map) {
+ map.deleteTiles(new File(dirWithTiles, map.getName()).getAbsolutePath());
+ TilesCache cache = getTilesCache(map);
+ if (cache != null) {
+ cache.clearTiles();
+ }
+ }
////////////////////////////////////////////// Working with indexes ////////////////////////////////////////////////