Exclude altitude from paid packages & fix update required

This commit is contained in:
Victor Shcherb 2014-12-06 23:22:24 +01:00
parent 948b29697e
commit 65525005c5
3 changed files with 36 additions and 26 deletions

View file

@ -51,8 +51,9 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
if (downloadListIndexThread == null) {
downloadListIndexThread = new DownloadIndexesThread(this);
}
//Having the next line here causes bug AND-197: The storage folder dialogue popped up upon EVERY app startup, because the map list is not indexed yet. Hence line moved to updateDownloads() now.
// prepareDownloadDirectory();
// Having the next line here causes bug AND-197: The storage folder dialogue popped up upon EVERY app startup, because the map list is not indexed yet.
// Hence line moved to updateDownloads() now.
// prepareDownloadDirectory();
}
public void updateDownloads() {

View file

@ -542,28 +542,9 @@ public class DownloadIndexesThread {
if (filtered != null) {
itemsToUpdate.clear();
for (IndexItem item : filtered) {
String sfName = item.getTargetFileName();
java.text.DateFormat format = app.getResourceManager().getDateFormat();
String date = item.getDate(format);
String indexactivateddate = indexActivatedFileNames.get(sfName);
String indexfilesdate = indexFileNames.get(sfName);
if (date != null &&
!date.equals(indexactivateddate) &&
!date.equals(indexfilesdate) &&
indexActivatedFileNames.containsKey(sfName)) {
if ((item.getType() == DownloadActivityType.NORMAL_FILE && !item.extra) ||
item.getType() == DownloadActivityType.ROADS_FILE ||
item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE){
itemsToUpdate.add(item);
} else {
long itemSize = item.getContentSize();
File file = new File(item.getType().getDownloadFolder(app, item), sfName);
long oldItemSize = file.length();
if (itemSize != oldItemSize){
itemsToUpdate.add(item);
}
}
boolean outdated = checkIfItemOutdated(item);
if(outdated) {
itemsToUpdate.add(item);
}
}
if (uiActivity != null){
@ -572,6 +553,33 @@ public class DownloadIndexesThread {
}
}
public boolean checkIfItemOutdated(IndexItem item) {
boolean outdated = false;
String sfName = item.getTargetFileName();
java.text.DateFormat format = app.getResourceManager().getDateFormat();
String date = item.getDate(format);
String indexactivateddate = indexActivatedFileNames.get(sfName);
String indexfilesdate = indexFileNames.get(sfName);
if (date != null &&
!date.equals(indexactivateddate) &&
!date.equals(indexfilesdate) &&
indexActivatedFileNames.containsKey(sfName)) {
if ((item.getType() == DownloadActivityType.NORMAL_FILE && !item.extra) ||
item.getType() == DownloadActivityType.ROADS_FILE ||
item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE){
outdated = true;
} else {
long itemSize = item.getContentSize();
File file = new File(item.getType().getDownloadFolder(app, item), sfName);
long oldItemSize = file.length();
if (itemSize != oldItemSize){
outdated = true;
}
}
}
return outdated;
}
private void updateFilesToUpdate(){
List<IndexItem> stillUpdate = new ArrayList<IndexItem>();
for (IndexItem item : itemsToUpdate) {

View file

@ -239,7 +239,8 @@ public class UpdatesIndexFragment extends SherlockListFragment {
if (indexActivatedFileNames != null && indexFileNames != null){
String sfName = e.getTargetFileName();
if (e.getDate(format).equals(indexActivatedFileNames.get(sfName))) {
final boolean updatableResource = indexActivatedFileNames.containsKey(sfName);
if (updatableResource && !DownloadActivity.downloadListIndexThread.checkIfItemOutdated(e)) {
name.setText(name.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : "
+ indexActivatedFileNames.get(sfName));
name.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
@ -247,7 +248,7 @@ public class UpdatesIndexFragment extends SherlockListFragment {
name.setText(name.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : "
+ indexFileNames.get(sfName));
name.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
} else if (indexActivatedFileNames.containsKey(sfName)) {
} else if (updatableResource) {
name.setText(name.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : "
+ indexActivatedFileNames.get(sfName));
name.setTextColor(updateColor); // LIGHT_BLUE