Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-04-12 14:46:38 +02:00
commit 708ef7b9d5
29 changed files with 530 additions and 186 deletions

View file

@ -10,11 +10,15 @@ public class IndexConstants {
public final static int VOICE_VERSION = 0; //supported download versions
public final static int TTSVOICE_VERSION = 1; //supported download versions
public static final String SQLITE_EXT = ".sqlitedb"; //$NON-NLS-1$
public static final String TEMP_SOURCE_TO_LOAD = "temp";
public static final String POI_INDEX_EXT = ".poi.odb"; //$NON-NLS-1$
public static final String BINARY_MAP_INDEX_EXT = ".obf"; //$NON-NLS-1$
public static final String BINARY_MAP_INDEX_EXT_ZIP = ".obf.zip"; //$NON-NLS-1$
public static final String BINARY_WIKIVOYAGE_MAP_INDEX_EXT = ".sqlite"; //$NON-NLS-1$
public static final String BINARY_WIKI_MAP_INDEX_EXT = ".wiki.obf"; //$NON-NLS-1$
public static final String BINARY_WIKI_MAP_INDEX_EXT_ZIP = ".wiki.obf.zip"; //$NON-NLS-1$
public static final String BINARY_ROAD_MAP_INDEX_EXT = ".road.obf"; //$NON-NLS-1$
@ -54,7 +58,7 @@ public class IndexConstants {
public static final String SRTM_INDEX_DIR = "srtm/"; //$NON-NLS-1$
public static final String ROADS_INDEX_DIR = "roads/"; //$NON-NLS-1$
public static final String WIKI_INDEX_DIR = "wiki/"; //$NON-NLS-1$
public static final String WIKIVOYAGE_INDEX_DIR = "wikivoyage/";
public static final String WIKIVOYAGE_INDEX_DIR = "travel/";
public static final String AV_INDEX_DIR = "avnotes/"; //$NON-NLS-1$
public static final String FONT_INDEX_DIR = "fonts/"; //$NON-NLS-1$
public static final String VOICE_INDEX_DIR = "voice/"; //$NON-NLS-1$
@ -62,8 +66,7 @@ public class IndexConstants {
public static final String ROUTING_XML_FILE= "routing.xml";
public static final String SQLITE_EXT = ".sqlitedb"; //$NON-NLS-1$
public static final String TEMP_SOURCE_TO_LOAD = "temp";
}

View file

@ -126,3 +126,8 @@ pre {
font-style: italic;
text-align: center;
}
.content {
display: none;
overflow: hidden;
}

View file

@ -74,12 +74,6 @@
android:layout_height="10dp"
android:background="@drawable/bg_contextmenu_shadow_top_light" />
<View
android:id="@+id/bottom_row_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/wikivoyage_bottom_bar_divider_color"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
@ -98,7 +92,7 @@
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
android:paddingLeft="@dimen/bottom_sheet_content_margin"
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
android:text="@string/shared_string_contents"
@ -107,7 +101,7 @@
osmand:typeface="@string/font_roboto_medium"
tools:drawableLeft="@drawable/ic_action_list_header"
tools:drawableTint="?attr/wikivoyage_active_color"
tools:ignore="UnusedAttribute"/>
tools:ignore="UnusedAttribute" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/save_button"
@ -123,7 +117,7 @@
android:maxLines="1"
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
android:paddingRight="@dimen/bottom_sheet_content_margin"
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
android:textColor="?attr/wikivoyage_active_color"
android:textSize="@dimen/default_desc_text_size"
@ -131,7 +125,7 @@
tools:drawableRight="@drawable/ic_action_read_later_fill"
tools:drawableTint="?attr/wikivoyage_active_color"
tools:ignore="UnusedAttribute"
tools:text="Save"/>
tools:text="Save" />
</LinearLayout>

View file

@ -55,8 +55,8 @@
<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/wikivoyage_saved_article_icon_size"
android:layout_height="@dimen/wikivoyage_saved_article_icon_size"
android:layout_width="@dimen/wikivoyage_article_card_icon_size"
android:layout_height="@dimen/wikivoyage_article_card_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"

View file

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/wikivoyage_card_bg_color">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"
android:paddingTop="@dimen/content_padding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/context_menu_padding_margin_medium"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="London"/>
<TextView
android:id="@+id/part_of"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha=".5"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
tools:text="England • United Kingdom"/>
</LinearLayout>
<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/wikivoyage_article_card_icon_size"
android:layout_height="@dimen/wikivoyage_article_card_alternative_icon_height"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"
android:visibility="gone"
tools:ignore="ContentDescription"
tools:src="@drawable/ic_empty_state_marker_history_night"
tools:visibility="visible"/>
</LinearLayout>
<TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/context_menu_padding_margin_tiny"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginTop="@dimen/bottom_sheet_content_padding_small"
android:ellipsize="end"
android:maxLines="3"
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
tools:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/left_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/bottom_sheet_content_padding_small"
android:layout_marginStart="@dimen/bottom_sheet_content_padding_small"
android:background="?attr/selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
android:ellipsize="end"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
android:textColor="?attr/wikivoyage_active_color"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:drawableLeft="@drawable/ic_action_read_article"
tools:drawableTint="?attr/wikivoyage_active_color"
tools:ignore="UnusedAttribute"
tools:text="Read"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/right_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_content_padding_small"
android:layout_marginRight="@dimen/bottom_sheet_content_padding_small"
android:background="?attr/selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
android:ellipsize="end"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
android:textColor="?attr/wikivoyage_active_color"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:drawableRight="@drawable/ic_action_read_later_fill"
tools:drawableTint="?attr/wikivoyage_active_color"
tools:ignore="UnusedAttribute"
tools:text="Delete"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/wikivoyage_card_divider_color"/>
<include
android:id="@+id/shadow"
layout="@layout/card_bottom_divider"
android:visibility="gone"
tools:visibility="visible"/>
</LinearLayout>

View file

@ -1,23 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/expandable_list_item_background"
android:orientation="vertical">
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:orientation="vertical">
<TextView
android:id="@+id/item_label"
android:layout_width="wrap_content"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:layout_gravity="center_vertical"
android:drawablePadding="@dimen/showAllButtonMarginRight"
android:gravity="center"
android:paddingLeft="@dimen/showAllButtonMarginRight"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:drawableStart="@drawable/ic_action_list_sort"
tools:text="@string/shared_string_contents"
tools:textStyle="bold" />
<View
android:id="@+id/upper_row_divider"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
android:background="?attr/wikivoyage_card_divider_color" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/item_label"
android:layout_width="0dp"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:layout_weight="1"
android:drawablePadding="@dimen/bottom_sheet_content_margin"
android:gravity="start|center_vertical"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:drawableStart="@drawable/ic_action_list_header"
tools:text="@string/shared_string_contents" />
<ImageView
android:id="@+id/explist_indicator"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:scaleType="center"
tools:src="@drawable/ic_action_arrow_up" />
</LinearLayout>
<View
android:id="@+id/bottom_row_divider"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
android:background="?attr/wikivoyage_card_divider_color" />
</LinearLayout>

View file

@ -195,5 +195,6 @@
<dimen name="toolbar_height">84dp</dimen>
<dimen name="wikivoyage_search_list_header_height">54dp</dimen>
<dimen name="wikivoyage_saved_article_icon_size">120dp</dimen>
<dimen name="wikivoyage_article_card_icon_size">120dp</dimen>
<dimen name="wikivoyage_article_card_alternative_icon_height">60dp</dimen>
</resources>

View file

@ -3779,4 +3779,8 @@
<string name="poi_aerialway_zip_line">Зиплайн</string>
<string name="poi_via_ferrata">Виа феррата</string>
<string name="poi_cable_number">Количество тросов</string>
<string name="poi_via_ferrata_scale">Сложность</string>
</resources>

View file

@ -3799,4 +3799,8 @@
<string name="poi_climbing_adventure">Climbing adventure</string>
<string name="poi_via_ferrata">Via ferrata</string>
<string name="poi_cable_number">Cable number</string>
<string name="poi_via_ferrata_scale">Difficulty</string>
</resources>

View file

@ -269,7 +269,8 @@
<dimen name="toolbar_height">56dp</dimen>
<dimen name="wikivoyage_search_list_header_height">36dp</dimen>
<dimen name="wikivoyage_saved_article_icon_size">80dp</dimen>
<dimen name="wikivoyage_article_card_icon_size">80dp</dimen>
<dimen name="wikivoyage_article_card_alternative_icon_height">40dp</dimen>
<dimen name="text_button_letter_spacing" format="float">0.01</dimen>
</resources>

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="download_maps_travel">Travel maps</string>
<string name="shared_string_wikivoyage">Wikivoyage</string>
<string name="article_removed">Article removed</string>
<string name="wikivoyage_search_hint">Search: Country, City, Province</string>
<string name="shared_string_read">Read</string>
@ -309,6 +311,8 @@
<string name="depth_contour_descr">Sea depth contour lines and nautical point maps.</string>
<string name="sea_depth_thanks">Thank you for purchasing nautical depth contours</string>
<string name="index_item_depth_contours_osmand_ext">Nautical depth contours</string>
<string name="index_item_world_wikivoyage">Worldwide Wikivoyage articles</string>
<string name="index_item_depth_points_southern_hemisphere">Southern hemisphere nautical depth points </string>
<string name="index_item_depth_points_northern_hemisphere">Northern hemisphere nautical depth points</string>
<string name="download_depth_countours">Nautical depth contours</string>

View file

@ -114,9 +114,9 @@ public class PlatformUtil {
@Override
public boolean isDebugEnabled() {
// For debur purposes always true
return android.util.Log.isLoggable(TAG, android.util.Log.DEBUG);
// return true;
// For debug purposes always true
// return android.util.Log.isLoggable(TAG, android.util.Log.DEBUG);
return true;
}
@Override

View file

@ -2997,6 +2997,8 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> FOLLOW_THE_ROUTE = new BooleanPreference("follow_to_route", false).makeGlobal();
public final OsmandPreference<String> FOLLOW_THE_GPX_ROUTE = new StringPreference("follow_gpx", null).makeGlobal();
public final OsmandPreference<String> SELECTED_TRAVEL_BOOK = new StringPreference("selected_travel_book", "").makeGlobal();
public final ListStringPreference TRANSPORT_DEFAULT_SETTINGS =
(ListStringPreference) new ListStringPreference("transport_default_settings", "transportStops", ",").makeProfile();

View file

@ -83,6 +83,8 @@ public class LocalIndexHelper {
info.setDescription(app.getString(R.string.download_srtm_maps));
} else if (info.getType() == LocalIndexType.WIKI_DATA) {
info.setDescription(getInstalledDate(f));
} else if (info.getType() == LocalIndexType.TRAVEL_DATA) {
info.setDescription(getInstalledDate(f));
} else if (info.getType() == LocalIndexType.TTS_VOICE_DATA) {
info.setDescription(getInstalledDate(f));
} else if (info.getType() == LocalIndexType.DEACTIVATED) {
@ -117,6 +119,10 @@ public class LocalIndexHelper {
fileDir = app.getAppPath(IndexConstants.WIKI_INDEX_DIR);
fileName = Algorithms.capitalizeFirstLetterAndLowercase(downloadName)
+ IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
} else if (type == LocalIndexType.TRAVEL_DATA) {
fileDir = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR);
fileName = Algorithms.capitalizeFirstLetterAndLowercase(downloadName)
+ IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT;
}
if (backuped) {
@ -135,33 +141,7 @@ public class LocalIndexHelper {
return null;
}
public LocalIndexInfo getLocalIndexInfo(String downloadName) {
LocalIndexInfo info = getLocalIndexInfo(LocalIndexType.MAP_DATA, downloadName, false, false);
if (info == null) {
info = getLocalIndexInfo(LocalIndexType.MAP_DATA, downloadName, true, false);
}
if (info == null) {
info = getLocalIndexInfo(LocalIndexType.SRTM_DATA, downloadName, false, false);
}
if (info == null) {
info = getLocalIndexInfo(LocalIndexType.WIKI_DATA, downloadName, false, false);
}
if (info == null) {
info = getLocalIndexInfo(LocalIndexType.MAP_DATA, downloadName, false, true);
}
if (info == null) {
info = getLocalIndexInfo(LocalIndexType.MAP_DATA, downloadName, true, true);
}
if (info == null) {
info = getLocalIndexInfo(LocalIndexType.SRTM_DATA, downloadName, false, true);
}
if (info == null) {
info = getLocalIndexInfo(LocalIndexType.WIKI_DATA, downloadName, false, true);
}
return info;
}
public List<LocalIndexInfo> getLocalIndexInfos(String downloadName) {
List<LocalIndexInfo> list = new ArrayList<>();
@ -210,6 +190,7 @@ public class LocalIndexHelper {
loadTilesData(app.getAppPath(IndexConstants.TILES_INDEX_DIR), result, false, loadTask);
loadSrtmData(app.getAppPath(IndexConstants.SRTM_INDEX_DIR), result, loadTask);
loadWikiData(app.getAppPath(IndexConstants.WIKI_INDEX_DIR), result, loadTask);
loadTravelData(app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), result, loadTask);
//loadVoiceData(app.getAppPath(IndexConstants.TTSVOICE_INDEX_EXT_ZIP), result, true, loadTask);
loadVoiceData(app.getAppPath(IndexConstants.VOICE_INDEX_DIR), result, false, loadTask);
loadFontData(app.getAppPath(IndexConstants.FONT_INDEX_DIR), result, false, loadTask);
@ -329,6 +310,19 @@ public class LocalIndexHelper {
}
}
}
private void loadTravelData(File mapPath, List<LocalIndexInfo> result, AbstractLoadLocalIndexTask loadTask) {
if (mapPath.canRead()) {
for (File mapFile : listFilesSorted(mapPath)) {
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) {
LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TRAVEL_DATA, mapFile, false, app);
updateDescription(info);
result.add(info);
loadTask.loadFile(info);
}
}
}
}
private void loadObfData(File mapPath, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask, Map<String, String> loadedMaps) {
if (mapPath.canRead()) {
@ -357,6 +351,7 @@ public class LocalIndexHelper {
TILES_DATA(R.string.local_indexes_cat_tile, R.drawable.ic_map, 60),
SRTM_DATA(R.string.local_indexes_cat_srtm, R.drawable.ic_plugin_srtm, 40),
WIKI_DATA(R.string.local_indexes_cat_wiki, R.drawable.ic_plugin_wikipedia, 50),
TRAVEL_DATA(R.string.download_maps_travel, R.drawable.ic_plugin_wikipedia, 60),
TTS_VOICE_DATA(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up, 20),
VOICE_DATA(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up, 30),
FONT_DATA(R.string.fonts_header, R.drawable.ic_action_map_language, 35),
@ -403,6 +398,10 @@ public class LocalIndexHelper {
if (fileName.endsWith(IndexConstants.SQLITE_EXT)) {
return fileName.substring(0, fileName.length() - IndexConstants.SQLITE_EXT.length());
}
if (localIndexInfo.getType() == TRAVEL_DATA &&
fileName.endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) {
return fileName.substring(0, fileName.length() - IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT.length());
}
if (this == VOICE_DATA) {
int l = fileName.lastIndexOf('_');
if (l == -1) {

View file

@ -766,18 +766,17 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
}
if (WikivoyageDbHelper.isDbFileExists(app)) {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_travel, mapActivity)
.setIcon(R.drawable.ic_action_travel)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
MapActivity.clearPrevActivityIntent();
WikivoyageExploreDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
}
optionsMenuHelper.addItem(new ItemBuilder().setTitle(getString(R.string.shared_string_travel) + " (Beta)")
.setIcon(R.drawable.ic_action_travel)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
getMyApplication().getWikivoyageDbHelper().initTravelBooks();
MapActivity.clearPrevActivityIntent();
WikivoyageExploreDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
.setIcon(R.drawable.ic_action_ruler)

View file

@ -45,6 +45,8 @@ public class DownloadActivityType {
new DownloadActivityType(R.string.download_hillshade_maps, R.drawable.ic_action_hillshade_dark, "hillshade", 50);
public static final DownloadActivityType WIKIPEDIA_FILE =
new DownloadActivityType(R.string.download_wikipedia_maps, R.drawable.ic_plugin_wikipedia, "wikimap", 60);
public static final DownloadActivityType WIKIVOYAGE_FILE =
new DownloadActivityType(R.string.shared_string_wikivoyage, R.drawable.ic_plugin_wikipedia, "wikivoyage", 65);
public static final DownloadActivityType LIVE_UPDATES_FILE =
new DownloadActivityType(R.string.download_live_updates, "live_updates", 70);
private final int stringResource;
@ -121,6 +123,8 @@ public class DownloadActivityType {
} else if (WIKIPEDIA_FILE == this) {
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT_ZIP,
IndexConstants.BINARY_MAP_VERSION));
} else if (WIKIVOYAGE_FILE == this) {
return fileName.endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT);
} else if (SRTM_COUNTRY_FILE == this) {
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT_ZIP,
IndexConstants.BINARY_MAP_VERSION));
@ -148,6 +152,8 @@ public class DownloadActivityType {
return ctx.getAppPath(IndexConstants.SRTM_INDEX_DIR);
} else if (WIKIPEDIA_FILE == this) {
return ctx.getAppPath(IndexConstants.WIKI_INDEX_DIR);
} else if (WIKIVOYAGE_FILE == this) {
return ctx.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR);
} else if (LIVE_UPDATES_FILE == this) {
return ctx.getAppPath(IndexConstants.LIVE_INDEX_DIR);
} else if (HILLSHADE_FILE == this) {
@ -159,7 +165,7 @@ public class DownloadActivityType {
}
public boolean isZipStream(OsmandApplication ctx, IndexItem indexItem) {
return HILLSHADE_FILE != this;
return HILLSHADE_FILE != this && WIKIVOYAGE_FILE != this;
}
public boolean isZipFolder(OsmandApplication ctx, IndexItem indexItem) {
@ -193,6 +199,8 @@ public class DownloadActivityType {
return IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
} else if (WIKIPEDIA_FILE == this) {
return IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
} else if (WIKIVOYAGE_FILE == this) {
return IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT;
} else if (LIVE_UPDATES_FILE == this) {
return BINARY_MAP_INDEX_EXT;
} else if (HILLSHADE_FILE == this) {
@ -212,6 +220,8 @@ public class DownloadActivityType {
return "&srtmcountry=yes";
} else if (this == WIKIPEDIA_FILE) {
return "&wiki=yes";
} else if (this == WIKIVOYAGE_FILE) {
return "&wikivoyage=yes";
} else if (this == HILLSHADE_FILE) {
return "&hillshade=yes";
} else if (this == FONT_FILE) {
@ -269,6 +279,8 @@ public class DownloadActivityType {
return ctx.getString(R.string.download_srtm_maps);
} else if (this == WIKIPEDIA_FILE) {
return ctx.getString(R.string.shared_string_wikipedia);
} else if (this == WIKIVOYAGE_FILE) {
return ctx.getString(R.string.shared_string_wikivoyage);
} else if (this == ROADS_FILE) {
return ctx.getString(R.string.download_roads_only_item);
} else if (this == DEPTH_CONTOUR_FILE) {
@ -356,6 +368,10 @@ public class DownloadActivityType {
if (this == WIKIPEDIA_FILE) {
return baseNameWithoutVersion + IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
}
if (this == WIKIVOYAGE_FILE) {
return baseNameWithoutVersion + IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT;
}
if (this == ROADS_FILE) {
return baseNameWithoutVersion + IndexConstants.BINARY_ROAD_MAP_INDEX_EXT;
}
@ -383,6 +399,10 @@ public class DownloadActivityType {
if (fileName.endsWith(IndexConstants.SQLITE_EXT)) {
return fileName.substring(0, fileName.length() - IndexConstants.SQLITE_EXT.length());
}
if (indexItem.getType() == WIKIVOYAGE_FILE &&
fileName.endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) {
return fileName.substring(0, fileName.length() - IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT.length());
}
if (this == VOICE_FILE) {
int l = fileName.lastIndexOf('_');
if (l == -1) {

View file

@ -205,7 +205,7 @@ public class DownloadFileHelper {
try {
final List<InputStream> downloadInputStreams = new ArrayList<InputStream>();
URL url = new URL(de.urlToDownload); //$NON-NLS-1$
log.debug("Url downloading " + de.urlToDownload);
log.info("Url downloading " + de.urlToDownload);
downloadInputStreams.add(getInputStreamToDownload(url, forceWifi));
de.fileToDownload = de.targetFile;
if(!de.unzipFolder) {

View file

@ -204,7 +204,7 @@ public class DownloadOsmandIndexesHelper {
DownloadActivityType tp = DownloadActivityType.getIndexType(parser.getAttributeValue(null, "type"));
if (tp != null) {
IndexItem it = tp.parseIndexItem(ctx, parser);
if(it != null && !it.getFileName().contains("_wiki")) {
if(it != null) {
result.add(it);
}
} else if ("osmand_regions".equals(parser.getName())) {

View file

@ -34,6 +34,8 @@ public class DownloadResourceGroup {
SRTM_HEADER(R.string.download_srtm_maps),
HILLSHADE_HEADER(R.string.download_hillshade_maps),
OTHER_MAPS_HEADER(R.string.download_select_map_types),
WIKIVOYAGE_HEADER(R.string.shared_string_wikivoyage),
NAUTICAL_MAPS_HEADER(R.string.nautical_maps),
// headers with voice items
VOICE_HEADER_TTS(R.string.index_name_tts_voice),
@ -42,11 +44,13 @@ public class DownloadResourceGroup {
FONTS_HEADER(R.string.fonts_header),
// headers with resources
NAUTICAL_MAPS_GROUP(R.string.nautical_maps),
TRAVEL_GROUP(R.string.download_maps_travel),
OTHER_MAPS_GROUP(R.string.download_select_map_types),
OTHER_GROUP(R.string.other_menu_group),
SUBREGIONS(R.string.regions),
// screen items
NAUTICAL_MAPS(R.string.nautical_maps),
WIKIVOYAGE_MAPS(R.string.download_maps_travel),
VOICE_TTS(R.string.index_name_tts_voice),
FONTS(R.string.fonts_header),
VOICE_REC(R.string.index_name_voice),
@ -62,7 +66,7 @@ public class DownloadResourceGroup {
public boolean isScreen() {
return this == WORLD || this == REGION || this == VOICE_TTS
|| this == VOICE_REC || this == OTHER_MAPS || this == FONTS || this == NAUTICAL_MAPS;
|| this == VOICE_REC || this == OTHER_MAPS || this == FONTS || this == NAUTICAL_MAPS || this == WIKIVOYAGE_MAPS;
}
public String getDefaultId() {
@ -75,15 +79,17 @@ public class DownloadResourceGroup {
public boolean containsIndexItem() {
return isHeader() && this != SUBREGIONS && this != OTHER_GROUP && this != OTHER_MAPS_GROUP
&& this != NAUTICAL_MAPS_GROUP;
&& this != NAUTICAL_MAPS_GROUP && this != TRAVEL_GROUP;
}
public boolean isHeader() {
return this == VOICE_HEADER_REC || this == VOICE_HEADER_TTS || this == SUBREGIONS
|| this == WORLD_MAPS || this == REGION_MAPS || this == OTHER_GROUP
|| this == WORLD_MAPS || this == REGION_MAPS || this == OTHER_GROUP
|| this == HILLSHADE_HEADER || this == SRTM_HEADER
|| this == OTHER_MAPS_HEADER || this == OTHER_MAPS_GROUP
|| this == FONTS_HEADER || this == NAUTICAL_MAPS_HEADER || this == NAUTICAL_MAPS_GROUP;
|| this == FONTS_HEADER
|| this == NAUTICAL_MAPS_HEADER || this == NAUTICAL_MAPS_GROUP
|| this == WIKIVOYAGE_HEADER || this == TRAVEL_GROUP;
}
public static String getVoiceTTSId() {

View file

@ -1,6 +1,7 @@
package net.osmand.plus.download;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.LatLon;
@ -22,6 +23,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
public class DownloadResources extends DownloadResourceGroup {
public boolean isDownloadedFromInternet = false;
public boolean downloadFromInternetFailed = false;
@ -36,6 +39,8 @@ public class DownloadResources extends DownloadResourceGroup {
public static final String WORLD_SEAMARKS_NAME = "World_seamarks";
public static final String WORLD_SEAMARKS_OLD_KEY = "world_seamarks_basemap";
public static final String WORLD_SEAMARKS_OLD_NAME = "World_seamarks_basemap";
private static final Log LOG = PlatformUtil.getLog(DownloadResources.class);
public DownloadResources(OsmandApplication app) {
@ -98,10 +103,14 @@ public class DownloadResources extends DownloadResourceGroup {
java.text.DateFormat dateFormat = app.getResourceManager().getDateFormat();
Map<String, String> indexActivatedFileNames = app.getResourceManager().getIndexFileNames();
listWithAlternatives(dateFormat, app.getAppPath(""), IndexConstants.EXTRA_EXT, indexActivatedFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT,
indexActivatedFileNames);
Map<String, String> indexFileNames = app.getResourceManager().getIndexFileNames();
listWithAlternatives(dateFormat, app.getAppPath(""), IndexConstants.EXTRA_EXT, indexFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.TILES_INDEX_DIR), IndexConstants.SQLITE_EXT,
indexFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT,
indexFileNames);
app.getResourceManager().getBackupIndexes(indexFileNames);
this.indexFileNames = indexFileNames;
this.indexActivatedFileNames = indexActivatedFileNames;
@ -140,6 +149,7 @@ public class DownloadResources extends DownloadResourceGroup {
if ((item.getType() == DownloadActivityType.NORMAL_FILE && !item.extra)
|| item.getType() == DownloadActivityType.ROADS_FILE
|| item.getType() == DownloadActivityType.WIKIPEDIA_FILE
|| item.getType() == DownloadActivityType.WIKIVOYAGE_FILE
|| item.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE
|| item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
outdated = true;
@ -268,6 +278,10 @@ public class DownloadResources extends DownloadResourceGroup {
DownloadResourceGroup nauticalMapsGroup = new DownloadResourceGroup(this, DownloadResourceGroupType.NAUTICAL_MAPS_GROUP);
DownloadResourceGroup nauticalMapsScreen = new DownloadResourceGroup(nauticalMapsGroup, DownloadResourceGroupType.NAUTICAL_MAPS);
DownloadResourceGroup nauticalMaps = new DownloadResourceGroup(nauticalMapsGroup, DownloadResourceGroupType.NAUTICAL_MAPS_HEADER);
DownloadResourceGroup wikivoyageMapsGroup = new DownloadResourceGroup(this, DownloadResourceGroupType.TRAVEL_GROUP);
DownloadResourceGroup wikivoyageMapsScreen = new DownloadResourceGroup(wikivoyageMapsGroup, DownloadResourceGroupType.WIKIVOYAGE_MAPS);
DownloadResourceGroup wikivoyageMaps = new DownloadResourceGroup(wikivoyageMapsGroup, DownloadResourceGroupType.WIKIVOYAGE_HEADER);
Map<WorldRegion, List<IndexItem> > groupByRegion = new LinkedHashMap<WorldRegion, List<IndexItem>>();
OsmandRegions regs = app.getRegions();
@ -290,6 +304,10 @@ public class DownloadResources extends DownloadResourceGroup {
}
continue;
}
if(ii.getType() == DownloadActivityType.WIKIVOYAGE_FILE) {
wikivoyageMaps.addItem(ii);
continue;
}
String basename = ii.getBasename().toLowerCase();
WorldRegion wg = regs.getRegionDataByDownloadName(basename);
if (wg != null) {
@ -354,6 +372,10 @@ public class DownloadResources extends DownloadResourceGroup {
nauticalMapsGroup.addGroup(nauticalMapsScreen);
addGroup(nauticalMapsGroup);
wikivoyageMapsScreen.addGroup(wikivoyageMaps);
wikivoyageMapsGroup.addGroup(wikivoyageMapsScreen);
addGroup(wikivoyageMapsGroup);
if (otherMaps.size() > 0) {
addGroup(otherMapsGroup);
}
@ -365,6 +387,8 @@ public class DownloadResources extends DownloadResourceGroup {
}
otherGroup.addGroup(voiceScreenTTS);
otherGroup.addGroup(voiceScreenRec);
if (fonts.getIndividualResources() != null) {
otherGroup.addGroup(fontScreen);
}

View file

@ -405,6 +405,8 @@ public class ItemViewHolder {
tp = LocalIndexType.SRTM_DATA;
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
tp = LocalIndexType.MAP_DATA;
} else if (indexItem.getType() == DownloadActivityType.WIKIVOYAGE_FILE) {
tp = LocalIndexType.MAP_DATA;
} else if (indexItem.getType() == DownloadActivityType.FONT_FILE) {
tp = LocalIndexType.FONT_DATA;
} else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {

View file

@ -183,7 +183,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
}
};
if (info.getType() == LocalIndexType.MAP_DATA || info.getType() == LocalIndexType.SRTM_DATA ||
info.getType() == LocalIndexType.WIKI_DATA) {
info.getType() == LocalIndexType.WIKI_DATA ) {
if (!info.isBackupedData()) {
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.local_index_mi_backup, getContext())
@ -444,6 +444,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
parent = getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR);
} else if (i.getOriginalType() == LocalIndexType.WIKI_DATA) {
parent = getMyApplication().getAppPath(IndexConstants.WIKI_INDEX_DIR);
} else if (i.getOriginalType() == LocalIndexType.TRAVEL_DATA) {
parent = getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR);
} else if (i.getOriginalType() == LocalIndexType.TTS_VOICE_DATA) {
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
} else if (i.getOriginalType() == LocalIndexType.VOICE_DATA) {

View file

@ -220,6 +220,8 @@ public class FileNameTranslationHelper {
} else if (basename.equals(DownloadResources.WORLD_SEAMARKS_KEY) ||
basename.equals(DownloadResources.WORLD_SEAMARKS_OLD_KEY)) {
return ctx.getString(R.string.index_item_world_seamarks);
} else if (basename.equals("world_wikivoyage")) {
return ctx.getString(R.string.index_item_world_wikivoyage);
} else if (basename.equals("depth_contours_osmand_ext")) {
return ctx.getString(R.string.index_item_depth_contours_osmand_ext);
} else if (basename.equals("depth_points_southern_hemisphere_osmand_ext")) {

View file

@ -537,6 +537,8 @@ public class MapDataMenuController extends MenuController {
parent = app.getAppPath(IndexConstants.SRTM_INDEX_DIR);
} else if (i.getOriginalType() == LocalIndexType.WIKI_DATA) {
parent = app.getAppPath(IndexConstants.WIKI_INDEX_DIR);
} else if (i.getOriginalType() == LocalIndexType.TRAVEL_DATA) {
parent = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR);
} else if (i.getOriginalType() == LocalIndexType.TTS_VOICE_DATA) {
parent = app.getAppPath(IndexConstants.VOICE_INDEX_DIR);
} else if (i.getOriginalType() == LocalIndexType.VOICE_DATA) {
@ -561,6 +563,8 @@ public class MapDataMenuController extends MenuController {
return DownloadActivityType.SRTM_COUNTRY_FILE;
} else if (localIndexInfo.getOriginalType() == LocalIndexType.WIKI_DATA) {
return DownloadActivityType.WIKIPEDIA_FILE;
} else if (localIndexInfo.getOriginalType() == LocalIndexType.TRAVEL_DATA) {
return DownloadActivityType.WIKIVOYAGE_FILE;
} else if (localIndexInfo.getOriginalType() == LocalIndexType.TTS_VOICE_DATA
|| localIndexInfo.getOriginalType() == LocalIndexType.VOICE_DATA) {
return DownloadActivityType.VOICE_FILE;

View file

@ -41,6 +41,8 @@ public class RendererRegistry {
public final static String NAUTICAL_RENDER = "Nautical"; //$NON-NLS-1$
public final static String TOPO_RENDER = "Topo"; //$NON-NLS-1$
public final static String MAPNIK_RENDER = "Mapnik"; //$NON-NLS-1$
public final static String OFFROAD_RENDER = "Offroad"; //$NON-NLS-1$
public final static String LIGHTRS_RENDER = "LightRS"; //$NON-NLS-1$
private RenderingRulesStorage defaultRender = null;
private RenderingRulesStorage currentSelectedRender = null;
@ -64,10 +66,10 @@ public class RendererRegistry {
internalRenderers.put(TOURING_VIEW, "Touring-view_(more-contrast-and-details)" +".render.xml");
internalRenderers.put(TOPO_RENDER, "topo" + ".render.xml");
internalRenderers.put(MAPNIK_RENDER, "mapnik" + ".render.xml");
internalRenderers.put("UniRS", "UniRS" + ".render.xml");
internalRenderers.put("LightRS", "LightRS" + ".render.xml");
internalRenderers.put(LIGHTRS_RENDER, "LightRS" + ".render.xml");
internalRenderers.put(NAUTICAL_RENDER, "nautical" + ".render.xml");
internalRenderers.put(WINTER_SKI_RENDER, "skimap" + ".render.xml");
internalRenderers.put(OFFROAD_RENDER, "offroad" + ".render.xml");
}
public RenderingRulesStorage defaultRender() {

View file

@ -0,0 +1,30 @@
package net.osmand.plus.widgets.tools;
import android.graphics.Bitmap;
import com.squareup.picasso.Transformation;
public class CropRectTransformation implements Transformation {
private static final String KEY = "CropRectTransformation";
@Override
public Bitmap transform(Bitmap source) {
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size * 2) / 2;
int y = (source.getHeight() - size) / 2;
Bitmap bitmap = Bitmap.createBitmap(source, x, y, size * 2, size);
if (bitmap != source) {
source.recycle();
}
return bitmap;
}
@Override
public String key() {
return KEY;
}
}

View file

@ -10,11 +10,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnGroupClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
@ -36,6 +35,8 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
public static final int REQUEST_LINK_CODE = 0;
private ExpandableListView expListView;
private LinkedHashMap<String, String> map;
private String link;
@ -63,11 +64,14 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
items.add(new TitleItem(getString(R.string.shared_string_contents)));
ExpandableListView expListView = new ExpandableListView(getContext());
expListView = new ExpandableListView(getContext());
ExpandableListAdapter listAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild);
expListView.setAdapter(listAdapter);
expListView.setChildDivider(ContextCompat.getDrawable(getContext(), R.color.color_transparent));
Drawable transparent = ContextCompat.getDrawable(getContext(), R.color.color_transparent);
expListView.setDivider(transparent);
expListView.setGroupIndicator(transparent);
expListView.setSelector(transparent);
expListView.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT)
@ -83,23 +87,12 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
return false;
}
});
int width = AndroidUtils.getScreenWidth(getActivity());
if (android.os.Build.VERSION.SDK_INT < 18) {
expListView.setIndicatorBounds(width - (AndroidUtils.dpToPx(getContext(), 50)),
width - (AndroidUtils.dpToPx(getContext(), 10)));
} else {
expListView.setIndicatorBoundsRelative(width - (AndroidUtils.dpToPx(getContext(), 50)),
width - (AndroidUtils.dpToPx(getContext(), 10)));
}
expListView.setOnGroupClickListener(new OnGroupClickListener() {
expListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
link = map.get(listDataHeader.get(groupPosition));
sendResult();
if (listDataChild.get(listDataHeader.get(groupPosition)) == null) {
dismiss();
}
dismiss();
return false;
}
});
@ -158,7 +151,7 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
@Override
public Object getChild(int groupPosition, int childPosititon) {
return this.listDataChild.get(this.listDataHeader.get(groupPosition)).get(childPosititon);
return listDataChild.get(listDataHeader.get(groupPosition)).get(childPosititon);
}
@Override
@ -181,6 +174,14 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
: R.color.wikivoyage_contents_parent_icon_light));
txtListChild.setCompoundDrawablesWithIntrinsicBounds(itemChildIcon, null, null, null);
convertView.findViewById(R.id.upper_row_divider).setVisibility(View.GONE);
txtListChild.setTypeface(null);
if (childPosition == listDataChild.get(listDataHeader.get(groupPosition)).size() - 1) {
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.VISIBLE);
} else {
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.GONE);
}
return convertView;
}
@ -206,18 +207,36 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
public View getGroupView(final int groupPosition, final boolean isExpanded,
View convertView, ViewGroup parent) {
String headerTitle = (String) getGroup(groupPosition);
if (convertView == null) {
convertView = LayoutInflater.from(context)
.inflate(R.layout.wikivoyage_contents_list_item, parent, false);
}
boolean light = getMyApplication().getSettings().isLightContent();
TextView lblListHeader = (TextView) convertView.findViewById(R.id.item_label);
lblListHeader.setText(headerTitle);
lblListHeader.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_contents_parent_icon_dark : R.color.wikivoyage_contents_parent_icon_light));
lblListHeader.setCompoundDrawablesWithIntrinsicBounds(itemGroupIcon, null, null, null);
adjustIndicator(getMyApplication(), groupPosition, isExpanded, convertView, light);
ImageView indicator = (ImageView) convertView.findViewById(R.id.explist_indicator);
indicator.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(isExpanded){
expListView.collapseGroup(groupPosition);
} else {
expListView.expandGroup(groupPosition);
}
}
});
if (isExpanded) {
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.GONE);
} else {
convertView.findViewById(R.id.bottom_row_divider).setVisibility(View.VISIBLE);
}
return convertView;
}
@ -231,4 +250,4 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
return true;
}
}
}
}

View file

@ -2,7 +2,6 @@ package net.osmand.plus.wikivoyage.data;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import net.osmand.Collator;
import net.osmand.CollatorStringMatcher;
import net.osmand.CollatorStringMatcher.StringMatcherMode;
@ -65,18 +64,56 @@ public class WikivoyageDbHelper {
private static final String SEARCH_COL_LANG = "lang";
private final OsmandApplication application;
private SQLiteConnection connection = null;
private File selectedTravelBook = null;
private List<File> existingTravelBooks = new ArrayList<File>();
private Collator collator;
public WikivoyageDbHelper(OsmandApplication application) {
this.application = application;
collator = OsmAndCollator.primaryCollator();
initTravelBooks();
}
public void initTravelBooks() {
File[] possibleFiles = application.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles();
String travelBook = application.getSettings().SELECTED_TRAVEL_BOOK.get();
if (possibleFiles != null) {
for (File f : possibleFiles) {
if (f.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) {
existingTravelBooks.add(f);
if (selectedTravelBook == null) {
selectedTravelBook = f;
} else if (Algorithms.objectEquals(travelBook, f.getName())) {
selectedTravelBook = f;
}
}
}
}
}
public File getSelectedTravelBook() {
return selectedTravelBook;
}
public List<File> getExistingTravelBooks() {
return existingTravelBooks;
}
@Nullable
private SQLiteConnection openConnection() {
String path = getDbFile(application).getAbsolutePath();
return application.getSQLiteAPI().openByAbsolutePath(path, true);
if(connection == null && selectedTravelBook != null) {
application.getSettings().SELECTED_TRAVEL_BOOK.set(selectedTravelBook.getName());
connection = application.getSQLiteAPI().openByAbsolutePath(selectedTravelBook.getAbsolutePath(), true);
}
return connection;
}
public void closeConnection() {
if(connection != null) {
connection.close();
connection = null;
}
}
@NonNull
@ -85,42 +122,39 @@ public class WikivoyageDbHelper {
SQLiteConnection conn = openConnection();
String[] queries = searchQuery.replace('_', ' ').replace('/', ' ').split(" ");
if (conn != null) {
try {
List<String> params = new ArrayList<>();
String query = "SELECT distinct wa.city_id, wa.title, wa.lang, wa.is_part_of, wa.image_title " +
"FROM wikivoyage_articles wa WHERE wa.city_id in " +
" (SELECT city_id FROM wikivoyage_search WHERE search_term LIKE";
for (String q : queries) {
if (q.trim().length() > 0) {
if (params.size() > 5) {
// don't explode the query search much
break;
}
if (params.size() > 0) {
query += " AND city_id IN (SELECT city_id FROM wikivoyage_search WHERE search_term LIKE ?) ";
} else {
query += "?";
}
params.add(q.trim() + "%");
List<String> params = new ArrayList<>();
String query = "SELECT distinct wa.city_id, wa.title, wa.lang, wa.is_part_of, wa.image_title "
+ "FROM wikivoyage_articles wa WHERE wa.city_id in "
+ " (SELECT city_id FROM wikivoyage_search WHERE search_term LIKE";
for (String q : queries) {
if (q.trim().length() > 0) {
if (params.size() > 5) {
// don't explode the query search much
break;
}
}
query += ") ";
if (params.size() > 0) {
SQLiteCursor cursor = conn.rawQuery(query, params.toArray(new String[params.size()]));
if (cursor.moveToFirst()) {
do {
WikivoyageSearchResult rs = new WikivoyageSearchResult();
rs.cityId = cursor.getLong(0);
rs.articleTitles.add(cursor.getString(1));
rs.langs.add(cursor.getString(2));
rs.isPartOf = cursor.getString(3);
rs.imageTitle = cursor.getString(4);
res.add(rs);
} while (cursor.moveToNext());
if (params.size() > 0) {
query += " AND city_id IN (SELECT city_id FROM wikivoyage_search WHERE search_term LIKE ?) ";
} else {
query += "?";
}
params.add(q.trim() + "%");
}
} finally {
conn.close();
}
query += ") ";
if (params.size() > 0) {
SQLiteCursor cursor = conn.rawQuery(query, params.toArray(new String[params.size()]));
if (cursor.moveToFirst()) {
do {
WikivoyageSearchResult rs = new WikivoyageSearchResult();
rs.cityId = cursor.getLong(0);
rs.articleTitles.add(cursor.getString(1));
rs.langs.add(cursor.getString(2));
rs.isPartOf = cursor.getString(3);
rs.imageTitle = cursor.getString(4);
res.add(rs);
} while (cursor.moveToNext());
}
cursor.close();
}
}
@ -180,18 +214,12 @@ public class WikivoyageDbHelper {
WikivoyageArticle res = null;
SQLiteConnection conn = openConnection();
if (conn != null) {
try {
SQLiteCursor cursor = conn.rawQuery(ARTICLES_TABLE_SELECT + " WHERE " +
ARTICLES_COL_CITY_ID + " = ? AND " +
ARTICLES_COL_LANG + " = ?",
new String[]{String.valueOf(cityId), lang});
if (cursor.moveToFirst()) {
res = readArticle(cursor);
}
cursor.close();
} finally {
conn.close();
SQLiteCursor cursor = conn.rawQuery(ARTICLES_TABLE_SELECT + " WHERE " + ARTICLES_COL_CITY_ID + " = ? AND "
+ ARTICLES_COL_LANG + " = ?", new String[] { String.valueOf(cityId), lang });
if (cursor.moveToFirst()) {
res = readArticle(cursor);
}
cursor.close();
}
return res;
}
@ -201,31 +229,27 @@ public class WikivoyageDbHelper {
ArrayList<String> res = new ArrayList<>();
SQLiteConnection conn = openConnection();
if (conn != null) {
try {
SQLiteCursor cursor = conn.rawQuery("SELECT " + ARTICLES_COL_LANG +
" FROM " + ARTICLES_TABLE_NAME +
" WHERE " + ARTICLES_COL_CITY_ID + " = ?",
new String[]{String.valueOf(cityId)});
if (cursor.moveToFirst()) {
String baseLang = application.getLanguage();
do {
String lang = cursor.getString(0);
if (lang.equals(baseLang)) {
res.add(0, lang);
} else if (lang.equals("en")) {
if (res.size() > 0 && res.get(0).equals(baseLang)) {
res.add(1, lang);
} else {
res.add(0, lang);
}
SQLiteCursor cursor = conn.rawQuery("SELECT " + ARTICLES_COL_LANG + " FROM " + ARTICLES_TABLE_NAME
+ " WHERE " + ARTICLES_COL_CITY_ID + " = ?", new String[] { String.valueOf(cityId) });
if (cursor.moveToFirst()) {
String baseLang = application.getLanguage();
do {
String lang = cursor.getString(0);
if (lang.equals(baseLang)) {
res.add(0, lang);
} else if (lang.equals("en")) {
if (res.size() > 0 && res.get(0).equals(baseLang)) {
res.add(1, lang);
} else {
res.add(lang);
res.add(0, lang);
}
} while (cursor.moveToNext());
}
} finally {
conn.close();
} else {
res.add(lang);
}
} while (cursor.moveToNext());
}
cursor.close();
}
return res;
}
@ -255,12 +279,8 @@ public class WikivoyageDbHelper {
return res;
}
public static boolean isDbFileExists(OsmandApplication app) {
return getDbFile(app).exists();
public boolean isDbFileExists() {
return selectedTravelBook != null;
}
@NonNull
private static File getDbFile(OsmandApplication app) {
return app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR + DB_NAME);
}
}

View file

@ -19,6 +19,7 @@ import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.widgets.tools.CropCircleTransformation;
import net.osmand.plus.widgets.tools.CropRectTransformation;
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
@ -30,6 +31,8 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
private static final int HEADER_TYPE = 0;
private static final int ITEM_TYPE = 1;
private static final boolean USE_ALTERNATIVE_CARD = false;
private final OsmandApplication app;
private final List<Object> items = new ArrayList<>();
@ -56,7 +59,9 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
boolean header = viewType == HEADER_TYPE;
int layoutId = header ? R.layout.wikivoyage_list_header : R.layout.wikivoyage_article_card;
int layoutId = header
? R.layout.wikivoyage_list_header
: USE_ALTERNATIVE_CARD ? R.layout.wikivoyage_article_card_alternative : R.layout.wikivoyage_article_card;
View itemView = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
return header ? new HeaderVH(itemView) : new ItemVH(itemView);
}
@ -74,7 +79,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
Picasso.get()
.load(WikivoyageArticle.getImageUrl(article.getImageTitle(), false))
.transform(new CropCircleTransformation())
.transform(USE_ALTERNATIVE_CARD ? new CropRectTransformation() : new CropCircleTransformation())
.into(holder.icon, new Callback() {
@Override
public void onSuccess() {