Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-01-30 17:36:24 +01:00
commit 701115ecca
37 changed files with 341 additions and 76 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/dialog_content_bottom_margin"
android:paddingLeft="@dimen/dialog_content_margin"
android:paddingRight="@dimen/dialog_content_margin"
android:paddingTop="@dimen/dialog_content_bottom_margin">
<TextView
android:id="@+id/parkTime"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:text="@string/osmand_parking_position_description_add"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:orientation="horizontal">>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/osmand_parking_hours"/>
<TimePicker
android:id="@+id/parking_time_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/osmand_parking_minutes"/>
</LinearLayout>
<CheckBox
android:id="@+id/check_event_in_calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/osmand_parking_add_event"/>
</LinearLayout>
</ScrollView>

View file

@ -3726,4 +3726,6 @@
<string name="poi_agrarian">Сельскохозяйственный магазин</string> <string name="poi_agrarian">Сельскохозяйственный магазин</string>
<string name="poi_shop_fireplace">Магазин каминов</string>
</resources> </resources>

View file

@ -3702,5 +3702,6 @@
<string name="poi_agrarian">Agricultural store</string> <string name="poi_agrarian">Agricultural store</string>
<string name="poi_shop_fireplace">Fireplace store</string>
</resources> </resources>

View file

@ -49,6 +49,8 @@ import net.osmand.aidl.note.StartVideoRecordingParams;
import net.osmand.aidl.note.StartAudioRecordingParams; import net.osmand.aidl.note.StartAudioRecordingParams;
import net.osmand.aidl.note.StopRecordingParams; import net.osmand.aidl.note.StopRecordingParams;
import net.osmand.aidl.gpx.RemoveGpxParams;
// NOTE: Add new methods at the end of file!!! // NOTE: Add new methods at the end of file!!!
interface IOsmAndAidlInterface { interface IOsmAndAidlInterface {
@ -98,4 +100,5 @@ interface IOsmAndAidlInterface {
boolean navigate(in NavigateParams params); boolean navigate(in NavigateParams params);
boolean navigateGpx(in NavigateGpxParams params); boolean navigateGpx(in NavigateGpxParams params);
boolean removeGpx(in RemoveGpxParams params);
} }

View file

@ -944,6 +944,7 @@ public class OsmandAidlApi {
app.getRendererRegistry().getCurrentSelectedRenderer(), color); app.getRendererRegistry().getCurrentSelectedRenderer(), color);
if (!destinationExists) { if (!destinationExists) {
GpxDataItem gpxDataItem = new GpxDataItem(destination, col); GpxDataItem gpxDataItem = new GpxDataItem(destination, col);
gpxDataItem.setApiImported(true);
app.getGpxDatabase().add(gpxDataItem); app.getGpxDatabase().add(gpxDataItem);
} else { } else {
GpxDataItem item = app.getGpxDatabase().getItem(destination); GpxDataItem item = app.getGpxDatabase().getItem(destination);
@ -1112,6 +1113,7 @@ public class OsmandAidlApi {
if (selectedGpxFile != null) { if (selectedGpxFile != null) {
app.getSelectedGpxHelper().selectGpxFile(selectedGpxFile.getGpxFile(), false, false); app.getSelectedGpxHelper().selectGpxFile(selectedGpxFile.getGpxFile(), false, false);
refreshMap(); refreshMap();
return true;
} }
} }
return false; return false;
@ -1135,6 +1137,21 @@ public class OsmandAidlApi {
return false; return false;
} }
boolean removeGpx(String fileName) {
if (!Algorithms.isEmpty(fileName)) {
final File f = app.getAppPath(IndexConstants.GPX_INDEX_DIR + fileName);
if (f.exists()) {
GpxDataItem item = app.getGpxDatabase().getItem(f);
if (item != null && item.isApiImported()) {
Algorithms.removeAllFiles(f);
app.getGpxDatabase().remove(f);
return true;
}
}
}
return false;
}
boolean setMapLocation(double latitude, double longitude, int zoom, boolean animated) { boolean setMapLocation(double latitude, double longitude, int zoom, boolean animated) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(AIDL_SET_MAP_LOCATION); intent.setAction(AIDL_SET_MAP_LOCATION);

View file

@ -15,6 +15,7 @@ import net.osmand.aidl.favorite.group.UpdateFavoriteGroupParams;
import net.osmand.aidl.gpx.ASelectedGpxFile; import net.osmand.aidl.gpx.ASelectedGpxFile;
import net.osmand.aidl.gpx.HideGpxParams; import net.osmand.aidl.gpx.HideGpxParams;
import net.osmand.aidl.gpx.ImportGpxParams; import net.osmand.aidl.gpx.ImportGpxParams;
import net.osmand.aidl.gpx.RemoveGpxParams;
import net.osmand.aidl.gpx.ShowGpxParams; import net.osmand.aidl.gpx.ShowGpxParams;
import net.osmand.aidl.gpx.StartGpxRecordingParams; import net.osmand.aidl.gpx.StartGpxRecordingParams;
import net.osmand.aidl.gpx.StopGpxRecordingParams; import net.osmand.aidl.gpx.StopGpxRecordingParams;
@ -269,6 +270,14 @@ public class OsmandAidlService extends Service {
return getApi().getActiveGpx(files); return getApi().getActiveGpx(files);
} }
@Override
public boolean removeGpx(RemoveGpxParams params) throws RemoteException {
if (params != null && params.getFileName() != null) {
return getApi().removeGpx(params.getFileName());
}
return false;
}
@Override @Override
public boolean setMapLocation(SetMapLocationParams params) throws RemoteException { public boolean setMapLocation(SetMapLocationParams params) throws RemoteException {
if (params != null) { if (params != null) {

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.gpx;
parcelable RemoveGpxParams;

View file

@ -0,0 +1,48 @@
package net.osmand.aidl.gpx;
import android.os.Parcel;
import android.os.Parcelable;
public class RemoveGpxParams implements Parcelable {
private String fileName;
public RemoveGpxParams(String fileName) {
this.fileName = fileName;
}
public RemoveGpxParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<RemoveGpxParams> CREATOR = new
Creator<RemoveGpxParams>() {
@Override
public RemoveGpxParams createFromParcel(Parcel in) {
return new RemoveGpxParams(in);
}
@Override
public RemoveGpxParams[] newArray(int size) {
return new RemoveGpxParams[size];
}
};
public String getFileName() {
return fileName;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeString(fileName);
}
private void readFromParcel(Parcel in) {
fileName = in.readString();
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -15,7 +15,7 @@ import java.util.List;
public class GPXDatabase { public class GPXDatabase {
private static final String DB_NAME = "gpx_database"; private static final String DB_NAME = "gpx_database";
private static final int DB_VERSION = 5; private static final int DB_VERSION = 6;
private static final String GPX_TABLE_NAME = "gpxTable"; private static final String GPX_TABLE_NAME = "gpxTable";
private static final String GPX_COL_NAME = "fileName"; private static final String GPX_COL_NAME = "fileName";
private static final String GPX_COL_DIR = "fileDir"; private static final String GPX_COL_DIR = "fileDir";
@ -45,6 +45,8 @@ public class GPXDatabase {
private static final String GPX_COL_SPLIT_TYPE = "splitType"; private static final String GPX_COL_SPLIT_TYPE = "splitType";
private static final String GPX_COL_SPLIT_INTERVAL = "splitInterval"; private static final String GPX_COL_SPLIT_INTERVAL = "splitInterval";
private static final String GPX_COL_API_IMPORTED = "apiImported";
public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1; public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1;
public static final int GPX_SPLIT_TYPE_DISTANCE = 1; public static final int GPX_SPLIT_TYPE_DISTANCE = 1;
public static final int GPX_SPLIT_TYPE_TIME = 2; public static final int GPX_SPLIT_TYPE_TIME = 2;
@ -74,7 +76,8 @@ public class GPXDatabase {
GPX_COL_COLOR + " TEXT, " + GPX_COL_COLOR + " TEXT, " +
GPX_COL_FILE_LAST_MODIFIED_TIME + " long, " + GPX_COL_FILE_LAST_MODIFIED_TIME + " long, " +
GPX_COL_SPLIT_TYPE + " int, " + GPX_COL_SPLIT_TYPE + " int, " +
GPX_COL_SPLIT_INTERVAL + " double);"; GPX_COL_SPLIT_INTERVAL + " double, " +
GPX_COL_API_IMPORTED + " int);"; // 1 = true, 0 = false
private static final String GPX_TABLE_SELECT = "SELECT " + private static final String GPX_TABLE_SELECT = "SELECT " +
GPX_COL_NAME + ", " + GPX_COL_NAME + ", " +
@ -98,7 +101,8 @@ public class GPXDatabase {
GPX_COL_COLOR + ", " + GPX_COL_COLOR + ", " +
GPX_COL_FILE_LAST_MODIFIED_TIME + ", " + GPX_COL_FILE_LAST_MODIFIED_TIME + ", " +
GPX_COL_SPLIT_TYPE + ", " + GPX_COL_SPLIT_TYPE + ", " +
GPX_COL_SPLIT_INTERVAL + GPX_COL_SPLIT_INTERVAL + ", " +
GPX_COL_API_IMPORTED +
" FROM " + GPX_TABLE_NAME; " FROM " + GPX_TABLE_NAME;
private OsmandApplication context; private OsmandApplication context;
@ -110,6 +114,7 @@ public class GPXDatabase {
private long fileLastModifiedTime; private long fileLastModifiedTime;
private int splitType; private int splitType;
private double splitInterval; private double splitInterval;
private boolean apiImported;
public GpxDataItem(File file, GPXTrackAnalysis analysis) { public GpxDataItem(File file, GPXTrackAnalysis analysis) {
this.file = file; this.file = file;
@ -144,6 +149,14 @@ public class GPXDatabase {
public double getSplitInterval() { public double getSplitInterval() {
return splitInterval; return splitInterval;
} }
public boolean isApiImported() {
return apiImported;
}
public void setApiImported(boolean apiImported) {
this.apiImported = apiImported;
}
} }
public GPXDatabase(OsmandApplication app) { public GPXDatabase(OsmandApplication app) {
@ -224,6 +237,13 @@ public class GPXDatabase {
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_INTERVAL + " double"); db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_INTERVAL + " double");
} }
} }
if (oldVersion < 6) {
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_API_IMPORTED + " int");
db.execSQL("UPDATE " + GPX_TABLE_NAME +
" SET " + GPX_COL_API_IMPORTED + " = ? " +
"WHERE " + GPX_COL_API_IMPORTED + " IS NULL", new Object[]{0});
}
} }
private boolean updateLastModifiedTime(GpxDataItem item) { private boolean updateLastModifiedTime(GpxDataItem item) {
@ -362,16 +382,22 @@ public class GPXDatabase {
} }
if (a != null) { if (a != null) {
db.execSQL( db.execSQL(
"INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new Object[]{ fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime, new Object[]{ fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime,
a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown, a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown,
a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints, a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints,
color, item.file.lastModified(), item.splitType, item.splitInterval }); color, item.file.lastModified(), item.splitType, item.splitInterval, item.apiImported ? 1 : 0});
} else { } else {
db.execSQL( db.execSQL("INSERT INTO " + GPX_TABLE_NAME + "(" +
"INSERT INTO " + GPX_TABLE_NAME + "(" + GPX_COL_NAME + ", " + GPX_COL_DIR + ", " + GPX_COL_NAME + ", " +
GPX_COL_COLOR + ", " + GPX_COL_FILE_LAST_MODIFIED_TIME + ", " + GPX_COL_SPLIT_TYPE + ", " + GPX_COL_SPLIT_INTERVAL + ") VALUES (?, ?, ?, ?, ?, ?)", GPX_COL_DIR + ", " +
new Object[]{ fileName, fileDir, color, 0, item.splitType, item.splitInterval }); GPX_COL_COLOR + ", " +
GPX_COL_FILE_LAST_MODIFIED_TIME + ", " +
GPX_COL_SPLIT_TYPE + ", " +
GPX_COL_SPLIT_INTERVAL + ", " +
GPX_COL_API_IMPORTED +
") VALUES (?, ?, ?, ?, ?, ?, ?)",
new Object[]{fileName, fileDir, color, 0, item.splitType, item.splitInterval, item.apiImported ? 1 : 0});
} }
} }
@ -436,6 +462,7 @@ public class GPXDatabase {
long fileLastModifiedTime = query.getLong(19); long fileLastModifiedTime = query.getLong(19);
int splitType = (int)query.getInt(20); int splitType = (int)query.getInt(20);
double splitInterval = query.getDouble(21); double splitInterval = query.getDouble(21);
boolean apiImported = query.getInt(22) == 1;
GPXTrackAnalysis a = new GPXTrackAnalysis(); GPXTrackAnalysis a = new GPXTrackAnalysis();
a.totalDistance = totalDistance; a.totalDistance = totalDistance;
@ -471,6 +498,7 @@ public class GPXDatabase {
item.fileLastModifiedTime = fileLastModifiedTime; item.fileLastModifiedTime = fileLastModifiedTime;
item.splitType = splitType; item.splitType = splitType;
item.splitInterval = splitInterval; item.splitInterval = splitInterval;
item.apiImported = apiImported;
return item; return item;
} }

View file

@ -51,7 +51,7 @@ public abstract class BaseMenuController {
} }
public float getHalfScreenMaxHeightKoef() { public float getHalfScreenMaxHeightKoef() {
return .7f; return .75f;
} }
public int getSlideInAnimation() { public int getSlideInAnimation() {

View file

@ -521,6 +521,13 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}, timeout); }, timeout);
} }
public void updateLayout() {
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().updateLayout();
}
}
public void updateMenuUI() { public void updateMenuUI() {
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment(); WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) { if (fragmentRef != null) {

View file

@ -98,6 +98,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private int markerPaddingPx; private int markerPaddingPx;
private int markerPaddingXPx; private int markerPaddingXPx;
private int topScreenPosY;
private OsmandMapTileView map; private OsmandMapTileView map;
private LatLon mapCenter; private LatLon mapCenter;
@ -112,7 +113,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private boolean wasDrawerDisabled; private boolean wasDrawerDisabled;
private boolean zoomIn; private boolean zoomIn;
private float skipHalfScreenStateLimit; private float skipScreenStateLimit;
private int screenOrientation; private int screenOrientation;
private boolean created; private boolean created;
@ -125,6 +126,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
markerPaddingPx = dpToPx(MARKER_PADDING_DP); markerPaddingPx = dpToPx(MARKER_PADDING_DP);
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP); markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
topScreenPosY = addStatusBarHeightIfNeeded(-dpToPx(SHADOW_HEIGHT_TOP_DP));
menu = getMapActivity().getContextMenu(); menu = getMapActivity().getContextMenu();
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false); view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
@ -270,11 +272,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
openMenuHalfScreen(); openMenuHalfScreen();
return true; return true;
} }
}
if (menu.isLandscapeLayout()) { if (menu.isLandscapeLayout()) {
if (swipeDetector.onTouchEvent(event)) { if (swipeDetector.onTouchEvent(event)) {
menu.close(); menu.close();
}
return true; return true;
} }
} }
@ -299,6 +300,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
hasMoved = true; hasMoved = true;
float y = event.getY(); float y = event.getY();
float newY = getViewY() + (y - dy); float newY = getViewY() + (y - dy);
if (menu.isLandscapeLayout() && newY > 0) {
newY = 0;
}
setViewY((int) newY, false, false); setViewY((int) newY, false, false);
menuFullHeight = view.getHeight() - (int) newY + 10; menuFullHeight = view.getHeight() - (int) newY + 10;
@ -307,11 +311,14 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
mainView.setLayoutParams(lp); mainView.setLayoutParams(lp);
mainView.requestLayout(); mainView.requestLayout();
velocity.addMovement(event); if (velocity != null) {
velocity.computeCurrentVelocity(1000); velocity.addMovement(event);
velocityY = Math.abs(velocity.getYVelocity()); velocity.computeCurrentVelocity(1000);
if (velocityY > maxVelocityY) velocityY = Math.abs(velocity.getYVelocity());
maxVelocityY = velocityY; if (velocityY > maxVelocityY) {
maxVelocityY = velocityY;
}
}
} }
break; break;
@ -325,10 +332,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
slidingUp = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) < -50; slidingUp = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) < -50;
slidingDown = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) > 50; slidingDown = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) > 50;
velocity.recycle(); if (velocity != null) {
velocity.recycle();
}
boolean skipHalfScreenState = Math.abs(currentY - dyMain) > skipHalfScreenStateLimit; boolean skipScreenState = Math.abs(currentY - dyMain) > skipScreenStateLimit;
changeMenuState(currentY, skipHalfScreenState, slidingUp, slidingDown); changeMenuState(currentY, skipScreenState, slidingUp, slidingDown);
} }
break; break;
@ -487,7 +496,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
detailsButton.setOnClickListener(new View.OnClickListener() { detailsButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
menu.openMenuFullScreen(); openMenuHalfScreen();
} }
}); });
TextView directionsButton = (TextView) view.findViewById(R.id.context_menu_directions_button); TextView directionsButton = (TextView) view.findViewById(R.id.context_menu_directions_button);
@ -543,7 +552,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
if (showShowHideButton) { if (showShowHideButton) {
openMenuHeaderOnly(); openMenuHeaderOnly();
} else { } else {
openMenuFullScreen(); openMenuHalfScreen();
} }
} }
}); });
@ -575,7 +584,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private void processScreenHeight(ViewParent parent) { private void processScreenHeight(ViewParent parent) {
View container = (View)parent; View container = (View)parent;
screenHeight = container.getHeight() + AndroidUtils.getStatusBarHeight(getActivity()); screenHeight = container.getHeight() + AndroidUtils.getStatusBarHeight(getActivity());
skipHalfScreenStateLimit = screenHeight * SKIP_HALF_SCREEN_STATE_KOEF; skipScreenStateLimit = screenHeight * SKIP_HALF_SCREEN_STATE_KOEF;
viewHeight = screenHeight - AndroidUtils.getStatusBarHeight(getMapActivity()); viewHeight = screenHeight - AndroidUtils.getStatusBarHeight(getMapActivity());
} }
@ -596,20 +605,25 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
} }
private void changeMenuState(int currentY, boolean skipHalfScreenState, private void changeMenuState(int currentY, boolean skipScreenState,
boolean slidingUp, boolean slidingDown) { boolean slidingUp, boolean slidingDown) {
boolean needCloseMenu = false; boolean needCloseMenu = false;
int oldMenuState = menu.getCurrentMenuState(); int oldMenuState = menu.getCurrentMenuState();
if (menuBottomViewHeight > 0 && slidingUp) { if (!menu.isLandscapeLayout()) {
menu.slideUp(); if (slidingDown && !skipScreenState && oldMenuState == MenuState.FULL_SCREEN && currentY < topScreenPosY) {
if (skipHalfScreenState) { slidingDown = false;
menu.slideUp();
} }
} else if (slidingDown) { if (menuBottomViewHeight > 0 && slidingUp) {
needCloseMenu = !menu.slideDown(); menu.slideUp();
if (!needCloseMenu && skipHalfScreenState) { if (skipScreenState) {
menu.slideDown(); menu.slideUp();
}
} else if (slidingDown) {
needCloseMenu = !menu.slideDown();
if (!needCloseMenu && skipScreenState) {
menu.slideDown();
}
} }
} }
int newMenuState = menu.getCurrentMenuState(); int newMenuState = menu.getCurrentMenuState();
@ -1240,6 +1254,19 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
} }
private void updateZoomButtonsVisibility(int menuState) {
boolean zoomButtonsVisible = menu.zoomButtonsVisible() && menuState == MenuState.HEADER_ONLY;
if (zoomButtonsVisible) {
if (zoomButtonsView.getVisibility() != View.VISIBLE) {
zoomButtonsView.setVisibility(View.VISIBLE);
}
} else {
if (zoomButtonsView.getVisibility() == View.VISIBLE) {
zoomButtonsView.setVisibility(View.INVISIBLE);
}
}
}
private int getPosY() { private int getPosY() {
return getPosY(CURRENT_Y_UNDEFINED, false); return getPosY(CURRENT_Y_UNDEFINED, false);
} }
@ -1256,22 +1283,23 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
minHalfY = viewHeight - (int) (viewHeight * menu.getHalfScreenMaxHeightKoef()); minHalfY = viewHeight - (int) (viewHeight * menu.getHalfScreenMaxHeightKoef());
} else { } else {
destinationState = MenuState.HEADER_ONLY; destinationState = MenuState.HEADER_ONLY;
minHalfY = viewHeight; minHalfY = viewHeight - (int) (viewHeight * .75f);
} }
updateZoomButtonsVisibility(destinationState);
int posY = 0; int posY = 0;
switch (destinationState) { switch (destinationState) {
case MenuState.HEADER_ONLY: case MenuState.HEADER_ONLY:
posY = viewHeight - menuTitleHeight; posY = viewHeight - menuTitleHeight;
break; break;
case MenuState.HALF_SCREEN: case MenuState.HALF_SCREEN:
posY = viewHeight - menuFullHeightMax; posY = minHalfY;
posY = Math.max(posY, minHalfY);
break; break;
case MenuState.FULL_SCREEN: case MenuState.FULL_SCREEN:
if (currentY != CURRENT_Y_UNDEFINED) { if (currentY != CURRENT_Y_UNDEFINED) {
int maxPosY = viewHeight - menuFullHeightMax; int maxPosY = viewHeight - menuFullHeightMax;
int minPosY = Math.max(maxPosY, minHalfY); int minPosY = topScreenPosY;
if (maxPosY > minPosY) { if (maxPosY > minPosY) {
maxPosY = minPosY; maxPosY = minPosY;
} }
@ -1283,8 +1311,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
posY = currentY; posY = currentY;
} }
} else { } else {
posY = -dpToPx(SHADOW_HEIGHT_TOP_DP); posY = topScreenPosY;
posY = addStatusBarHeightIfNeeded(posY);
} }
break; break;
default: default:
@ -1417,7 +1444,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
private void doLayoutMenu() { private void doLayoutMenu() {
final int posY = getPosY(); final int posY = getPosY(getViewY(), false);
setViewY(posY, true, !initLayout || !centered); setViewY(posY, true, !initLayout || !centered);
updateMainViewLayout(posY); updateMainViewLayout(posY);
} }
@ -1432,6 +1459,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
} }
public void updateLayout() {
runLayoutListener();
}
public void refreshTitle() { public void refreshTitle() {
setAddressLocation(); setAddressLocation();
runLayoutListener(); runLayoutListener();

View file

@ -95,10 +95,16 @@ public class MenuBuilder {
private CardsRowBuilder onlinePhotoCardsRow; private CardsRowBuilder onlinePhotoCardsRow;
private List<AbstractCard> onlinePhotoCards; private List<AbstractCard> onlinePhotoCards;
private CollapseExpandListener collapseExpandListener;
private String preferredMapLang; private String preferredMapLang;
private String preferredMapAppLang; private String preferredMapAppLang;
private boolean transliterateNames; private boolean transliterateNames;
public interface CollapseExpandListener {
void onCollapseExpand(boolean collapsed);
}
public class PlainMenuItem { public class PlainMenuItem {
private int iconId; private int iconId;
private String buttonText; private String buttonText;
@ -158,22 +164,22 @@ public class MenuBuilder {
public static class CollapsableView { public static class CollapsableView {
private View contenView; private View contenView;
private MenuBuilder menuBuilder;
private OsmandPreference<Boolean> collapsedPref; private OsmandPreference<Boolean> collapsedPref;
private boolean collapsed; private boolean collapsed;
private OnCollExpListener onCollExpListener; private CollapseExpandListener collapseExpandListener;
public interface OnCollExpListener { public CollapsableView(@NonNull View contenView, @NonNull MenuBuilder menuBuilder,
void onCollapseExpand(boolean collapsed); @NonNull OsmandPreference<Boolean> collapsedPref) {
}
public CollapsableView(@NonNull View contenView, @NonNull OsmandPreference<Boolean> collapsedPref) {
this.contenView = contenView; this.contenView = contenView;
this.menuBuilder = menuBuilder;
this.collapsedPref = collapsedPref; this.collapsedPref = collapsedPref;
} }
public CollapsableView(@NonNull View contenView, boolean collapsed) { public CollapsableView(@NonNull View contenView, @NonNull MenuBuilder menuBuilder, boolean collapsed) {
this.contenView = contenView; this.contenView = contenView;
this.collapsed = collapsed; this.collapsed = collapsed;
this.menuBuilder = menuBuilder;
} }
public View getContenView() { public View getContenView() {
@ -194,17 +200,20 @@ public class MenuBuilder {
} else { } else {
this.collapsed = collapsed; this.collapsed = collapsed;
} }
if (onCollExpListener != null) { if (collapseExpandListener != null) {
onCollExpListener.onCollapseExpand(collapsed); collapseExpandListener.onCollapseExpand(collapsed);
}
if (menuBuilder.collapseExpandListener != null) {
menuBuilder.collapseExpandListener.onCollapseExpand(collapsed);
} }
} }
public OnCollExpListener getOnCollExpListener() { public CollapseExpandListener getCollapseExpandListener() {
return onCollExpListener; return collapseExpandListener;
} }
public void setOnCollExpListener(OnCollExpListener onCollExpListener) { public void setCollapseExpandListener(CollapseExpandListener collapseExpandListener) {
this.onCollExpListener = onCollExpListener; this.collapseExpandListener = collapseExpandListener;
} }
} }
@ -221,6 +230,10 @@ public class MenuBuilder {
transliterateNames = app.getSettings().MAP_TRANSLITERATE_NAMES.get(); transliterateNames = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
} }
public void setCollapseExpandListener(CollapseExpandListener collapseExpandListener) {
this.collapseExpandListener = collapseExpandListener;
}
public void setRoutes(List<TransportStopRoute> routes) { public void setRoutes(List<TransportStopRoute> routes) {
this.routes = routes; this.routes = routes;
} }
@ -378,9 +391,9 @@ public class MenuBuilder {
boolean needUpdateOnly = onlinePhotoCardsRow != null && onlinePhotoCardsRow.getMenuBuilder() == this; boolean needUpdateOnly = onlinePhotoCardsRow != null && onlinePhotoCardsRow.getMenuBuilder() == this;
onlinePhotoCardsRow = new CardsRowBuilder(this, view, false); onlinePhotoCardsRow = new CardsRowBuilder(this, view, false);
onlinePhotoCardsRow.build(); onlinePhotoCardsRow.build();
CollapsableView collapsableView = new CollapsableView(onlinePhotoCardsRow.getContentView(), CollapsableView collapsableView = new CollapsableView(onlinePhotoCardsRow.getContentView(), this,
app.getSettings().ONLINE_PHOTOS_ROW_COLLAPSED); app.getSettings().ONLINE_PHOTOS_ROW_COLLAPSED);
collapsableView.setOnCollExpListener(new CollapsableView.OnCollExpListener() { collapsableView.setCollapseExpandListener(new CollapseExpandListener() {
@Override @Override
public void onCollapseExpand(boolean collapsed) { public void onCollapseExpand(boolean collapsed) {
if (!collapsed && onlinePhotoCards == null) { if (!collapsed && onlinePhotoCards == null) {
@ -584,13 +597,13 @@ public class MenuBuilder {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (collapsableView.getContenView().getVisibility() == View.VISIBLE) { if (collapsableView.getContenView().getVisibility() == View.VISIBLE) {
collapsableView.setCollapsed(true);
collapsableView.getContenView().setVisibility(View.GONE); collapsableView.getContenView().setVisibility(View.GONE);
iconViewCollapse.setImageDrawable(getCollapseIcon(true)); iconViewCollapse.setImageDrawable(getCollapseIcon(true));
collapsableView.setCollapsed(true);
} else { } else {
collapsableView.setCollapsed(false);
collapsableView.getContenView().setVisibility(View.VISIBLE); collapsableView.getContenView().setVisibility(View.VISIBLE);
iconViewCollapse.setImageDrawable(getCollapseIcon(false)); iconViewCollapse.setImageDrawable(getCollapseIcon(false));
collapsableView.setCollapsed(false);
} }
} }
}); });
@ -844,7 +857,7 @@ public class MenuBuilder {
buildTransportRouteRow(view, r, listener, showDivider); buildTransportRouteRow(view, r, listener, showDivider);
} }
return new CollapsableView(view, collapsed); return new CollapsableView(view, this, collapsed);
} }
protected CollapsableView getCollapsableTextView(Context context, boolean collapsed, String text) { protected CollapsableView getCollapsableTextView(Context context, boolean collapsed, String text) {
@ -857,7 +870,7 @@ public class MenuBuilder {
textView.setTextSize(16); textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
textView.setText(text); textView.setText(text);
return new CollapsableView(textView, collapsed); return new CollapsableView(textView, this, collapsed);
} }
protected CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) { protected CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
@ -901,7 +914,7 @@ public class MenuBuilder {
view.addView(button); view.addView(button);
} }
return new CollapsableView(view, collapsed); return new CollapsableView(view, this, collapsed);
} }
protected CollapsableView getCollapsableWaypointsView(final Context context, boolean collapsed, @NonNull final GPXFile gpxFile, WptPt selectedPoint) { protected CollapsableView getCollapsableWaypointsView(final Context context, boolean collapsed, @NonNull final GPXFile gpxFile, WptPt selectedPoint) {
@ -944,7 +957,7 @@ public class MenuBuilder {
view.addView(button); view.addView(button);
} }
return new CollapsableView(view, collapsed); return new CollapsableView(view, this, collapsed);
} }
protected CollapsableView getCollapsableWikiView(Context context, boolean collapsed) { protected CollapsableView getCollapsableWikiView(Context context, boolean collapsed) {
@ -966,7 +979,7 @@ public class MenuBuilder {
view.addView(button); view.addView(button);
} }
return new CollapsableView(view, collapsed); return new CollapsableView(view, this, collapsed);
} }
protected LinearLayout buildCollapsableContentView(Context context, boolean collapsed, boolean needMargin) { protected LinearLayout buildCollapsableContentView(Context context, boolean collapsed, boolean needMargin) {

View file

@ -42,6 +42,7 @@ import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.DownloadValidationManager; import net.osmand.plus.download.DownloadValidationManager;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapseExpandListener;
import net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController; import net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController;
import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController; import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController;
import net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController; import net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController;
@ -81,7 +82,7 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
public abstract class MenuController extends BaseMenuController { public abstract class MenuController extends BaseMenuController implements CollapseExpandListener {
public static class MenuState { public static class MenuState {
public static final int HEADER_ONLY = 1; public static final int HEADER_ONLY = 1;
@ -124,10 +125,46 @@ public abstract class MenuController extends BaseMenuController {
super(mapActivity); super(mapActivity);
this.pointDescription = pointDescription; this.pointDescription = pointDescription;
this.builder = builder; this.builder = builder;
this.builder.setCollapseExpandListener(this);
this.currentMenuState = getInitialMenuState(); this.currentMenuState = getInitialMenuState();
this.builder.setLight(isLight()); this.builder.setLight(isLight());
} }
public void onCreated() {
/*
toolbarController = new ContextMenuToolbarController(this);
toolbarController.setTitle(getNameStr());
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mapContextMenu != null) {
mapContextMenu.backToolbarAction(MenuController.this);
}
}
});
toolbarController.setOnTitleClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
toolbarController.setOnCloseButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mapContextMenu != null) {
mapContextMenu.close();
}
}
});
*/
}
@Override
public void onCollapseExpand(boolean collapsed) {
if (mapContextMenu != null) {
mapContextMenu.updateMenuUI();
}
}
public String getPreferredMapLang() { public String getPreferredMapLang() {
return builder.getPreferredMapLang(); return builder.getPreferredMapLang();
} }
@ -208,6 +245,7 @@ public abstract class MenuController extends BaseMenuController {
} }
menuController.menuType = menuType; menuController.menuType = menuType;
menuController.setLatLon(latLon); menuController.setLatLon(latLon);
menuController.onCreated();
return menuController; return menuController;
} }

View file

@ -200,13 +200,13 @@ public class AmenityMenuBuilder extends MenuBuilder {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (collapsableView.getContenView().getVisibility() == View.VISIBLE) { if (collapsableView.getContenView().getVisibility() == View.VISIBLE) {
collapsableView.setCollapsed(true);
collapsableView.getContenView().setVisibility(View.GONE); collapsableView.getContenView().setVisibility(View.GONE);
iconViewCollapse.setImageDrawable(getCollapseIcon(true)); iconViewCollapse.setImageDrawable(getCollapseIcon(true));
collapsableView.setCollapsed(true);
} else { } else {
collapsableView.setCollapsed(false);
collapsableView.getContenView().setVisibility(View.VISIBLE); collapsableView.getContenView().setVisibility(View.VISIBLE);
iconViewCollapse.setImageDrawable(getCollapseIcon(false)); iconViewCollapse.setImageDrawable(getCollapseIcon(false));
collapsableView.setCollapsed(false);
} }
} }
}); });

View file

@ -25,6 +25,7 @@ import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.DownloadValidationManager; import net.osmand.plus.download.DownloadValidationManager;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.liveupdates.LiveUpdatesHelper;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin;
@ -107,9 +108,10 @@ public class MapDataMenuController extends MenuController {
Toast.makeText(mapActivity, mapActivity.getString(R.string.activate_srtm_plugin), Toast.makeText(mapActivity, mapActivity.getString(R.string.activate_srtm_plugin),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
} }
} else { } else if (!downloaded || indexItem.isOutdated()) {
new DownloadValidationManager(getMapActivity().getMyApplication()) new DownloadValidationManager(app).startDownload(mapActivity, indexItem);
.startDownload(getMapActivity(), indexItem); } else if (isLiveUpdatesOn()) {
LiveUpdatesHelper.runLiveUpdate(mapActivity, indexItem.getTargetFileName(), true);
} }
} }
} }
@ -179,6 +181,10 @@ public class MapDataMenuController extends MenuController {
updateData(); updateData();
} }
private boolean isLiveUpdatesOn() {
return getMapActivity().getMyApplication().getSettings().IS_LIVE_UPDATES_ON.get();
}
@Override @Override
public boolean displayDistanceDirection() { public boolean displayDistanceDirection() {
return true; return true;
@ -380,6 +386,8 @@ public class MapDataMenuController extends MenuController {
leftDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_update); leftDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_update);
} else if (!downloaded) { } else if (!downloaded) {
leftDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_download); leftDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_download);
} else if (isLiveUpdatesOn()) {
leftDownloadButtonController.caption = getMapActivity().getString(R.string.live_update);
} else { } else {
leftDownloadButtonController.visible = false; leftDownloadButtonController.visible = false;
} }

View file

@ -12,11 +12,7 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.ConsoleMessage;
import android.webkit.JavascriptInterface; import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@ -237,7 +233,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
view.setLayoutParams(lp); view.setLayoutParams(lp);
webView.setWebViewClient(new WebViewClient() { webView.setWebViewClient(new WebViewClient() {
@Override @Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
webView.loadUrl("about:blank"); webView.loadUrl("about:blank");
noInternetView.setVisibility(View.VISIBLE); noInternetView.setVisibility(View.VISIBLE);
} }