Merge branch 'master' of github.com:osmandapp/Osmand
This commit is contained in:
commit
e95aa4483b
20 changed files with 583 additions and 328 deletions
|
@ -46,7 +46,6 @@ public class GPXUtilities {
|
||||||
private static final String ICON_NAME_EXTENSION = "icon";
|
private static final String ICON_NAME_EXTENSION = "icon";
|
||||||
private static final String DEFAULT_ICON_NAME = "special_star";
|
private static final String DEFAULT_ICON_NAME = "special_star";
|
||||||
private static final String BACKGROUND_TYPE_EXTENSION = "background";
|
private static final String BACKGROUND_TYPE_EXTENSION = "background";
|
||||||
private static final String DEFAULT_BACKGROUND_TYPE = "circle";
|
|
||||||
|
|
||||||
private final static String GPX_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; //$NON-NLS-1$
|
private final static String GPX_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; //$NON-NLS-1$
|
||||||
private final static String GPX_TIME_FORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; //$NON-NLS-1$
|
private final static String GPX_TIME_FORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; //$NON-NLS-1$
|
||||||
|
@ -280,6 +279,10 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIconName() {
|
public String getIconName() {
|
||||||
|
return getExtensionsToRead().get(ICON_NAME_EXTENSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIconNameOrDefault() {
|
||||||
String iconName = getExtensionsToRead().get(ICON_NAME_EXTENSION);
|
String iconName = getExtensionsToRead().get(ICON_NAME_EXTENSION);
|
||||||
if (iconName == null) {
|
if (iconName == null) {
|
||||||
iconName = DEFAULT_ICON_NAME;
|
iconName = DEFAULT_ICON_NAME;
|
||||||
|
@ -292,11 +295,7 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBackgroundType() {
|
public String getBackgroundType() {
|
||||||
String backgroundType = getExtensionsToRead().get(BACKGROUND_TYPE_EXTENSION);
|
return getExtensionsToRead().get(BACKGROUND_TYPE_EXTENSION);
|
||||||
if (backgroundType == null) {
|
|
||||||
backgroundType = DEFAULT_BACKGROUND_TYPE;
|
|
||||||
}
|
|
||||||
return backgroundType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBackgroundType(String backType) {
|
public void setBackgroundType(String backType) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class PoiFilter extends AbstractPoiType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPoiType(PoiType type) {
|
public void addPoiType(PoiType type) {
|
||||||
if(!map.containsKey(type.getKeyName())) {
|
if (!map.containsKey(type.getKeyName())) {
|
||||||
poiTypes.add(type);
|
poiTypes.add(type);
|
||||||
map.put(type.getKeyName(), type);
|
map.put(type.getKeyName(), type);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -133,6 +133,20 @@
|
||||||
<category android:name="android.intent.category.DESK_DOCK" />
|
<category android:name="android.intent.category.DESK_DOCK" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<data android:scheme="http" />
|
||||||
|
<data android:scheme="https" />
|
||||||
|
<data android:host="osmand.net" />
|
||||||
|
<data android:pathPrefix="/open-gpx" />
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<category android:name="android.intent.category.APP_MAPS" />
|
||||||
|
<category android:name="android.intent.category.CAR_MODE" />
|
||||||
|
<category android:name="android.intent.category.CAR_DOCK" />
|
||||||
|
<category android:name="android.intent.category.DESK_DOCK" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
<!-- android matches non-greedy : http://stackoverflow.com/questions/3400072/pathpattern-to-match-file-extension-does-not-work-if-a-period-exists-elsewhere-i-->
|
<!-- android matches non-greedy : http://stackoverflow.com/questions/3400072/pathpattern-to-match-file-extension-does-not-work-if-a-period-exists-elsewhere-i-->
|
||||||
<!-- mimeType&host are both needed or you will either have unwanted matching or no match when needed -->
|
<!-- mimeType&host are both needed or you will either have unwanted matching or no match when needed -->
|
||||||
<!-- Capture file open requests (pathPattern is honoured) where no MIME type is provided in the Intent. An Intent with a null
|
<!-- Capture file open requests (pathPattern is honoured) where no MIME type is provided in the Intent. An Intent with a null
|
||||||
|
|
|
@ -3792,4 +3792,6 @@
|
||||||
<string name="poi_socket_chademo_output_medium">Среднее</string>
|
<string name="poi_socket_chademo_output_medium">Среднее</string>
|
||||||
<string name="poi_socket_chademo_output_high">Высокое</string>
|
<string name="poi_socket_chademo_output_high">Высокое</string>
|
||||||
<string name="poi_fire_hydrant_pressure_filter">Давление</string>
|
<string name="poi_fire_hydrant_pressure_filter">Давление</string>
|
||||||
|
<string name="poi_pump_status_missing_beam">Состояние насоса: отсутствует рычаг</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -4228,4 +4228,6 @@
|
||||||
<string name="poi_osmand_fire_hydrant_pressure_pressurized">Pressurized</string>
|
<string name="poi_osmand_fire_hydrant_pressure_pressurized">Pressurized</string>
|
||||||
<string name="poi_osmand_fire_hydrant_pressure_suction">Suction</string>
|
<string name="poi_osmand_fire_hydrant_pressure_suction">Suction</string>
|
||||||
|
|
||||||
|
<string name="poi_pump_status_missing_beam">Pump status: missing beam</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -20,6 +20,7 @@ import java.io.BufferedOutputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
@ -127,6 +128,25 @@ public class AndroidNetworkUtils {
|
||||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void downloadFileAsync(final String url,
|
||||||
|
final File fileToSave,
|
||||||
|
final CallbackWithObject<String> listener) {
|
||||||
|
|
||||||
|
new AsyncTask<Void, Void, String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String doInBackground(Void... params) {
|
||||||
|
return downloadFile(url, fileToSave);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(String error) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.processResult(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
|
||||||
|
}
|
||||||
|
|
||||||
public static String sendRequest(OsmandApplication ctx, String url, Map<String, String> parameters,
|
public static String sendRequest(OsmandApplication ctx, String url, Map<String, String> parameters,
|
||||||
String userOperation, boolean toastAllowed, boolean post) {
|
String userOperation, boolean toastAllowed, boolean post) {
|
||||||
|
@ -247,6 +267,33 @@ public class AndroidNetworkUtils {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String downloadFile(@NonNull String url, @NonNull File fileToSave) {
|
||||||
|
String error = null;
|
||||||
|
try {
|
||||||
|
URLConnection connection = NetworkUtils.getHttpURLConnection(url);
|
||||||
|
connection.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||||
|
connection.setReadTimeout(CONNECTION_TIMEOUT);
|
||||||
|
BufferedInputStream inputStream = new BufferedInputStream(connection.getInputStream(), 8 * 1024);
|
||||||
|
fileToSave.getParentFile().mkdirs();
|
||||||
|
OutputStream stream = null;
|
||||||
|
try {
|
||||||
|
stream = new FileOutputStream(fileToSave);
|
||||||
|
Algorithms.streamCopy(inputStream, stream);
|
||||||
|
stream.flush();
|
||||||
|
} finally {
|
||||||
|
Algorithms.closeStream(inputStream);
|
||||||
|
Algorithms.closeStream(stream);
|
||||||
|
}
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
error = e.getMessage();
|
||||||
|
LOG.error("UnknownHostException, cannot download file " + url + " " + error);
|
||||||
|
} catch (Exception e) {
|
||||||
|
error = e.getMessage();
|
||||||
|
LOG.warn("Cannot download file : " + url, e);
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
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(String urlText, File file, boolean gzip, Map<String, String> additionalParams) throws IOException {
|
||||||
|
|
|
@ -23,6 +23,8 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
|
|
||||||
private static final String HIDDEN = "hidden";
|
private static final String HIDDEN = "hidden";
|
||||||
private static final String ADDRESS_EXTENSION = "address";
|
private static final String ADDRESS_EXTENSION = "address";
|
||||||
|
public static final BackgroundType DEFAULT_BACKGROUND_TYPE = BackgroundType.CIRCLE;
|
||||||
|
public static final int DEFAULT_UI_ICON_ID = R.drawable.mx_special_star;
|
||||||
|
|
||||||
protected String name = "";
|
protected String name = "";
|
||||||
protected String description;
|
protected String description;
|
||||||
|
@ -97,7 +99,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIconId() {
|
public int getIconId() {
|
||||||
return iconId == 0 ? R.drawable.mx_special_star : iconId;
|
return iconId == 0 ? DEFAULT_UI_ICON_ID : iconId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIconEntryName(Context ctx) {
|
public String getIconEntryName(Context ctx) {
|
||||||
|
@ -202,7 +204,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackgroundType getBackgroundType() {
|
public BackgroundType getBackgroundType() {
|
||||||
return backgroundType == null ? BackgroundType.CIRCLE : backgroundType;
|
return backgroundType == null ? DEFAULT_BACKGROUND_TYPE : backgroundType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBackgroundType(BackgroundType backgroundType) {
|
public void setBackgroundType(BackgroundType backgroundType) {
|
||||||
|
@ -363,7 +365,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
if (iconName != null) {
|
if (iconName != null) {
|
||||||
fp.setIconIdFromName(ctx, iconName);
|
fp.setIconIdFromName(ctx, iconName);
|
||||||
}
|
}
|
||||||
BackgroundType backgroundType = BackgroundType.getByTypeName(pt.getBackgroundType(), BackgroundType.CIRCLE);
|
BackgroundType backgroundType = BackgroundType.getByTypeName(pt.getBackgroundType(), null);
|
||||||
fp.setBackgroundType(backgroundType);
|
fp.setBackgroundType(backgroundType);
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
@ -381,7 +383,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
if (iconId != 0) {
|
if (iconId != 0) {
|
||||||
pt.setIconName(getIconEntryName(ctx).substring(3));
|
pt.setIconName(getIconEntryName(ctx).substring(3));
|
||||||
}
|
}
|
||||||
if(backgroundType != null) {
|
if (backgroundType != null) {
|
||||||
pt.setBackgroundType(backgroundType.typeName);
|
pt.setBackgroundType(backgroundType.typeName);
|
||||||
}
|
}
|
||||||
if (getColor() != 0) {
|
if (getColor() != 0) {
|
||||||
|
|
|
@ -83,6 +83,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import btools.routingapp.BRouterServiceConnection;
|
import btools.routingapp.BRouterServiceConnection;
|
||||||
|
|
||||||
|
import static net.osmand.plus.AppVersionUpgradeOnInit.LAST_APP_VERSION;
|
||||||
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
|
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
|
||||||
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
|
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
|
||||||
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn;
|
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn;
|
||||||
|
@ -94,27 +95,10 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.setAlarmForPendingIn
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class AppInitializer implements IProgress {
|
public class AppInitializer implements IProgress {
|
||||||
// 22 - 2.2
|
|
||||||
public static final int VERSION_2_2 = 22;
|
|
||||||
// 23 - 2.3
|
|
||||||
public static final int VERSION_2_3 = 23;
|
|
||||||
// 32 - 3.2
|
|
||||||
public static final int VERSION_3_2 = 32;
|
|
||||||
// 35 - 3.5
|
|
||||||
public static final int VERSION_3_5 = 35;
|
|
||||||
// 36 - 3.6
|
|
||||||
public static final int VERSION_3_6 = 36;
|
|
||||||
// 37 - 3.7
|
|
||||||
public static final int VERSION_3_7 = 37;
|
|
||||||
|
|
||||||
|
|
||||||
public static final boolean TIPS_AND_TRICKS = false;
|
public static final boolean TIPS_AND_TRICKS = false;
|
||||||
public static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$
|
|
||||||
public static final String VERSION_INSTALLED_NUMBER = "VERSION_INSTALLED_NUMBER"; //$NON-NLS-1$
|
|
||||||
public static final String NUMBER_OF_STARTS = "NUMBER_OF_STARTS"; //$NON-NLS-1$
|
|
||||||
public static final String FIRST_INSTALLED = "FIRST_INSTALLED"; //$NON-NLS-1$
|
|
||||||
private static final String VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$NON-NLS-1$
|
private static final String VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$NON-NLS-1$
|
||||||
private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$
|
|
||||||
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
|
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String LATEST_CHANGES_URL = "https://osmand.net/blog/osmand-3-7-released";
|
public static final String LATEST_CHANGES_URL = "https://osmand.net/blog/osmand-3-7-released";
|
||||||
|
@ -122,13 +106,11 @@ public class AppInitializer implements IProgress {
|
||||||
public static final int APP_EXIT_CODE = 4;
|
public static final int APP_EXIT_CODE = 4;
|
||||||
public static final String APP_EXIT_KEY = "APP_EXIT_KEY";
|
public static final String APP_EXIT_KEY = "APP_EXIT_KEY";
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
private AppVersionUpgradeOnInit appVersionUpgrade;
|
||||||
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(AppInitializer.class);
|
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(AppInitializer.class);
|
||||||
|
|
||||||
private boolean initSettings = false;
|
private boolean initSettings = false;
|
||||||
private boolean firstTime;
|
|
||||||
private boolean activityChangesShowed = false;
|
private boolean activityChangesShowed = false;
|
||||||
private boolean appVersionChanged;
|
|
||||||
private int prevAppVersion;
|
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private long startBgTime;
|
private long startBgTime;
|
||||||
private boolean appInitializing = true;
|
private boolean appInitializing = true;
|
||||||
|
@ -158,6 +140,7 @@ public class AppInitializer implements IProgress {
|
||||||
|
|
||||||
public AppInitializer(OsmandApplication app) {
|
public AppInitializer(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
appVersionUpgrade = new AppVersionUpgradeOnInit(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,105 +162,38 @@ public class AppInitializer implements IProgress {
|
||||||
startPrefs = app.getSharedPreferences(
|
startPrefs = app.getSharedPreferences(
|
||||||
getLocalClassName(app.getAppCustomization().getMapActivity().getName()),
|
getLocalClassName(app.getAppCustomization().getMapActivity().getName()),
|
||||||
Context.MODE_PRIVATE);
|
Context.MODE_PRIVATE);
|
||||||
if(!startPrefs.contains(NUMBER_OF_STARTS)) {
|
appVersionUpgrade.upgradeVersion(startPrefs, LAST_APP_VERSION);
|
||||||
startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit();
|
|
||||||
} else {
|
|
||||||
startPrefs.edit().putInt(NUMBER_OF_STARTS, startPrefs.getInt(NUMBER_OF_STARTS, 0) + 1).commit();
|
|
||||||
}
|
|
||||||
if (!startPrefs.contains(FIRST_INSTALLED)) {
|
|
||||||
startPrefs.edit().putLong(FIRST_INSTALLED, System.currentTimeMillis()).commit();
|
|
||||||
}
|
|
||||||
if (!startPrefs.contains(FIRST_TIME_APP_RUN)) {
|
|
||||||
firstTime = true;
|
|
||||||
startPrefs.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
|
|
||||||
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit();
|
|
||||||
} else if (!Version.getFullVersion(app).equals(startPrefs.getString(VERSION_INSTALLED, ""))) {
|
|
||||||
prevAppVersion = startPrefs.getInt(VERSION_INSTALLED_NUMBER, 0);
|
|
||||||
if(prevAppVersion < VERSION_2_2) {
|
|
||||||
app.getSettings().SHOW_DASHBOARD_ON_START.set(true);
|
|
||||||
app.getSettings().SHOW_DASHBOARD_ON_MAP_SCREEN.set(true);
|
|
||||||
app.getSettings().SHOW_CARD_TO_CHOOSE_DRAWER.set(true);
|
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_2).commit();
|
|
||||||
}
|
|
||||||
if(prevAppVersion < VERSION_2_3) {
|
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_3).commit();
|
|
||||||
}
|
|
||||||
if (prevAppVersion < VERSION_3_2) {
|
|
||||||
app.getSettings().BILLING_PURCHASE_TOKENS_SENT.set("");
|
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit();
|
|
||||||
}
|
|
||||||
if (prevAppVersion < VERSION_3_5 || Version.getAppVersion(app).equals("3.5.3")
|
|
||||||
|| Version.getAppVersion(app).equals("3.5.4")) {
|
|
||||||
app.getSettings().migratePreferences();
|
|
||||||
addListener(new AppInitializeListener() {
|
|
||||||
@Override
|
|
||||||
public void onProgress(AppInitializer init, InitEvents event) {
|
|
||||||
if (event.equals(InitEvents.FAVORITES_INITIALIZED)) {
|
|
||||||
app.getSettings().migrateHomeWorkParkingToFavorites();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish(AppInitializer init) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit();
|
|
||||||
}
|
|
||||||
if (prevAppVersion < VERSION_3_6) {
|
|
||||||
app.getSettings().migratePreferences();
|
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_6).commit();
|
|
||||||
}
|
|
||||||
if (prevAppVersion < VERSION_3_7) {
|
|
||||||
app.getSettings().migrateEnumPreferences();
|
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_7).commit();
|
|
||||||
}
|
|
||||||
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
|
||||||
appVersionChanged = true;
|
|
||||||
}
|
|
||||||
app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(true);
|
|
||||||
app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(true);
|
|
||||||
initSettings = true;
|
initSettings = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfStarts() {
|
public int getNumberOfStarts() {
|
||||||
if(startPrefs == null) {
|
return appVersionUpgrade.getNumberOfStarts(startPrefs);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return startPrefs.getInt(NUMBER_OF_STARTS, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getFirstInstalledDays() {
|
public long getFirstInstalledDays() {
|
||||||
if(startPrefs == null) {
|
return appVersionUpgrade.getFirstInstalledDays(startPrefs);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
long nd = startPrefs.getLong(FIRST_INSTALLED, 0);
|
|
||||||
|
|
||||||
return (System.currentTimeMillis() - nd) / (1000l * 24l * 60l * 60l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetFirstTimeRun() {
|
public void resetFirstTimeRun() {
|
||||||
if(startPrefs != null) {
|
appVersionUpgrade.resetFirstTimeRun(startPrefs);
|
||||||
startPrefs.edit().remove(FIRST_TIME_APP_RUN).commit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFirstTime() {
|
public boolean isFirstTime() {
|
||||||
initVariables();
|
initVariables();
|
||||||
return firstTime;
|
return appVersionUpgrade.isFirstTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAppVersionChanged() {
|
public boolean isAppVersionChanged() {
|
||||||
return appVersionChanged;
|
return appVersionUpgrade.isAppVersionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPrevAppVersion() {
|
public int getPrevAppVersion() {
|
||||||
return prevAppVersion;
|
return appVersionUpgrade.getPrevAppVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkAppVersionChanged() {
|
public boolean checkAppVersionChanged() {
|
||||||
initVariables();
|
initVariables();
|
||||||
boolean showRecentChangesDialog = !firstTime && appVersionChanged;
|
boolean showRecentChangesDialog = !isFirstTime() && isAppVersionChanged();
|
||||||
// showRecentChangesDialog = true;
|
// showRecentChangesDialog = true;
|
||||||
if (showRecentChangesDialog && !activityChangesShowed) {
|
if (showRecentChangesDialog && !activityChangesShowed) {
|
||||||
activityChangesShowed = true;
|
activityChangesShowed = true;
|
||||||
|
@ -303,7 +219,7 @@ public class AppInitializer implements IProgress {
|
||||||
long size = activity.getPreferences(Context.MODE_PRIVATE).getLong(EXCEPTION_FILE_SIZE, 0);
|
long size = activity.getPreferences(Context.MODE_PRIVATE).getLong(EXCEPTION_FILE_SIZE, 0);
|
||||||
final File file = app.getAppPath(OsmandApplication.EXCEPTION_PATH);
|
final File file = app.getAppPath(OsmandApplication.EXCEPTION_PATH);
|
||||||
if (file.exists() && file.length() > 0) {
|
if (file.exists() && file.length() > 0) {
|
||||||
if (size != file.length() && !firstTime) {
|
if (size != file.length() && !isFirstTime()) {
|
||||||
if (writeFileSize) {
|
if (writeFileSize) {
|
||||||
activity.getPreferences(Context.MODE_PRIVATE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
|
activity.getPreferences(Context.MODE_PRIVATE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
|
||||||
}
|
}
|
||||||
|
@ -1021,6 +937,6 @@ public class AppInitializer implements IProgress {
|
||||||
|| cls.charAt(packageLen) != '.') {
|
|| cls.charAt(packageLen) != '.') {
|
||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
return cls.substring(packageLen+1);
|
return cls.substring(packageLen + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
157
OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java
Normal file
157
OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
package net.osmand.plus;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
class AppVersionUpgradeOnInit {
|
||||||
|
public static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$
|
||||||
|
public static final String VERSION_INSTALLED_NUMBER = "VERSION_INSTALLED_NUMBER"; //$NON-NLS-1$
|
||||||
|
public static final String NUMBER_OF_STARTS = "NUMBER_OF_STARTS"; //$NON-NLS-1$
|
||||||
|
public static final String FIRST_INSTALLED = "FIRST_INSTALLED"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
// 22 - 2.2
|
||||||
|
public static final int VERSION_2_2 = 22;
|
||||||
|
// 23 - 2.3
|
||||||
|
public static final int VERSION_2_3 = 23;
|
||||||
|
// 32 - 3.2
|
||||||
|
public static final int VERSION_3_2 = 32;
|
||||||
|
// 35 - 3.5
|
||||||
|
public static final int VERSION_3_5 = 35;
|
||||||
|
// 36 - 3.6
|
||||||
|
public static final int VERSION_3_6 = 36;
|
||||||
|
// 37 - 3.7
|
||||||
|
public static final int VERSION_3_7 = 37;
|
||||||
|
// 3701 - 3.7-01 (4 digits version)
|
||||||
|
// Each upgrade should have independent version!
|
||||||
|
// So, we could have multiple upgrades per 1 release i.e. 3701, 3702, 3703, ... - will be for 3.7
|
||||||
|
public static final int VERSION_3_7_01 = 3701;
|
||||||
|
|
||||||
|
|
||||||
|
public static final int LAST_APP_VERSION = VERSION_3_7_01;
|
||||||
|
|
||||||
|
static final String VERSION_INSTALLED = "VERSION_INSTALLED";
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
private int prevAppVersion;
|
||||||
|
private boolean appVersionChanged;
|
||||||
|
private boolean firstTime;
|
||||||
|
|
||||||
|
AppVersionUpgradeOnInit(OsmandApplication app) {
|
||||||
|
this.app = app;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ApplySharedPref")
|
||||||
|
void upgradeVersion(SharedPreferences startPrefs, int lastVersion) {
|
||||||
|
if(!startPrefs.contains(NUMBER_OF_STARTS)) {
|
||||||
|
startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit();
|
||||||
|
} else {
|
||||||
|
startPrefs.edit().putInt(NUMBER_OF_STARTS, startPrefs.getInt(NUMBER_OF_STARTS, 0) + 1).commit();
|
||||||
|
}
|
||||||
|
if (!startPrefs.contains(FIRST_INSTALLED)) {
|
||||||
|
startPrefs.edit().putLong(FIRST_INSTALLED, System.currentTimeMillis()).commit();
|
||||||
|
}
|
||||||
|
if (!startPrefs.contains(FIRST_TIME_APP_RUN)) {
|
||||||
|
firstTime = true;
|
||||||
|
startPrefs.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
|
||||||
|
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||||
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, lastVersion).commit();
|
||||||
|
} else {
|
||||||
|
prevAppVersion = startPrefs.getInt(VERSION_INSTALLED_NUMBER, 0);
|
||||||
|
if (needsUpgrade(startPrefs, lastVersion)) {
|
||||||
|
if (prevAppVersion < VERSION_2_2) {
|
||||||
|
app.getSettings().SHOW_DASHBOARD_ON_START.set(true);
|
||||||
|
app.getSettings().SHOW_DASHBOARD_ON_MAP_SCREEN.set(true);
|
||||||
|
app.getSettings().SHOW_CARD_TO_CHOOSE_DRAWER.set(true);
|
||||||
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_2).commit();
|
||||||
|
}
|
||||||
|
if (prevAppVersion < VERSION_2_3) {
|
||||||
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_3).commit();
|
||||||
|
}
|
||||||
|
if (prevAppVersion < VERSION_3_2) {
|
||||||
|
app.getSettings().BILLING_PURCHASE_TOKENS_SENT.set("");
|
||||||
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit();
|
||||||
|
}
|
||||||
|
if (prevAppVersion < VERSION_3_5 || Version.getAppVersion(app).equals("3.5.3")
|
||||||
|
|| Version.getAppVersion(app).equals("3.5.4")) {
|
||||||
|
app.getSettings().migratePreferences();
|
||||||
|
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
|
||||||
|
@Override
|
||||||
|
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
|
||||||
|
if (event.equals(AppInitializer.InitEvents.FAVORITES_INITIALIZED)) {
|
||||||
|
app.getSettings().migrateHomeWorkParkingToFavorites();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish(AppInitializer init) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit();
|
||||||
|
}
|
||||||
|
if (prevAppVersion < VERSION_3_6) {
|
||||||
|
app.getSettings().migratePreferences();
|
||||||
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_6).commit();
|
||||||
|
}
|
||||||
|
if (prevAppVersion < VERSION_3_7) {
|
||||||
|
app.getSettings().migrateEnumPreferences();
|
||||||
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_7).commit();
|
||||||
|
}
|
||||||
|
if (prevAppVersion < VERSION_3_7_01) {
|
||||||
|
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
|
||||||
|
@Override
|
||||||
|
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
|
||||||
|
if (event.equals(AppInitializer.InitEvents.FAVORITES_INITIALIZED)) {
|
||||||
|
app.getFavorites().fixBlackBackground();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onFinish(AppInitializer init) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_7_01).commit();
|
||||||
|
}
|
||||||
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, lastVersion).commit();
|
||||||
|
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||||
|
appVersionChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean needsUpgrade(SharedPreferences startPrefs, int maxVersion) {
|
||||||
|
return !(Version.getFullVersion(app)).equals(startPrefs.getString(VERSION_INSTALLED, "")) || prevAppVersion < maxVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isAppVersionChanged() {
|
||||||
|
return appVersionChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPrevAppVersion() {
|
||||||
|
return prevAppVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetFirstTimeRun(SharedPreferences startPrefs) {
|
||||||
|
if(startPrefs != null) {
|
||||||
|
startPrefs.edit().remove(FIRST_TIME_APP_RUN).commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumberOfStarts(SharedPreferences startPrefs) {
|
||||||
|
if(startPrefs == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return startPrefs.getInt(NUMBER_OF_STARTS, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getFirstInstalledDays(SharedPreferences startPrefs) {
|
||||||
|
if(startPrefs == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
long nd = startPrefs.getLong(FIRST_INSTALLED, 0);
|
||||||
|
|
||||||
|
return (System.currentTimeMillis() - nd) / (1000l * 24l * 60l * 60l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFirstTime() {
|
||||||
|
return firstTime;
|
||||||
|
}
|
||||||
|
}
|
|
@ -173,6 +173,31 @@ public class FavouritesDbHelper {
|
||||||
saveCurrentPointsIntoFile();
|
saveCurrentPointsIntoFile();
|
||||||
}
|
}
|
||||||
favoritesLoaded = true;
|
favoritesLoaded = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void fixBlackBackground() {
|
||||||
|
flatGroups.clear();
|
||||||
|
favoriteGroups.clear();
|
||||||
|
for (FavouritePoint fp : cachedFavoritePoints) {
|
||||||
|
if (fp.getColor() == 0xFF000000 || fp.getColor() == ContextCompat.getColor(context, R.color.color_favorite)) {
|
||||||
|
fp.setColor(0);
|
||||||
|
}
|
||||||
|
if (fp.getBackgroundType() == FavouritePoint.DEFAULT_BACKGROUND_TYPE){
|
||||||
|
fp.setBackgroundType(null);
|
||||||
|
}
|
||||||
|
if(fp.getIconId()== FavouritePoint.DEFAULT_UI_ICON_ID){
|
||||||
|
fp.setIconId(0);
|
||||||
|
}
|
||||||
|
FavoriteGroup group = getOrCreateGroup(fp, 0);
|
||||||
|
group.points.add(fp);
|
||||||
|
}
|
||||||
|
sortAll();
|
||||||
|
saveCurrentPointsIntoFile();
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyListeners() {
|
||||||
context.runInUIThread(new Runnable() {
|
context.runInUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
appCustomization.setup(this);
|
appCustomization.setup(this);
|
||||||
osmandSettings = appCustomization.getOsmandSettings();
|
osmandSettings = appCustomization.getOsmandSettings();
|
||||||
appInitializer.initVariables();
|
appInitializer.initVariables();
|
||||||
if (appInitializer.isAppVersionChanged() && appInitializer.getPrevAppVersion() < AppInitializer.VERSION_2_3) {
|
if (appInitializer.isAppVersionChanged() && appInitializer.getPrevAppVersion() < AppVersionUpgradeOnInit.VERSION_2_3) {
|
||||||
osmandSettings.freezeExternalStorageDirectory();
|
osmandSettings.freezeExternalStorageDirectory();
|
||||||
} else if (appInitializer.isFirstTime()) {
|
} else if (appInitializer.isFirstTime()) {
|
||||||
osmandSettings.initExternalStorageDirectory();
|
osmandSettings.initExternalStorageDirectory();
|
||||||
|
|
|
@ -3800,9 +3800,6 @@ public class OsmandSettings {
|
||||||
|
|
||||||
public final OsmandPreference<String> SELECTED_TRAVEL_BOOK = new StringPreference("selected_travel_book", "").makeGlobal();
|
public final OsmandPreference<String> SELECTED_TRAVEL_BOOK = new StringPreference("selected_travel_book", "").makeGlobal();
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> SHOW_TRAVEL_UPDATE_CARD = new BooleanPreference("show_travel_update_card", true).makeGlobal();
|
|
||||||
public final OsmandPreference<Boolean> SHOW_TRAVEL_NEEDED_MAPS_CARD = new BooleanPreference("show_travel_needed_maps_card", true).makeGlobal();
|
|
||||||
|
|
||||||
public final ListStringPreference DISPLAYED_TRANSPORT_SETTINGS = (ListStringPreference)
|
public final ListStringPreference DISPLAYED_TRANSPORT_SETTINGS = (ListStringPreference)
|
||||||
new ListStringPreference("displayed_transport_settings", null, ",").makeProfile();
|
new ListStringPreference("displayed_transport_settings", null, ",").makeProfile();
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentManager.BackStackEntry;
|
import androidx.fragment.app.FragmentManager.BackStackEntry;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
@ -62,15 +63,12 @@ import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.map.MapTileDownloader.DownloadRequest;
|
import net.osmand.map.MapTileDownloader.DownloadRequest;
|
||||||
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
|
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
|
||||||
import net.osmand.map.TileSourceManager;
|
|
||||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
|
||||||
import net.osmand.plus.AppInitializer;
|
import net.osmand.plus.AppInitializer;
|
||||||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||||
import net.osmand.plus.AppInitializer.InitEvents;
|
import net.osmand.plus.AppInitializer.InitEvents;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
import net.osmand.plus.HuaweiDrmHelper;
|
import net.osmand.plus.HuaweiDrmHelper;
|
||||||
import net.osmand.plus.MapMarkersHelper;
|
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||||
import net.osmand.plus.OnDismissDialogFragmentListener;
|
import net.osmand.plus.OnDismissDialogFragmentListener;
|
||||||
|
@ -103,11 +101,13 @@ import net.osmand.plus.firstusage.FirstUsageWelcomeFragment;
|
||||||
import net.osmand.plus.firstusage.FirstUsageWizardFragment;
|
import net.osmand.plus.firstusage.FirstUsageWizardFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.DiscountHelper;
|
import net.osmand.plus.helpers.DiscountHelper;
|
||||||
import net.osmand.plus.helpers.ExternalApiHelper;
|
|
||||||
import net.osmand.plus.helpers.ImportHelper;
|
import net.osmand.plus.helpers.ImportHelper;
|
||||||
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
|
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.helpers.IntentHelper;
|
||||||
import net.osmand.plus.helpers.LockHelper;
|
import net.osmand.plus.helpers.LockHelper;
|
||||||
|
import net.osmand.plus.helpers.LockHelper.LockUIAdapter;
|
||||||
import net.osmand.plus.helpers.ScrollHelper;
|
import net.osmand.plus.helpers.ScrollHelper;
|
||||||
|
import net.osmand.plus.helpers.ScrollHelper.OnScrollEventListener;
|
||||||
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
|
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
|
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
|
||||||
|
@ -162,10 +162,8 @@ import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -173,8 +171,6 @@ import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
|
||||||
import static net.osmand.plus.OsmandSettings.GENERIC_EXTERNAL_DEVICE;
|
import static net.osmand.plus.OsmandSettings.GENERIC_EXTERNAL_DEVICE;
|
||||||
|
@ -184,8 +180,8 @@ import static net.osmand.plus.OsmandSettings.WUNDERLINQ_EXTERNAL_DEVICE;
|
||||||
public class MapActivity extends OsmandActionBarActivity implements DownloadEvents,
|
public class MapActivity extends OsmandActionBarActivity implements DownloadEvents,
|
||||||
OnRequestPermissionsResultCallback, IRouteInformationListener, AMapPointUpdateListener,
|
OnRequestPermissionsResultCallback, IRouteInformationListener, AMapPointUpdateListener,
|
||||||
MapMarkerChangedListener, OnDismissDialogFragmentListener, OnDrawMapListener,
|
MapMarkerChangedListener, OnDismissDialogFragmentListener, OnDrawMapListener,
|
||||||
OsmAndAppCustomizationListener, LockHelper.LockUIAdapter, PreferenceFragmentCompat.OnPreferenceStartFragmentCallback,
|
OsmAndAppCustomizationListener, LockUIAdapter, OnPreferenceStartFragmentCallback,
|
||||||
ScrollHelper.OnScrollEventListener {
|
OnScrollEventListener {
|
||||||
|
|
||||||
public static final String INTENT_KEY_PARENT_MAP_ACTIVITY = "intent_parent_map_activity_key";
|
public static final String INTENT_KEY_PARENT_MAP_ACTIVITY = "intent_parent_map_activity_key";
|
||||||
public static final String INTENT_PARAMS = "intent_prarams";
|
public static final String INTENT_PARAMS = "intent_prarams";
|
||||||
|
@ -227,13 +223,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
|
||||||
private boolean landscapeLayout;
|
private LockHelper lockHelper;
|
||||||
|
private ImportHelper importHelper;
|
||||||
|
private IntentHelper intentHelper;
|
||||||
|
private ScrollHelper mapScrollHelper;
|
||||||
|
|
||||||
private Dialog progressDlg = null;
|
private boolean landscapeLayout;
|
||||||
|
|
||||||
private List<DialogProvider> dialogProviders = new ArrayList<>(2);
|
private List<DialogProvider> dialogProviders = new ArrayList<>(2);
|
||||||
private StateChangedListener<ApplicationMode> applicationModeListener;
|
private StateChangedListener<ApplicationMode> applicationModeListener;
|
||||||
private ImportHelper importHelper;
|
|
||||||
private boolean intentLocation = false;
|
private boolean intentLocation = false;
|
||||||
|
|
||||||
private DashboardOnMap dashboardOnMap = new DashboardOnMap(this);
|
private DashboardOnMap dashboardOnMap = new DashboardOnMap(this);
|
||||||
|
@ -253,8 +251,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
private boolean stopped = true;
|
private boolean stopped = true;
|
||||||
|
|
||||||
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||||||
private LockHelper lockHelper;
|
|
||||||
private ScrollHelper mapScrollHelper;
|
|
||||||
|
|
||||||
private StateChangedListener<Integer> mapScreenOrientationSettingListener = new StateChangedListener<Integer>() {
|
private StateChangedListener<Integer> mapScreenOrientationSettingListener = new StateChangedListener<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -304,11 +300,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
AndroidUtils.addStatusBarPadding21v(this, findViewById(R.id.menuItems));
|
AndroidUtils.addStatusBarPadding21v(this, findViewById(R.id.menuItems));
|
||||||
}
|
}
|
||||||
|
|
||||||
int statusBarHeight = 0;
|
int statusBarHeight = AndroidUtils.getStatusBarHeight(this);
|
||||||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
|
||||||
if (resourceId > 0) {
|
|
||||||
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
|
||||||
}
|
|
||||||
DisplayMetrics dm = new DisplayMetrics();
|
DisplayMetrics dm = new DisplayMetrics();
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(dm);
|
getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||||
int w = dm.widthPixels;
|
int w = dm.widthPixels;
|
||||||
|
@ -327,7 +320,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
}
|
}
|
||||||
dashboardOnMap.createDashboardView();
|
dashboardOnMap.createDashboardView();
|
||||||
checkAppInitialization();
|
checkAppInitialization();
|
||||||
parseLaunchIntents();
|
|
||||||
|
intentHelper = new IntentHelper(this, getMyApplication());
|
||||||
|
intentHelper.parseLaunchIntents();
|
||||||
|
|
||||||
mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener() {
|
mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTrackBallEvent(MotionEvent e) {
|
public boolean onTrackBallEvent(MotionEvent e) {
|
||||||
|
@ -769,7 +765,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
@Override
|
@Override
|
||||||
protected void onRestart() {
|
protected void onRestart() {
|
||||||
super.onRestart();
|
super.onRestart();
|
||||||
parseLaunchIntents();
|
intentHelper.parseLaunchIntents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -858,68 +854,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
OsmandPlugin.checkInstalledMarketPlugins(app, this);
|
OsmandPlugin.checkInstalledMarketPlugins(app, this);
|
||||||
OsmandPlugin.onMapActivityResume(this);
|
OsmandPlugin.onMapActivityResume(this);
|
||||||
|
|
||||||
boolean showOsmAndWelcomeScreen = true;
|
intentHelper.parseContentIntent();
|
||||||
final Intent intent = getIntent();
|
|
||||||
if (intent != null) {
|
|
||||||
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
|
||||||
final Uri data = intent.getData();
|
|
||||||
if (data != null) {
|
|
||||||
final String scheme = data.getScheme();
|
|
||||||
if ("file".equals(scheme)) {
|
|
||||||
final String path = data.getPath();
|
|
||||||
if (path != null) {
|
|
||||||
importHelper.handleFileImport(data, new File(path).getName(), intent.getExtras(), true);
|
|
||||||
}
|
|
||||||
clearIntent(intent);
|
|
||||||
} else if ("content".equals(scheme)) {
|
|
||||||
importHelper.handleContentImport(data, intent.getExtras(), true);
|
|
||||||
clearIntent(intent);
|
|
||||||
} else if ("google.navigation".equals(scheme) || "osmand.navigation".equals(scheme)) {
|
|
||||||
parseNavigationIntent(data);
|
|
||||||
} else if ("osmand.api".equals(scheme)) {
|
|
||||||
ExternalApiHelper apiHelper = new ExternalApiHelper(this);
|
|
||||||
Intent result = apiHelper.processApiRequest(intent);
|
|
||||||
setResult(apiHelper.getResultCode(), result);
|
|
||||||
result.setAction(null);
|
|
||||||
setIntent(result);
|
|
||||||
if (apiHelper.needFinish()) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (intent.hasExtra(FirstUsageWelcomeFragment.SHOW_OSMAND_WELCOME_SCREEN)) {
|
|
||||||
showOsmAndWelcomeScreen = intent.getBooleanExtra(FirstUsageWelcomeFragment.SHOW_OSMAND_WELCOME_SCREEN, true);
|
|
||||||
}
|
|
||||||
if (intent.hasExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS)) {
|
|
||||||
Bundle openMapMarkersGroupsExtra = intent.getBundleExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS);
|
|
||||||
if (openMapMarkersGroupsExtra != null) {
|
|
||||||
MapMarkersDialogFragment.showInstance(this, openMapMarkersGroupsExtra.getString(MapMarkersHelper.MapMarkersGroup.MARKERS_SYNC_GROUP_ID));
|
|
||||||
}
|
|
||||||
setIntent(null);
|
|
||||||
}
|
|
||||||
if (intent.hasExtra(BaseSettingsFragment.OPEN_SETTINGS)) {
|
|
||||||
String settingsType = intent.getStringExtra(BaseSettingsFragment.OPEN_SETTINGS);
|
|
||||||
String appMode = intent.getStringExtra(BaseSettingsFragment.APP_MODE_KEY);
|
|
||||||
if (BaseSettingsFragment.OPEN_CONFIG_PROFILE.equals(settingsType)) {
|
|
||||||
BaseSettingsFragment.showInstance(this, SettingsScreenType.CONFIGURE_PROFILE, ApplicationMode.valueOfStringKey(appMode, null));
|
|
||||||
}
|
|
||||||
setIntent(null);
|
|
||||||
}
|
|
||||||
if (intent.hasExtra(BaseSettingsFragment.OPEN_CONFIG_ON_MAP)) {
|
|
||||||
switch (intent.getStringExtra(BaseSettingsFragment.OPEN_CONFIG_ON_MAP)) {
|
|
||||||
case BaseSettingsFragment.MAP_CONFIG:
|
|
||||||
this.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, null);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BaseSettingsFragment.SCREEN_CONFIG:
|
|
||||||
this.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, null);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
setIntent(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
mapView.refreshMap(true);
|
mapView.refreshMap(true);
|
||||||
if (atlasMapRendererView != null) {
|
if (atlasMapRendererView != null) {
|
||||||
atlasMapRendererView.handleOnResume();
|
atlasMapRendererView.handleOnResume();
|
||||||
|
@ -947,6 +882,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
|
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean showOsmAndWelcomeScreen = true;
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
if (intent != null && intent.hasExtra(FirstUsageWelcomeFragment.SHOW_OSMAND_WELCOME_SCREEN)) {
|
||||||
|
showOsmAndWelcomeScreen = intent.getBooleanExtra(FirstUsageWelcomeFragment.SHOW_OSMAND_WELCOME_SCREEN, true);
|
||||||
|
}
|
||||||
boolean showWelcomeScreen = ((app.getAppInitializer().isFirstTime() && Version.isDeveloperVersion(app)) || !app.getResourceManager().isAnyMapInstalled())
|
boolean showWelcomeScreen = ((app.getAppInitializer().isFirstTime() && Version.isDeveloperVersion(app)) || !app.getResourceManager().isAnyMapInstalled())
|
||||||
&& FirstUsageWelcomeFragment.SHOW && settings.SHOW_OSMAND_WELCOME_SCREEN.get() && showOsmAndWelcomeScreen;
|
&& FirstUsageWelcomeFragment.SHOW && settings.SHOW_OSMAND_WELCOME_SCREEN.get() && showOsmAndWelcomeScreen;
|
||||||
|
|
||||||
|
@ -1035,11 +975,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearIntent(Intent intent) {
|
|
||||||
intent.setAction(null);
|
|
||||||
intent.setData(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateStatusBarColor() {
|
public void updateStatusBarColor() {
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
int colorId = -1;
|
int colorId = -1;
|
||||||
|
@ -1233,32 +1168,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseNavigationIntent(final Uri data) {
|
|
||||||
final String schemeSpecificPart = data.getSchemeSpecificPart();
|
|
||||||
|
|
||||||
final Matcher matcher = Pattern.compile("(?:q|ll)=([\\-0-9.]+),([\\-0-9.]+)(?:.*)").matcher(
|
|
||||||
schemeSpecificPart);
|
|
||||||
if (matcher.matches()) {
|
|
||||||
try {
|
|
||||||
final double lat = Double.valueOf(matcher.group(1));
|
|
||||||
final double lon = Double.valueOf(matcher.group(2));
|
|
||||||
|
|
||||||
getMyApplication().getTargetPointsHelper().navigateToPoint(new LatLon(lat, lon), false,
|
|
||||||
-1);
|
|
||||||
getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, false, true);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Toast.makeText(this,
|
|
||||||
getString(R.string.navigation_intent_invalid, schemeSpecificPart),
|
|
||||||
Toast.LENGTH_LONG).show(); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.makeText(this,
|
|
||||||
getString(R.string.navigation_intent_invalid, schemeSpecificPart),
|
|
||||||
Toast.LENGTH_LONG).show(); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
clearIntent(getIntent());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readLocationToShow() {
|
public void readLocationToShow() {
|
||||||
showMapControls();
|
showMapControls();
|
||||||
|
|
||||||
|
@ -1438,18 +1347,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
getMyApplication().getNotificationHelper().showNotifications();
|
getMyApplication().getNotificationHelper().showNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setProgressDlg(Dialog progressDlg) {
|
|
||||||
this.progressDlg = progressDlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Dialog getProgressDlg() {
|
|
||||||
return progressDlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
getMyApplication().getNotificationHelper().removeNotifications(true);
|
getMyApplication().getNotificationHelper().removeNotifications(true);
|
||||||
if(pendingPause) {
|
if (pendingPause) {
|
||||||
onPauseActivity();
|
onPauseActivity();
|
||||||
}
|
}
|
||||||
stopped = true;
|
stopped = true;
|
||||||
|
@ -1746,80 +1647,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
return mapViewTrackingUtilities;
|
return mapViewTrackingUtilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean parseLaunchIntents() {
|
|
||||||
boolean applied = parseLocationIntent();
|
|
||||||
if (!applied) {
|
|
||||||
applied = parseTileSourceIntent();
|
|
||||||
}
|
|
||||||
return applied;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean parseLocationIntent() {
|
|
||||||
Intent intent = getIntent();
|
|
||||||
if (intent != null && intent.getData() != null) {
|
|
||||||
Uri data = intent.getData();
|
|
||||||
if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme())) && data.getHost() != null && data.getHost().contains("osmand.net") &&
|
|
||||||
data.getPath() != null && data.getPath().startsWith("/go")) {
|
|
||||||
String lat = data.getQueryParameter("lat");
|
|
||||||
String lon = data.getQueryParameter("lon");
|
|
||||||
String url = data.getQueryParameter("url");
|
|
||||||
if (lat != null && lon != null) {
|
|
||||||
try {
|
|
||||||
double lt = Double.parseDouble(lat);
|
|
||||||
double ln = Double.parseDouble(lon);
|
|
||||||
String zoom = data.getQueryParameter("z");
|
|
||||||
int z = settings.getLastKnownMapZoom();
|
|
||||||
if (zoom != null) {
|
|
||||||
z = Integer.parseInt(zoom);
|
|
||||||
}
|
|
||||||
settings.setMapLocationToShow(lt, ln, z, new PointDescription(lt, ln));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
LOG.error("error", e);
|
|
||||||
}
|
|
||||||
} else if (url != null) {
|
|
||||||
url = DiscountHelper.parseUrl(app, url);
|
|
||||||
if (DiscountHelper.validateUrl(app, url)) {
|
|
||||||
DiscountHelper.openUrl(this, url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setIntent(null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean parseTileSourceIntent() {
|
|
||||||
Intent intent = getIntent();
|
|
||||||
if (intent != null && intent.getData() != null) {
|
|
||||||
Uri data = intent.getData();
|
|
||||||
if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme())) && data.getHost() != null && data.getHost().contains("osmand.net") &&
|
|
||||||
data.getPath() != null && data.getPath().startsWith("/add-tile-source")) {
|
|
||||||
Map<String, String> attrs = new HashMap<>();
|
|
||||||
for (String name : data.getQueryParameterNames()) {
|
|
||||||
String value = data.getQueryParameter(name);
|
|
||||||
if (value != null) {
|
|
||||||
attrs.put(name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!attrs.isEmpty()) {
|
|
||||||
try {
|
|
||||||
TileSourceTemplate r = TileSourceManager.createTileSourceTemplate(attrs);
|
|
||||||
if (r != null && settings.installTileSource(r)) {
|
|
||||||
Toast.makeText(this, getString(R.string.edit_tilesource_successfully, r.getName()),
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("parseAddTileSourceIntent error", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setIntent(null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapActivityActions getMapActions() {
|
public MapActivityActions getMapActions() {
|
||||||
return mapActions;
|
return mapActions;
|
||||||
}
|
}
|
||||||
|
@ -2573,5 +2400,4 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
return this != NEW && this != NEW_IF_EXPIRED && this != CURRENT;
|
return this != NEW && this != NEW_IF_EXPIRED && this != CURRENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -23,6 +23,9 @@ import net.osmand.plus.UiUtilities;
|
||||||
|
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||||
|
import static net.osmand.data.FavouritePoint.DEFAULT_UI_ICON_ID;
|
||||||
|
|
||||||
public class FavoriteImageDrawable extends Drawable {
|
public class FavoriteImageDrawable extends Drawable {
|
||||||
|
|
||||||
private boolean withShadow;
|
private boolean withShadow;
|
||||||
|
@ -55,7 +58,7 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
uiIconId = overlayIconId;
|
uiIconId = overlayIconId;
|
||||||
} else {
|
} else {
|
||||||
favIcon = res.getDrawable(R.drawable.mm_special_star);
|
favIcon = res.getDrawable(R.drawable.mm_special_star);
|
||||||
uiIconId = R.drawable.mx_special_star;
|
uiIconId = DEFAULT_UI_ICON_ID;
|
||||||
}
|
}
|
||||||
int col = color == 0 ? res.getColor(R.color.color_favorite) : color;
|
int col = color == 0 ? res.getColor(R.color.color_favorite) : color;
|
||||||
uiListIcon = uiUtilities.getIcon(uiIconId, R.color.color_white);
|
uiListIcon = uiUtilities.getIcon(uiIconId, R.color.color_white);
|
||||||
|
@ -216,8 +219,8 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
FavouritePoint point = null;
|
FavouritePoint point = null;
|
||||||
if (pt != null) {
|
if (pt != null) {
|
||||||
point = new FavouritePoint(pt.getLatitude(), pt.getLongitude(), pt.name, pt.category);
|
point = new FavouritePoint(pt.getLatitude(), pt.getLongitude(), pt.name, pt.category);
|
||||||
point.setIconIdFromName(a, pt.getIconName());
|
point.setIconIdFromName(a, pt.getIconNameOrDefault());
|
||||||
point.setBackgroundType(BackgroundType.getByTypeName(pt.getBackgroundType(), BackgroundType.CIRCLE));
|
point.setBackgroundType(BackgroundType.getByTypeName(pt.getBackgroundType(), DEFAULT_BACKGROUND_TYPE));
|
||||||
}
|
}
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,7 @@ import static net.osmand.IndexConstants.GPX_FILE_EXT;
|
||||||
import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT;
|
import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT;
|
||||||
import static net.osmand.IndexConstants.RENDERER_INDEX_EXT;
|
import static net.osmand.IndexConstants.RENDERER_INDEX_EXT;
|
||||||
import static net.osmand.IndexConstants.ROUTING_FILE_EXT;
|
import static net.osmand.IndexConstants.ROUTING_FILE_EXT;
|
||||||
|
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||||
import static net.osmand.plus.AppInitializer.loadRoutingFiles;
|
import static net.osmand.plus.AppInitializer.loadRoutingFiles;
|
||||||
import static net.osmand.plus.myplaces.FavoritesActivity.FAV_TAB;
|
import static net.osmand.plus.myplaces.FavoritesActivity.FAV_TAB;
|
||||||
import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB;
|
import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB;
|
||||||
|
@ -1190,7 +1191,7 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
fp.setColor(p.getColor(0));
|
fp.setColor(p.getColor(0));
|
||||||
fp.setIconIdFromName(app, p.getIconName());
|
fp.setIconIdFromName(app, p.getIconName());
|
||||||
fp.setBackgroundType(BackgroundType.getByTypeName(p.getBackgroundType(), BackgroundType.CIRCLE));
|
fp.setBackgroundType(BackgroundType.getByTypeName(p.getBackgroundType(), DEFAULT_BACKGROUND_TYPE));
|
||||||
favourites.add(fp);
|
favourites.add(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
254
OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java
Normal file
254
OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java
Normal file
|
@ -0,0 +1,254 @@
|
||||||
|
package net.osmand.plus.helpers;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import net.osmand.AndroidNetworkUtils;
|
||||||
|
import net.osmand.CallbackWithObject;
|
||||||
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.map.TileSourceManager;
|
||||||
|
import net.osmand.plus.ApplicationMode;
|
||||||
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||||
|
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
||||||
|
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||||
|
import net.osmand.plus.settings.BaseSettingsFragment.SettingsScreenType;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class IntentHelper {
|
||||||
|
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(IntentHelper.class);
|
||||||
|
|
||||||
|
private final OsmandApplication app;
|
||||||
|
private final OsmandSettings settings;
|
||||||
|
private final MapActivity mapActivity;
|
||||||
|
|
||||||
|
public IntentHelper(MapActivity mapActivity, OsmandApplication app) {
|
||||||
|
this.app = app;
|
||||||
|
this.mapActivity = mapActivity;
|
||||||
|
this.settings = app.getSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean parseLaunchIntents() {
|
||||||
|
boolean applied = parseLocationIntent();
|
||||||
|
if (!applied) {
|
||||||
|
applied = parseTileSourceIntent();
|
||||||
|
}
|
||||||
|
if (!applied) {
|
||||||
|
applied = parseOpenGpxIntent();
|
||||||
|
}
|
||||||
|
return applied;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean parseLocationIntent() {
|
||||||
|
Intent intent = mapActivity.getIntent();
|
||||||
|
if (intent != null && intent.getData() != null) {
|
||||||
|
Uri data = intent.getData();
|
||||||
|
if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme()))
|
||||||
|
&& data.getHost() != null && data.getHost().contains("osmand.net") &&
|
||||||
|
data.getPath() != null && data.getPath().startsWith("/go")) {
|
||||||
|
String lat = data.getQueryParameter("lat");
|
||||||
|
String lon = data.getQueryParameter("lon");
|
||||||
|
String url = data.getQueryParameter("url");
|
||||||
|
if (lat != null && lon != null) {
|
||||||
|
try {
|
||||||
|
double lt = Double.parseDouble(lat);
|
||||||
|
double ln = Double.parseDouble(lon);
|
||||||
|
String zoom = data.getQueryParameter("z");
|
||||||
|
int z = settings.getLastKnownMapZoom();
|
||||||
|
if (zoom != null) {
|
||||||
|
z = Integer.parseInt(zoom);
|
||||||
|
}
|
||||||
|
settings.setMapLocationToShow(lt, ln, z, new PointDescription(lt, ln));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
LOG.error("error", e);
|
||||||
|
}
|
||||||
|
} else if (url != null) {
|
||||||
|
url = DiscountHelper.parseUrl(app, url);
|
||||||
|
if (DiscountHelper.validateUrl(app, url)) {
|
||||||
|
DiscountHelper.openUrl(mapActivity, url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapActivity.setIntent(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean parseTileSourceIntent() {
|
||||||
|
Intent intent = mapActivity.getIntent();
|
||||||
|
if (intent != null && intent.getData() != null) {
|
||||||
|
Uri data = intent.getData();
|
||||||
|
if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme()))
|
||||||
|
&& data.getHost() != null && data.getHost().contains("osmand.net") &&
|
||||||
|
data.getPath() != null && data.getPath().startsWith("/add-tile-source")) {
|
||||||
|
Map<String, String> attrs = new HashMap<>();
|
||||||
|
for (String name : data.getQueryParameterNames()) {
|
||||||
|
String value = data.getQueryParameter(name);
|
||||||
|
if (value != null) {
|
||||||
|
attrs.put(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!attrs.isEmpty()) {
|
||||||
|
try {
|
||||||
|
TileSourceManager.TileSourceTemplate r = TileSourceManager.createTileSourceTemplate(attrs);
|
||||||
|
if (r != null && settings.installTileSource(r)) {
|
||||||
|
app.showShortToastMessage(app.getString(R.string.edit_tilesource_successfully, r.getName()));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("parseAddTileSourceIntent error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapActivity.setIntent(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean parseOpenGpxIntent() {
|
||||||
|
Intent intent = mapActivity.getIntent();
|
||||||
|
if (intent != null && intent.getData() != null) {
|
||||||
|
Uri data = intent.getData();
|
||||||
|
if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme()))
|
||||||
|
&& data.getHost() != null && data.getHost().contains("osmand.net")
|
||||||
|
&& data.getPath() != null && data.getPath().startsWith("/open-gpx")) {
|
||||||
|
String url = data.getQueryParameter("url");
|
||||||
|
if (Algorithms.isEmpty(url)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String name = data.getQueryParameter("name");
|
||||||
|
if (Algorithms.isEmpty(name)) {
|
||||||
|
name = Algorithms.getFileWithoutDirs(url);
|
||||||
|
}
|
||||||
|
if (!name.endsWith(IndexConstants.GPX_FILE_EXT)) {
|
||||||
|
name += IndexConstants.GPX_FILE_EXT;
|
||||||
|
}
|
||||||
|
final String fileName = name;
|
||||||
|
AndroidNetworkUtils.downloadFileAsync(url, app.getAppPath(IndexConstants.GPX_IMPORT_DIR + fileName),
|
||||||
|
new CallbackWithObject<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean processResult(String error) {
|
||||||
|
if (error == null) {
|
||||||
|
String downloaded = app.getString(R.string.shared_string_download_successful);
|
||||||
|
app.showShortToastMessage(app.getString(R.string.ltr_or_rtl_combine_via_colon, downloaded, fileName));
|
||||||
|
} else {
|
||||||
|
app.showShortToastMessage(app.getString(R.string.error_occurred_loading_gpx));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mapActivity.setIntent(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void parseContentIntent() {
|
||||||
|
final Intent intent = mapActivity.getIntent();
|
||||||
|
if (intent != null) {
|
||||||
|
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||||
|
final Uri data = intent.getData();
|
||||||
|
if (data != null) {
|
||||||
|
final String scheme = data.getScheme();
|
||||||
|
if ("file".equals(scheme)) {
|
||||||
|
final String path = data.getPath();
|
||||||
|
if (path != null) {
|
||||||
|
mapActivity.getImportHelper().handleFileImport(data, new File(path).getName(), intent.getExtras(), true);
|
||||||
|
}
|
||||||
|
clearIntent(intent);
|
||||||
|
} else if ("content".equals(scheme)) {
|
||||||
|
mapActivity.getImportHelper().handleContentImport(data, intent.getExtras(), true);
|
||||||
|
clearIntent(intent);
|
||||||
|
} else if ("google.navigation".equals(scheme) || "osmand.navigation".equals(scheme)) {
|
||||||
|
parseNavigationIntent(intent);
|
||||||
|
} else if ("osmand.api".equals(scheme)) {
|
||||||
|
ExternalApiHelper apiHelper = new ExternalApiHelper(mapActivity);
|
||||||
|
Intent result = apiHelper.processApiRequest(intent);
|
||||||
|
mapActivity.setResult(apiHelper.getResultCode(), result);
|
||||||
|
result.setAction(null);
|
||||||
|
mapActivity.setIntent(result);
|
||||||
|
if (apiHelper.needFinish()) {
|
||||||
|
mapActivity.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intent.hasExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS)) {
|
||||||
|
Bundle openMapMarkersGroupsExtra = intent.getBundleExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS);
|
||||||
|
if (openMapMarkersGroupsExtra != null) {
|
||||||
|
MapMarkersDialogFragment.showInstance(mapActivity, openMapMarkersGroupsExtra.getString(MapMarkersHelper.MapMarkersGroup.MARKERS_SYNC_GROUP_ID));
|
||||||
|
}
|
||||||
|
mapActivity.setIntent(null);
|
||||||
|
}
|
||||||
|
if (intent.hasExtra(BaseSettingsFragment.OPEN_SETTINGS)) {
|
||||||
|
String settingsType = intent.getStringExtra(BaseSettingsFragment.OPEN_SETTINGS);
|
||||||
|
String appMode = intent.getStringExtra(BaseSettingsFragment.APP_MODE_KEY);
|
||||||
|
if (BaseSettingsFragment.OPEN_CONFIG_PROFILE.equals(settingsType)) {
|
||||||
|
BaseSettingsFragment.showInstance(mapActivity, SettingsScreenType.CONFIGURE_PROFILE, ApplicationMode.valueOfStringKey(appMode, null));
|
||||||
|
}
|
||||||
|
mapActivity.setIntent(null);
|
||||||
|
}
|
||||||
|
if (intent.hasExtra(BaseSettingsFragment.OPEN_CONFIG_ON_MAP)) {
|
||||||
|
switch (intent.getStringExtra(BaseSettingsFragment.OPEN_CONFIG_ON_MAP)) {
|
||||||
|
case BaseSettingsFragment.MAP_CONFIG:
|
||||||
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, null);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BaseSettingsFragment.SCREEN_CONFIG:
|
||||||
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mapActivity.setIntent(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseNavigationIntent(Intent intent) {
|
||||||
|
Uri data = intent.getData();
|
||||||
|
if (data != null) {
|
||||||
|
final String schemeSpecificPart = data.getSchemeSpecificPart();
|
||||||
|
|
||||||
|
final Matcher matcher = Pattern.compile("(?:q|ll)=([\\-0-9.]+),([\\-0-9.]+)(?:.*)").matcher(schemeSpecificPart);
|
||||||
|
if (matcher.matches()) {
|
||||||
|
try {
|
||||||
|
double lat = Double.parseDouble(matcher.group(1));
|
||||||
|
double lon = Double.parseDouble(matcher.group(2));
|
||||||
|
|
||||||
|
app.getTargetPointsHelper().navigateToPoint(new LatLon(lat, lon), false, -1);
|
||||||
|
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, false, true);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
app.showToastMessage(app.getString(R.string.navigation_intent_invalid, schemeSpecificPart));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.showToastMessage(app.getString(R.string.navigation_intent_invalid, schemeSpecificPart));
|
||||||
|
}
|
||||||
|
clearIntent(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearIntent(Intent intent) {
|
||||||
|
intent.setAction(null);
|
||||||
|
intent.setData(null);
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,6 +34,8 @@ import net.osmand.util.Algorithms;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||||
|
|
||||||
public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -45,7 +47,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
private int color;
|
private int color;
|
||||||
private int iconId;
|
private int iconId;
|
||||||
@NonNull
|
@NonNull
|
||||||
private BackgroundType backgroundType = BackgroundType.CIRCLE;
|
private BackgroundType backgroundType = DEFAULT_BACKGROUND_TYPE;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private FavouritesDbHelper helper;
|
private FavouritesDbHelper helper;
|
||||||
|
|
|
@ -78,7 +78,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
private int selectedIcon;
|
private int selectedIcon;
|
||||||
@ColorInt
|
@ColorInt
|
||||||
private int selectedColor;
|
private int selectedColor;
|
||||||
private BackgroundType selectedShape = BackgroundType.CIRCLE;
|
private BackgroundType selectedShape = DEFAULT_BACKGROUND_TYPE;
|
||||||
private ImageView nameIcon;
|
private ImageView nameIcon;
|
||||||
private GroupAdapter groupListAdapter;
|
private GroupAdapter groupListAdapter;
|
||||||
private int scrollViewY;
|
private int scrollViewY;
|
||||||
|
@ -489,7 +489,8 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
setIconSelectorBackground(backgroundCircle);
|
setIconSelectorBackground(backgroundCircle);
|
||||||
ImageView icon = iconItemView.findViewById(R.id.icon);
|
ImageView icon = iconItemView.findViewById(R.id.icon);
|
||||||
icon.setVisibility(View.VISIBLE);
|
icon.setVisibility(View.VISIBLE);
|
||||||
final int iconRes = app.getResources().getIdentifier("mx_" + iconName, "drawable", app.getPackageName());
|
int validIconId = app.getResources().getIdentifier("mx_" + iconName, "drawable", app.getPackageName());
|
||||||
|
final int iconRes = validIconId != 0 ? validIconId : DEFAULT_UI_ICON_ID;
|
||||||
icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.icon_color_default_light));
|
icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.icon_color_default_light));
|
||||||
backgroundCircle.setOnClickListener(new View.OnClickListener() {
|
backgroundCircle.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,6 +37,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||||
|
import static net.osmand.data.FavouritePoint.DEFAULT_UI_ICON_ID;
|
||||||
|
|
||||||
public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -54,7 +57,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
protected boolean skipDialog;
|
protected boolean skipDialog;
|
||||||
private String iconName;
|
private String iconName;
|
||||||
@NonNull
|
@NonNull
|
||||||
private String backgroundTypeName = BackgroundType.CIRCLE.getTypeName();
|
private String backgroundTypeName = DEFAULT_BACKGROUND_TYPE.getTypeName();
|
||||||
|
|
||||||
private Map<String, Integer> categoriesMap;
|
private Map<String, Integer> categoriesMap;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
@ -103,7 +106,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
WptPt wpt = editor.getWptPt();
|
WptPt wpt = editor.getWptPt();
|
||||||
this.wpt = wpt;
|
this.wpt = wpt;
|
||||||
color = wpt.getColor(0);
|
color = wpt.getColor(0);
|
||||||
iconName = wpt.getIconName();
|
iconName = wpt.getIconNameOrDefault();
|
||||||
categoriesMap = editor.getGpxFile().getWaypointCategoriesWithColors(false);
|
categoriesMap = editor.getGpxFile().getWaypointCategoriesWithColors(false);
|
||||||
backgroundTypeName = wpt.getBackgroundType();
|
backgroundTypeName = wpt.getBackgroundType();
|
||||||
}
|
}
|
||||||
|
@ -432,7 +435,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackgroundType getBackgroundType() {
|
public BackgroundType getBackgroundType() {
|
||||||
return BackgroundType.getByTypeName(backgroundTypeName, BackgroundType.CIRCLE);
|
return BackgroundType.getByTypeName(backgroundTypeName, DEFAULT_BACKGROUND_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -441,7 +444,8 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIconIdFromName(String iconName) {
|
public int getIconIdFromName(String iconName) {
|
||||||
return app.getResources().getIdentifier("mx_" + iconName, "drawable", app.getPackageName());
|
int iconId = app.getResources().getIdentifier("mx_" + iconName, "drawable", app.getPackageName());
|
||||||
|
return iconId != 0 ? iconId : DEFAULT_UI_ICON_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -48,6 +48,9 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
||||||
|
|
||||||
private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.sqlite";
|
private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.sqlite";
|
||||||
|
|
||||||
|
private static boolean SHOW_TRAVEL_UPDATE_CARD = true;
|
||||||
|
private static boolean SHOW_TRAVEL_NEEDED_MAPS_CARD = true;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ExploreRvAdapter adapter = new ExploreRvAdapter();
|
private ExploreRvAdapter adapter = new ExploreRvAdapter();
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
|
@ -237,7 +240,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
||||||
boolean needsDownloading = mainIndexItem != null && !mainIndexItem.isDownloaded();
|
boolean needsDownloading = mainIndexItem != null && !mainIndexItem.isDownloaded();
|
||||||
File selectedTravelBook = app.getTravelDbHelper().getSelectedTravelBook();
|
File selectedTravelBook = app.getTravelDbHelper().getSelectedTravelBook();
|
||||||
|
|
||||||
if (selectedTravelBook == null || needsDownloading || (outdated && app.getSettings().SHOW_TRAVEL_UPDATE_CARD.get())) {
|
if (selectedTravelBook == null || needsDownloading || (outdated && SHOW_TRAVEL_UPDATE_CARD)) {
|
||||||
boolean showOtherMaps = false;
|
boolean showOtherMaps = false;
|
||||||
if (needsDownloading) {
|
if (needsDownloading) {
|
||||||
List<IndexItem> items = downloadThread.getIndexes().getWikivoyageItems();
|
List<IndexItem> items = downloadThread.getIndexes().getWikivoyageItems();
|
||||||
|
@ -261,7 +264,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
||||||
downloadThread.cancelDownload(mainIndexItem);
|
downloadThread.cancelDownload(mainIndexItem);
|
||||||
adapter.updateDownloadUpdateCard(false);
|
adapter.updateDownloadUpdateCard(false);
|
||||||
} else if (!downloadUpdateCard.isDownload()) {
|
} else if (!downloadUpdateCard.isDownload()) {
|
||||||
app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(false);
|
SHOW_TRAVEL_UPDATE_CARD = false;
|
||||||
removeDownloadUpdateCard();
|
removeDownloadUpdateCard();
|
||||||
} else if (downloadUpdateCard.isShowOtherMapsBtn()) {
|
} else if (downloadUpdateCard.isShowOtherMapsBtn()) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
|
@ -282,7 +285,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
||||||
|
|
||||||
private void addNeededMapsCard() {
|
private void addNeededMapsCard() {
|
||||||
final OsmandApplication app = getMyApplication();
|
final OsmandApplication app = getMyApplication();
|
||||||
if (app != null && !neededIndexItems.isEmpty() && adapter != null && app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.get()) {
|
if (app != null && !neededIndexItems.isEmpty() && adapter != null && SHOW_TRAVEL_NEEDED_MAPS_CARD) {
|
||||||
neededMapsCard = new TravelNeededMapsCard(app, nightMode, neededIndexItems);
|
neededMapsCard = new TravelNeededMapsCard(app, nightMode, neededIndexItems);
|
||||||
neededMapsCard.setListener(new TravelNeededMapsCard.CardListener() {
|
neededMapsCard.setListener(new TravelNeededMapsCard.CardListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -301,7 +304,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
||||||
adapter.updateNeededMapsCard(false);
|
adapter.updateNeededMapsCard(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(false);
|
SHOW_TRAVEL_NEEDED_MAPS_CARD = false;
|
||||||
removeNeededMapsCard();
|
removeNeededMapsCard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue