Merge branch 'master' into plan_route_point_menu
# Conflicts: # OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java
This commit is contained in:
commit
43fe12c05c
16 changed files with 100 additions and 27 deletions
|
@ -32,6 +32,8 @@ public interface ITileSource {
|
|||
|
||||
public String getReferer();
|
||||
|
||||
public String getUserAgent();
|
||||
|
||||
public void deleteTiles(String path);
|
||||
|
||||
public int getAvgSize();
|
||||
|
|
|
@ -90,6 +90,7 @@ public class MapTileDownloader {
|
|||
public final int yTile;
|
||||
public String url;
|
||||
public String referer = null;
|
||||
public String userAgent = null;
|
||||
public boolean error;
|
||||
|
||||
public DownloadRequest(String url, File fileToSave, int xTile, int yTile, int zoom) {
|
||||
|
@ -266,7 +267,7 @@ public class MapTileDownloader {
|
|||
request.setError(false);
|
||||
try {
|
||||
URLConnection connection = NetworkUtils.getHttpURLConnection(request.url);
|
||||
connection.setRequestProperty("User-Agent", USER_AGENT); //$NON-NLS-1$
|
||||
connection.setRequestProperty("User-Agent", Algorithms.isEmpty(request.userAgent) ? USER_AGENT : request.userAgent); //$NON-NLS-1$
|
||||
if (request.referer != null)
|
||||
connection.setRequestProperty("Referer", request.referer); //$NON-NLS-1$
|
||||
connection.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||
|
|
|
@ -68,6 +68,7 @@ public class TileSourceManager {
|
|||
private String[] randomsArray;
|
||||
private String rule;
|
||||
private String referer;
|
||||
private String userAgent;
|
||||
private boolean hidden; // if hidden in configure map settings, for example mapillary sources
|
||||
|
||||
private boolean isRuleAcceptable = true;
|
||||
|
@ -261,6 +262,14 @@ public class TileSourceManager {
|
|||
this.referer = referer;
|
||||
}
|
||||
|
||||
public String getUserAgent() {
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
public void setUserAgent(String userAgent) {
|
||||
this.userAgent = userAgent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileSize() {
|
||||
return tileSize;
|
||||
|
@ -484,6 +493,9 @@ public class TileSourceManager {
|
|||
if (!Algorithms.isEmpty(tm.getReferer())) {
|
||||
properties.put("referer", tm.getReferer());
|
||||
}
|
||||
if (!Algorithms.isEmpty(tm.getUserAgent())) {
|
||||
properties.put("user_agent", tm.getUserAgent());
|
||||
}
|
||||
|
||||
properties.put("ext", tm.getTileFormat());
|
||||
properties.put("min_zoom", tm.getMinimumZoomSupported() + "");
|
||||
|
@ -708,6 +720,12 @@ public class TileSourceManager {
|
|||
}
|
||||
String randoms = attributes.get("randoms");
|
||||
TileSourceTemplate templ = new TileSourceTemplate(name, urlTemplate, ext, maxZoom, minZoom, tileSize, bitDensity, avgTileSize);
|
||||
if (attributes.get("referer") != null) {
|
||||
templ.setReferer(attributes.get("referer"));
|
||||
}
|
||||
if (attributes.get("user_agent") != null) {
|
||||
templ.setUserAgent(attributes.get("user_agent"));
|
||||
}
|
||||
if(expirationTime >= 0) {
|
||||
templ.setExpirationTimeMinutes(expirationTime);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/measurement_tool_menu_title_padding_top"
|
||||
android:orientation="vertical"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingBottom="@dimen/measurement_tool_menu_title_padding_bottom"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Some title" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
tools:text="Some description" />
|
||||
|
||||
</LinearLayout>
|
|
@ -14,8 +14,8 @@
|
|||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/multi_selection_menu_padding_top"
|
||||
android:paddingBottom="@dimen/bottom_sheet_title_padding_bottom"
|
||||
android:paddingTop="@dimen/measurement_tool_menu_title_padding_top"
|
||||
android:paddingBottom="@dimen/measurement_tool_menu_title_padding_bottom"
|
||||
android:text="@string/plan_route_open_existing_track"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
|
|
@ -304,7 +304,7 @@
|
|||
android:paddingLeft="@dimen/measurement_tool_button_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_button_padding"
|
||||
android:text="@string/shared_string_apply"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textColor="@color/color_white"
|
||||
android:textAllCaps="false"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
|
|
|
@ -20,8 +20,10 @@
|
|||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/choose_navigation_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="@dimen/measurement_tool_menu_title_padding_top"
|
||||
android:paddingBottom="@dimen/measurement_tool_menu_title_padding_bottom"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
|
@ -42,7 +44,6 @@
|
|||
android:textColor="?android:textColorPrimary"
|
||||
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:textSize="@dimen/default_desc_text_size" />
|
||||
|
||||
<include layout="@layout/custom_radio_buttons" />
|
||||
|
@ -61,7 +62,6 @@
|
|||
android:textColor="?android:textColorPrimary"
|
||||
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:textSize="@dimen/default_desc_text_size" />
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -248,6 +248,8 @@
|
|||
<dimen name="content_padding_small">12dp</dimen>
|
||||
<dimen name="content_padding_half">8dp</dimen>
|
||||
<dimen name="bottom_sheet_content_padding_small">8dp</dimen>
|
||||
<dimen name="measurement_tool_menu_title_padding_top">13dp</dimen>
|
||||
<dimen name="measurement_tool_menu_title_padding_bottom">5dp</dimen>
|
||||
<dimen name="measurement_tool_divider_margin">8dp</dimen>
|
||||
<dimen name="measurement_tool_content_padding_medium">12dp</dimen>
|
||||
<dimen name="text_margin_small">4dp</dimen>
|
||||
|
|
|
@ -39,6 +39,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
private static final String ELLIPSOID = "ellipsoid";
|
||||
private static final String INVERTED_Y = "inverted_y";
|
||||
private static final String REFERER = "referer";
|
||||
private static final String USER_AGENT = "useragent";
|
||||
private static final String TIME_COLUMN = "timecolumn";
|
||||
private static final String EXPIRE_MINUTES = "expireminutes";
|
||||
private static final String RULE = "rule";
|
||||
|
@ -62,6 +63,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
private String[] randomsArray;
|
||||
private String rule = null;
|
||||
private String referer = null;
|
||||
private String userAgent = null;
|
||||
|
||||
int tileSize = 256;
|
||||
boolean tileSizeSpecified = false;
|
||||
|
@ -93,7 +95,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
}
|
||||
|
||||
public SQLiteTileSource(OsmandApplication ctx, String name, int minZoom, int maxZoom, String urlTemplate,
|
||||
String randoms, boolean isEllipsoid, boolean invertedY, String referer,
|
||||
String randoms, boolean isEllipsoid, boolean invertedY, String referer, String userAgent,
|
||||
boolean timeSupported, long expirationTimeMillis, boolean inversiveZoom, String rule) {
|
||||
this.ctx = ctx;
|
||||
this.name = name;
|
||||
|
@ -104,6 +106,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
this.expirationTimeMillis = expirationTimeMillis;
|
||||
this.randoms = randoms;
|
||||
this.referer = referer;
|
||||
this.userAgent = userAgent;
|
||||
this.rule = rule;
|
||||
this.invertedY = invertedY;
|
||||
this.timeSupported = timeSupported;
|
||||
|
@ -120,6 +123,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
this.expirationTimeMillis = tileSource.getExpirationTimeMillis();
|
||||
this.randoms = tileSource.getRandoms();
|
||||
this.referer = tileSource.getReferer();
|
||||
this.userAgent = tileSource.getUserAgent();
|
||||
this.invertedY = tileSource.isInvertedYTile();
|
||||
this.timeSupported = tileSource.isTimeSupported();
|
||||
this.inversiveZoom = tileSource.getInversiveZoom();
|
||||
|
@ -139,6 +143,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
addInfoColumn(db, ELLIPSOID, isEllipsoid ? "1" : "0");
|
||||
addInfoColumn(db, INVERTED_Y, invertedY ? "1" : "0");
|
||||
addInfoColumn(db, REFERER, referer);
|
||||
addInfoColumn(db, USER_AGENT, userAgent);
|
||||
addInfoColumn(db, TIME_COLUMN, timeSupported ? "yes" : "no");
|
||||
addInfoColumn(db, EXPIRE_MINUTES, String.valueOf(getExpirationTimeMinutes()));
|
||||
|
||||
|
@ -264,6 +269,10 @@ public class SQLiteTileSource implements ITileSource {
|
|||
if(refererId != -1) {
|
||||
referer = cursor.getString(refererId);
|
||||
}
|
||||
int userAgentId = list.indexOf(USER_AGENT);
|
||||
if(userAgentId != -1) {
|
||||
userAgent = cursor.getString(userAgentId);
|
||||
}
|
||||
int tnumbering = list.indexOf(TILENUMBERING);
|
||||
if(tnumbering != -1) {
|
||||
inversiveZoom = BIG_PLANET_TILE_NUMBERING.equalsIgnoreCase(cursor.getString(tnumbering));
|
||||
|
@ -673,4 +682,8 @@ public class SQLiteTileSource implements ITileSource {
|
|||
return referer;
|
||||
}
|
||||
|
||||
public String getUserAgent() {
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
|
|||
SQLiteTileSource sqLiteTileSource =
|
||||
new SQLiteTileSource(app, newName, minZoom,
|
||||
maxZoom, urlToLoad, "",
|
||||
elliptic, false, "", expireTimeMinutes > 0,
|
||||
elliptic, false, "", "", expireTimeMinutes > 0,
|
||||
expireTimeMinutes * 60 * 1000L, false, ""
|
||||
);
|
||||
sqLiteTileSource.createDataBase();
|
||||
|
|
|
@ -14,7 +14,6 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
|||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
|
||||
public class ExitBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
|
@ -27,12 +26,10 @@ public class ExitBottomSheetDialogFragment extends MenuBottomSheetDialogFragment
|
|||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
|
||||
items.add(new TitleItem(getString(R.string.exit_without_saving)));
|
||||
|
||||
items.add(new ShortDescriptionItem.Builder()
|
||||
.setDescription(getString(R.string.plan_route_exit_dialog_descr))
|
||||
.setDescriptionColorId(nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_description_long)
|
||||
.setTitle(getString(R.string.exit_without_saving))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_list_title_with_descr)
|
||||
.create());
|
||||
|
||||
items.add(new DividerSpaceItem(getContext(),
|
||||
|
@ -75,7 +72,7 @@ public class ExitBottomSheetDialogFragment extends MenuBottomSheetDialogFragment
|
|||
|
||||
@Override
|
||||
protected int getDismissButtonTextId() {
|
||||
return R.string.shared_string_close;
|
||||
return R.string.shared_string_cancel;
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fragmentManager, @Nullable Fragment targetFragment) {
|
||||
|
|
|
@ -72,7 +72,8 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
|
|||
FragmentActivity activity = requireActivity();
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(activity);
|
||||
final View mainView = UiUtilities.getInflater(getContext(), nightMode)
|
||||
.inflate(R.layout.fragment_route_between_points_bottom_sheet_dialog, container, false);
|
||||
.inflate(R.layout.fragment_route_between_points_bottom_sheet_dialog,
|
||||
container, false);
|
||||
AndroidUtils.setBackground(activity, mainView, nightMode,
|
||||
portrait ? R.drawable.bg_bottom_menu_light : R.drawable.bg_bottom_sheet_topsides_landscape_light,
|
||||
portrait ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
|
|
|
@ -8,14 +8,12 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
import net.osmand.plus.helpers.GpxTrackAdapter;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -38,15 +36,13 @@ public class SnapTrackWarningBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
if (activity instanceof MapActivity) {
|
||||
activity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
|
||||
}
|
||||
OsmandApplication app = requiredMyApplication();
|
||||
items.add(new TitleItem(getString(R.string.route_between_points)));
|
||||
BaseBottomSheetItem description = new BottomSheetItemWithDescription.Builder()
|
||||
.setDescription(app.getString(R.string.rourte_between_points_warning_desc))
|
||||
.setDescriptionColorId(R.color.text_color_primary_light)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_description_long)
|
||||
.setDescription(getString(R.string.rourte_between_points_warning_desc))
|
||||
.setTitle(getString(R.string.route_between_points))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_list_title_with_descr)
|
||||
.create();
|
||||
items.add(description);
|
||||
items.add(new DividerSpaceItem(app, app.getResources().getDimensionPixelSize(R.dimen.content_padding_half)));
|
||||
items.add(new DividerSpaceItem(getContext(), getResources().getDimensionPixelSize(R.dimen.content_padding_half)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -105,12 +105,13 @@ public class AsyncLoadingThread extends Thread {
|
|||
}
|
||||
|
||||
public TileLoadDownloadRequest(File dirWithTiles, String url, File fileToSave, String tileId, ITileSource source, int tileX,
|
||||
int tileY, int zoom, String referer) {
|
||||
int tileY, int zoom, String referer, String userAgent) {
|
||||
super(url, fileToSave, tileX, tileY, zoom);
|
||||
this.dirWithTiles = dirWithTiles;
|
||||
this.tileSource = source;
|
||||
this.tileId = tileId;
|
||||
this.referer = referer;
|
||||
this.userAgent = userAgent;
|
||||
}
|
||||
|
||||
public void saveTile(InputStream inputStream) throws IOException {
|
||||
|
|
|
@ -144,7 +144,7 @@ public abstract class TilesCache<T> {
|
|||
}
|
||||
}
|
||||
TileLoadDownloadRequest req = new TileLoadDownloadRequest(dirWithTiles, url, toSave,
|
||||
tileId, map, x, y, zoom, map.getReferer());
|
||||
tileId, map, x, y, zoom, map.getReferer(), map.getUserAgent());
|
||||
if (sync) {
|
||||
return getRequestedTile(req);
|
||||
} else {
|
||||
|
|
|
@ -2035,6 +2035,7 @@ public class SettingsHelper {
|
|||
boolean ellipsoid = object.optBoolean("ellipsoid", false);
|
||||
boolean invertedY = object.optBoolean("inverted_y", false);
|
||||
String referer = object.optString("referer");
|
||||
String userAgent = object.optString("userAgent");
|
||||
boolean timeSupported = object.optBoolean("timesupported", false);
|
||||
long expire = object.optLong("expire", -1);
|
||||
boolean inversiveZoom = object.optBoolean("inversiveZoom", false);
|
||||
|
@ -2054,13 +2055,14 @@ public class SettingsHelper {
|
|||
tileSourceTemplate.setRule(rule);
|
||||
tileSourceTemplate.setRandoms(randoms);
|
||||
tileSourceTemplate.setReferer(referer);
|
||||
tileSourceTemplate.setUserAgent(userAgent);
|
||||
tileSourceTemplate.setEllipticYTile(ellipsoid);
|
||||
tileSourceTemplate.setInvertedYTile(invertedY);
|
||||
tileSourceTemplate.setExpirationTimeMillis(timeSupported ? expire : -1);
|
||||
|
||||
template = tileSourceTemplate;
|
||||
} else {
|
||||
template = new SQLiteTileSource(app, name, minZoom, maxZoom, url, randoms, ellipsoid, invertedY, referer, timeSupported, expire, inversiveZoom, rule);
|
||||
template = new SQLiteTileSource(app, name, minZoom, maxZoom, url, randoms, ellipsoid, invertedY, referer, userAgent, timeSupported, expire, inversiveZoom, rule);
|
||||
}
|
||||
items.add(template);
|
||||
}
|
||||
|
@ -2087,6 +2089,7 @@ public class SettingsHelper {
|
|||
jsonObject.put("ellipsoid", template.isEllipticYTile());
|
||||
jsonObject.put("inverted_y", template.isInvertedYTile());
|
||||
jsonObject.put("referer", template.getReferer());
|
||||
jsonObject.put("userAgent", template.getUserAgent());
|
||||
jsonObject.put("timesupported", template.isTimeSupported());
|
||||
jsonObject.put("expire", template.getExpirationTimeMinutes());
|
||||
jsonObject.put("inversiveZoom", template.getInversiveZoom());
|
||||
|
|
Loading…
Reference in a new issue