commit
d846f95fdf
44 changed files with 1004 additions and 100 deletions
|
@ -1026,6 +1026,7 @@
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="net.osmand.plus.development.TestVoiceActivity" />
|
<activity android:name="net.osmand.plus.development.TestVoiceActivity" />
|
||||||
|
<activity android:name="net.osmand.plus.development.TestBackupActivity" />
|
||||||
<activity android:name="net.osmand.plus.development.LogcatActivity" />
|
<activity android:name="net.osmand.plus.development.LogcatActivity" />
|
||||||
<activity android:name="net.osmand.plus.download.DownloadActivity" android:label="" />
|
<activity android:name="net.osmand.plus.download.DownloadActivity" android:label="" />
|
||||||
|
|
||||||
|
|
151
OsmAnd/res/layout/test_backup_layout.xml
Normal file
151
OsmAnd/res/layout/test_backup_layout.xml
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/activity_background_basic"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
android:theme="?attr/toolbar_theme">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="right"
|
||||||
|
android:paddingStart="@dimen/content_padding"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingEnd="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:layout_width="@dimen/card_button_progress_size"
|
||||||
|
android:layout_height="@dimen/card_button_progress_size"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/content_padding"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="@dimen/content_padding">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
||||||
|
android:id="@+id/edit_email_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:paddingBottom="@dimen/content_padding_small"
|
||||||
|
app:errorColor="@color/color_invalid"
|
||||||
|
app:hasClearButton="true"
|
||||||
|
app:labelText="Email"
|
||||||
|
app:primaryColor="@color/active_color_primary_dark"
|
||||||
|
app:secondaryColor="?android:textColorSecondary">
|
||||||
|
|
||||||
|
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||||
|
android:id="@+id/edit_email"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:imeOptions="actionNext"
|
||||||
|
android:inputType="textEmailAddress"
|
||||||
|
android:maxLines="1"
|
||||||
|
tools:text="test@test.com" />
|
||||||
|
|
||||||
|
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/btn_register"
|
||||||
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/dialog_button_height" />
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
||||||
|
android:id="@+id/edit_token_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:paddingTop="@dimen/content_padding_small"
|
||||||
|
android:paddingBottom="@dimen/content_padding_small"
|
||||||
|
app:errorColor="@color/color_invalid"
|
||||||
|
app:hasClearButton="true"
|
||||||
|
app:labelText="Token"
|
||||||
|
app:primaryColor="@color/active_color_primary_dark"
|
||||||
|
app:secondaryColor="?android:textColorSecondary">
|
||||||
|
|
||||||
|
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||||
|
android:id="@+id/edit_token"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:imeOptions="actionNext"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:maxLines="1"
|
||||||
|
tools:text="123456" />
|
||||||
|
|
||||||
|
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/btn_verify"
|
||||||
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/dialog_button_height" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/content_padding"
|
||||||
|
android:text="Actions"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_list_text_size" />
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/btn_backup"
|
||||||
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/dialog_button_height"
|
||||||
|
android:layout_marginTop="@dimen/content_padding_half" />
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/btn_restore"
|
||||||
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/dialog_button_height"
|
||||||
|
android:layout_marginTop="@dimen/content_padding_half" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_info"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/content_padding"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
tools:text="Last backup time: 2021-04-01 10:10:00\nModified files: 3" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -4154,5 +4154,4 @@
|
||||||
<string name="announce_when_exceeded">الإعلان عند التجاوز</string>
|
<string name="announce_when_exceeded">الإعلان عند التجاوز</string>
|
||||||
<string name="user_points">نقاط المستخدم</string>
|
<string name="user_points">نقاط المستخدم</string>
|
||||||
<string name="output">الإخراج</string>
|
<string name="output">الإخراج</string>
|
||||||
<string name="map_quick_action_pattern">%1$s ← …</string>
|
|
||||||
</resources>
|
</resources>
|
|
@ -4089,5 +4089,4 @@
|
||||||
<string name="announce_when_exceeded">Meldung bei Überschreitung</string>
|
<string name="announce_when_exceeded">Meldung bei Überschreitung</string>
|
||||||
<string name="user_points">Anwenderpunkte</string>
|
<string name="user_points">Anwenderpunkte</string>
|
||||||
<string name="output">Leistung</string>
|
<string name="output">Leistung</string>
|
||||||
<string name="map_quick_action_pattern">%1$s → …</string>
|
|
||||||
</resources>
|
</resources>
|
|
@ -4085,5 +4085,4 @@
|
||||||
<string name="exit_number">Numero de elirejo</string>
|
<string name="exit_number">Numero de elirejo</string>
|
||||||
<string name="user_points">Poentoj de uzanto</string>
|
<string name="user_points">Poentoj de uzanto</string>
|
||||||
<string name="output">Eligo</string>
|
<string name="output">Eligo</string>
|
||||||
<string name="map_quick_action_pattern">%1$s → …</string>
|
|
||||||
</resources>
|
</resources>
|
|
@ -4087,5 +4087,4 @@
|
||||||
<string name="announce_when_exceeded">Anunciar al excederse</string>
|
<string name="announce_when_exceeded">Anunciar al excederse</string>
|
||||||
<string name="user_points">Puntos de usuario</string>
|
<string name="user_points">Puntos de usuario</string>
|
||||||
<string name="output">Salida</string>
|
<string name="output">Salida</string>
|
||||||
<string name="map_quick_action_pattern">%1$s → …</string>
|
|
||||||
</resources>
|
</resources>
|
|
@ -4075,5 +4075,4 @@
|
||||||
<string name="exit_number">Numéro de sortie</string>
|
<string name="exit_number">Numéro de sortie</string>
|
||||||
<string name="announce_when_exceeded">Annoncer en cas de dépassement</string>
|
<string name="announce_when_exceeded">Annoncer en cas de dépassement</string>
|
||||||
<string name="output">Sortie</string>
|
<string name="output">Sortie</string>
|
||||||
<string name="map_quick_action_pattern">%1$s → …</string>
|
|
||||||
</resources>
|
</resources>
|
|
@ -4074,7 +4074,6 @@
|
||||||
<string name="on_hold">Várakoztatva</string>
|
<string name="on_hold">Várakoztatva</string>
|
||||||
<string name="expired">Lejárt</string>
|
<string name="expired">Lejárt</string>
|
||||||
<string name="update_all_maps_added">Frissüljön minden térkép, amely hozzá lett adva ehhez: %1$s\?</string>
|
<string name="update_all_maps_added">Frissüljön minden térkép, amely hozzá lett adva ehhez: %1$s\?</string>
|
||||||
<string name="map_quick_action_pattern">%1$s → …</string>
|
|
||||||
<string name="exit_number">Kijárat száma</string>
|
<string name="exit_number">Kijárat száma</string>
|
||||||
<string name="announce_when_exceeded">Értesítés túllépéskor</string>
|
<string name="announce_when_exceeded">Értesítés túllépéskor</string>
|
||||||
<string name="user_points">Felhasználói pontok</string>
|
<string name="user_points">Felhasználói pontok</string>
|
||||||
|
|
|
@ -4087,5 +4087,4 @@
|
||||||
<string name="announce_when_exceeded">להכריז בחריגה</string>
|
<string name="announce_when_exceeded">להכריז בחריגה</string>
|
||||||
<string name="user_points">נקודות משתמש</string>
|
<string name="user_points">נקודות משתמש</string>
|
||||||
<string name="output">פלט</string>
|
<string name="output">פלט</string>
|
||||||
<string name="map_quick_action_pattern">%1$s ← …</string>
|
|
||||||
</resources>
|
</resources>
|
|
@ -4089,5 +4089,4 @@
|
||||||
<string name="announce_when_exceeded">Anunciar quando ultrapassado</string>
|
<string name="announce_when_exceeded">Anunciar quando ultrapassado</string>
|
||||||
<string name="user_points">Pontos do utilizador</string>
|
<string name="user_points">Pontos do utilizador</string>
|
||||||
<string name="output">Saída</string>
|
<string name="output">Saída</string>
|
||||||
<string name="map_quick_action_pattern">%1$s → …</string>
|
|
||||||
</resources>
|
</resources>
|
|
@ -4084,5 +4084,4 @@
|
||||||
<string name="announce_when_exceeded">Повідомляти про перевищення</string>
|
<string name="announce_when_exceeded">Повідомляти про перевищення</string>
|
||||||
<string name="user_points">Користувацькі точки</string>
|
<string name="user_points">Користувацькі точки</string>
|
||||||
<string name="output">Вивід</string>
|
<string name="output">Вивід</string>
|
||||||
<string name="map_quick_action_pattern">%1$s → …</string>
|
|
||||||
</resources>
|
</resources>
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<string name="map_quick_action_pattern">%1$s → …</string>
|
|
||||||
<string name="output">Output</string>
|
<string name="output">Output</string>
|
||||||
<string name="user_points">User points</string>
|
<string name="user_points">User points</string>
|
||||||
<string name="announce_when_exceeded">Announce when exceeded</string>
|
<string name="announce_when_exceeded">Announce when exceeded</string>
|
||||||
|
|
|
@ -70,6 +70,13 @@
|
||||||
android:summary="@string/play_commands_of_currently_selected_voice"
|
android:summary="@string/play_commands_of_currently_selected_voice"
|
||||||
android:title="@string/test_voice_prompts" />
|
android:title="@string/test_voice_prompts" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="test_backup"
|
||||||
|
android:layout="@layout/preference_with_descr"
|
||||||
|
android:persistent="false"
|
||||||
|
android:summary="Register and backup/restore tracks and favorites"
|
||||||
|
android:title="Test backup" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="logcat_buffer"
|
android:key="logcat_buffer"
|
||||||
android:layout="@layout/preference_with_descr"
|
android:layout="@layout/preference_with_descr"
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.util.Pair;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -33,8 +34,10 @@ import java.net.URLEncoder;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public class AndroidNetworkUtils {
|
public class AndroidNetworkUtils {
|
||||||
|
@ -46,6 +49,13 @@ public class AndroidNetworkUtils {
|
||||||
void onResult(String result);
|
void onResult(String result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnFilesUploadCallback {
|
||||||
|
@Nullable
|
||||||
|
Map<String, String> getAdditionalParams(@NonNull File file);
|
||||||
|
void onFileUploadProgress(@NonNull File file, int percent);
|
||||||
|
void onFilesUploadDone(@NonNull Map<File, String> errors);
|
||||||
|
}
|
||||||
|
|
||||||
public static class RequestResponse {
|
public static class RequestResponse {
|
||||||
private Request request;
|
private Request request;
|
||||||
private String response;
|
private String response;
|
||||||
|
@ -156,7 +166,7 @@ public class AndroidNetworkUtils {
|
||||||
String params = null;
|
String params = null;
|
||||||
if (parameters != null && parameters.size() > 0) {
|
if (parameters != null && parameters.size() > 0) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
for (Entry<String, String> entry : parameters.entrySet()) {
|
||||||
if (sb.length() > 0) {
|
if (sb.length() > 0) {
|
||||||
sb.append("&");
|
sb.append("&");
|
||||||
}
|
}
|
||||||
|
@ -296,16 +306,18 @@ public class AndroidNetworkUtils {
|
||||||
|
|
||||||
private static final String BOUNDARY = "CowMooCowMooCowCowCow";
|
private static final String BOUNDARY = "CowMooCowMooCowCowCow";
|
||||||
|
|
||||||
public static String uploadFile(String urlText, File file, boolean gzip, Map<String, String> additionalParams) throws IOException {
|
public static String uploadFile(@NonNull String urlText, @NonNull File file, boolean gzip,
|
||||||
return uploadFile(urlText, new FileInputStream(file), file.getName(), gzip, additionalParams);
|
@NonNull Map<String, String> additionalParams, @Nullable Map<String, String> headers) throws IOException {
|
||||||
|
return uploadFile(urlText, new FileInputStream(file), file.getName(), gzip, additionalParams, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String uploadFile(String urlText, InputStream inputStream, String fileName, boolean gzip, Map<String, String> additionalParams) {
|
public static String uploadFile(@NonNull String urlText, @NonNull InputStream inputStream, @NonNull String fileName, boolean gzip,
|
||||||
|
Map<String, String> additionalParams, @Nullable Map<String, String> headers) {
|
||||||
URL url;
|
URL url;
|
||||||
try {
|
try {
|
||||||
boolean firstPrm = !urlText.contains("?");
|
boolean firstPrm = !urlText.contains("?");
|
||||||
StringBuilder sb = new StringBuilder(urlText);
|
StringBuilder sb = new StringBuilder(urlText);
|
||||||
for (Map.Entry<String, String> entry : additionalParams.entrySet()) {
|
for (Entry<String, String> entry : additionalParams.entrySet()) {
|
||||||
sb.append(firstPrm ? "?" : "&").append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue(), "UTF-8"));
|
sb.append(firstPrm ? "?" : "&").append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue(), "UTF-8"));
|
||||||
firstPrm = false;
|
firstPrm = false;
|
||||||
}
|
}
|
||||||
|
@ -320,6 +332,11 @@ public class AndroidNetworkUtils {
|
||||||
conn.setRequestMethod("POST");
|
conn.setRequestMethod("POST");
|
||||||
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
|
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
|
||||||
conn.setRequestProperty("User-Agent", "OsmAnd");
|
conn.setRequestProperty("User-Agent", "OsmAnd");
|
||||||
|
if (headers != null) {
|
||||||
|
for (Entry<String, String> header : headers.entrySet()) {
|
||||||
|
conn.setRequestProperty(header.getKey(), header.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OutputStream ous = conn.getOutputStream();
|
OutputStream ous = conn.getOutputStream();
|
||||||
ous.write(("--" + BOUNDARY + "\r\n").getBytes());
|
ous.write(("--" + BOUNDARY + "\r\n").getBytes());
|
||||||
|
@ -376,6 +393,58 @@ public class AndroidNetworkUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void uploadFilesAsync(final @NonNull String url,
|
||||||
|
final @NonNull List<File> files,
|
||||||
|
final boolean gzip,
|
||||||
|
final @NonNull Map<String, String> parameters,
|
||||||
|
final @Nullable Map<String, String> headers,
|
||||||
|
final OnFilesUploadCallback callback) {
|
||||||
|
|
||||||
|
new AsyncTask<Void, Object, Map<File, String>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
protected Map<File, String> doInBackground(Void... v) {
|
||||||
|
Map<File, String> errors = new HashMap<>();
|
||||||
|
for (File file : files) {
|
||||||
|
publishProgress(file, 0);
|
||||||
|
try {
|
||||||
|
Map<String, String> params = new HashMap<>(parameters);
|
||||||
|
if (callback != null) {
|
||||||
|
Map<String, String> additionalParams = callback.getAdditionalParams(file);
|
||||||
|
if (additionalParams != null) {
|
||||||
|
params.putAll(additionalParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String res = uploadFile(url, file, gzip, params, headers);
|
||||||
|
if (res != null) {
|
||||||
|
errors.put(file, res);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
errors.put(file, e.getMessage());
|
||||||
|
}
|
||||||
|
publishProgress(file, 100);
|
||||||
|
}
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(Object... objects) {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onFileUploadProgress((File) objects[0], (Integer) objects[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(@NonNull Map<File, String> errors) {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onFilesUploadDone(errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
|
||||||
|
}
|
||||||
|
|
||||||
private static void showToast(OsmandApplication ctx, String message) {
|
private static void showToast(OsmandApplication ctx, String message) {
|
||||||
ctx.showToastMessage(message);
|
ctx.showToastMessage(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
String jsonStr = json.toString();
|
String jsonStr = json.toString();
|
||||||
InputStream inputStream = new ByteArrayInputStream(jsonStr.getBytes());
|
InputStream inputStream = new ByteArrayInputStream(jsonStr.getBytes());
|
||||||
String res = AndroidNetworkUtils.uploadFile(ANALYTICS_UPLOAD_URL, inputStream, ANALYTICS_FILE_NAME, true, additionalData);
|
String res = AndroidNetworkUtils.uploadFile(ANALYTICS_UPLOAD_URL, inputStream, ANALYTICS_FILE_NAME, true, additionalData, null);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,6 +169,11 @@ public class AudioNotesLayer extends OsmandMapLayer implements
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects, boolean unknownLocation) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
|
||||||
setupSimulateInitialStartupPref();
|
setupSimulateInitialStartupPref();
|
||||||
setupShouldShowFreeVersionBannerPref();
|
setupShouldShowFreeVersionBannerPref();
|
||||||
setupTestVoiceCommandsPref();
|
setupTestVoiceCommandsPref();
|
||||||
|
setupTestBackupsPref();
|
||||||
setupLogcatBufferPref();
|
setupLogcatBufferPref();
|
||||||
|
|
||||||
Preference info = findPreference("info");
|
Preference info = findPreference("info");
|
||||||
|
@ -117,6 +118,12 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
|
||||||
testVoiceCommands.setIconSpaceReserved(false);
|
testVoiceCommands.setIconSpaceReserved(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupTestBackupsPref() {
|
||||||
|
Preference testBackups = findPreference("test_backup");
|
||||||
|
testBackups.setIntent(new Intent(getActivity(), TestBackupActivity.class));
|
||||||
|
testBackups.setIconSpaceReserved(false);
|
||||||
|
}
|
||||||
|
|
||||||
private void setupLogcatBufferPref() {
|
private void setupLogcatBufferPref() {
|
||||||
Preference logcatBuffer = findPreference("logcat_buffer");
|
Preference logcatBuffer = findPreference("logcat_buffer");
|
||||||
logcatBuffer.setIntent(new Intent(getActivity(), LogcatActivity.class));
|
logcatBuffer.setIntent(new Intent(getActivity(), LogcatActivity.class));
|
||||||
|
|
595
OsmAnd/src/net/osmand/plus/development/TestBackupActivity.java
Normal file
595
OsmAnd/src/net/osmand/plus/development/TestBackupActivity.java
Normal file
|
@ -0,0 +1,595 @@
|
||||||
|
package net.osmand.plus.development;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Patterns;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import net.osmand.AndroidNetworkUtils;
|
||||||
|
import net.osmand.AndroidNetworkUtils.OnFilesUploadCallback;
|
||||||
|
import net.osmand.AndroidNetworkUtils.OnRequestResultListener;
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.ProgressImplementation;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||||
|
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TestBackupActivity extends OsmandActionBarActivity {
|
||||||
|
|
||||||
|
// TODO pass actual sub order id!
|
||||||
|
private static final String TEST_ORDER_ID = "";
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
private OsmandSettings settings;
|
||||||
|
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
private View buttonRegister;
|
||||||
|
private View buttonVerify;
|
||||||
|
private View buttonBackup;
|
||||||
|
private View buttonRestore;
|
||||||
|
private EditText emailEditText;
|
||||||
|
private EditText tokenEditText;
|
||||||
|
private TextView infoView;
|
||||||
|
|
||||||
|
public interface OnResultListener {
|
||||||
|
void onResult(boolean success, @Nullable String result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
app = getMyApplication();
|
||||||
|
settings = app.getSettings();
|
||||||
|
final WeakReference<TestBackupActivity> activityRef = new WeakReference<>(this);
|
||||||
|
|
||||||
|
boolean nightMode = !app.getSettings().isLightContent();
|
||||||
|
int themeId = nightMode ? R.style.OsmandDarkTheme_NoActionbar : R.style.OsmandLightTheme_NoActionbar;
|
||||||
|
setTheme(themeId);
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.test_backup_layout);
|
||||||
|
Toolbar tb = findViewById(R.id.toolbar);
|
||||||
|
tb.setTitle("Backup test");
|
||||||
|
|
||||||
|
tb.setClickable(true);
|
||||||
|
Drawable icBack = ((OsmandApplication) getApplication()).getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(app));
|
||||||
|
tb.setNavigationIcon(icBack);
|
||||||
|
tb.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
||||||
|
tb.setBackgroundColor(getResources().getColor(resolveResourceId(this, R.attr.pstsTabBackground)));
|
||||||
|
tb.setTitleTextColor(getResources().getColor(resolveResourceId(this, R.attr.pstsTextColor)));
|
||||||
|
tb.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(final View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonRegister = findViewById(R.id.btn_register);
|
||||||
|
UiUtilities.setupDialogButton(nightMode, buttonRegister, DialogButtonType.PRIMARY, "Register");
|
||||||
|
buttonVerify = findViewById(R.id.btn_verify);
|
||||||
|
UiUtilities.setupDialogButton(nightMode, buttonVerify, DialogButtonType.PRIMARY, "Verify");
|
||||||
|
buttonBackup = findViewById(R.id.btn_backup);
|
||||||
|
UiUtilities.setupDialogButton(nightMode, buttonBackup, DialogButtonType.PRIMARY, "Backup");
|
||||||
|
buttonRestore = findViewById(R.id.btn_restore);
|
||||||
|
UiUtilities.setupDialogButton(nightMode, buttonRestore, DialogButtonType.PRIMARY, "Restore");
|
||||||
|
|
||||||
|
tokenEditText = findViewById(R.id.edit_token);
|
||||||
|
infoView = findViewById(R.id.text_info);
|
||||||
|
progressBar = findViewById(R.id.progress_bar);
|
||||||
|
|
||||||
|
buttonVerify.setEnabled(false);
|
||||||
|
emailEditText = findViewById(R.id.edit_email);
|
||||||
|
String email = settings.BACKUP_USER_EMAIL.get();
|
||||||
|
if (!Algorithms.isEmpty(email)) {
|
||||||
|
emailEditText.setText(email);
|
||||||
|
}
|
||||||
|
buttonRegister.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String email = emailEditText.getText().toString();
|
||||||
|
if (isEmailValid(email)) {
|
||||||
|
buttonRegister.setEnabled(false);
|
||||||
|
settings.BACKUP_USER_EMAIL.set(email);
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
registerUser(email, new OnResultListener() {
|
||||||
|
@Override
|
||||||
|
public void onResult(boolean success, @Nullable String result) {
|
||||||
|
TestBackupActivity a = activityRef.get();
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(a)) {
|
||||||
|
a.progressBar.setVisibility(View.GONE);
|
||||||
|
a.buttonRegister.setEnabled(!success);
|
||||||
|
a.buttonVerify.setEnabled(success);
|
||||||
|
a.tokenEditText.requestFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
emailEditText.requestFocus();
|
||||||
|
emailEditText.setError(getString(R.string.osm_live_enter_email));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttonVerify.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String token = tokenEditText.getText().toString();
|
||||||
|
if (isTokenValid(token)) {
|
||||||
|
buttonVerify.setEnabled(false);
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
registerDevice(token, new OnResultListener() {
|
||||||
|
@Override
|
||||||
|
public void onResult(boolean success, @Nullable String result) {
|
||||||
|
TestBackupActivity a = activityRef.get();
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(a)) {
|
||||||
|
a.progressBar.setVisibility(View.GONE);
|
||||||
|
a.buttonVerify.setEnabled(!success);
|
||||||
|
a.loadBackupInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
tokenEditText.requestFocus();
|
||||||
|
tokenEditText.setError("Token is not valid");
|
||||||
|
buttonVerify.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttonBackup.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
uploadFiles();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttonRestore.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loadBackupInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadBackupInfo() {
|
||||||
|
if (!Algorithms.isEmpty(getDeviceId()) && !Algorithms.isEmpty(getAccessToken())) {
|
||||||
|
final WeakReference<TestBackupActivity> activityRef = new WeakReference<>(this);
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
loadBackupInfo(new OnResultListener() {
|
||||||
|
@Override
|
||||||
|
public void onResult(boolean success, @Nullable String result) {
|
||||||
|
TestBackupActivity a = activityRef.get();
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(a)) {
|
||||||
|
a.progressBar.setVisibility(View.GONE);
|
||||||
|
a.infoView.setText(result);
|
||||||
|
a.infoView.requestFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isEmailValid(CharSequence target) {
|
||||||
|
return (!TextUtils.isEmpty(target) && Patterns.EMAIL_ADDRESS.matcher(target).matches());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getOrderId() {
|
||||||
|
return TEST_ORDER_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDeviceId() {
|
||||||
|
return settings.BACKUP_DEVICE_ID.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getAccessToken() {
|
||||||
|
return settings.BACKUP_ACCESS_TOKEN.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerUser(@NonNull String email, @Nullable final OnResultListener listener) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("email", email);
|
||||||
|
params.put("orderid", getOrderId());
|
||||||
|
params.put("deviceid", app.getUserAndroidId());
|
||||||
|
AndroidNetworkUtils.sendRequestAsync(app, "https://osmand.net/userdata/user-register", params, "Register user", true, true, new OnRequestResultListener() {
|
||||||
|
@Override
|
||||||
|
public void onResult(String resultJson) {
|
||||||
|
boolean success = false;
|
||||||
|
if (!Algorithms.isEmpty(resultJson)) {
|
||||||
|
try {
|
||||||
|
// {"status":"ok"}
|
||||||
|
JSONObject result = new JSONObject(resultJson);
|
||||||
|
String status = result.getString("status");
|
||||||
|
success = status.equals("ok");
|
||||||
|
app.showToastMessage(success
|
||||||
|
? "You have been registered successfully. Please check for email with activation code."
|
||||||
|
: "User registration error: " + status);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
app.showToastMessage("User registration error: json parsing");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.showToastMessage("User registration error: empty response");
|
||||||
|
}
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onResult(success, resultJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerDevice(String token, @Nullable final OnResultListener listener) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("email", settings.BACKUP_USER_EMAIL.get());
|
||||||
|
params.put("orderid", getOrderId());
|
||||||
|
params.put("deviceid", app.getUserAndroidId());
|
||||||
|
params.put("token", token);
|
||||||
|
AndroidNetworkUtils.sendRequestAsync(app, "https://osmand.net/userdata/device-register", params, "Register device", true, true, new OnRequestResultListener() {
|
||||||
|
@Override
|
||||||
|
public void onResult(String resultJson) {
|
||||||
|
boolean success = false;
|
||||||
|
if (!Algorithms.isEmpty(resultJson)) {
|
||||||
|
try {
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"id": 1034,
|
||||||
|
"userid": 1033,
|
||||||
|
"deviceid": "2fa8080d2985a777",
|
||||||
|
"orderid": "460000687003939",
|
||||||
|
"accesstoken": "4bc0a61f-397a-4c3e-9ffc-db382ec00372",
|
||||||
|
"udpatetime": "Apr 11, 2021, 11:32:20 AM"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
JSONObject result = new JSONObject(resultJson);
|
||||||
|
settings.BACKUP_DEVICE_ID.set(result.getString("id"));
|
||||||
|
settings.BACKUP_USER_ID.set(result.getString("userid"));
|
||||||
|
settings.BACKUP_NATIVE_DEVICE_ID.set(result.getString("deviceid"));
|
||||||
|
settings.BACKUP_ACCESS_TOKEN.set(result.getString("accesstoken"));
|
||||||
|
settings.BACKUP_ACCESS_TOKEN_UPDATE_TIME.set(result.getString("udpatetime"));
|
||||||
|
success = true;
|
||||||
|
app.showToastMessage("Device have been registered successfully");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
app.showToastMessage("Device registration error: json parsing");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.showToastMessage("Device registration error: empty response");
|
||||||
|
}
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onResult(success, resultJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uploadFiles() {
|
||||||
|
LoadGpxTask loadGpxTask = new LoadGpxTask(this, new LoadGpxTask.OnLoadGpxListener() {
|
||||||
|
@Override
|
||||||
|
public void onLoadGpxDone(@NonNull List<GpxInfo> result) {
|
||||||
|
uploadFiles(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loadGpxTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uploadFiles(List<GpxInfo> gpxFiles) {
|
||||||
|
//{"status":"ok"}
|
||||||
|
final WeakReference<TestBackupActivity> activityRef = new WeakReference<>(this);
|
||||||
|
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("deviceid", getDeviceId());
|
||||||
|
params.put("accessToken", getAccessToken());
|
||||||
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("Accept-Encoding", "deflate, gzip");
|
||||||
|
|
||||||
|
final Map<File, GpxInfo> gpxInfos = new HashMap<>();
|
||||||
|
for (GpxInfo gpxFile : gpxFiles) {
|
||||||
|
gpxInfos.put(gpxFile.file, gpxFile);
|
||||||
|
}
|
||||||
|
final List<File> files = new ArrayList<>(gpxInfos.keySet());
|
||||||
|
File favoritesFile = app.getFavorites().getExternalFile();
|
||||||
|
files.add(favoritesFile);
|
||||||
|
|
||||||
|
final ProgressImplementation progress = ProgressImplementation.createProgressDialog(this,
|
||||||
|
"Create backup", "Uploading " + files.size() + " file(s) to server", ProgressDialog.STYLE_HORIZONTAL);
|
||||||
|
|
||||||
|
AndroidNetworkUtils.uploadFilesAsync("https://osmand.net/userdata/upload-file", files, true, params, headers, new OnFilesUploadCallback() {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getAdditionalParams(@NonNull File file) {
|
||||||
|
GpxInfo gpxInfo = gpxInfos.get(file);
|
||||||
|
Map<String, String> additionaParams = new HashMap<>();
|
||||||
|
additionaParams.put("name", gpxInfo == null ? file.getName() : gpxInfo.getFileName(true));
|
||||||
|
additionaParams.put("type", Algorithms.getFileExtension(file));
|
||||||
|
return additionaParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFileUploadProgress(@NonNull File file, int percent) {
|
||||||
|
Activity a = activityRef.get();
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(a)) {
|
||||||
|
if (percent < 100) {
|
||||||
|
progress.startTask(file.getName(), percent);
|
||||||
|
} else {
|
||||||
|
progress.finishTask();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFilesUploadDone(@NonNull Map<File, String> errors) {
|
||||||
|
Activity a = activityRef.get();
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(a)) {
|
||||||
|
app.runInUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
if (progress.getDialog().isShowing()) {
|
||||||
|
progress.getDialog().dismiss();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
//ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
app.showToastMessage("Uploaded " + (files.size() - errors.size() + " files" +
|
||||||
|
(errors.size() > 0 ? ". Errors: " + errors.size() : "")));
|
||||||
|
loadBackupInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadBackupInfo(@Nullable final OnResultListener listener) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("deviceid", getDeviceId());
|
||||||
|
params.put("accessToken", getAccessToken());
|
||||||
|
AndroidNetworkUtils.sendRequestAsync(app, "https://osmand.net/userdata/list-files", params, "Get backup info", true, false, new OnRequestResultListener() {
|
||||||
|
@Override
|
||||||
|
public void onResult(String resultJson) {
|
||||||
|
boolean success = false;
|
||||||
|
StringBuilder resultString = new StringBuilder();
|
||||||
|
if (!Algorithms.isEmpty(resultJson)) {
|
||||||
|
try {
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"totalZipSize": 21792,
|
||||||
|
"totalFileSize": 185920,
|
||||||
|
"totalFiles": 1,
|
||||||
|
"totalFileVersions": 2,
|
||||||
|
"uniqueFiles": [
|
||||||
|
{
|
||||||
|
"userid": 1033,
|
||||||
|
"id": 7,
|
||||||
|
"deviceid": 1034,
|
||||||
|
"filesize": 92960,
|
||||||
|
"type": "gpx",
|
||||||
|
"name": "test/Day 2.gpx",
|
||||||
|
"updatetime": "Apr 11, 2021, 1:49:01 PM",
|
||||||
|
"updatetimems": 1618141741822,
|
||||||
|
"zipSize": 10896
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"deviceid": 1034
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
JSONObject result = new JSONObject(resultJson);
|
||||||
|
String totalZipSize = result.getString("totalZipSize");
|
||||||
|
String totalFiles = result.getString("totalFiles");
|
||||||
|
String totalFileVersions = result.getString("totalFileVersions");
|
||||||
|
JSONArray files = result.getJSONArray("uniqueFiles");
|
||||||
|
resultString.append("Total files: ").append(totalFiles).append("\n");
|
||||||
|
resultString.append("Total zip size: ").append(AndroidUtils.formatSize(app, Long.parseLong(totalZipSize))).append("\n");
|
||||||
|
resultString.append("Total file versions: ").append(totalFileVersions);
|
||||||
|
|
||||||
|
success = true;
|
||||||
|
} catch (JSONException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onResult(success, resultString.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTokenValid(String token) {
|
||||||
|
return token.matches("[0-9]+");
|
||||||
|
}
|
||||||
|
|
||||||
|
private int resolveResourceId(final Activity activity, final int attr) {
|
||||||
|
final TypedValue typedvalueattr = new TypedValue();
|
||||||
|
activity.getTheme().resolveAttribute(attr, typedvalueattr, true);
|
||||||
|
return typedvalueattr.resourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class LoadGpxTask extends AsyncTask<Activity, GpxInfo, List<GpxInfo>> {
|
||||||
|
|
||||||
|
private final OsmandApplication app;
|
||||||
|
private final OnLoadGpxListener listener;
|
||||||
|
private final WeakReference<Activity> activityRef;
|
||||||
|
private List<GpxInfo> result;
|
||||||
|
private ProgressImplementation progress;
|
||||||
|
|
||||||
|
interface OnLoadGpxListener {
|
||||||
|
void onLoadGpxDone(@NonNull List<GpxInfo> result);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadGpxTask(@NonNull Activity activity, @Nullable OnLoadGpxListener listener) {
|
||||||
|
this.activityRef = new WeakReference<>(activity);
|
||||||
|
this.app = (OsmandApplication) activity.getApplication();
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GpxInfo> getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
protected List<GpxInfo> doInBackground(Activity... params) {
|
||||||
|
List<GpxInfo> result = new ArrayList<>();
|
||||||
|
loadGPXData(app.getAppPath(IndexConstants.GPX_INDEX_DIR), result, this);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFile(GpxInfo... loaded) {
|
||||||
|
publishProgress(loaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
Activity a = activityRef.get();
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(a)) {
|
||||||
|
progress = ProgressImplementation.createProgressDialog(a,
|
||||||
|
"Create backup", "Collecting gpx files...", ProgressDialog.STYLE_HORIZONTAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(GpxInfo... values) {
|
||||||
|
Activity a = activityRef.get();
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(a)) {
|
||||||
|
progress.startTask(values[0].getFileName(true), -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(@NonNull List<GpxInfo> result) {
|
||||||
|
this.result = result;
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onLoadGpxDone(result);
|
||||||
|
}
|
||||||
|
Activity a = activityRef.get();
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(a)) {
|
||||||
|
progress.finishTask();
|
||||||
|
app.runInUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
if (progress.getDialog().isShowing()) {
|
||||||
|
progress.getDialog().dismiss();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
//ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadGPXData(File mapPath, List<GpxInfo> result, LoadGpxTask loadTask) {
|
||||||
|
if (mapPath.canRead()) {
|
||||||
|
List<GpxInfo> progress = new ArrayList<>();
|
||||||
|
loadGPXFolder(mapPath, result, loadTask, progress, "");
|
||||||
|
if (!progress.isEmpty()) {
|
||||||
|
loadTask.loadFile(progress.toArray(new GpxInfo[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadGPXFolder(File mapPath, List<GpxInfo> result, LoadGpxTask loadTask, List<GpxInfo> progress,
|
||||||
|
String gpxSubfolder) {
|
||||||
|
File[] listFiles = mapPath.listFiles();
|
||||||
|
if (listFiles != null) {
|
||||||
|
for (File gpxFile : listFiles) {
|
||||||
|
if (gpxFile.isDirectory()) {
|
||||||
|
String sub = gpxSubfolder.length() == 0 ? gpxFile.getName() : gpxSubfolder + "/"
|
||||||
|
+ gpxFile.getName();
|
||||||
|
loadGPXFolder(gpxFile, result, loadTask, progress, sub);
|
||||||
|
} else if (gpxFile.isFile() && gpxFile.getName().toLowerCase().endsWith(IndexConstants.GPX_FILE_EXT)) {
|
||||||
|
GpxInfo info = new GpxInfo();
|
||||||
|
info.subfolder = gpxSubfolder;
|
||||||
|
info.file = gpxFile;
|
||||||
|
result.add(info);
|
||||||
|
progress.add(info);
|
||||||
|
if (progress.size() > 7) {
|
||||||
|
loadTask.loadFile(progress.toArray(new GpxInfo[0]));
|
||||||
|
progress.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class GpxInfo {
|
||||||
|
public File file;
|
||||||
|
public String subfolder;
|
||||||
|
|
||||||
|
private String name = null;
|
||||||
|
private int sz = -1;
|
||||||
|
private String fileName = null;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
if (name == null) {
|
||||||
|
name = formatName(file.getName());
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatName(String name) {
|
||||||
|
int ext = name.lastIndexOf('.');
|
||||||
|
if (ext != -1) {
|
||||||
|
name = name.substring(0, ext);
|
||||||
|
}
|
||||||
|
return name.replace('_', ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usage: AndroidUtils.formatSize(v.getContext(), getSize() * 1024l);
|
||||||
|
public int getSize() {
|
||||||
|
if (sz == -1) {
|
||||||
|
if (file == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sz = (int) ((file.length() + 512) >> 10);
|
||||||
|
}
|
||||||
|
return sz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getFileDate() {
|
||||||
|
if (file == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return file.lastModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName(boolean includeSubfolder) {
|
||||||
|
String result;
|
||||||
|
if (fileName != null) {
|
||||||
|
result = fileName;
|
||||||
|
} else {
|
||||||
|
if (file == null) {
|
||||||
|
result = "";
|
||||||
|
} else {
|
||||||
|
result = fileName = file.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (includeSubfolder && !Algorithms.isEmpty(subfolder)) {
|
||||||
|
result = subfolder + "/" + result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import com.vividsolutions.jts.geom.Coordinate;
|
import com.vividsolutions.jts.geom.Coordinate;
|
||||||
|
@ -346,6 +347,11 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void getImagesFromPoint(RotatedTileBox tb, PointF point, List<? super MapillaryImage> images) {
|
private void getImagesFromPoint(RotatedTileBox tb, PointF point, List<? super MapillaryImage> images) {
|
||||||
Map<QuadPointDouble, Map> points = this.visiblePoints;
|
Map<QuadPointDouble, Map> points = this.visiblePoints;
|
||||||
if (points != null) {
|
if (points != null) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
|
@ -516,6 +517,11 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private Location getLocationFromLL(double lat, double lon) {
|
private Location getLocationFromLL(double lat, double lon) {
|
||||||
Location l = new Location("");
|
Location l = new Location("");
|
||||||
l.setLatitude(lat);
|
l.setLatitude(lat);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -467,6 +468,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
|
|
|
@ -194,6 +194,11 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.ColorRes;
|
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
|
@ -32,6 +31,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.osmand.AndroidUtils.isLayoutRtl;
|
||||||
|
|
||||||
public abstract class SwitchableAction<T> extends QuickAction {
|
public abstract class SwitchableAction<T> extends QuickAction {
|
||||||
|
|
||||||
public static final String KEY_ID = "id";
|
public static final String KEY_ID = "id";
|
||||||
|
@ -62,7 +63,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.quick_action_switchable_action, parent, false);
|
.inflate(R.layout.quick_action_switchable_action, parent, false);
|
||||||
|
|
||||||
final SwitchCompat showDialog = (SwitchCompat) view.findViewById(R.id.saveButton);
|
final SwitchCompat showDialog = view.findViewById(R.id.saveButton);
|
||||||
if (!getParams().isEmpty()) {
|
if (!getParams().isEmpty()) {
|
||||||
showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
|
showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
|
||||||
}
|
}
|
||||||
|
@ -74,7 +75,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
RecyclerView list = (RecyclerView) view.findViewById(R.id.list);
|
RecyclerView list = view.findViewById(R.id.list);
|
||||||
adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() {
|
adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
|
public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
|
||||||
|
@ -92,9 +93,9 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
||||||
|
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
|
|
||||||
TextView dscrTitle = (TextView) view.findViewById(R.id.textDscrTitle);
|
TextView dscrTitle = view.findViewById(R.id.textDscrTitle);
|
||||||
TextView dscrHint = (TextView) view.findViewById(R.id.textDscrHint);
|
TextView dscrHint = view.findViewById(R.id.textDscrHint);
|
||||||
Button addBtn = (Button) view.findViewById(R.id.btnAdd);
|
Button addBtn = view.findViewById(R.id.btnAdd);
|
||||||
|
|
||||||
dscrTitle.setText(parent.getContext().getString(getDiscrTitle()) + ":");
|
dscrTitle.setText(parent.getContext().getString(getDiscrTitle()) + ":");
|
||||||
dscrHint.setText(getDiscrHint());
|
dscrHint.setText(getDiscrHint());
|
||||||
|
@ -104,10 +105,18 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
||||||
parent.addView(view);
|
parent.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getActionText(OsmandApplication application) {
|
||||||
|
String item = getSelectedItem(application);
|
||||||
|
String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
|
||||||
|
|
||||||
|
return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, item), arrowDirection + "\u2026");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fillParams(View root, MapActivity activity) {
|
public boolean fillParams(View root, MapActivity activity) {
|
||||||
|
|
||||||
final RecyclerView list = (RecyclerView) root.findViewById(R.id.list);
|
final RecyclerView list = root.findViewById(R.id.list);
|
||||||
final Adapter adapter = (Adapter) list.getAdapter();
|
final Adapter adapter = (Adapter) list.getAdapter();
|
||||||
|
|
||||||
boolean hasParams = adapter.itemsList != null && !adapter.itemsList.isEmpty();
|
boolean hasParams = adapter.itemsList != null && !adapter.itemsList.isEmpty();
|
||||||
|
@ -143,7 +152,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
||||||
|
|
||||||
private List<T> itemsList = new ArrayList<>();
|
private List<T> itemsList = new ArrayList<>();
|
||||||
private final QuickActionListFragment.OnStartDragListener onStartDragListener;
|
private final QuickActionListFragment.OnStartDragListener onStartDragListener;
|
||||||
private Context context;
|
private final Context context;
|
||||||
|
|
||||||
public Adapter(Context context, QuickActionListFragment.OnStartDragListener onStartDragListener) {
|
public Adapter(Context context, QuickActionListFragment.OnStartDragListener onStartDragListener) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -293,10 +302,10 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
||||||
public ItemHolder(View itemView) {
|
public ItemHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
title = (TextView) itemView.findViewById(R.id.title);
|
title = itemView.findViewById(R.id.title);
|
||||||
handleView = (ImageView) itemView.findViewById(R.id.handle_view);
|
handleView = itemView.findViewById(R.id.handle_view);
|
||||||
closeBtn = (ImageView) itemView.findViewById(R.id.closeImageButton);
|
closeBtn = itemView.findViewById(R.id.closeImageButton);
|
||||||
icon = (ImageView) itemView.findViewById(R.id.imageView);
|
icon = itemView.findViewById(R.id.imageView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,10 +246,4 @@ public class MapStyleAction extends SwitchableAction<String> {
|
||||||
: filters.get(0);
|
: filters.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getActionText(OsmandApplication application) {
|
|
||||||
String currentSource = application.getSettings().RENDERER.get();
|
|
||||||
|
|
||||||
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -27,6 +27,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.osmand.AndroidUtils.isLayoutRtl;
|
||||||
|
|
||||||
public class SwitchProfileAction extends SwitchableAction<String> {
|
public class SwitchProfileAction extends SwitchableAction<String> {
|
||||||
|
|
||||||
private final static String KEY_PROFILES = "profiles";
|
private final static String KEY_PROFILES = "profiles";
|
||||||
|
@ -230,4 +232,9 @@ public class SwitchProfileAction extends SwitchableAction<String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getActionText(OsmandApplication application) {
|
||||||
|
return getName(application);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,13 @@ import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.quickaction.QuickActionType;
|
import net.osmand.plus.quickaction.QuickActionType;
|
||||||
import net.osmand.plus.quickaction.SwitchableAction;
|
import net.osmand.plus.quickaction.SwitchableAction;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -59,7 +59,7 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSelectedItem(OsmandApplication app) {
|
public String getSelectedItem(OsmandApplication app) {
|
||||||
return app.getSettings().MAP_OVERLAY.get();
|
return app.getSettings().MAP_OVERLAY.get() != null ? app.getSettings().MAP_OVERLAY.get() : KEY_NO_OVERLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -224,12 +224,4 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
||||||
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
||||||
return super.fillParams(root, activity);
|
return super.fillParams(root, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getActionText(OsmandApplication application) {
|
|
||||||
String currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
|
|
||||||
: application.getSettings().MAP_OVERLAY.get();
|
|
||||||
|
|
||||||
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,13 @@ import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.quickaction.QuickActionType;
|
import net.osmand.plus.quickaction.QuickActionType;
|
||||||
import net.osmand.plus.quickaction.SwitchableAction;
|
import net.osmand.plus.quickaction.SwitchableAction;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -214,13 +214,4 @@ public class MapSourceAction extends SwitchableAction<Pair<String, String>> {
|
||||||
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
||||||
return super.fillParams(root, activity);
|
return super.fillParams(root, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getActionText(OsmandApplication application) {
|
|
||||||
String currentSource = application.getSettings().MAP_ONLINE_DATA.get()
|
|
||||||
? application.getSettings().MAP_TILE_SOURCES.get()
|
|
||||||
: application.getString(R.string.vector_data);
|
|
||||||
|
|
||||||
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSelectedItem(OsmandApplication app) {
|
public String getSelectedItem(OsmandApplication app) {
|
||||||
return app.getSettings().MAP_UNDERLAY.get();
|
return app.getSettings().MAP_UNDERLAY.get() != null ? app.getSettings().MAP_UNDERLAY.get() : KEY_NO_UNDERLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -226,12 +226,4 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
|
||||||
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
||||||
return super.fillParams(root, activity);
|
return super.fillParams(root, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getActionText(OsmandApplication application) {
|
|
||||||
String currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY
|
|
||||||
: application.getSettings().MAP_UNDERLAY.get();
|
|
||||||
|
|
||||||
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1165,6 +1165,13 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Integer> DISCOUNT_TOTAL_SHOW = new IntPreference(this, "discount_total_show", 0).makeGlobal();
|
public final OsmandPreference<Integer> DISCOUNT_TOTAL_SHOW = new IntPreference(this, "discount_total_show", 0).makeGlobal();
|
||||||
public final OsmandPreference<Long> DISCOUNT_SHOW_DATETIME_MS = new LongPreference(this, "show_discount_datetime_ms", 0).makeGlobal();
|
public final OsmandPreference<Long> DISCOUNT_SHOW_DATETIME_MS = new LongPreference(this, "show_discount_datetime_ms", 0).makeGlobal();
|
||||||
|
|
||||||
|
public final OsmandPreference<String> BACKUP_USER_EMAIL = new StringPreference(this, "backup_user_email", "").makeGlobal();
|
||||||
|
public final OsmandPreference<String> BACKUP_USER_ID = new StringPreference(this, "backup_user_id", "").makeGlobal();
|
||||||
|
public final OsmandPreference<String> BACKUP_DEVICE_ID = new StringPreference(this, "backup_device_id", "").makeGlobal();
|
||||||
|
public final OsmandPreference<String> BACKUP_NATIVE_DEVICE_ID = new StringPreference(this, "backup_native_device_id", "").makeGlobal();
|
||||||
|
public final OsmandPreference<String> BACKUP_ACCESS_TOKEN = new StringPreference(this, "backup_access_token", "").makeGlobal();
|
||||||
|
public final OsmandPreference<String> BACKUP_ACCESS_TOKEN_UPDATE_TIME = new StringPreference(this, "backup_access_token_update_time", "").makeGlobal();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final OsmandPreference<String> USER_OSM_BUG_NAME =
|
public final OsmandPreference<String> USER_OSM_BUG_NAME =
|
||||||
new StringPreference(this, "user_osm_bug_name", "NoName/OsmAnd").makeGlobal().makeShared();
|
new StringPreference(this, "user_osm_bug_name", "NoName/OsmAnd").makeGlobal().makeShared();
|
||||||
|
|
|
@ -852,9 +852,9 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
osmEditingPlugin.sendGPXFiles(mapActivity, this, gpxInfo);
|
osmEditingPlugin.sendGPXFiles(mapActivity, this, gpxInfo);
|
||||||
}
|
}
|
||||||
} else if (buttonIndex == EDIT_BUTTON_INDEX) {
|
} else if (buttonIndex == EDIT_BUTTON_INDEX) {
|
||||||
|
dismiss();
|
||||||
String fileName = Algorithms.getFileWithoutDirs(gpxFile.path);
|
String fileName = Algorithms.getFileWithoutDirs(gpxFile.path);
|
||||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), fileName);
|
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), fileName);
|
||||||
dismiss();
|
|
||||||
} else if (buttonIndex == RENAME_BUTTON_INDEX) {
|
} else if (buttonIndex == RENAME_BUTTON_INDEX) {
|
||||||
FileUtils.renameFile(mapActivity, new File(gpxFile.path), this, true);
|
FileUtils.renameFile(mapActivity, new File(gpxFile.path), this, true);
|
||||||
} else if (buttonIndex == CHANGE_FOLDER_BUTTON_INDEX) {
|
} else if (buttonIndex == CHANGE_FOLDER_BUTTON_INDEX) {
|
||||||
|
|
|
@ -24,13 +24,14 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.settings.backend.CommonPreference;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
|
import net.osmand.plus.settings.backend.CommonPreference;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
|
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
|
||||||
|
import net.osmand.plus.views.layers.MapTextLayer.MapTextProvider;
|
||||||
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -46,7 +47,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import static net.osmand.aidl.ConnectedApp.AIDL_LAYERS_PREFIX;
|
import static net.osmand.aidl.ConnectedApp.AIDL_LAYERS_PREFIX;
|
||||||
|
|
||||||
public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider, MapTextLayer.MapTextProvider<AidlMapPointWrapper> {
|
public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider, MapTextProvider<AidlMapPointWrapper> {
|
||||||
|
|
||||||
private static final float POINT_IMAGE_VERTICAL_OFFSET = 0.91f;
|
private static final float POINT_IMAGE_VERTICAL_OFFSET = 0.91f;
|
||||||
|
|
||||||
|
@ -281,6 +282,11 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
||||||
if (isLayerEnabled()) {
|
if (isLayerEnabled()) {
|
||||||
|
|
|
@ -609,7 +609,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
String title = pointDescription == null ? "" : pointDescription.getName();
|
String title = pointDescription == null ? "" : pointDescription.getName();
|
||||||
mAddGpxPointBottomSheetHelper.setTitle(title);
|
mAddGpxPointBottomSheetHelper.setTitle(title);
|
||||||
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
|
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
|
||||||
} else {
|
} else if (provider == null || !provider.showMenuAction(object)) {
|
||||||
selectedObjectContextMenuProvider = provider;
|
selectedObjectContextMenuProvider = provider;
|
||||||
hideVisibleMenues();
|
hideVisibleMenues();
|
||||||
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||||
|
@ -1106,6 +1106,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
boolean isObjectClickable(Object o);
|
boolean isObjectClickable(Object o);
|
||||||
|
|
||||||
boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation);
|
boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation);
|
||||||
|
|
||||||
|
boolean showMenuAction(@Nullable Object o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IMoveObjectProvider {
|
public interface IMoveObjectProvider {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.binary.BinaryMapDataObject;
|
import net.osmand.binary.BinaryMapDataObject;
|
||||||
|
@ -580,6 +581,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super DownloadMapObject> dataObjects) {
|
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super DownloadMapObject> dataObjects) {
|
||||||
int zoom = tb.getZoom();
|
int zoom = tb.getZoom();
|
||||||
if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION
|
if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION
|
||||||
|
|
|
@ -227,6 +227,11 @@ public class FavouritesLayer extends OsmandMapLayer implements IContextMenuProvi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
|
||||||
if (this.settings.SHOW_FAVORITES.get() && tileBox.getZoom() >= startZoom) {
|
if (this.settings.SHOW_FAVORITES.get() && tileBox.getZoom() >= startZoom) {
|
||||||
|
|
|
@ -1108,14 +1108,8 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean runExclusiveAction(Object object, boolean unknownLocation) {
|
public boolean runExclusiveAction(Object object, boolean unknownLocation) {
|
||||||
if (unknownLocation || !(object instanceof SelectedGpxPoint)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MapActivity mapActivity = (MapActivity) view.getContext();
|
|
||||||
SelectedGpxPoint point = (SelectedGpxPoint) object;
|
|
||||||
TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), point, null, null, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
|
||||||
|
@ -1158,14 +1152,24 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
SelectedGpxPoint selectedGpxPoint = (SelectedGpxPoint) trackPoints.get(0);
|
SelectedGpxPoint selectedGpxPoint = (SelectedGpxPoint) trackPoints.get(0);
|
||||||
WptPt wptPt = selectedGpxPoint.getSelectedPoint();
|
WptPt wptPt = selectedGpxPoint.getSelectedPoint();
|
||||||
PointDescription description = getObjectName(selectedGpxPoint);
|
PointDescription description = getObjectName(selectedGpxPoint);
|
||||||
ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
|
mapActivity.getContextMenu().show(new LatLon(wptPt.lat, wptPt.lon), description, selectedGpxPoint);
|
||||||
contextMenuLayer.showContextMenu(new LatLon(wptPt.lat, wptPt.lon), description, selectedGpxPoint, this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object object) {
|
||||||
|
if (!(object instanceof SelectedGpxPoint)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MapActivity mapActivity = (MapActivity) view.getContext();
|
||||||
|
SelectedGpxPoint point = (SelectedGpxPoint) object;
|
||||||
|
TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), point, null, null, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LatLon getTextLocation(WptPt o) {
|
public LatLon getTextLocation(WptPt o) {
|
||||||
return new LatLon(o.lat, o.lon);
|
return new LatLon(o.lat, o.lon);
|
||||||
|
|
|
@ -142,6 +142,11 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
||||||
if (tileBox.getZoom() >= START_ZOOM) {
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
|
|
|
@ -531,6 +531,11 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
||||||
if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().SHOW_MAP_MARKERS.get()) {
|
if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().SHOW_MAP_MARKERS.get()) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import android.widget.LinearLayout.LayoutParams;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
@ -408,6 +409,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LatLon getTextLocation(Amenity o) {
|
public LatLon getTextLocation(Amenity o) {
|
||||||
return o.getLocation();
|
return o.getLocation();
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.graphics.RectF;
|
||||||
import android.graphics.drawable.LayerDrawable;
|
import android.graphics.drawable.LayerDrawable;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.graphics.drawable.DrawableCompat;
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
|
@ -22,14 +23,15 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
|
||||||
import net.osmand.plus.OsmAndLocationProvider;
|
import net.osmand.plus.OsmAndLocationProvider;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||||
import net.osmand.plus.profiles.ProfileIconColors;
|
import net.osmand.plus.profiles.ProfileIconColors;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -38,7 +40,7 @@ import java.util.List;
|
||||||
import static android.graphics.Paint.ANTI_ALIAS_FLAG;
|
import static android.graphics.Paint.ANTI_ALIAS_FLAG;
|
||||||
import static android.graphics.Paint.FILTER_BITMAP_FLAG;
|
import static android.graphics.Paint.FILTER_BITMAP_FLAG;
|
||||||
|
|
||||||
public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
public class PointLocationLayer extends OsmandMapLayer implements IContextMenuProvider {
|
||||||
private static final Log LOG = PlatformUtil.getLog(PointLocationLayer.class);
|
private static final Log LOG = PlatformUtil.getLog(PointLocationLayer.class);
|
||||||
|
|
||||||
protected final static int RADIUS = 7;
|
protected final static int RADIUS = 7;
|
||||||
|
@ -240,6 +242,11 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private LatLon getMyLocation() {
|
private LatLon getMyLocation() {
|
||||||
Location location = locationProvider.getLastKnownLocation();
|
Location location = locationProvider.getLastKnownLocation();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
|
|
@ -23,11 +23,13 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
|
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
|
||||||
|
import net.osmand.plus.views.layers.ContextMenuLayer.IMoveObjectProvider;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PointNavigationLayer extends OsmandMapLayer implements
|
public class PointNavigationLayer extends OsmandMapLayer implements
|
||||||
IContextMenuProvider, ContextMenuLayer.IMoveObjectProvider {
|
IContextMenuProvider, IMoveObjectProvider {
|
||||||
|
|
||||||
protected final static int DIST_TO_SHOW = 80;
|
protected final static int DIST_TO_SHOW = 80;
|
||||||
|
|
||||||
private Paint mPoint;
|
private Paint mPoint;
|
||||||
|
@ -186,6 +188,11 @@ public class PointNavigationLayer extends OsmandMapLayer implements
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
|
||||||
if (tileBox.getZoom() >= 3) {
|
if (tileBox.getZoom() >= 3) {
|
||||||
|
|
|
@ -46,6 +46,7 @@ import net.osmand.plus.routing.TransportRoutingHelper;
|
||||||
import net.osmand.plus.settings.backend.CommonPreference;
|
import net.osmand.plus.settings.backend.CommonPreference;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
|
||||||
import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWay;
|
import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWay;
|
||||||
import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWayContext;
|
import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWayContext;
|
||||||
import net.osmand.plus.views.layers.geometry.RouteGeometryWay;
|
import net.osmand.plus.views.layers.geometry.RouteGeometryWay;
|
||||||
|
@ -67,7 +68,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR;
|
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR;
|
||||||
|
|
||||||
public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
public class RouteLayer extends OsmandMapLayer implements IContextMenuProvider {
|
||||||
|
|
||||||
private static final Log log = PlatformUtil.getLog(RouteLayer.class);
|
private static final Log log = PlatformUtil.getLog(RouteLayer.class);
|
||||||
|
|
||||||
|
@ -815,4 +816,9 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
||||||
public boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation) {
|
public boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
|
@ -21,16 +22,17 @@ import net.osmand.data.TransportStop;
|
||||||
import net.osmand.osm.edit.Node;
|
import net.osmand.osm.edit.Node;
|
||||||
import net.osmand.osm.edit.Way;
|
import net.osmand.osm.edit.Way;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.base.PointImageDrawable;
|
|
||||||
import net.osmand.plus.settings.backend.CommonPreference;
|
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.base.PointImageDrawable;
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
|
import net.osmand.plus.settings.backend.CommonPreference;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.transport.TransportStopRoute;
|
import net.osmand.plus.transport.TransportStopRoute;
|
||||||
import net.osmand.plus.transport.TransportStopType;
|
import net.osmand.plus.transport.TransportStopType;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
|
||||||
import net.osmand.plus.views.layers.geometry.GeometryWay;
|
import net.osmand.plus.views.layers.geometry.GeometryWay;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -40,7 +42,7 @@ import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
public class TransportStopsLayer extends OsmandMapLayer implements IContextMenuProvider {
|
||||||
|
|
||||||
public static final String TRANSPORT_STOPS_OVER_MAP = "transportStops";
|
public static final String TRANSPORT_STOPS_OVER_MAP = "transportStops";
|
||||||
|
|
||||||
|
@ -308,6 +310,11 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showMenuAction(@Nullable Object o) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
|
||||||
if(tileBox.getZoom() >= startZoomRoute && stopRoute != null) {
|
if(tileBox.getZoom() >= startZoomRoute && stopRoute != null) {
|
||||||
|
|
|
@ -21,10 +21,10 @@ import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
public class WidgetsVisibilityHelper {
|
public class WidgetsVisibilityHelper {
|
||||||
|
|
||||||
private MapActivity mapActivity;
|
private final MapActivity mapActivity;
|
||||||
private OsmandSettings settings;
|
private final OsmandSettings settings;
|
||||||
private RoutingHelper routingHelper;
|
private final RoutingHelper routingHelper;
|
||||||
private MapActivityLayers mapLayers;
|
private final MapActivityLayers mapLayers;
|
||||||
|
|
||||||
public WidgetsVisibilityHelper(@NonNull MapActivity mapActivity) {
|
public WidgetsVisibilityHelper(@NonNull MapActivity mapActivity) {
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
|
@ -104,7 +104,6 @@ public class WidgetsVisibilityHelper {
|
||||||
public boolean shouldHideCompass() {
|
public boolean shouldHideCompass() {
|
||||||
return mapActivity.shouldHideTopControls()
|
return mapActivity.shouldHideTopControls()
|
||||||
|| isTrackDetailsMenuOpened()
|
|| isTrackDetailsMenuOpened()
|
||||||
|| isInMeasurementToolMode()
|
|
||||||
|| isInPlanRouteMode()
|
|| isInPlanRouteMode()
|
||||||
|| isInChoosingRoutesMode()
|
|| isInChoosingRoutesMode()
|
||||||
|| isInTrackAppearanceMode()
|
|| isInTrackAppearanceMode()
|
||||||
|
@ -116,7 +115,6 @@ public class WidgetsVisibilityHelper {
|
||||||
public boolean shouldShowTopButtons() {
|
public boolean shouldShowTopButtons() {
|
||||||
return !mapActivity.shouldHideTopControls()
|
return !mapActivity.shouldHideTopControls()
|
||||||
&& !isTrackDetailsMenuOpened()
|
&& !isTrackDetailsMenuOpened()
|
||||||
&& !isInMeasurementToolMode()
|
|
||||||
&& !isInPlanRouteMode()
|
&& !isInPlanRouteMode()
|
||||||
&& !isInChoosingRoutesMode()
|
&& !isInChoosingRoutesMode()
|
||||||
&& !isInTrackAppearanceMode()
|
&& !isInTrackAppearanceMode()
|
||||||
|
|
|
@ -10,7 +10,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
//classpath 'com.android.tools.build:gradle:2.+'
|
//classpath 'com.android.tools.build:gradle:2.+'
|
||||||
classpath 'com.android.tools.build:gradle:4.1.2'
|
classpath 'com.android.tools.build:gradle:4.1.3'
|
||||||
classpath 'com.google.gms:google-services:3.0.0'
|
classpath 'com.google.gms:google-services:3.0.0'
|
||||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
Loading…
Reference in a new issue