diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 604e1620a7..2c12d35383 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -445,7 +445,7 @@ public class AppInitializer implements IProgress { app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class); app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class); app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class); - app.wikivoyageDbHelper = startupInit(new TravelDbHelper(app), TravelDbHelper.class); + app.travelDbHelper = startupInit(new TravelDbHelper(app), TravelDbHelper.class); initOpeningHoursParser(); } diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index db61b71e28..456d1ae47b 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -20,7 +20,7 @@ import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.mapmarkers.MapMarkersDbHelper; import net.osmand.plus.mapmarkers.MarkersPlanRouteContext; import net.osmand.plus.wikivoyage.data.TravelDbHelper; -import net.osmand.plus.wikivoyage.data.WikivoyageArticle; +import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; @@ -504,8 +504,8 @@ public class MapMarkersHelper { List res = new ArrayList<>(); TravelDbHelper travelDbHelper = ctx.getTravelDbHelper(); if(travelDbHelper.getSelectedTravelBook() != null) { - List savedArticles = travelDbHelper.getLocalDataHelper().getSavedArticles(); - for (WikivoyageArticle art : savedArticles) { + List savedArticles = travelDbHelper.getLocalDataHelper().getSavedArticles(); + for (TravelArticle art : savedArticles) { String gpxName = travelDbHelper.getGPXName(art); File path = ctx.getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName); MapMarkersGroup group = getOrCreateGroup(new File(path.getAbsolutePath())); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 15e9e666d4..c4bd9066c6 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -34,9 +34,9 @@ import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment; import net.osmand.plus.wikivoyage.WikivoyageWebViewClient; -import net.osmand.plus.wikivoyage.data.WikivoyageArticle; +import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelDbHelper; -import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; +import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import net.osmand.util.Algorithms; import java.io.File; @@ -98,7 +98,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private long cityId = NO_VALUE; private ArrayList langs; private String selectedLang; - private WikivoyageArticle article; + private TravelArticle article; private TextView trackButton; private TextView selectedLangTv; @@ -267,7 +267,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private void updateSaveButton() { if (article != null) { - final WikivoyageLocalDataHelper helper = getMyApplication().getTravelDbHelper().getLocalDataHelper(); + final TravelLocalDataHelper helper = getMyApplication().getTravelDbHelper().getLocalDataHelper(); final boolean saved = helper.isArticleSaved(article); Drawable icon = getActiveIcon(saved ? R.drawable.ic_action_read_later_fill : R.drawable.ic_action_read_later); saveBtn.setText(getString(saved ? R.string.shared_string_delete : R.string.shared_string_save)); @@ -335,7 +335,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen trackButton.setText(getString(R.string.points) + " (" + article.getGpxFile().getPointsSize() +")"); } - WikivoyageLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper(); + TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper(); ldh.addToHistory(article); updateSaveButton(); @@ -348,12 +348,12 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen } @NonNull - private String createHtmlContent(@NonNull WikivoyageArticle article) { + private String createHtmlContent(@NonNull TravelArticle article) { StringBuilder sb = new StringBuilder(HEADER_INNER); String imageTitle = article.getImageTitle(); if (!TextUtils.isEmpty(imageTitle)) { - String url = WikivoyageArticle.getImageUrl(imageTitle, false); + String url = TravelArticle.getImageUrl(imageTitle, false); sb.append("
"); } sb.append("
\n"); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java similarity index 98% rename from OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java rename to OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java index 492021bfe7..14b2e9e482 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java @@ -11,7 +11,7 @@ import net.osmand.plus.GPXUtilities.GPXFile; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; -public class WikivoyageArticle { +public class TravelArticle { private static final String IMAGE_ROOT_URL = "https://upload.wikimedia.org/wikipedia/commons/"; private static final String THUMB_PREFIX = "320px-"; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 369d705b6f..532d807787 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -75,7 +75,7 @@ public class TravelDbHelper { private File selectedTravelBook = null; private List existingTravelBooks = new ArrayList<>(); private Collator collator; - private WikivoyageLocalDataHelper localDataHelper; + private TravelLocalDataHelper localDataHelper; private boolean initialized = false; @@ -87,7 +87,7 @@ public class TravelDbHelper { } } - public WikivoyageLocalDataHelper getLocalDataHelper() { + public TravelLocalDataHelper getLocalDataHelper() { initTravelBooks(); return localDataHelper; } @@ -100,7 +100,7 @@ public class TravelDbHelper { File[] possibleFiles = application.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles(); String travelBook = application.getSettings().SELECTED_TRAVEL_BOOK.get(); existingTravelBooks.clear(); - localDataHelper = new WikivoyageLocalDataHelper(application); + localDataHelper = new TravelLocalDataHelper(application); if (possibleFiles != null) { for (File f : possibleFiles) { if (f.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) { @@ -243,8 +243,8 @@ public class TravelDbHelper { } @Nullable - public WikivoyageArticle getArticle(long cityId, String lang) { - WikivoyageArticle res = null; + public TravelArticle getArticle(long cityId, String lang) { + TravelArticle res = null; SQLiteConnection conn = openConnection(); if (conn != null) { SQLiteCursor cursor = conn.rawQuery(ARTICLES_TABLE_SELECT + " WHERE " + ARTICLES_COL_CITY_ID + " = ? AND " @@ -302,8 +302,8 @@ public class TravelDbHelper { } @NonNull - private WikivoyageArticle readArticle(SQLiteCursor cursor) { - WikivoyageArticle res = new WikivoyageArticle(); + private TravelArticle readArticle(SQLiteCursor cursor) { + TravelArticle res = new TravelArticle(); res.id = cursor.getString(0); res.title = cursor.getString(1); @@ -339,7 +339,7 @@ public class TravelDbHelper { return nm.substring(0, nm.indexOf('.')).replace('_', ' '); } - public String getGPXName(WikivoyageArticle article) { + public String getGPXName(TravelArticle article) { return article.getTitle().replace('/', '_').replace('\'', '_').replace('\"', '_') + ".gpx"; } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java similarity index 91% rename from OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java rename to OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index c81372d15a..86f1762493 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -14,14 +14,14 @@ import java.util.List; import gnu.trove.map.hash.TLongObjectHashMap; -public class WikivoyageLocalDataHelper { +public class TravelLocalDataHelper { private static final int HISTORY_ITEMS_LIMIT = 300; private WikivoyageLocalDataDbHelper dbHelper; private TLongObjectHashMap historyMap; - private List savedArticles; + private List savedArticles; private Listener listener; @@ -29,7 +29,7 @@ public class WikivoyageLocalDataHelper { this.listener = listener; } - WikivoyageLocalDataHelper(OsmandApplication app) { + TravelLocalDataHelper(OsmandApplication app) { dbHelper = new WikivoyageLocalDataDbHelper(app); refreshCachedData(); } @@ -60,7 +60,7 @@ public class WikivoyageLocalDataHelper { dbHelper.clearAllHistory(); } - public void addToHistory(@NonNull WikivoyageArticle article) { + public void addToHistory(@NonNull TravelArticle article) { addToHistory(article.getCityId(), article.getTitle(), article.getLang(), article.getIsPartOf()); } @@ -90,13 +90,13 @@ public class WikivoyageLocalDataHelper { } @NonNull - public List getSavedArticles() { + public List getSavedArticles() { return new ArrayList<>(savedArticles); } - public void addArticleToSaved(@NonNull WikivoyageArticle article) { + public void addArticleToSaved(@NonNull TravelArticle article) { if (!isArticleSaved(article)) { - WikivoyageArticle saved = new WikivoyageArticle(); + TravelArticle saved = new TravelArticle(); saved.cityId = article.cityId; saved.title = article.title; saved.lang = article.lang; @@ -109,7 +109,7 @@ public class WikivoyageLocalDataHelper { } } - public void restoreSavedArticle(@NonNull WikivoyageArticle article) { + public void restoreSavedArticle(@NonNull TravelArticle article) { if (!isArticleSaved(article)) { savedArticles.add(article); dbHelper.addSavedArticle(article); @@ -117,8 +117,8 @@ public class WikivoyageLocalDataHelper { } } - public void removeArticleFromSaved(@NonNull WikivoyageArticle article) { - WikivoyageArticle savedArticle = getArticle(article.cityId, article.lang); + public void removeArticleFromSaved(@NonNull TravelArticle article) { + TravelArticle savedArticle = getArticle(article.cityId, article.lang); if (savedArticle != null) { savedArticles.remove(savedArticle); dbHelper.removeSavedArticle(savedArticle); @@ -126,7 +126,7 @@ public class WikivoyageLocalDataHelper { } } - public boolean isArticleSaved(@NonNull WikivoyageArticle article) { + public boolean isArticleSaved(@NonNull TravelArticle article) { return getArticle(article.cityId, article.lang) != null; } @@ -137,8 +137,8 @@ public class WikivoyageLocalDataHelper { } @Nullable - private WikivoyageArticle getArticle(long cityId, String lang) { - for (WikivoyageArticle article : savedArticles) { + private TravelArticle getArticle(long cityId, String lang) { + for (TravelArticle article : savedArticles) { if (article.cityId == cityId && article.lang != null && article.lang.equals(lang)) { return article; } @@ -340,8 +340,8 @@ public class WikivoyageLocalDataHelper { } @NonNull - List getSavedArticles() { - List res = new ArrayList<>(); + List getSavedArticles() { + List res = new ArrayList<>(); SQLiteConnection conn = openConnection(true); if (conn != null) { try { @@ -361,7 +361,7 @@ public class WikivoyageLocalDataHelper { return res; } - void addSavedArticle(WikivoyageArticle article) { + void addSavedArticle(TravelArticle article) { SQLiteConnection conn = openConnection(false); if (conn != null) { try { @@ -375,7 +375,7 @@ public class WikivoyageLocalDataHelper { } } - void removeSavedArticle(WikivoyageArticle article) { + void removeSavedArticle(TravelArticle article) { SQLiteConnection conn = openConnection(false); if (conn != null) { try { @@ -403,8 +403,8 @@ public class WikivoyageLocalDataHelper { return res; } - private WikivoyageArticle readSavedArticle(SQLiteCursor cursor) { - WikivoyageArticle res = new WikivoyageArticle(); + private TravelArticle readSavedArticle(SQLiteCursor cursor) { + TravelArticle res = new TravelArticle(); res.cityId = cursor.getLong(0); res.title = cursor.getString(1); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 8da2f261d6..f2d1277bf6 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -23,8 +23,8 @@ import net.osmand.plus.R; import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.widgets.tools.CropRectTransformation; import net.osmand.plus.wikivoyage.WikivoyageUtils; -import net.osmand.plus.wikivoyage.data.WikivoyageArticle; -import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; +import net.osmand.plus.wikivoyage.data.TravelArticle; +import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import java.util.ArrayList; import java.util.List; @@ -80,10 +80,10 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter getItems() { List items = new ArrayList<>(); - List savedArticles = dataHelper.getSavedArticles(); + List savedArticles = dataHelper.getSavedArticles(); if (!savedArticles.isEmpty()) { Collections.reverse(savedArticles); items.add(getString(R.string.saved_articles)); @@ -126,12 +126,12 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Wiki Object newItem = newItems.get(newItemPosition); if (oldItem instanceof String && newItem instanceof String) { return false; - } else if (oldItem instanceof WikivoyageArticle && newItem instanceof WikivoyageArticle) { + } else if (oldItem instanceof TravelArticle && newItem instanceof TravelArticle) { if (newItemPosition == newItems.size() - 1 && lastItemChanged()) { return false; } - WikivoyageArticle oldArticle = (WikivoyageArticle) oldItem; - WikivoyageArticle newArticle = (WikivoyageArticle) newItem; + TravelArticle oldArticle = (TravelArticle) oldItem; + TravelArticle newArticle = (TravelArticle) newItem; return oldArticle.getCityId() == newArticle.getCityId() && oldArticle.getLang().equals(newArticle.getLang()); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java index 6df0633cd5..a4209ac0f2 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java @@ -22,7 +22,7 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.wikivoyage.data.TravelDbHelper; -import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; +import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import java.io.File; import java.util.List; @@ -110,7 +110,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - WikivoyageLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper(); + TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper(); ldh.clearHistory(); dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java index 213a7ed470..8811b3c203 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java @@ -20,7 +20,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.wikivoyage.WikivoyageUtils; -import net.osmand.plus.wikivoyage.data.WikivoyageArticle; +import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.WikivoyageSearchHistoryItem; import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; import net.osmand.util.Algorithms; @@ -77,7 +77,7 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter items) { if (items == null || items.isEmpty()) { - WikivoyageLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper(); + TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper(); adapter.setHistoryItems(ldh.getAllHistory()); } else { adapter.setItems(items);