Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-06-27 17:51:02 +02:00
commit bb3e8a9fb2
9 changed files with 181 additions and 50 deletions

View file

@ -30,6 +30,6 @@ public interface ITileSource {
public String getReferer();
public void clearTiles(String path);
public void deleteTiles(String path);
}

View file

@ -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) {

View file

@ -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" />
<android.support.v7.widget.SwitchCompat
@ -42,14 +41,77 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_toEndOf="@+id/toggle_row_icon"
android:layout_toLeftOf="@id/toggle_row_toggle"
android:layout_toRightOf="@+id/toggle_row_icon"
android:layout_toStartOf="@id/toggle_row_toggle"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="Some title text" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_marginTop="12dp"
android:layout_toEndOf="@+id/toggle_row_icon"
android:layout_toRightOf="@+id/toggle_row_icon"
android:background="?attr/dashboard_divider" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="60dp">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/mapillary_filters_tile_cache_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_margin="16dp"
tools:src="@drawable/ic_layer_top_dark" />
<Button
android:id="@+id/button_reload_tile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="?attr/selectableItemBackground"
android:text="@string/shared_string_reload"
android:textColor="?attr/color_dialog_buttons" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_toEndOf="@+id/mapillary_filters_tile_cache_icon"
android:layout_toLeftOf="@id/button_reload_tile"
android:layout_toRightOf="@+id/mapillary_filters_tile_cache_icon"
android:layout_toStartOf="@id/button_reload_tile"
android:minHeight="60dp"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingTop="10dp">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mapillary_menu_title_tile_cache"
android:textAppearance="@style/TextAppearance.ListItemTitle" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/mapillary_menu_descr_tile_cache"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size" />
</LinearLayout>
</RelativeLayout>
<LinearLayout xmlns:osmand="http://schemas.android.com/apk/res-auto"
@ -95,7 +157,6 @@
android:text="@string/mapillary_menu_filter_description"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
</LinearLayout>
<View
@ -309,7 +370,7 @@
android:background="?attr/bg_color">
<Button
android:id="@+id/button_apply"
android:id="@+id/button_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
@ -317,17 +378,17 @@
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:background="?attr/selectableItemBackground"
android:text="@string/shared_string_apply"
android:text="@string/shared_string_clear"
android:textColor="?attr/color_dialog_buttons" />
<Button
android:id="@+id/button_clear"
android:id="@+id/button_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="?attr/selectableItemBackground"
android:text="@string/shared_string_clear"
android:text="@string/shared_string_apply"
android:textColor="?attr/color_dialog_buttons" />
</RelativeLayout>

View file

@ -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
-->
<string name="shared_string_reload">Reload</string>
<string name="mapillary_menu_descr_tile_cache">Reload tiles if you want see latest data.</string>
<string name="mapillary_menu_title_tile_cache">Tile cache</string>
<string name="wrong_user_name">Wrong user name!</string>
<string name="shared_string_to">To</string>
<string name="mapillary_menu_date_from">From</string>
@ -17,7 +20,7 @@
<string name="mapillary_menu_edit_text_hint">Type user name</string>
<string name="mapillary_menu_descr_username">View images added by a certain user.</string>
<string name="mapillary_menu_title_username">Username</string>
<string name="mapillary_menu_filter_description">You can filter images by the name of the user or by the date.</string>
<string name="mapillary_menu_filter_description">You can filter images by the name of the user or by the date, filter apply only for close zoom.</string>
<string name="map_widget_ruler_control_first_mode">Two point ruler</string>
<string name="map_widget_ruler_control_second_mode">Radius ruler</string>
<string name="shared_string_permissions">Permissions</string>

View file

@ -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;

View file

@ -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) {

View file

@ -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++;

View file

@ -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) {

View file

@ -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 ////////////////////////////////////////////////