Merge branch 'master' of https://github.com/osmandapp/OsmAnd into custom_tabs_in_opr
This commit is contained in:
commit
d3e73e103e
7 changed files with 56 additions and 32 deletions
|
@ -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<IndexItem> 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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<File> getExistingTravelBooks() {
|
||||
return existingTravelBooks;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -142,7 +142,9 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
public void addNeededMapsCard(TravelNeededMapsCard card) {
|
||||
this.neededMapsCard = card;
|
||||
if (addItem(getNeededMapsCardPosition(), card)) {
|
||||
if (neededMapsCardExists(getNeededMapsCardPosition())) {
|
||||
updateNeededMapsCard(false);
|
||||
} else if (addItem(getNeededMapsCardPosition(), card)) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +185,9 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
public void addDownloadUpdateCard(TravelDownloadUpdateCard card) {
|
||||
this.downloadCard = card;
|
||||
if (addItem(getDownloadUpdateCardPosition(), card)) {
|
||||
if (downloadUpdateCardExists(getDownloadUpdateCardPosition())) {
|
||||
updateDownloadUpdateCard(false);
|
||||
} else if (addItem(getDownloadUpdateCardPosition(), card)) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@ import java.util.List;
|
|||
|
||||
public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEvents, TravelLocalDataHelper.Listener {
|
||||
|
||||
private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.sqlite";
|
||||
|
||||
private static boolean SHOW_TRAVEL_UPDATE_CARD = true;
|
||||
private static boolean SHOW_TRAVEL_NEEDED_MAPS_CARD = true;
|
||||
|
||||
|
@ -342,14 +340,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
|||
return res.toArray(new IndexItem[0]);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String getWikivoyageFileName() {
|
||||
// OsmandApplication app = getMyApplication();
|
||||
// File selectedTravelBook = app != null ? app.getTravelDbHelper().getSelectedTravelBook() : null;
|
||||
// return selectedTravelBook == null ? WORLD_WIKIVOYAGE_FILE_NAME : selectedTravelBook.getName();
|
||||
return WORLD_WIKIVOYAGE_FILE_NAME;
|
||||
}
|
||||
|
||||
private void removeDownloadUpdateCard() {
|
||||
if (adapter != null) {
|
||||
adapter.removeDownloadUpdateCard();
|
||||
|
@ -379,7 +369,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
|||
ProcessIndexItemsTask(ExploreTabFragment fragment) {
|
||||
app = fragment.getMyApplication();
|
||||
weakFragment = new WeakReference<>(fragment);
|
||||
fileName = fragment.getWikivoyageFileName();
|
||||
fileName = app.getTravelHelper().getWikivoyageFileName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue