Fix download tour file
This commit is contained in:
parent
098e1a6782
commit
3b59d2112e
6 changed files with 32 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.Window;
|
||||
|
@ -27,6 +28,7 @@ public class OsmAndAppCustomization {
|
|||
return new OsmandSettings(app, api);
|
||||
}
|
||||
|
||||
// Main menu
|
||||
public boolean checkExceptionsOnStart() {
|
||||
return true;
|
||||
}
|
||||
|
@ -43,7 +45,7 @@ public class OsmAndAppCustomization {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// Activities
|
||||
public Class<? extends Activity> getSettingsActivity(){
|
||||
return SettingsActivity.class;
|
||||
}
|
||||
|
@ -76,8 +78,12 @@ public class OsmAndAppCustomization {
|
|||
return LocalIndexesActivity.class;
|
||||
}
|
||||
|
||||
// Download screen
|
||||
public void getDownloadTypes(List<DownloadActivityType> items) {
|
||||
|
||||
}
|
||||
|
||||
public void updatedLoadedFiles(Map<String, String> indexFileNames, Map<String, String> indexActivatedFileNames) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -501,13 +501,27 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
@Override
|
||||
public boolean accept(File dir, String filename) {
|
||||
if (filename.endsWith(ext)) {
|
||||
String date = dateFormat.format(new File(dir, filename).lastModified());
|
||||
String date = dateFormat.format(findFile(new File(dir, filename)).lastModified());
|
||||
files.put(filename, date);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private File findFile(File file) {
|
||||
if(file.isDirectory()) {
|
||||
File[] lf = file.listFiles();
|
||||
if(lf != null) {
|
||||
for(File f : lf) {
|
||||
if(f.isFile()) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -281,6 +281,7 @@ public class DownloadFileHelper {
|
|||
|
||||
private void copyFile(DownloadEntry de, IProgress progress, CountingMultiInputStream countIS, int length, InputStream toRead, File targetFile)
|
||||
throws IOException {
|
||||
targetFile.getParentFile().mkdirs();
|
||||
FileOutputStream out = new FileOutputStream(targetFile);
|
||||
int read;
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
|
|
|
@ -93,6 +93,7 @@ public class DownloadIndexesThread {
|
|||
Map<String, String> indexFileNames = app.getResourceManager().getIndexFileNames();
|
||||
DownloadIndexActivity.listWithAlternatives(dateFormat, app.getAppPath(""), IndexConstants.EXTRA_EXT,
|
||||
indexFileNames);
|
||||
app.getAppCustomization().updatedLoadedFiles(indexFileNames, indexActivatedFileNames);
|
||||
DownloadIndexActivity.listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.TILES_INDEX_DIR),
|
||||
IndexConstants.SQLITE_EXT, indexFileNames);
|
||||
app.getResourceManager().getBackupIndexes(indexFileNames);
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.sherpafy.TourDownloadType;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
|
|
@ -4,11 +4,13 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.DownloadIndexActivity;
|
||||
import net.osmand.plus.activities.MainMenuActivity;
|
||||
import net.osmand.plus.api.FileSettingsAPIImpl;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
|
@ -93,4 +95,9 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
super.getDownloadTypes(items);
|
||||
items.add(0, TourDownloadType.TOUR);
|
||||
}
|
||||
|
||||
public void updatedLoadedFiles(java.util.Map<String,String> indexFileNames, java.util.Map<String,String> indexActivatedFileNames) {
|
||||
DownloadIndexActivity.listWithAlternatives(app.getResourceManager().getDateFormat(),
|
||||
app.getAppPath("tours"), "", indexFileNames);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue