Fix modified date (unified UTC solution)
This commit is contained in:
parent
7552c91b01
commit
71b98f79f0
5 changed files with 20 additions and 25 deletions
|
@ -1,6 +1,5 @@
|
|||
package net.osmand;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.util.ArrayList;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
|
@ -31,7 +30,6 @@ import net.osmand.plus.srtmplugin.SRTMPlugin;
|
|||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
|
@ -41,7 +39,6 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
|
@ -506,16 +503,14 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
}
|
||||
|
||||
|
||||
public static Map<String, String> listWithAlternatives(final Context ctx, File file, final String ext,
|
||||
public static Map<String, String> listWithAlternatives(final java.text.DateFormat dateFormat, File file, final String ext,
|
||||
final Map<String, String> files) {
|
||||
if (file.isDirectory()) {
|
||||
final java.text.DateFormat format = DateFormat.getDateFormat(ctx);
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT+01:00"));
|
||||
file.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String filename) {
|
||||
if (filename.endsWith(ext)) {
|
||||
String date = format.format(new File(dir, filename).lastModified());
|
||||
String date = dateFormat.format(new File(dir, filename).lastModified());
|
||||
files.put(filename, date);
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -47,7 +47,7 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem
|
|||
list.clear();
|
||||
list.addAll(cats);
|
||||
}
|
||||
format = DateFormat.getDateFormat(downloadActivity);
|
||||
format = downloadActivity.getMyApplication().getResourceManager().getDateFormat();
|
||||
okColor = downloadActivity.getResources().getColor(R.color.color_ok);
|
||||
TypedArray ta = downloadActivity.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary});
|
||||
defaultColor = ta.getColor(0, downloadActivity.getResources().getColor(R.color.color_unknown));
|
||||
|
|
|
@ -43,7 +43,6 @@ import android.os.AsyncTask;
|
|||
import android.os.AsyncTask.Status;
|
||||
import android.os.Build;
|
||||
import android.os.StatFs;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -66,7 +65,7 @@ public class DownloadIndexesThread {
|
|||
this.ctx = ctx;
|
||||
app = (OsmandApplication) ctx.getApplicationContext();
|
||||
downloadFileHelper = new DownloadFileHelper(app);
|
||||
dateFormat = DateFormat.getDateFormat(app);
|
||||
dateFormat = app.getResourceManager().getDateFormat();
|
||||
}
|
||||
|
||||
public void setUiActivity(DownloadIndexActivity uiActivity) {
|
||||
|
@ -89,12 +88,12 @@ public class DownloadIndexesThread {
|
|||
|
||||
public void updateLoadedFiles() {
|
||||
Map<String, String> indexActivatedFileNames = app.getResourceManager().getIndexFileNames();
|
||||
DownloadIndexActivity.listWithAlternatives(app, app.getAppPath(""),
|
||||
IndexConstants.EXTRA_EXT, indexActivatedFileNames);
|
||||
DownloadIndexActivity.listWithAlternatives(dateFormat, app.getAppPath(""), IndexConstants.EXTRA_EXT,
|
||||
indexActivatedFileNames);
|
||||
Map<String, String> indexFileNames = app.getResourceManager().getIndexFileNames();
|
||||
DownloadIndexActivity.listWithAlternatives(app, app.getAppPath(""),
|
||||
IndexConstants.EXTRA_EXT, indexFileNames);
|
||||
DownloadIndexActivity.listWithAlternatives(app,app.getAppPath(IndexConstants.TILES_INDEX_DIR),
|
||||
DownloadIndexActivity.listWithAlternatives(dateFormat, app.getAppPath(""), IndexConstants.EXTRA_EXT,
|
||||
indexFileNames);
|
||||
DownloadIndexActivity.listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.TILES_INDEX_DIR),
|
||||
IndexConstants.SQLITE_EXT, indexFileNames);
|
||||
app.getResourceManager().getBackupIndexes(indexFileNames);
|
||||
this.indexFileNames = indexFileNames;
|
||||
|
@ -535,8 +534,8 @@ public class DownloadIndexesThread {
|
|||
}
|
||||
|
||||
|
||||
public boolean isDownloadRunning(){
|
||||
for(int i =0; i<currentRunningTask.size(); i++) {
|
||||
public boolean isDownloadRunning() {
|
||||
for (int i = 0; i < currentRunningTask.size(); i++) {
|
||||
if (currentRunningTask.get(i) instanceof DownloadIndexesAsyncTask) {
|
||||
return true;
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.Collections;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -135,8 +134,10 @@ public class ResourceManager {
|
|||
private HandlerThread renderingBufferImageThread;
|
||||
|
||||
protected boolean internetIsNotAccessible = false;
|
||||
private java.text.DateFormat dateFormat;
|
||||
|
||||
public ResourceManager(OsmandApplication context) {
|
||||
|
||||
this.context = context;
|
||||
this.renderer = new MapRenderRepositories(context);
|
||||
asyncLoadingThread.start();
|
||||
|
@ -144,7 +145,7 @@ public class ResourceManager {
|
|||
renderingBufferImageThread.start();
|
||||
|
||||
tileDownloader = MapTileDownloader.getInstance(Version.getFullVersion(context));
|
||||
|
||||
dateFormat = DateFormat.getDateFormat(context);
|
||||
resetStoreDirectory();
|
||||
WindowManager mgr = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
|
@ -176,6 +177,9 @@ public class ResourceManager {
|
|||
}
|
||||
}
|
||||
|
||||
public java.text.DateFormat getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public OsmandApplication getContext() {
|
||||
return context;
|
||||
|
@ -436,7 +440,6 @@ public class ResourceManager {
|
|||
file.mkdirs();
|
||||
List<String> warnings = new ArrayList<String>();
|
||||
if (file.exists() && file.canRead()) {
|
||||
final java.text.DateFormat format = DateFormat.getDateFormat(context);
|
||||
File[] lf = file.listFiles();
|
||||
if (lf != null) {
|
||||
for (File f : lf) {
|
||||
|
@ -446,7 +449,7 @@ public class ResourceManager {
|
|||
conf = new File(f, "_ttsconfig.p");
|
||||
}
|
||||
if (conf.exists()) {
|
||||
indexFileNames.put(f.getName(), format.format(conf.lastModified())); //$NON-NLS-1$
|
||||
indexFileNames.put(f.getName(), dateFormat.format(conf.lastModified())); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +617,6 @@ public class ResourceManager {
|
|||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
final java.text.DateFormat format = DateFormat.getDateFormat(context);
|
||||
for (File f : files) {
|
||||
progress.startTask(context.getString(R.string.indexing_map) + " " + f.getName(), -1); //$NON-NLS-1$
|
||||
try {
|
||||
|
@ -640,7 +642,7 @@ public class ResourceManager {
|
|||
if (dateCreated == 0) {
|
||||
dateCreated = f.lastModified();
|
||||
}
|
||||
indexFileNames.put(f.getName(), format.format(dateCreated)); //$NON-NLS-1$
|
||||
indexFileNames.put(f.getName(), dateFormat.format(dateCreated)); //$NON-NLS-1$
|
||||
for (String rName : index.getRegionNames()) {
|
||||
// skip duplicate names (don't make collision between getName() and name in the map)
|
||||
// it can be dangerous to use one file to different indexes if it is multithreaded
|
||||
|
|
Loading…
Reference in a new issue