Fix issues with paths
This commit is contained in:
parent
cd83761c28
commit
590f62a758
18 changed files with 77 additions and 100 deletions
|
@ -15,6 +15,7 @@ import net.osmand.Algoritms;
|
|||
import net.osmand.FavouritePoint;
|
||||
import net.osmand.LogUtil;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.activities.DayNightHelper;
|
||||
|
@ -55,7 +56,7 @@ import android.widget.Toast;
|
|||
import com.bidforfix.andorid.BidForFixHelper;
|
||||
|
||||
public class OsmandApplication extends Application implements ClientContext {
|
||||
public static final String EXCEPTION_PATH = ResourceManager.APP_DIR + "exception.log"; //$NON-NLS-1$
|
||||
public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$
|
||||
private static final org.apache.commons.logging.Log LOG = LogUtil.getLog(OsmandApplication.class);
|
||||
|
||||
ResourceManager manager = null;
|
||||
|
@ -465,7 +466,7 @@ public class OsmandApplication extends Application implements ClientContext {
|
|||
savingTrackHelper.close();
|
||||
|
||||
// restore backuped favorites to normal file
|
||||
final File appDir = getSettings().extendOsmandPath(ResourceManager.APP_DIR);
|
||||
final File appDir = getAppPath(null);
|
||||
File save = new File(appDir, FavouritesDbHelper.FILE_TO_SAVE);
|
||||
File bak = new File(appDir, FavouritesDbHelper.FILE_TO_BACKUP);
|
||||
if (bak.exists() && (!save.exists() || bak.lastModified() > save.lastModified())) {
|
||||
|
@ -541,7 +542,7 @@ public class OsmandApplication extends Application implements ClientContext {
|
|||
|
||||
@Override
|
||||
public void uncaughtException(final Thread thread, final Throwable ex) {
|
||||
File file = osmandSettings.extendOsmandPath(EXCEPTION_PATH);
|
||||
File file = getAppPath(EXCEPTION_PATH);
|
||||
try {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
PrintStream printStream = new PrintStream(out);
|
||||
|
@ -629,4 +630,12 @@ public class OsmandApplication extends Application implements ClientContext {
|
|||
uiHandler.postDelayed(run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getAppPath(String path) {
|
||||
if(path == null) {
|
||||
path = "";
|
||||
}
|
||||
return new File(getSettings().getExternalStorageDirectory(), IndexConstants.APP_DIR + path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,22 +68,12 @@ import android.view.WindowManager;
|
|||
*/
|
||||
public class ResourceManager {
|
||||
|
||||
public static final String APP_DIR = "osmand/"; //$NON-NLS-1$
|
||||
public static final String ROUTING_XML = APP_DIR + IndexConstants.ROUTING_XML_FILE;
|
||||
public static final String AV_PATH = APP_DIR + IndexConstants.AV_INDEX_DIR;
|
||||
public static final String SRTM_PATH = APP_DIR + IndexConstants.SRTM_INDEX_DIR;
|
||||
public static final String VOICE_PATH = APP_DIR + IndexConstants.VOICE_INDEX_DIR;
|
||||
public static final String GPX_PATH = APP_DIR + IndexConstants.GPX_INDEX_DIR;
|
||||
public static final String MAPS_PATH = APP_DIR;
|
||||
public static final String INDEXES_CACHE = APP_DIR + "ind.cache";
|
||||
public static final String BACKUP_PATH = APP_DIR + IndexConstants.BACKUP_INDEX_DIR;
|
||||
public static final String TILES_PATH = APP_DIR + IndexConstants.TILES_INDEX_DIR; //$NON-NLS-1$
|
||||
public static final String TEMP_SOURCE_TO_LOAD = IndexConstants.TEMP_SOURCE_TO_LOAD; //$NON-NLS-1$
|
||||
public static final String VECTOR_MAP = "#vector_map"; //$NON-NLS-1$
|
||||
private static final String INDEXES_CACHE = "ind.cache";
|
||||
|
||||
|
||||
private static final Log log = LogUtil.getLog(ResourceManager.class);
|
||||
private static final String MINE_POI_DB = APP_DIR + "mine"+ IndexConstants.POI_INDEX_EXT;
|
||||
private static final String MINE_POI_DB = "mine"+ IndexConstants.POI_INDEX_EXT;
|
||||
|
||||
|
||||
protected static ResourceManager manager = null;
|
||||
|
@ -150,11 +140,11 @@ public class ResourceManager {
|
|||
|
||||
|
||||
public void resetStoreDirectory() {
|
||||
dirWithTiles = context.getSettings().extendOsmandPath(TILES_PATH);
|
||||
dirWithTiles = context.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||
dirWithTiles.mkdirs();
|
||||
// ".nomedia" indicates there are no pictures and no music to list in this dir for the Gallery app
|
||||
try {
|
||||
context.getSettings().extendOsmandPath(APP_DIR + ".nomedia").createNewFile(); //$NON-NLS-1$
|
||||
context.getAppPath(".nomedia").createNewFile(); //$NON-NLS-1$
|
||||
} catch( Exception e ) {
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +258,7 @@ public class ResourceManager {
|
|||
public synchronized String calculateTileId(ITileSource map, int x, int y, int zoom) {
|
||||
builder.setLength(0);
|
||||
if (map == null) {
|
||||
builder.append(TEMP_SOURCE_TO_LOAD);
|
||||
builder.append(IndexConstants.TEMP_SOURCE_TO_LOAD);
|
||||
} else {
|
||||
builder.append(map.getName());
|
||||
}
|
||||
|
@ -392,7 +382,7 @@ public class ResourceManager {
|
|||
// check we have some assets to copy to sdcard
|
||||
warnings.addAll(checkAssets(progress));
|
||||
initRenderers(progress);
|
||||
geoidAltitudeCorrection = new GeoidAltitudeCorrection(context.getSettings().extendOsmandPath(APP_DIR));
|
||||
geoidAltitudeCorrection = new GeoidAltitudeCorrection(context.getAppPath(null));
|
||||
// do it lazy
|
||||
// indexingImageTiles(progress);
|
||||
warnings.addAll(indexingMaps(progress));
|
||||
|
@ -404,7 +394,7 @@ public class ResourceManager {
|
|||
}
|
||||
|
||||
public List<String> indexVoiceFiles(IProgress progress){
|
||||
File file = context.getSettings().extendOsmandPath(VOICE_PATH);
|
||||
File file = context.getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||
file.mkdirs();
|
||||
List<String> warnings = new ArrayList<String>();
|
||||
if (file.exists() && file.canRead()) {
|
||||
|
@ -427,7 +417,7 @@ public class ResourceManager {
|
|||
private List<String> checkAssets(IProgress progress) {
|
||||
if (!Version.getFullVersion(context)
|
||||
.equalsIgnoreCase(context.getSettings().previousInstalledVesrion().get())) {
|
||||
File applicationDataDir = context.getSettings().extendOsmandPath(APP_DIR);
|
||||
File applicationDataDir = context.getAppPath(null);
|
||||
applicationDataDir.mkdirs();
|
||||
if(applicationDataDir.canWrite()){
|
||||
try {
|
||||
|
@ -516,7 +506,7 @@ public class ResourceManager {
|
|||
}
|
||||
|
||||
private void initRenderers(IProgress progress) {
|
||||
File file = context.getSettings().extendOsmandPath(APP_DIR + IndexConstants.RENDERERS_DIR);
|
||||
File file = context.getAppPath(IndexConstants.RENDERERS_DIR);
|
||||
file.mkdirs();
|
||||
Map<String, File> externalRenderers = new LinkedHashMap<String, File>();
|
||||
if (file.exists() && file.canRead()) {
|
||||
|
@ -558,14 +548,15 @@ public class ResourceManager {
|
|||
public List<String> indexingMaps(final IProgress progress) {
|
||||
long val = System.currentTimeMillis();
|
||||
ArrayList<File> files = new ArrayList<File>();
|
||||
collectFiles(context.getSettings().extendOsmandPath(MAPS_PATH), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||
File appPath = context.getAppPath(null);
|
||||
collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||
if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
|
||||
collectFiles(context.getSettings().extendOsmandPath(SRTM_PATH), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||
collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||
}
|
||||
List<String> warnings = new ArrayList<String>();
|
||||
renderer.clearAllResources();
|
||||
CachedOsmandIndexes cachedOsmandIndexes = new CachedOsmandIndexes();
|
||||
File indCache = context.getSettings().extendOsmandPath(INDEXES_CACHE);
|
||||
File indCache = context.getAppPath(INDEXES_CACHE);
|
||||
if (indCache.exists()) {
|
||||
try {
|
||||
cachedOsmandIndexes.readFromFile(indCache, CachedOsmandIndexes.VERSION);
|
||||
|
@ -658,7 +649,7 @@ public class ResourceManager {
|
|||
|
||||
// POI INDEX //
|
||||
private List<String> indexingPoi(final IProgress progress) {
|
||||
File updatablePoiDbFile = context.getSettings().extendOsmandPath(MINE_POI_DB);
|
||||
File updatablePoiDbFile = context.getAppPath(MINE_POI_DB);
|
||||
if(updatablePoiDbFile.exists() && updatablePoiDbFile.canRead()){
|
||||
tryToOpenUpdatablePoiDb(updatablePoiDbFile);
|
||||
}
|
||||
|
@ -667,7 +658,7 @@ public class ResourceManager {
|
|||
|
||||
public AmenityIndexRepositoryOdb getUpdatablePoiDb() {
|
||||
if (updatablePoiDb == null) {
|
||||
File updatablePoiDbFile = context.getSettings().extendOsmandPath(MINE_POI_DB);
|
||||
File updatablePoiDbFile = context.getAppPath(MINE_POI_DB);
|
||||
if (!tryToOpenUpdatablePoiDb(updatablePoiDbFile)) {
|
||||
if (updatablePoiDbFile.exists()) {
|
||||
updatablePoiDbFile.delete();
|
||||
|
@ -923,7 +914,7 @@ public class ResourceManager {
|
|||
}
|
||||
|
||||
public Map<String, String> getBackupIndexes(Map<String, String> map) {
|
||||
File file = context.getSettings().extendOsmandPath(BACKUP_PATH);
|
||||
File file = context.getAppPath(IndexConstants.BACKUP_INDEX_DIR);
|
||||
if (file != null && file.isDirectory()) {
|
||||
File[] lf = file.listFiles();
|
||||
if (lf != null) {
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.List;
|
|||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
@ -58,7 +57,7 @@ public class ContributionVersionActivity extends OsmandListActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
pathToDownload = getMyApplication().getSettings().extendOsmandPath(ResourceManager.APP_DIR + "osmandToInstall.apk");
|
||||
pathToDownload = getMyApplication().getAppPath("osmandToInstall.apk");
|
||||
CustomTitleBar titleBar = new CustomTitleBar(this, R.string.download_files, R.drawable.tab_download_screen_icon);
|
||||
setContentView(R.layout.download_builds);
|
||||
titleBar.afterSetContentView();
|
||||
|
|
|
@ -498,13 +498,13 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
|
||||
private Map<String, String> listAlreadyDownloadedWithAlternatives() {
|
||||
Map<String, String> files = new TreeMap<String, String>();
|
||||
listWithAlternatives(settings.extendOsmandPath(ResourceManager.BACKUP_PATH),BINARY_MAP_INDEX_EXT, files);
|
||||
listWithAlternatives(settings.extendOsmandPath(ResourceManager.APP_DIR),BINARY_MAP_INDEX_EXT, files);
|
||||
listWithAlternatives(settings.extendOsmandPath(ResourceManager.APP_DIR),EXTRA_EXT, files);
|
||||
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.BACKUP_INDEX_DIR),BINARY_MAP_INDEX_EXT, files);
|
||||
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.MAPS_PATH),BINARY_MAP_INDEX_EXT, files);
|
||||
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.MAPS_PATH),EXTRA_EXT, files);
|
||||
if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
|
||||
listWithAlternatives(settings.extendOsmandPath(ResourceManager.SRTM_PATH),BINARY_MAP_INDEX_EXT, files);
|
||||
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR),BINARY_MAP_INDEX_EXT, files);
|
||||
}
|
||||
listWithAlternatives(settings.extendOsmandPath(ResourceManager.VOICE_PATH),"", files);
|
||||
listWithAlternatives(getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR),"", files);
|
||||
return files;
|
||||
}
|
||||
|
||||
|
@ -580,7 +580,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
sz += es.sizeMB;
|
||||
}
|
||||
// get availabile space
|
||||
File dir = settings.extendOsmandPath("");
|
||||
File dir = getMyApplication().getAppPath("").getParentFile();
|
||||
double asz = -1;
|
||||
if(dir.canRead()){
|
||||
StatFs fs = new StatFs(dir.getAbsolutePath());
|
||||
|
|
|
@ -28,7 +28,6 @@ import net.osmand.plus.GPXUtilities.WptPt;
|
|||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -325,12 +324,11 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
final File appDir = getMyApplication().getSettings().extendOsmandPath(ResourceManager.APP_DIR);
|
||||
final File tosave = new File(appDir, FavouritesDbHelper.FILE_TO_SAVE);
|
||||
final File tosave = getMyApplication().getAppPath(FavouritesDbHelper.FILE_TO_SAVE);
|
||||
if(item.getItemId() == EXPORT_ID){
|
||||
if(favouritesAdapter.isEmpty()){
|
||||
AccessibleToast.makeText(this, R.string.no_fav_to_save, Toast.LENGTH_LONG).show();
|
||||
} else if(!appDir.exists()){
|
||||
} else if(!tosave.getParentFile().exists()){
|
||||
AccessibleToast.makeText(this, R.string.sd_dir_not_accessible, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
final AsyncTask<Void, Void, String> exportTask = new AsyncTask<Void, Void, String>(){
|
||||
|
|
|
@ -32,9 +32,7 @@ import net.osmand.plus.GPXUtilities.TrkSegment;
|
|||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.SQLiteTileSource;
|
||||
import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask;
|
||||
import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
||||
|
@ -202,18 +200,17 @@ public class LocalIndexHelper {
|
|||
}
|
||||
|
||||
public List<LocalIndexInfo> getLocalIndexData(LocalIndexType type, LoadLocalIndexTask loadTask){
|
||||
OsmandSettings settings = app.getSettings();
|
||||
Map<String, String> loadedMaps = app.getResourceManager().getIndexFileNames();
|
||||
List<LocalIndexInfo> result = new ArrayList<LocalIndexInfo>();
|
||||
|
||||
loadObfData(settings.extendOsmandPath(ResourceManager.MAPS_PATH), result, false, loadTask, loadedMaps);
|
||||
loadObfData(settings.extendOsmandPath(ResourceManager.BACKUP_PATH), result, true, loadTask, loadedMaps);
|
||||
loadTilesData(settings.extendOsmandPath(ResourceManager.TILES_PATH), result, false, loadTask);
|
||||
loadTilesData(settings.extendOsmandPath(ResourceManager.BACKUP_PATH), result, false, loadTask);
|
||||
loadVoiceData(settings.extendOsmandPath(ResourceManager.VOICE_PATH), result, false, loadTask);
|
||||
loadVoiceData(settings.extendOsmandPath(ResourceManager.BACKUP_PATH), result, true, loadTask);
|
||||
loadGPXData(settings.extendOsmandPath(ResourceManager.GPX_PATH), result, false, loadTask);
|
||||
loadGPXData(settings.extendOsmandPath(ResourceManager.BACKUP_PATH), result, true, loadTask);
|
||||
loadObfData(app.getAppPath(IndexConstants.MAPS_PATH), result, false, loadTask, loadedMaps);
|
||||
loadObfData(app.getAppPath(IndexConstants.BACKUP_INDEX_DIR), result, true, loadTask, loadedMaps);
|
||||
loadTilesData(app.getAppPath(IndexConstants.TILES_INDEX_DIR), result, false, loadTask);
|
||||
loadTilesData(app.getAppPath(IndexConstants.BACKUP_INDEX_DIR), result, false, loadTask);
|
||||
loadVoiceData(app.getAppPath(IndexConstants.VOICE_INDEX_DIR), result, false, loadTask);
|
||||
loadVoiceData(app.getAppPath(IndexConstants.TTSVOICE_INDEX_EXT_ZIP), result, true, loadTask);
|
||||
loadGPXData(app.getAppPath(IndexConstants.GPX_INDEX_DIR), result, false, loadTask);
|
||||
loadGPXData(app.getAppPath(IndexConstants.BACKUP_INDEX_DIR), result, true, loadTask);
|
||||
|
||||
|
||||
return result;
|
||||
|
|
|
@ -13,11 +13,11 @@ import java.util.Set;
|
|||
import net.osmand.Algoritms;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.activities.EnumAdapter.IEnumWithResource;
|
||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexInfo;
|
||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||
|
@ -330,15 +330,15 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
|||
if(i.isBackupedData()){
|
||||
File parent = new File(i.getPathToData()).getParentFile();
|
||||
if(i.getType() == LocalIndexType.GPX_DATA){
|
||||
parent = settings.extendOsmandPath(ResourceManager.GPX_PATH);
|
||||
parent = getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
} else if(i.getType() == LocalIndexType.MAP_DATA){
|
||||
parent = settings.extendOsmandPath(ResourceManager.MAPS_PATH);
|
||||
parent = getMyApplication().getAppPath(IndexConstants.MAPS_PATH);
|
||||
} else if(i.getType() == LocalIndexType.TILES_DATA){
|
||||
parent = settings.extendOsmandPath(ResourceManager.TILES_PATH);
|
||||
parent = getMyApplication().getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||
} else if(i.getType() == LocalIndexType.VOICE_DATA){
|
||||
parent = settings.extendOsmandPath(ResourceManager.VOICE_PATH);
|
||||
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||
} else if(i.getType() == LocalIndexType.TTS_VOICE_DATA){
|
||||
parent = settings.extendOsmandPath(ResourceManager.VOICE_PATH);
|
||||
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||
}
|
||||
return new File(parent, i.getFileName());
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
|||
|
||||
private File getFileToBackup(LocalIndexInfo i) {
|
||||
if(!i.isBackupedData()){
|
||||
return new File(settings.extendOsmandPath(ResourceManager.BACKUP_PATH), i.getFileName());
|
||||
return new File(getMyApplication().getAppPath(IndexConstants.BACKUP_INDEX_DIR), i.getFileName());
|
||||
}
|
||||
return new File(i.getPathToData());
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
|||
}
|
||||
|
||||
private void updateDescriptionTextWithSize(){
|
||||
File dir = getMyApplication().getSettings().extendOsmandPath("");
|
||||
File dir = getMyApplication().getAppPath("").getParentFile();
|
||||
String size = formatGb.format(new Object[]{0});
|
||||
if(dir.canRead()){
|
||||
StatFs fs = new StatFs(dir.getAbsolutePath());
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Random;
|
|||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
|
@ -45,7 +44,7 @@ public class MainMenuActivity extends Activity {
|
|||
private static final String VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$NON-NLS-1$
|
||||
private static final String TIPS_SHOW = "TIPS_SHOW"; //$NON-NLS-1$
|
||||
private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$
|
||||
private static final String EXCEPTION_FILE_SIZE = ResourceManager.APP_DIR + "exception.log"; //$NON-NLS-1$
|
||||
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
|
||||
|
||||
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
|
||||
|
||||
|
@ -57,7 +56,7 @@ public class MainMenuActivity extends Activity {
|
|||
public void checkPreviousRunsForExceptions(boolean firstTime) {
|
||||
long size = getPreferences(MODE_WORLD_READABLE).getLong(EXCEPTION_FILE_SIZE, 0);
|
||||
final OsmandApplication app = ((OsmandApplication) getApplication());
|
||||
final File file = app.getSettings().extendOsmandPath(OsmandApplication.EXCEPTION_PATH);
|
||||
final File file = app.getAppPath(OsmandApplication.EXCEPTION_PATH);
|
||||
if (file.exists() && file.length() > 0) {
|
||||
if (size != file.length() && !firstTime) {
|
||||
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.osmand.LogUtil;
|
|||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.osm.LatLon;
|
||||
import net.osmand.osm.MapUtils;
|
||||
|
@ -38,7 +39,6 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
|
@ -50,12 +50,10 @@ import net.osmand.plus.views.OsmandMapTileView;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Application;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
||||
import android.content.Intent;
|
||||
|
@ -746,8 +744,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
public static Dialog createSaveDirections(Activity activity) {
|
||||
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
|
||||
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
|
||||
final File fileDir = settings.extendOsmandPath(ResourceManager.GPX_PATH);
|
||||
final File fileDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
final Dialog dlg = new Dialog(activity);
|
||||
dlg.setTitle(R.string.save_route_dialog_title);
|
||||
dlg.setContentView(R.layout.save_directions_dialog);
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.osmand.CallbackWithObject;
|
|||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
|
@ -29,7 +30,6 @@ import net.osmand.plus.OsmandSettings.CommonPreference;
|
|||
import net.osmand.plus.PoiFilter;
|
||||
import net.osmand.plus.PoiFiltersHelper;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.SQLiteTileSource;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.render.MapVectorLayer;
|
||||
|
@ -381,8 +381,7 @@ public class MapActivityLayers {
|
|||
public void selectGPXFileLayer(final CallbackWithObject<GPXFile> callbackWithObject, final boolean convertCloudmade,
|
||||
final boolean showCurrentGpx) {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final OsmandSettings settings = getApplication().getSettings();
|
||||
final File dir = settings.extendOsmandPath(ResourceManager.GPX_PATH);
|
||||
final File dir = getApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
if (dir != null && dir.canRead()) {
|
||||
File[] files = dir.listFiles();
|
||||
if (files != null) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import net.osmand.LogUtil;
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.osm.LatLon;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
|
@ -17,7 +18,6 @@ import net.osmand.plus.GPXUtilities.TrkSegment;
|
|||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -130,12 +130,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
*/
|
||||
public List<String> saveDataToGpx() {
|
||||
List<String> warnings = new ArrayList<String>();
|
||||
File dir = ((OsmandApplication) ctx.getApplicationContext()).getSettings().getExternalStorageDirectory();
|
||||
if (dir.canWrite()) {
|
||||
dir = new File(dir, ResourceManager.GPX_PATH);
|
||||
File dir = ctx.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
if (dir.getParentFile().canWrite()) {
|
||||
dir.mkdirs();
|
||||
if (dir.exists()) {
|
||||
|
||||
Map<String, GPXFile> data = collectRecordedData();
|
||||
|
||||
// save file
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Set;
|
|||
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.map.TileSourceManager;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
|
@ -22,7 +23,6 @@ import net.osmand.plus.OsmandSettings.MetricsConstants;
|
|||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.ProgressDialogImplementation;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.CustomTitleBar.CustomTitleBarView;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
|
@ -240,7 +240,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
|||
|
||||
private Set<String> getVoiceFiles() {
|
||||
// read available voice data
|
||||
File extStorage = osmandSettings.extendOsmandPath(ResourceManager.VOICE_PATH);
|
||||
File extStorage = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||
Set<String> setFiles = new LinkedHashSet<String>();
|
||||
if (extStorage.exists()) {
|
||||
for (File f : extStorage.listFiles()) {
|
||||
|
@ -737,7 +737,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
|||
if (preference.getKey().equals(OsmandSettings.LOCAL_INDEXES)) {
|
||||
boolean empty = getMyApplication().getResourceManager().getIndexFileNames().isEmpty();
|
||||
if (empty) {
|
||||
File folder = getMyApplication().getSettings().extendOsmandPath(ResourceManager.BACKUP_PATH);
|
||||
File folder = getMyApplication().getAppPath(IndexConstants.BACKUP_INDEX_DIR);
|
||||
if (folder.exists() && folder.isDirectory()) {
|
||||
String[] l = folder.list();
|
||||
empty = l == null || l.length == 0;
|
||||
|
|
|
@ -55,15 +55,6 @@ public class InternalOsmAndAPIImpl implements InternalOsmAndAPI {
|
|||
return app.getAssets().open(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getAppDir() {
|
||||
return app.getSettings().extendOsmandPath(ResourceManager.APP_DIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getAppDir(String extend) {
|
||||
return app.getSettings().extendOsmandPath(ResourceManager.APP_DIR + extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NativeLibrary getNativeLibrary() {
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.Location;
|
|||
import net.osmand.LogUtil;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.DataTileManager;
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.osm.LatLon;
|
||||
import net.osmand.osm.MapUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
|
@ -21,7 +22,6 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
|
@ -320,7 +320,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
private File getBaseFileName(double lat, double lon, OsmandApplication app, String ext) {
|
||||
String basename = MapUtils.createShortLocString(lat, lon, 15);
|
||||
int k = 1;
|
||||
File f = app.getSettings().extendOsmandPath(ResourceManager.AV_PATH);
|
||||
File f = app.getAppPath(IndexConstants.AV_INDEX_DIR);
|
||||
f.mkdirs();
|
||||
File fl;
|
||||
do {
|
||||
|
@ -535,7 +535,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public List<String> indexingFiles(IProgress progress) {
|
||||
File avPath = app.getSettings().extendOsmandPath(ResourceManager.AV_PATH);
|
||||
File avPath = app.getAppPath(IndexConstants.AV_INDEX_DIR);
|
||||
if (avPath.canRead()) {
|
||||
recordings.clear();
|
||||
File[] files = avPath.listFiles();
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.plus.ClientContext;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -47,12 +48,11 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem
|
|||
}
|
||||
|
||||
public void updateLoadedFiles() {
|
||||
OsmandSettings settings = getMyApplication().getSettings();
|
||||
indexActivatedFileNames = getMyApplication().getResourceManager().getIndexFileNames();
|
||||
DownloadIndexActivity.listWithAlternatives(settings.extendOsmandPath(ResourceManager.APP_DIR),
|
||||
DownloadIndexActivity.listWithAlternatives(getMyApplication().getAppPath(""),
|
||||
EXTRA_EXT, indexActivatedFileNames);
|
||||
indexFileNames = getMyApplication().getResourceManager().getIndexFileNames();
|
||||
DownloadIndexActivity.listWithAlternatives(settings.extendOsmandPath(ResourceManager.APP_DIR),
|
||||
DownloadIndexActivity.listWithAlternatives(getMyApplication().getAppPath(""),
|
||||
EXTRA_EXT, indexFileNames);
|
||||
getMyApplication().getResourceManager().getBackupIndexes(indexFileNames);
|
||||
}
|
||||
|
|
|
@ -8,12 +8,11 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import net.osmand.LogUtil;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.plus.ClientContext;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.Version;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -51,7 +50,7 @@ public class DownloadOsmandIndexesHelper {
|
|||
try {
|
||||
String ext = IndexItem.addVersionToExt(IndexConstants.TTSVOICE_INDEX_EXT_ZIP, IndexConstants.TTSVOICE_VERSION);
|
||||
String extvoice = IndexItem.addVersionToExt(IndexConstants.VOICE_INDEX_EXT_ZIP, IndexConstants.VOICE_VERSION);
|
||||
File voicePath = settings.extendOsmandPath(ResourceManager.VOICE_PATH);
|
||||
File voicePath = settings.getContext().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||
list = amanager.list("voice");
|
||||
String date = "";
|
||||
long dateModified = System.currentTimeMillis();
|
||||
|
|
|
@ -10,9 +10,9 @@ import java.net.URL;
|
|||
import net.osmand.Algoritms;
|
||||
import net.osmand.LogUtil;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class YandexTrafficAdapter extends MapTileAdapter {
|
|||
}
|
||||
|
||||
private void clearCache() {
|
||||
File dir = view.getSettings().extendOsmandPath(ResourceManager.TILES_PATH);
|
||||
File dir = view.getApplication().getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||
for (File ds : dir.listFiles()) {
|
||||
if (ds.isDirectory() && ds.getName().startsWith(YANDEX_PREFFIX)) {
|
||||
Algoritms.removeAllFiles(ds);
|
||||
|
|
|
@ -2,9 +2,9 @@ package net.osmand.plus.voice;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import net.osmand.data.IndexConstants;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import android.app.Activity;
|
||||
|
||||
public class CommandPlayerFactory
|
||||
|
@ -13,7 +13,7 @@ public class CommandPlayerFactory
|
|||
throws CommandPlayerException
|
||||
{
|
||||
if (voiceProvider != null){
|
||||
File parent = osmandApplication.getInternalAPI().getAppDir(ResourceManager.VOICE_PATH);
|
||||
File parent = osmandApplication.getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||
File voiceDir = new File(parent, voiceProvider);
|
||||
if(!voiceDir.exists()){
|
||||
throw new CommandPlayerException(ctx.getString(R.string.voice_data_unavailable));
|
||||
|
|
Loading…
Reference in a new issue