diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java index 2bff73d7b2..f28310645e 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java @@ -8,9 +8,9 @@ import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.map.OsmandRegions; import net.osmand.map.WorldRegion; +import net.osmand.plus.CustomRegion; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.CustomRegion; import net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.util.Algorithms; @@ -21,6 +21,7 @@ import java.io.File; import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; +import java.text.DateFormat; import java.text.ParseException; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -80,7 +81,7 @@ public class DownloadResources extends DownloadResourceGroup { List items = getWikivoyageItems(); if (items != null) { for (IndexItem ii : items) { - if (ii.getFileName().equals(fileName)) { + if (ii.getTargetFile(app).getName().equals(fileName)) { return ii; } } @@ -177,6 +178,8 @@ public class DownloadResources extends DownloadResourceGroup { } } if (date != null && !date.equals(indexActivatedDate) && !date.equals(indexFilesDate)) { + long oldItemSize = 0; + long itemSize = item.getContentSize(); if ((item.getType() == DownloadActivityType.NORMAL_FILE && !item.extra) || item.getType() == DownloadActivityType.ROADS_FILE || item.getType() == DownloadActivityType.WIKIPEDIA_FILE @@ -185,15 +188,12 @@ public class DownloadResources extends DownloadResourceGroup { outdated = true; } else if (item.getType() == DownloadActivityType.WIKIVOYAGE_FILE || item.getType() == DownloadActivityType.TRAVEL_FILE) { - long itemSize = item.getContentSize(); - long oldItemSize = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR + + oldItemSize = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR + item.getTargetFileName()).length(); if (itemSize != oldItemSize) { outdated = true; } } else { - long itemSize = item.getContentSize(); - long oldItemSize = 0; if (parsed && item.getTimestamp() > item.getLocalTimestamp()) { outdated = true; } else if (item.getType() == DownloadActivityType.VOICE_FILE) { @@ -223,12 +223,23 @@ public class DownloadResources extends DownloadResourceGroup { outdated = true; } } + if (outdated) { + logItemUpdateInfo(item, format, itemSize, oldItemSize); + } } item.setOutdated(outdated); return outdated; } - + private void logItemUpdateInfo(IndexItem item, DateFormat format, long itemSize, long oldItemSize) { + String date = item.getDate(format); + String sfName = item.getTargetFileName(); + String indexActivatedDate = indexActivatedFileNames.get(sfName); + String indexFilesDate = indexFileNames.get(sfName); + LOG.info("name " + item.getFileName() + " timestamp " + item.timestamp + " localTimestamp " + item.localTimestamp + " date " + date + + " indexActivatedDate " + indexActivatedDate + " indexFilesDate " + indexFilesDate + + " itemSize " + itemSize + " oldItemSize " + oldItemSize); + } protected void updateFilesToUpdate() { initAlreadyLoadedFiles(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java index a715c33354..21b61d1fe3 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java @@ -72,20 +72,13 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment { String userNameOpenID = settings.USER_NAME.get(); String userName = isLoginOAuth(settings) ? userNameOAuth : userNameOpenID; accountName.setText(userName); - closeChangeSet.setBackgroundResource(isNightMode ? R.drawable.layout_bg_dark : R.drawable.layout_bg); final int paddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small); - closeChangeSet.setPadding(paddingSmall, 0, paddingSmall, 0); + closeChangeSet.setChecked(true); + setCloseChangeSet(isNightMode, paddingSmall); closeChangeSet.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (isNightMode) { - closeChangeSet.setBackgroundResource( - isChecked ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark); - } else { - closeChangeSet.setBackgroundResource( - isChecked ? R.drawable.layout_bg_solid : R.drawable.layout_bg); - } - closeChangeSet.setPadding(paddingSmall, 0, paddingSmall, 0); + setCloseChangeSet(isNightMode, paddingSmall); } }); LinearLayout account = sendOsmPoiView.findViewById(R.id.account_container); @@ -254,5 +247,16 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment { } return comment; } + + private void setCloseChangeSet(boolean isNightMode, int paddingSmall) { + if (isNightMode) { + closeChangeSet.setBackgroundResource( + closeChangeSet.isChecked() ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark); + } else { + closeChangeSet.setBackgroundResource( + closeChangeSet.isChecked() ? R.drawable.layout_bg_solid : R.drawable.layout_bg); + } + closeChangeSet.setPadding(paddingSmall, 0, paddingSmall, 0); + } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index d50d05e42b..ef6dbd921e 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -46,6 +46,7 @@ public class TravelDbHelper implements TravelHelper { private static final Log LOG = PlatformUtil.getLog(TravelDbHelper.class); + private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.sqlite"; private static final String ARTICLES_TABLE_NAME = "travel_articles"; private static final String POPULAR_TABLE_NAME = "popular_articles"; private static final String ARTICLES_POP_INDEX = "popularity_index"; @@ -185,6 +186,11 @@ public class TravelDbHelper implements TravelHelper { return null; } + @Override + public String getWikivoyageFileName() { + return WORLD_WIKIVOYAGE_FILE_NAME; + } + public List getExistingTravelBooks() { return existingTravelBooks; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java index b55c398817..d8112cee0c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java @@ -49,4 +49,6 @@ public interface TravelHelper { // For TravelOBFHelper it could always return "" and should be no problem // Bookmarks should be refactored properly to support multiple files String getSelectedTravelBookName(); + + String getWikivoyageFileName(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 0816a2d2ef..f94ad6c592 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -37,8 +37,10 @@ import static net.osmand.CollatorStringMatcher.StringMatcherMode.CHECK_EQUALS_FR public class TravelObfHelper implements TravelHelper { private static final Log LOG = PlatformUtil.getLog(TravelObfHelper.class); - public static final String ROUTE_ARTICLE = "route_article"; - public static final int SEARCH_RADIUS = 100000; + + private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.travel.obf"; + private static final String ROUTE_ARTICLE = "route_article"; + private static final int SEARCH_RADIUS = 100000; private final OsmandApplication app; private final Collator collator; @@ -395,4 +397,9 @@ public class TravelObfHelper implements TravelHelper { public String getSelectedTravelBookName() { return ""; } + + @Override + public String getWikivoyageFileName() { + return WORLD_WIKIVOYAGE_FILE_NAME; + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java index 29951db19a..a95614bdb8 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java @@ -142,7 +142,9 @@ public class ExploreRvAdapter extends RecyclerView.Adapter(fragment); - fileName = fragment.getWikivoyageFileName(); + fileName = app.getTravelHelper().getWikivoyageFileName(); } @Override