diff --git a/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java b/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java index 3e4cd5af55..554eb7ced3 100644 --- a/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java +++ b/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java @@ -20,6 +20,8 @@ public class IndexConstants { 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_TRAVEL_GUIDE_MAP_INDEX_EXT = ".travel.obf"; //$NON-NLS-1$ + public static final String BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT_ZIP = ".travel.obf.zip"; //$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$ diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt index 35a397f4f5..65bd0b9d01 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt @@ -386,7 +386,7 @@ class ShareLocationHelper(private val app: TelegramApplication) { } app.locationMessages.removeBufferedMessage(locationMessage) if ((shareInfo.shouldSendViaBotTextMessage || shareInfo.shouldSendViaBotMapMessage) && osmandBotId != -1 && device != null) { - app.telegramHelper.sendViaBotLocationMessage(osmandBotId, shareInfo, TdApi.Location(locationMessage.lat, locationMessage.lon), device, shareType) + app.telegramHelper.sendViaBotLocationMessage(osmandBotId, shareInfo, TdApi.Location(locationMessage.lat, locationMessage.lon, locationMessage.hdop), device, shareType) shareInfo.shouldSendViaBotTextMessage = false shareInfo.shouldSendViaBotMapMessage = false } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt index 941e4a8aa4..4e8d657bbd 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt @@ -443,7 +443,7 @@ class TelegramHelper private constructor() { var offsetChatId: Long = 0 if (!chatList.isEmpty()) { val last = chatList.last() - offsetOrder = last.order + offsetOrder = last.position.order offsetChatId = last.chatId } client?.send(TdApi.GetChats(TdApi.ChatListMain(), offsetOrder, offsetChatId, CHATS_LIMIT - chatList.size)) { obj -> @@ -533,8 +533,8 @@ class TelegramHelper private constructor() { } resultArticles.forEach { shareInfo.lastTextMessageHandled = false - val sendOptions = TdApi.SendMessageOptions(true, true, null) - client?.send(TdApi.SendInlineQueryResultMessage(shareInfo.chatId, 0, sendOptions, + val sendOptions = TdApi.MessageSendOptions(true, true, null) + client?.send(TdApi.SendInlineQueryResultMessage(shareInfo.chatId, 0, 0, sendOptions, inlineQueryResults.inlineQueryId, it.id, false)) { obj -> handleTextLocationMessageUpdate(obj, shareInfo, true) } @@ -843,7 +843,12 @@ class TelegramHelper private constructor() { if (!shareInfo.isMapMessageIdPresent() && shareInfo.chatId != -1L) { shareInfo.lastSendMapMessageTime = (System.currentTimeMillis() / 1000).toInt() client?.send( - TdApi.EditMessageLiveLocation(shareInfo.chatId, shareInfo.currentMapMessageId, null, null)) { obj -> + TdApi.EditMessageLiveLocation( + shareInfo.chatId, shareInfo.currentMapMessageId, + null, null, 0, 0 + ) + ) + { obj -> handleMapLocationMessageUpdate(obj, shareInfo, false) } } @@ -863,8 +868,8 @@ class TelegramHelper private constructor() { shareInfo.pendingTdLibText++ shareInfo.lastSendTextMessageTime = (System.currentTimeMillis() / 1000).toInt() log.error("sendNewTextLocation ${shareInfo.pendingTdLibText}") - val sendOptions = TdApi.SendMessageOptions(false, true, null) - client?.send(TdApi.SendMessage(shareInfo.chatId, 0, sendOptions, null, content)) { obj -> + val sendOptions = TdApi.MessageSendOptions(false, true, null) + client?.send(TdApi.SendMessage(shareInfo.chatId, 0, 0, sendOptions, null, content)) { obj -> handleTextLocationMessageUpdate(obj, shareInfo, false) } } @@ -883,21 +888,21 @@ class TelegramHelper private constructor() { fun sendNewMapLocation(shareInfo: ShareChatInfo, locationMessage: LocationMessages.BufferMessage) { needRefreshActiveLiveLocationMessages = true - val location = TdApi.Location(locationMessage.lat, locationMessage.lon) + val location = TdApi.Location(locationMessage.lat, locationMessage.lon, locationMessage.hdop) val livePeriod = if (shareInfo.currentMessageLimit > (shareInfo.start + MAX_LOCATION_MESSAGE_LIVE_PERIOD_SEC)) { MAX_LOCATION_MESSAGE_LIVE_PERIOD_SEC } else { shareInfo.livePeriod.toInt() } - val content = TdApi.InputMessageLocation(location, livePeriod) + val content = TdApi.InputMessageLocation(location, livePeriod, locationMessage.bearing.toInt(), 0) if (!shareInfo.pendingMapMessage) { shareInfo.pendingMapMessage = true shareInfo.pendingTdLibMap++ shareInfo.lastSendMapMessageTime = (System.currentTimeMillis() / 1000).toInt() log.error("sendNewMapLocation ${shareInfo.pendingTdLibMap}") - val sendOptions = TdApi.SendMessageOptions(false, true, null) - client?.send(TdApi.SendMessage(shareInfo.chatId, 0, sendOptions, null, content)) { obj -> + val sendOptions = TdApi.MessageSendOptions(false, true, null) + client?.send(TdApi.SendMessage(shareInfo.chatId, 0, 0, sendOptions, null, content)) { obj -> handleMapLocationMessageUpdate(obj, shareInfo, false) } } @@ -905,12 +910,13 @@ class TelegramHelper private constructor() { fun editMapLocation(shareInfo: ShareChatInfo, locationMessage: LocationMessages.BufferMessage) { needRefreshActiveLiveLocationMessages = true - val location = TdApi.Location(locationMessage.lat, locationMessage.lon) + val location = TdApi.Location(locationMessage.lat, locationMessage.lon, locationMessage.hdop) if (shareInfo.currentMapMessageId!=-1L) { shareInfo.pendingTdLibMap++ shareInfo.lastSendMapMessageTime = (System.currentTimeMillis() / 1000).toInt() log.info("editMapLocation ${shareInfo.currentMapMessageId} pendingTdLibMap: ${shareInfo.pendingTdLibMap}") - client?.send(TdApi.EditMessageLiveLocation(shareInfo.chatId, shareInfo.currentMapMessageId, null, location)) { obj -> + client?.send(TdApi.EditMessageLiveLocation(shareInfo.chatId, shareInfo.currentMapMessageId, + null, location, locationMessage.bearing.toInt(), 0)) { obj -> handleMapLocationMessageUpdate(obj, shareInfo, false) } } @@ -1080,18 +1086,21 @@ class TelegramHelper private constructor() { } } - private fun setChatOrder(chat: TdApi.Chat, order: Long) { + private fun setChatPositions(chat: TdApi.Chat, positions: Array) { synchronized(chatList) { - val isChannel = isChannel(chat) - - if (chat.order != 0L) { - chatList.remove(OrderedChat(chat.order, chat.id, isChannel)) - } - - chat.order = order - - if (chat.order != 0L) { - chatList.add(OrderedChat(chat.order, chat.id, isChannel)) + synchronized(chat) { + val isChannel = isChannel(chat) + for (position in chat.positions) { + if (position.list.constructor == TdApi.ChatListMain.CONSTRUCTOR) { + chatList.remove(OrderedChat(chat.id, position, isChannel)) + } + } + chat.positions = positions + for (position in chat.positions) { + if (position.list.constructor == TdApi.ChatListMain.CONSTRUCTOR) { + chatList.add(OrderedChat(chat.id, position, isChannel)) + } + } } } } @@ -1188,11 +1197,15 @@ class TelegramHelper private constructor() { } } - class OrderedChat internal constructor(internal val order: Long, internal val chatId: Long, internal val isChannel: Boolean) : Comparable { + class OrderedChat internal constructor( + internal val chatId: Long, + internal val position: TdApi.ChatPosition, + internal val isChannel: Boolean + ) : Comparable { override fun compareTo(other: OrderedChat): Int { - if (this.order != other.order) { - return if (other.order < this.order) -1 else 1 + if (this.position.order != other.position.order) { + return if (other.position.order < this.position.order) -1 else 1 } return if (this.chatId != other.chatId) { if (other.chatId < this.chatId) -1 else 1 @@ -1206,12 +1219,11 @@ class TelegramHelper private constructor() { if (other !is OrderedChat) { return false } - val o = other as OrderedChat? - return this.order == o!!.order && this.chatId == o.chatId + return this.chatId == other.chatId && this.position.order == other.position.order; } override fun hashCode(): Int { - return (order + chatId).hashCode() + return (position.order + chatId).hashCode() } } @@ -1288,9 +1300,9 @@ class TelegramHelper private constructor() { } } } - val order = chat.order - chat.order = 0 - setChatOrder(chat, order) + val positions = chat.positions + chat.positions = arrayOfNulls(0) + setChatPositions(chat, positions) } listener?.onTelegramChatsChanged() } @@ -1320,28 +1332,38 @@ class TelegramHelper private constructor() { if (chat != null) { synchronized(chat) { chat.lastMessage = updateChat.lastMessage - setChatOrder(chat, updateChat.order) + setChatPositions(chat, updateChat.positions); } //listener?.onTelegramChatsChanged() } } - TdApi.UpdateChatOrder.CONSTRUCTOR -> { - val updateChat = obj as TdApi.UpdateChatOrder - val chat = chats[updateChat.chatId] - if (chat != null) { - synchronized(chat) { - setChatOrder(chat, updateChat.order) - } - listener?.onTelegramChatsChanged() - } - } - TdApi.UpdateChatIsPinned.CONSTRUCTOR -> { - val updateChat = obj as TdApi.UpdateChatIsPinned - val chat = chats[updateChat.chatId] - if (chat != null) { - synchronized(chat) { - chat.isPinned = updateChat.isPinned - setChatOrder(chat, updateChat.order) + TdApi.UpdateChatPosition.CONSTRUCTOR -> { + val updateChat = obj as TdApi.UpdateChatPosition + if (updateChat.position.list.constructor == TdApi.ChatListMain.CONSTRUCTOR) { + val chat = chats[updateChat.chatId] + if (chat != null) { + synchronized(chat) { + var index = 0 + for (i in chat.positions.indices) { + if (chat.positions[i].list.constructor == TdApi.ChatListMain.CONSTRUCTOR) { + index = i + break + } + } + val length = chat.positions.size + (if (updateChat.position.order == 0L) 0 else 1) - if (index < chat.positions.size) 1 else 0 + val newPositions = arrayOfNulls(length) + + var pos = 0 + if (updateChat.position.order != 0L) { + newPositions[pos++] = updateChat.position + } + for (j in chat.positions.indices) { + if (j != index) { + newPositions[pos++] = chat.positions[j]; + } + } + setChatPositions(chat, newPositions) + } } //listener?.onTelegramChatsChanged() } @@ -1453,7 +1475,7 @@ class TelegramHelper private constructor() { if (chat != null) { synchronized(chat) { chat.draftMessage = updateChat.draftMessage - setChatOrder(chat, updateChat.order) + setChatPositions(chat, updateChat.positions) } //listener?.onTelegramChatsChanged() } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt b/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt index 2f801fe17f..4b12c7d6b7 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt @@ -99,15 +99,15 @@ object OsmandLocationUtils { fun getSenderMessageId(message: TdApi.Message): Int { val forwardInfo = message.forwardInfo - return if (forwardInfo != null) { - val origin: TdApi.MessageForwardOrigin? = forwardInfo.origin - if (origin != null && origin is TdApi.MessageForwardOriginUser) { - origin.senderUserId - } else { - message.senderUserId - } + return if (forwardInfo != null && forwardInfo.origin is TdApi.MessageForwardOriginUser) { + (forwardInfo.origin as TdApi.MessageForwardOriginUser).senderUserId } else { - message.senderUserId + val sender = message.sender + if (sender is TdApi.MessageSenderUser) { + sender.userId + } else { + 0 + } } } diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index b18c61d0c8..025b1ce53c 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -4,7 +4,6 @@ android:installLocation="auto" package="net.osmand.plus"> - diff --git a/OsmAnd/res/drawable-hdpi/warnings_border_control.png b/OsmAnd/res/drawable-hdpi/warnings_border_control.png deleted file mode 100644 index 965d3a747f..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_border_control.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_hazard.png b/OsmAnd/res/drawable-hdpi/warnings_hazard.png deleted file mode 100644 index 6428bd71a4..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_hazard.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_hazard_us.png b/OsmAnd/res/drawable-hdpi/warnings_hazard_us.png deleted file mode 100644 index 139a28e6e8..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_hazard_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_limit.png b/OsmAnd/res/drawable-hdpi/warnings_limit.png deleted file mode 100644 index 3138dc3032..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_limit.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_pedestrian.png b/OsmAnd/res/drawable-hdpi/warnings_pedestrian.png deleted file mode 100644 index 4b7dba0f16..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_pedestrian.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_pedestrian_us.png b/OsmAnd/res/drawable-hdpi/warnings_pedestrian_us.png deleted file mode 100644 index e11394cf83..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_pedestrian_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_railways.png b/OsmAnd/res/drawable-hdpi/warnings_railways.png deleted file mode 100644 index af267bc88e..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_railways.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_railways_us.png b/OsmAnd/res/drawable-hdpi/warnings_railways_us.png deleted file mode 100644 index dfc5b73270..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_railways_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_speed_camera.png b/OsmAnd/res/drawable-hdpi/warnings_speed_camera.png deleted file mode 100644 index 3530337d60..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_speed_camera.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_speed_limit_ca.png b/OsmAnd/res/drawable-hdpi/warnings_speed_limit_ca.png deleted file mode 100644 index 987c7c4b3f..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_speed_limit_ca.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_speed_limit_us.png b/OsmAnd/res/drawable-hdpi/warnings_speed_limit_us.png deleted file mode 100644 index 83afaa224e..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_speed_limit_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_stop.png b/OsmAnd/res/drawable-hdpi/warnings_stop.png deleted file mode 100644 index 91d925357f..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_stop.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_traffic_calming.png b/OsmAnd/res/drawable-hdpi/warnings_traffic_calming.png deleted file mode 100644 index 0ec7391c59..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_traffic_calming.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_traffic_calming_us.png b/OsmAnd/res/drawable-hdpi/warnings_traffic_calming_us.png deleted file mode 100644 index a5b6e94430..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_traffic_calming_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_tunnel.png b/OsmAnd/res/drawable-hdpi/warnings_tunnel.png deleted file mode 100644 index 6138402b12..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_tunnel.png and /dev/null differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_tunnel_us.png b/OsmAnd/res/drawable-hdpi/warnings_tunnel_us.png deleted file mode 100644 index f369ba937b..0000000000 Binary files a/OsmAnd/res/drawable-hdpi/warnings_tunnel_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large-hdpi/warnings_hazard.png b/OsmAnd/res/drawable-large-hdpi/warnings_hazard.png deleted file mode 100644 index d89b0c1386..0000000000 Binary files a/OsmAnd/res/drawable-large-hdpi/warnings_hazard.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large-hdpi/warnings_hazard_us.png b/OsmAnd/res/drawable-large-hdpi/warnings_hazard_us.png deleted file mode 100644 index 27064e732e..0000000000 Binary files a/OsmAnd/res/drawable-large-hdpi/warnings_hazard_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_border_control.png b/OsmAnd/res/drawable-large/warnings_border_control.png deleted file mode 100644 index 3bba943911..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_border_control.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_hazard.png b/OsmAnd/res/drawable-large/warnings_hazard.png deleted file mode 100644 index 71d68c459c..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_hazard.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_hazard_us.png b/OsmAnd/res/drawable-large/warnings_hazard_us.png deleted file mode 100644 index 6bec6ca7ef..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_hazard_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_limit.png b/OsmAnd/res/drawable-large/warnings_limit.png deleted file mode 100644 index 007a8686b6..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_limit.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_pedestrian.png b/OsmAnd/res/drawable-large/warnings_pedestrian.png deleted file mode 100644 index cbe5f3fd36..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_pedestrian.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_pedestrian_us.png b/OsmAnd/res/drawable-large/warnings_pedestrian_us.png deleted file mode 100644 index 5c7735ee0f..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_pedestrian_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_railways.png b/OsmAnd/res/drawable-large/warnings_railways.png deleted file mode 100644 index bc46a41601..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_railways.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_railways_us.png b/OsmAnd/res/drawable-large/warnings_railways_us.png deleted file mode 100644 index 18cf24f46a..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_railways_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_speed_camera.png b/OsmAnd/res/drawable-large/warnings_speed_camera.png deleted file mode 100644 index c1867bb69a..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_speed_camera.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_speed_limit_ca.png b/OsmAnd/res/drawable-large/warnings_speed_limit_ca.png deleted file mode 100644 index 987c7c4b3f..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_speed_limit_ca.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_speed_limit_us.png b/OsmAnd/res/drawable-large/warnings_speed_limit_us.png deleted file mode 100644 index 9dea73d40a..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_speed_limit_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_stop.png b/OsmAnd/res/drawable-large/warnings_stop.png deleted file mode 100644 index 7a3239c28f..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_stop.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_traffic_calming.png b/OsmAnd/res/drawable-large/warnings_traffic_calming.png deleted file mode 100644 index 09790d0071..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_traffic_calming.png and /dev/null differ diff --git a/OsmAnd/res/drawable-large/warnings_traffic_calming_us.png b/OsmAnd/res/drawable-large/warnings_traffic_calming_us.png deleted file mode 100644 index 7ae0c0b3e0..0000000000 Binary files a/OsmAnd/res/drawable-large/warnings_traffic_calming_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_border_control.png b/OsmAnd/res/drawable-mdpi/warnings_border_control.png deleted file mode 100644 index 3d66c61e73..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_border_control.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_hazard.png b/OsmAnd/res/drawable-mdpi/warnings_hazard.png deleted file mode 100644 index a8ac5520b1..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_hazard.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_hazard_us.png b/OsmAnd/res/drawable-mdpi/warnings_hazard_us.png deleted file mode 100644 index f4230404e3..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_hazard_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_limit.png b/OsmAnd/res/drawable-mdpi/warnings_limit.png deleted file mode 100644 index 4f3a0bc2cf..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_limit.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_pedestrian.png b/OsmAnd/res/drawable-mdpi/warnings_pedestrian.png deleted file mode 100644 index a119f3bd3e..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_pedestrian.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_pedestrian_us.png b/OsmAnd/res/drawable-mdpi/warnings_pedestrian_us.png deleted file mode 100644 index 3538b1ff53..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_pedestrian_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_railways.png b/OsmAnd/res/drawable-mdpi/warnings_railways.png deleted file mode 100644 index 493382c1c2..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_railways.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_railways_us.png b/OsmAnd/res/drawable-mdpi/warnings_railways_us.png deleted file mode 100644 index 89f9ff5ca4..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_railways_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_speed_camera.png b/OsmAnd/res/drawable-mdpi/warnings_speed_camera.png deleted file mode 100644 index abdef2b2ee..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_speed_camera.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_speed_limit_ca.png b/OsmAnd/res/drawable-mdpi/warnings_speed_limit_ca.png deleted file mode 100644 index 06b987009b..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_speed_limit_ca.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_speed_limit_us.png b/OsmAnd/res/drawable-mdpi/warnings_speed_limit_us.png deleted file mode 100644 index bacb4991ce..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_speed_limit_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_stop.png b/OsmAnd/res/drawable-mdpi/warnings_stop.png deleted file mode 100644 index e7e689ed79..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_stop.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_traffic_calming.png b/OsmAnd/res/drawable-mdpi/warnings_traffic_calming.png deleted file mode 100644 index 4220b59158..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_traffic_calming.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_traffic_calming_us.png b/OsmAnd/res/drawable-mdpi/warnings_traffic_calming_us.png deleted file mode 100644 index 297604e243..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_traffic_calming_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_tunnel.png b/OsmAnd/res/drawable-mdpi/warnings_tunnel.png deleted file mode 100644 index f1cb47dec0..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_tunnel.png and /dev/null differ diff --git a/OsmAnd/res/drawable-mdpi/warnings_tunnel_us.png b/OsmAnd/res/drawable-mdpi/warnings_tunnel_us.png deleted file mode 100644 index e4f8ee90cc..0000000000 Binary files a/OsmAnd/res/drawable-mdpi/warnings_tunnel_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_border_control.png b/OsmAnd/res/drawable-xhdpi/warnings_border_control.png deleted file mode 100644 index 913aaac9a2..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_border_control.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_hazard.png b/OsmAnd/res/drawable-xhdpi/warnings_hazard.png deleted file mode 100644 index 8e25e1d9b9..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_hazard.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_hazard_us.png b/OsmAnd/res/drawable-xhdpi/warnings_hazard_us.png deleted file mode 100644 index ba6b2f285f..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_hazard_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_limit.png b/OsmAnd/res/drawable-xhdpi/warnings_limit.png deleted file mode 100644 index 1fb9bcb255..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_limit.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_pedestrian.png b/OsmAnd/res/drawable-xhdpi/warnings_pedestrian.png deleted file mode 100644 index b901b84084..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_pedestrian.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_pedestrian_us.png b/OsmAnd/res/drawable-xhdpi/warnings_pedestrian_us.png deleted file mode 100644 index 6095f8566c..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_pedestrian_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_railways.png b/OsmAnd/res/drawable-xhdpi/warnings_railways.png deleted file mode 100644 index 079f34836f..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_railways.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_railways_us.png b/OsmAnd/res/drawable-xhdpi/warnings_railways_us.png deleted file mode 100644 index 13651bf6f0..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_railways_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_speed_camera.png b/OsmAnd/res/drawable-xhdpi/warnings_speed_camera.png deleted file mode 100644 index 185e11626d..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_speed_camera.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_speed_limit_ca.png b/OsmAnd/res/drawable-xhdpi/warnings_speed_limit_ca.png deleted file mode 100644 index 65ea1e7632..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_speed_limit_ca.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_speed_limit_us.png b/OsmAnd/res/drawable-xhdpi/warnings_speed_limit_us.png deleted file mode 100644 index e1452dcf48..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_speed_limit_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_stop.png b/OsmAnd/res/drawable-xhdpi/warnings_stop.png deleted file mode 100644 index b0b7d92615..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_stop.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_traffic_calming.png b/OsmAnd/res/drawable-xhdpi/warnings_traffic_calming.png deleted file mode 100644 index 5914905897..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_traffic_calming.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_traffic_calming_us.png b/OsmAnd/res/drawable-xhdpi/warnings_traffic_calming_us.png deleted file mode 100644 index 9495ee87bb..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_traffic_calming_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_tunnel.png b/OsmAnd/res/drawable-xhdpi/warnings_tunnel.png deleted file mode 100644 index 60f46e25a9..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_tunnel.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xhdpi/warnings_tunnel_us.png b/OsmAnd/res/drawable-xhdpi/warnings_tunnel_us.png deleted file mode 100644 index f48ca400d1..0000000000 Binary files a/OsmAnd/res/drawable-xhdpi/warnings_tunnel_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_border_control.png b/OsmAnd/res/drawable-xxhdpi/warnings_border_control.png deleted file mode 100644 index cc9f355759..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_border_control.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_hazard.png b/OsmAnd/res/drawable-xxhdpi/warnings_hazard.png deleted file mode 100644 index 43fe941ccb..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_hazard.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_hazard_us.png b/OsmAnd/res/drawable-xxhdpi/warnings_hazard_us.png deleted file mode 100644 index f58cfdec50..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_hazard_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_limit.png b/OsmAnd/res/drawable-xxhdpi/warnings_limit.png deleted file mode 100644 index 60c0ee8fd8..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_limit.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_pedestrian.png b/OsmAnd/res/drawable-xxhdpi/warnings_pedestrian.png deleted file mode 100644 index 5006bf2faa..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_pedestrian.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_pedestrian_us.png b/OsmAnd/res/drawable-xxhdpi/warnings_pedestrian_us.png deleted file mode 100644 index e89446d9e9..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_pedestrian_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_railways.png b/OsmAnd/res/drawable-xxhdpi/warnings_railways.png deleted file mode 100644 index 9b4038bd3b..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_railways.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_railways_us.png b/OsmAnd/res/drawable-xxhdpi/warnings_railways_us.png deleted file mode 100644 index 915ad2a02a..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_railways_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_speed_camera.png b/OsmAnd/res/drawable-xxhdpi/warnings_speed_camera.png deleted file mode 100644 index a1c922060c..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_speed_camera.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_speed_limit_ca.png b/OsmAnd/res/drawable-xxhdpi/warnings_speed_limit_ca.png deleted file mode 100644 index 3dd5e83cd7..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_speed_limit_ca.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_speed_limit_us.png b/OsmAnd/res/drawable-xxhdpi/warnings_speed_limit_us.png deleted file mode 100644 index f04a1341d3..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_speed_limit_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_stop.png b/OsmAnd/res/drawable-xxhdpi/warnings_stop.png deleted file mode 100644 index 6a57c36d61..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_stop.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_traffic_calming.png b/OsmAnd/res/drawable-xxhdpi/warnings_traffic_calming.png deleted file mode 100644 index f9d8c6ccc3..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_traffic_calming.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_traffic_calming_us.png b/OsmAnd/res/drawable-xxhdpi/warnings_traffic_calming_us.png deleted file mode 100644 index 73cda7efd3..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_traffic_calming_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_tunnel.png b/OsmAnd/res/drawable-xxhdpi/warnings_tunnel.png deleted file mode 100644 index 1ac51c87c8..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_tunnel.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxhdpi/warnings_tunnel_us.png b/OsmAnd/res/drawable-xxhdpi/warnings_tunnel_us.png deleted file mode 100644 index 0ac5d0cff0..0000000000 Binary files a/OsmAnd/res/drawable-xxhdpi/warnings_tunnel_us.png and /dev/null differ diff --git a/OsmAnd/res/drawable-xxxhdpi/warnings_speed_limit_ca.png b/OsmAnd/res/drawable-xxxhdpi/warnings_speed_limit_ca.png deleted file mode 100644 index e06fded052..0000000000 Binary files a/OsmAnd/res/drawable-xxxhdpi/warnings_speed_limit_ca.png and /dev/null differ diff --git a/OsmAnd/res/drawable/ic_action_join_segments.xml b/OsmAnd/res/drawable/ic_action_join_segments.xml index 20b82f7a73..59505d67e9 100644 --- a/OsmAnd/res/drawable/ic_action_join_segments.xml +++ b/OsmAnd/res/drawable/ic_action_join_segments.xml @@ -1,46 +1,29 @@ - - - - - - - + android:pathData="M4.1707,11C4.0602,11.3128 4,11.6494 4,12C4,12.3506 4.0602,12.6872 4.1707,13H3C2.4477,13 2,12.5523 2,12C2,11.4477 2.4477,11 3,11H4.1707Z" + android:strokeAlpha="0.5" + android:fillColor="#ffffff" + android:fillAlpha="0.5"/> - - - - - - - - + + android:pathData="M9.8293,13H14.1707C14.0601,12.6872 14,12.3506 14,12C14,11.6494 14.0601,11.3128 14.1707,11H9.8293C9.9398,11.3128 10,11.6494 10,12C10,12.3506 9.9398,12.6872 9.8293,13Z" + android:strokeAlpha="0.8" + android:fillColor="#ffffff" + android:fillAlpha="0.8"/> diff --git a/OsmAnd/res/drawable/ic_action_plan_route.xml b/OsmAnd/res/drawable/ic_action_plan_route.xml index ba438f1f16..db6123c2ee 100644 --- a/OsmAnd/res/drawable/ic_action_plan_route.xml +++ b/OsmAnd/res/drawable/ic_action_plan_route.xml @@ -31,10 +31,8 @@ + android:strokeColor="#ffffff"/> + + + + diff --git a/OsmAnd/res/drawable/ic_action_split_before.xml b/OsmAnd/res/drawable/ic_action_split_before.xml new file mode 100644 index 0000000000..39f208948b --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_split_before.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/OsmAnd/res/drawable/warnings_border_control.xml b/OsmAnd/res/drawable/warnings_border_control.xml new file mode 100644 index 0000000000..097038f784 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_border_control.xml @@ -0,0 +1,9 @@ + + + diff --git a/OsmAnd/res/drawable/warnings_hazard.xml b/OsmAnd/res/drawable/warnings_hazard.xml new file mode 100644 index 0000000000..4eef7670f2 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_hazard.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/OsmAnd/res/drawable/warnings_hazard_us.xml b/OsmAnd/res/drawable/warnings_hazard_us.xml new file mode 100644 index 0000000000..3b6695cc8f --- /dev/null +++ b/OsmAnd/res/drawable/warnings_hazard_us.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/OsmAnd/res/drawable/warnings_limit.xml b/OsmAnd/res/drawable/warnings_limit.xml new file mode 100644 index 0000000000..6ed1c76445 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_limit.xml @@ -0,0 +1,13 @@ + + + + diff --git a/OsmAnd/res/drawable/warnings_pedestrian.xml b/OsmAnd/res/drawable/warnings_pedestrian.xml new file mode 100644 index 0000000000..4c2a86472f --- /dev/null +++ b/OsmAnd/res/drawable/warnings_pedestrian.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/OsmAnd/res/drawable/warnings_pedestrian_us.xml b/OsmAnd/res/drawable/warnings_pedestrian_us.xml new file mode 100644 index 0000000000..3582c05768 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_pedestrian_us.xml @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/OsmAnd/res/drawable/warnings_railways.xml b/OsmAnd/res/drawable/warnings_railways.xml new file mode 100644 index 0000000000..70cbe1086d --- /dev/null +++ b/OsmAnd/res/drawable/warnings_railways.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + diff --git a/OsmAnd/res/drawable/warnings_railways_us.xml b/OsmAnd/res/drawable/warnings_railways_us.xml new file mode 100644 index 0000000000..edb283fcd0 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_railways_us.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/OsmAnd/res/drawable/warnings_speed_camera.xml b/OsmAnd/res/drawable/warnings_speed_camera.xml new file mode 100644 index 0000000000..7350d42411 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_speed_camera.xml @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/OsmAnd/res/drawable/warnings_speed_limit_ca.xml b/OsmAnd/res/drawable/warnings_speed_limit_ca.xml new file mode 100644 index 0000000000..1784eea5c4 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_speed_limit_ca.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + diff --git a/OsmAnd/res/drawable/warnings_speed_limit_us.xml b/OsmAnd/res/drawable/warnings_speed_limit_us.xml new file mode 100644 index 0000000000..c1a8245d52 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_speed_limit_us.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/drawable/warnings_stop.xml b/OsmAnd/res/drawable/warnings_stop.xml new file mode 100644 index 0000000000..d50313ebf9 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_stop.xml @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/OsmAnd/res/drawable/warnings_traffic_calming.xml b/OsmAnd/res/drawable/warnings_traffic_calming.xml new file mode 100644 index 0000000000..077e2df01b --- /dev/null +++ b/OsmAnd/res/drawable/warnings_traffic_calming.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/OsmAnd/res/drawable/warnings_traffic_calming_us.xml b/OsmAnd/res/drawable/warnings_traffic_calming_us.xml new file mode 100644 index 0000000000..ae315d3726 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_traffic_calming_us.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/drawable/warnings_tunnel.xml b/OsmAnd/res/drawable/warnings_tunnel.xml new file mode 100644 index 0000000000..d201009405 --- /dev/null +++ b/OsmAnd/res/drawable/warnings_tunnel.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/OsmAnd/res/drawable/warnings_tunnel_us.xml b/OsmAnd/res/drawable/warnings_tunnel_us.xml new file mode 100644 index 0000000000..115308b4dd --- /dev/null +++ b/OsmAnd/res/drawable/warnings_tunnel_us.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 0afa87c32a..3a75558fe5 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -67,7 +67,6 @@ import net.osmand.plus.voice.MediaCommandPlayerImpl; import net.osmand.plus.voice.TTSCommandPlayerImpl; import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.plus.wikivoyage.data.TravelHelper; -import net.osmand.plus.wikivoyage.data.TravelObfHelper; import net.osmand.render.RenderingRulesStorage; import net.osmand.router.RoutingConfiguration; import net.osmand.util.Algorithms; @@ -459,11 +458,9 @@ public class AppInitializer implements IProgress { app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class); app.mapViewTrackingUtilities = startupInit(new MapViewTrackingUtilities(app), MapViewTrackingUtilities.class); - //TODO cleanup after Travel migration complete - app.travelHelper = TravelObfHelper.checkIfObfFileExists(app) ? new TravelObfHelper(app) : new TravelDbHelper(app); - if (app.getSettings().SELECTED_TRAVEL_BOOK.get() != null) { - app.travelHelper.initTravelBooks(); - } + // TODOTRAVEL_OBF_HELPER check ResourceManager and use TravelObfHelper + app.travelHelper = new TravelDbHelper(app); + app.travelHelper.initializeDataOnAppStartup(); app.travelHelper = startupInit(app.travelHelper, TravelHelper.class); app.lockHelper = startupInit(new LockHelper(app), LockHelper.class); diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java index 7c64e3a669..c1de43084e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java @@ -12,6 +12,7 @@ import net.osmand.map.TileSourceManager; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.SQLiteTileSource; +import net.osmand.plus.Version; import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask; import net.osmand.plus.voice.JSMediaCommandPlayerImpl; import net.osmand.plus.voice.JSTTSCommandPlayerImpl; @@ -316,7 +317,9 @@ public class LocalIndexHelper { private void loadTravelData(File mapPath, List result, AbstractLoadLocalIndexTask loadTask) { if (mapPath.canRead()) { for (File mapFile : listFilesSorted(mapPath)) { - if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) { + if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT) + || (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT) + && Version.isDeveloperVersion(app))) { //todo remove when .travel.obf will be used in production LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TRAVEL_DATA, mapFile, false, app); updateDescription(info); result.add(info); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 0213268a05..78864ae80d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -927,8 +927,8 @@ public class MapActivityActions implements DialogProvider { public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { MapActivity.clearPrevActivityIntent(); TravelHelper travelHelper = getMyApplication().getTravelHelper(); - travelHelper.initTravelBooks(); - if (travelHelper.getSelectedTravelBook() == null) { + travelHelper.initializeDataOnAppStartup(); + if (!travelHelper.isAnyTravelBookPresent()) { WikivoyageWelcomeDialogFragment.showInstance(mapActivity.getSupportFragmentManager()); } else { Intent intent = new Intent(mapActivity, WikivoyageExploreActivity.class); diff --git a/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java b/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java index e29139db23..b1f16ee4e7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java @@ -224,13 +224,6 @@ public class PluginsFragment extends BaseOsmAndFragment implements PluginStateLi name = plugin.getName(); pluginDescription.setText(plugin.getDescription()); - int linkTextColorId = nightMode ? R.color.ctx_menu_bottom_view_url_color_dark : R.color.ctx_menu_bottom_view_url_color_light; - int linkTextColor = ContextCompat.getColor(context, linkTextColorId); - - pluginDescription.setLinkTextColor(linkTextColor); - pluginDescription.setMovementMethod(LinkMovementMethod.getInstance()); - AndroidUtils.removeLinkUnderline(pluginDescription); - int color = AndroidUtils.getColorFromAttr(context, R.attr.list_background_color); pluginLogo.setImageDrawable(UiUtilities.tintDrawable(plugin.getLogoResource(), color)); pluginLogo.setOnClickListener(new View.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java index b516d73d2c..aaac5e6f9e 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java @@ -49,6 +49,8 @@ public class DownloadActivityType { 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 TRAVEL_FILE = + new DownloadActivityType(R.string.shared_string_wikivoyage, R.drawable.ic_plugin_wikipedia, "travel", 66); public static final DownloadActivityType LIVE_UPDATES_FILE = new DownloadActivityType(R.string.download_live_updates, "live_updates", 70); public static final DownloadActivityType GPX_FILE = @@ -131,7 +133,10 @@ public class DownloadActivityType { 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); + return fileName.endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT); + } else if (TRAVEL_FILE == this) { + return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT_ZIP, + IndexConstants.BINARY_MAP_VERSION)); } else if (SRTM_COUNTRY_FILE == this) { return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT_ZIP, IndexConstants.BINARY_MAP_VERSION)); @@ -165,7 +170,7 @@ 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) { + } else if (WIKIVOYAGE_FILE == this || TRAVEL_FILE == this) { return ctx.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR); } else if (LIVE_UPDATES_FILE == this) { return ctx.getAppPath(IndexConstants.LIVE_INDEX_DIR); @@ -220,6 +225,8 @@ public class DownloadActivityType { return IndexConstants.BINARY_WIKI_MAP_INDEX_EXT; } else if (WIKIVOYAGE_FILE == this) { return IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT; + } else if (TRAVEL_FILE == this) { + return IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT; } else if (LIVE_UPDATES_FILE == this) { return BINARY_MAP_INDEX_EXT; } else if (HILLSHADE_FILE == this) { @@ -247,6 +254,8 @@ public class DownloadActivityType { return "&wiki=yes"; } else if (this == WIKIVOYAGE_FILE) { return "&wikivoyage=yes"; + } else if (this == TRAVEL_FILE) { + return "&wikivoyage=yes"; } else if (this == HILLSHADE_FILE) { return "&hillshade=yes"; } else if (this == SLOPE_FILE) { @@ -282,9 +291,13 @@ public class DownloadActivityType { } - public IndexItem parseIndexItem(Context ctx, XmlPullParser parser) { + public IndexItem parseIndexItem(OsmandApplication ctx, XmlPullParser parser) { + if (TRAVEL_FILE == this && !Version.isDeveloperVersion(ctx)) { + //todo remove "if" when .travel.obf will be used in production + return null; + } String name = parser.getAttributeValue(null, "name"); //$NON-NLS-1$ - if(!isAccepted(name)) { + if (!isAccepted(name)) { return null; } String size = parser.getAttributeValue(null, "size"); //$NON-NLS-1$ @@ -415,7 +428,9 @@ public class DownloadActivityType { if (this == WIKIVOYAGE_FILE) { return baseNameWithoutVersion + IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT; } - + if (this == TRAVEL_FILE) { + return baseNameWithoutVersion + IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT; + } if (this == ROADS_FILE) { return baseNameWithoutVersion + IndexConstants.BINARY_ROAD_MAP_INDEX_EXT; } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java index 3d06d4c9e1..2bff73d7b2 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java @@ -130,14 +130,18 @@ public class DownloadResources extends DownloadResourceGroup { java.text.DateFormat dateFormat = app.getResourceManager().getDateFormat(); Map 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); + listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), + IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT, indexActivatedFileNames); + listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), + IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT, indexActivatedFileNames); Map 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); + listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), + IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT, indexFileNames); + listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), + IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT, indexFileNames); app.getResourceManager().getBackupIndexes(indexFileNames); this.indexFileNames = indexFileNames; this.indexActivatedFileNames = indexActivatedFileNames; @@ -179,7 +183,8 @@ public class DownloadResources extends DownloadResourceGroup { || item.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE || item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) { outdated = true; - } else if(item.getType() == DownloadActivityType.WIKIVOYAGE_FILE) { + } else if (item.getType() == DownloadActivityType.WIKIVOYAGE_FILE + || item.getType() == DownloadActivityType.TRAVEL_FILE) { long itemSize = item.getContentSize(); long oldItemSize = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR + item.getTargetFileName()).length(); @@ -343,7 +348,11 @@ public class DownloadResources extends DownloadResourceGroup { } continue; } - if(ii.getType() == DownloadActivityType.WIKIVOYAGE_FILE) { + if (ii.getType() == DownloadActivityType.WIKIVOYAGE_FILE) { + wikivoyageMaps.addItem(ii); + continue; + } + if (ii.getType() == DownloadActivityType.TRAVEL_FILE) { wikivoyageMaps.addItem(ii); continue; } diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index e4cdc5ce94..9ad1a0f89e 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -415,6 +415,8 @@ public class ItemViewHolder { tp = LocalIndexType.MAP_DATA; } else if (indexItem.getType() == DownloadActivityType.WIKIVOYAGE_FILE) { tp = LocalIndexType.MAP_DATA; + } else if (indexItem.getType() == DownloadActivityType.TRAVEL_FILE) { + tp = LocalIndexType.MAP_DATA; } else if (indexItem.getType() == DownloadActivityType.FONT_FILE) { tp = LocalIndexType.FONT_DATA; } else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java index 74797620f9..fac88b2069 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java @@ -26,7 +26,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.wikivoyage.data.TravelArticle; -import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.plus.wikivoyage.data.TravelHelper; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; @@ -569,12 +568,11 @@ public class MapMarkersHelper { public List getGroupsForSavedArticlesTravelBook() { List res = new ArrayList<>(); TravelHelper travelHelper = ctx.getTravelHelper(); - if (travelHelper.getSelectedTravelBook() != null) { - List savedArticles = travelHelper.getLocalDataHelper().getSavedArticles(); + if (travelHelper.isAnyTravelBookPresent()) { + List savedArticles = travelHelper.getBookmarksHelper().getSavedArticles(); for (TravelArticle art : savedArticles) { String gpxName = travelHelper.getGPXName(art); File path = ctx.getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName); - LOG.debug("Article group " + path.getAbsolutePath() + " " + path.exists()); MapMarkersGroup search = getMapMarkerGroupById(getMarkerGroupId(path), MapMarkersGroup.GPX_TYPE); if (search == null) { MapMarkersGroup group = createGPXMarkerGroup(path); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java index 4cb0b9f690..2277dded7c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java @@ -36,7 +36,6 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapmarkers.SelectWptCategoriesBottomSheetDialogFragment; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; -import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.plus.wikivoyage.data.TravelHelper; import java.io.File; @@ -165,8 +164,8 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter savedArticles = travelHelper.getLocalDataHelper().getSavedArticles(); + if (travelHelper.isAnyTravelBookPresent()) { + List savedArticles = travelHelper.getBookmarksHelper().getSavedArticles(); for (TravelArticle art : savedArticles) { String gpxName = travelHelper.getGPXName(art); File path = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName); @@ -428,7 +427,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter langs; private String selectedLang; private TravelArticle article; @@ -199,10 +197,10 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme updateWebSettings(); populateArticle(); } else if (requestCode == WikivoyageArticleNavigationFragment.OPEN_ARTICLE_REQUEST_CODE) { - long tripId = data.getLongExtra(WikivoyageArticleNavigationFragment.TRIP_ID_KEY, -1); + String tripId = data.getStringExtra(WikivoyageArticleNavigationFragment.ROUTE_ID_KEY); String selectedLang = data.getStringExtra(WikivoyageArticleNavigationFragment.SELECTED_LANG_KEY); - if (tripId != -1 && !TextUtils.isEmpty(selectedLang)) { - this.tripId = tripId; + if (!Algorithms.isEmpty(tripId) && !TextUtils.isEmpty(selectedLang)) { + this.routeId = tripId; this.selectedLang = selectedLang; populateArticle(); } @@ -235,7 +233,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme private void updateSaveButton() { if (article != null) { - final TravelLocalDataHelper helper = getMyApplication().getTravelHelper().getLocalDataHelper(); + final TravelLocalDataHelper helper = getMyApplication().getTravelHelper().getBookmarksHelper(); 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_remove : R.string.shared_string_bookmark)); @@ -288,21 +286,21 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme @Override protected void populateArticle() { - if (tripId == NO_VALUE || langs == null) { + if (Algorithms.isEmpty(routeId) || langs == null) { Bundle args = getArguments(); if (args != null) { - tripId = args.getLong(CITY_ID_KEY); + routeId = args.getString(ROUTE_ID_KEY); langs = args.getStringArrayList(LANGS_KEY); } } - if (tripId == NO_VALUE || langs == null || langs.isEmpty()) { + if (Algorithms.isEmpty(routeId) || langs == null || langs.isEmpty()) { return; } if (selectedLang == null) { selectedLang = langs.get(0); } articleToolbarText.setText(""); - article = getMyApplication().getTravelHelper().getArticle(tripId, selectedLang); + article = getMyApplication().getTravelHelper().getArticleById(routeId, selectedLang); if (article == null) { return; } @@ -315,7 +313,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme trackButton.setVisibility(View.GONE); } - TravelLocalDataHelper ldh = getMyApplication().getTravelHelper().getLocalDataHelper(); + TravelLocalDataHelper ldh = getMyApplication().getTravelHelper().getBookmarksHelper(); ldh.addToHistory(article); updateSaveButton(); @@ -367,35 +365,35 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme return sb.toString(); } - public static boolean showInstance(@NonNull OsmandApplication app, + public static boolean showInstanceByTitle(@NonNull OsmandApplication app, @NonNull FragmentManager fm, @NonNull String title, @NonNull String lang) { - long cityId = app.getTravelHelper().getArticleId(title, lang); - return showInstance(app, fm, cityId, lang); + String articleId = app.getTravelHelper().getArticleId(title, lang); + return showInstance(app, fm, articleId, lang); } public static boolean showInstance(@NonNull OsmandApplication app, @NonNull FragmentManager fm, - long cityId, + @NonNull String routeId, @Nullable String selectedLang) { - ArrayList langs = app.getTravelHelper().getArticleLangs(cityId); - return showInstance(fm, cityId, langs, selectedLang); + ArrayList langs = app.getTravelHelper().getArticleLangs(routeId); + return showInstance(fm, routeId, langs, selectedLang); } public static boolean showInstance(@NonNull FragmentManager fm, - long cityId, + String routeId, @NonNull ArrayList langs) { - return showInstance(fm, cityId, langs, null); + return showInstance(fm, routeId, langs, null); } public static boolean showInstance(@NonNull FragmentManager fm, - long cityId, + String routeId, @NonNull ArrayList langs, @Nullable String selectedLang) { try { Bundle args = new Bundle(); - args.putLong(CITY_ID_KEY, cityId); + args.putString(ROUTE_ID_KEY, routeId); args.putStringArrayList(LANGS_KEY, langs); if (langs.contains(selectedLang)) { args.putString(SELECTED_LANG_KEY, selectedLang); @@ -418,7 +416,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme return; } WikivoyageArticleNavigationFragment.showInstance(fm, - WikivoyageArticleDialogFragment.this, tripId, selectedLang); + WikivoyageArticleDialogFragment.this, routeId, selectedLang); } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java index 11ca183c50..7f0d9e8c0e 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java @@ -27,24 +27,25 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; +import net.osmand.util.Algorithms; import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFragment { public static final String TAG = WikivoyageArticleNavigationFragment.class.getSimpleName(); - public static final String TRIP_ID_KEY = "trip_id_key"; + public static final String ROUTE_ID_KEY = "route_id_key"; public static final String SELECTED_LANG_KEY = "selected_lang_key"; public static final int OPEN_ARTICLE_REQUEST_CODE = 2; private static final long UNDEFINED = -1; - private long cityId = UNDEFINED; + private String routeId = ""; private String selectedLang; private TravelArticle article; private List parentsList; @@ -60,26 +61,26 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr if (savedInstanceState != null) { selectedLang = savedInstanceState.getString(SELECTED_LANG_KEY); - cityId = savedInstanceState.getLong(TRIP_ID_KEY); + routeId = savedInstanceState.getString(ROUTE_ID_KEY); } else { Bundle args = getArguments(); if (args != null) { selectedLang = args.getString(SELECTED_LANG_KEY); - cityId = args.getLong(TRIP_ID_KEY); + routeId = args.getString(ROUTE_ID_KEY); } } - if (cityId == UNDEFINED || TextUtils.isEmpty(selectedLang)) { + if (Algorithms.isEmpty(routeId) || TextUtils.isEmpty(selectedLang)) { return; } - article = getMyApplication().getTravelHelper().getArticle(cityId, selectedLang); + article = getMyApplication().getTravelHelper().getArticleById(routeId, selectedLang); if (article == null) { return; } parentsList = new ArrayList<>(Arrays.asList(article.getAggregatedPartOf().split(","))); - LinkedHashMap> navigationMap = getMyApplication().getTravelHelper().getNavigationMap(article); + Map> navigationMap = getMyApplication().getTravelHelper().getNavigationMap(article); items.add(new TitleItem(getString(R.string.shared_string_navigation))); @@ -101,7 +102,7 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { WikivoyageSearchResult articleItem = listAdapter.getArticleItem(groupPosition, childPosition); - sendResults(articleItem.getTripId()); + sendResults(articleItem.getRouteId()); dismiss(); return true; } @@ -110,10 +111,10 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { WikivoyageSearchResult articleItem = (WikivoyageSearchResult) listAdapter.getGroup(groupPosition); - if (articleItem.getTripId() == UNDEFINED) { + if (Algorithms.isEmpty(articleItem.getRouteId())) { Toast.makeText(getContext(), R.string.wiki_article_not_found, Toast.LENGTH_LONG).show(); } else { - sendResults(articleItem.getTripId()); + sendResults(articleItem.getRouteId()); dismiss(); } return true; @@ -133,7 +134,7 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - outState.putLong(TRIP_ID_KEY, cityId); + outState.putString(ROUTE_ID_KEY, routeId); outState.putString(SELECTED_LANG_KEY, selectedLang); } @@ -147,17 +148,17 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr return nightMode ? R.color.wikivoyage_bottom_bar_bg_dark : R.color.list_background_color_light; } - private void sendResults(long cityId) { - WikivoyageArticleDialogFragment.showInstance(getMyApplication(), getFragmentManager(), cityId, selectedLang); + private void sendResults(String routeId) { + WikivoyageArticleDialogFragment.showInstance(getMyApplication(), getFragmentManager(), routeId, selectedLang); } public static boolean showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment, - long cityId, + String routeId, @NonNull String selectedLang) { try { Bundle args = new Bundle(); - args.putLong(TRIP_ID_KEY, cityId); + args.putString(ROUTE_ID_KEY, routeId); args.putString(SELECTED_LANG_KEY, selectedLang); WikivoyageArticleNavigationFragment fragment = new WikivoyageArticleNavigationFragment(); if (targetFragment != null) { @@ -175,13 +176,13 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr private Context context; - private LinkedHashMap> navigationMap; + private Map> navigationMap; private List headers; private Drawable itemGroupIcon; private Drawable itemChildIcon; - ExpandableListAdapter(Context context, LinkedHashMap> navigationMap) { + ExpandableListAdapter(Context context, Map> navigationMap) { this.context = context; this.navigationMap = navigationMap; headers = new ArrayList<>(navigationMap.keySet()); @@ -236,7 +237,7 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr boolean isLastChild, View convertView, ViewGroup parent) { WikivoyageSearchResult articleItem = getArticleItem(groupPosition, childPosition); String childTitle = articleItem.getArticleTitles().get(0); - boolean selected = cityId == articleItem.getTripId() || parentsList.contains(childTitle); + boolean selected = Algorithms.stringsEqual(routeId, articleItem.getRouteId()) || parentsList.contains(childTitle); if (convertView == null) { convertView = LayoutInflater.from(context) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java index a9de4e92a2..a559f3cf0f 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java @@ -28,7 +28,7 @@ public class TravelArticle { double lon; String imageTitle; GPXFile gpxFile; - long tripId; + String routeId; long originalId; String lang; String contentsJson; @@ -63,8 +63,8 @@ public class TravelArticle { return gpxFile; } - public long getTripId() { - return tripId; + public String getRouteId() { + return routeId; } public long getOriginalId() { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 0ca212164d..f5d6cc5898 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -42,8 +42,6 @@ import java.util.Map; import java.util.Random; import java.util.Set; -import gnu.trove.map.hash.TLongObjectHashMap; - public class TravelDbHelper implements TravelHelper { private static final Log LOG = PlatformUtil.getLog(TravelDbHelper.class); @@ -116,11 +114,16 @@ public class TravelDbHelper implements TravelHelper { localDataHelper = new TravelLocalDataHelper(application); } - public TravelLocalDataHelper getLocalDataHelper() { + public TravelLocalDataHelper getBookmarksHelper() { return localDataHelper; } - public void initTravelBooks() { + @Override + public boolean isAnyTravelBookPresent() { + return selectedTravelBook != null; + } + + public void initializeDataOnAppStartup() { List files = getPossibleFiles(); String travelBook = application.getSettings().SELECTED_TRAVEL_BOOK.get(); existingTravelBooks.clear(); @@ -153,13 +156,17 @@ public class TravelDbHelper implements TravelHelper { return null; } - public void loadDataForSelectedTravelBook() { + public void initializeDataToDisplay() { localDataHelper.refreshCachedData(); loadPopularArticles(); } - public File getSelectedTravelBook() { - return selectedTravelBook; + + public String getSelectedTravelBookName() { + if (selectedTravelBook != null) { + return selectedTravelBook.getName(); + } + return null; } public List getExistingTravelBooks() { @@ -222,7 +229,7 @@ public class TravelDbHelper implements TravelHelper { if (cursor.moveToFirst()) { do { WikivoyageSearchResult rs = new WikivoyageSearchResult(); - rs.tripId = cursor.getLong(0); + rs.routeId = cursor.getLong(0) + ""; rs.articleTitles.add(cursor.getString(1)); rs.langs.add(cursor.getString(2)); rs.isPartOf.add(cursor.getString(3)); @@ -235,7 +242,7 @@ public class TravelDbHelper implements TravelHelper { } } - List list = new ArrayList<>(groupSearchResultsByCityId(res)); + List list = new ArrayList<>(groupSearchResultsByRouteId(res)); sortSearchResults(searchQuery, list); return list; @@ -288,7 +295,7 @@ public class TravelDbHelper implements TravelHelper { } }); sortPopArticlesByDistance(popReadArticlesLocation); - List resArticleOrder = new ArrayList(); + List resArticleOrder = new ArrayList(); Iterator orderIterator = popReadArticlesOrder.iterator(); Iterator locIterator = popReadArticlesLocation.iterator(); Iterator otherIterator = popReadArticles.iterator(); @@ -314,13 +321,13 @@ public class TravelDbHelper implements TravelHelper { } - Map ts = readTravelArticles(conn, LANG_WHERE, resArticleOrder); + Map ts = readTravelArticles(conn, LANG_WHERE, resArticleOrder); popularArticles = sortArticlesToInitialOrder(resArticleOrder, ts); return popularArticles; } - private Map readTravelArticles(SQLiteConnection conn, String whereCondition, - List articleIds) { + private Map readTravelArticles(SQLiteConnection conn, String whereCondition, + List articleIds) { SQLiteCursor cursor; StringBuilder bld = new StringBuilder(); bld.append(ARTICLES_TABLE_SELECT).append(whereCondition) @@ -333,12 +340,12 @@ public class TravelDbHelper implements TravelHelper { } bld.append(")"); cursor = conn.rawQuery(bld.toString(), null); - Map ts = new HashMap(); + Map ts = new HashMap(); if (cursor != null) { if (cursor.moveToFirst()) { do { TravelArticle travelArticle = readArticle(cursor); - ts.put(travelArticle.tripId, travelArticle); + ts.put(travelArticle.routeId, travelArticle); } while (cursor.moveToNext()); } cursor.close(); @@ -346,7 +353,7 @@ public class TravelDbHelper implements TravelHelper { return ts; } - private List sortArticlesToInitialOrder(List resArticleOrder, Map ts) { + private List sortArticlesToInitialOrder(List resArticleOrder, Map ts) { List res = new ArrayList<>(); for (int i = 0; i < resArticleOrder.size(); i++) { TravelArticle ta = ts.get(resArticleOrder.get(i)); @@ -398,11 +405,11 @@ public class TravelDbHelper implements TravelHelper { } - private Collection groupSearchResultsByCityId(List res) { + private Collection groupSearchResultsByRouteId(List res) { String baseLng = application.getLanguage(); - TLongObjectHashMap wikivoyage = new TLongObjectHashMap<>(); + Map wikivoyage = new HashMap<>(); for (WikivoyageSearchResult rs : res) { - WikivoyageSearchResult prev = wikivoyage.get(rs.tripId); + WikivoyageSearchResult prev = wikivoyage.get(rs.routeId); if (prev != null) { int insInd = prev.langs.size(); if (rs.langs.get(0).equals(baseLng)) { @@ -418,10 +425,10 @@ public class TravelDbHelper implements TravelHelper { prev.langs.add(insInd, rs.langs.get(0)); prev.isPartOf.add(insInd, rs.isPartOf.get(0)); } else { - wikivoyage.put(rs.tripId, rs); + wikivoyage.put(rs.routeId, rs); } } - return wikivoyage.valueCollection(); + return wikivoyage.values(); } @NonNull @@ -473,7 +480,7 @@ public class TravelDbHelper implements TravelHelper { if (cursor != null && cursor.moveToFirst()) { do { WikivoyageSearchResult rs = new WikivoyageSearchResult(); - rs.tripId = cursor.getLong(0); + rs.routeId = cursor.getLong(0) + ""; rs.articleTitles.add(cursor.getString(1)); rs.langs.add(cursor.getString(2)); rs.isPartOf.add(cursor.getString(3)); @@ -506,7 +513,7 @@ public class TravelDbHelper implements TravelHelper { }); WikivoyageSearchResult emptyResult = new WikivoyageSearchResult(); emptyResult.articleTitles.add(header); - emptyResult.tripId = -1; + emptyResult.routeId = ""; searchResult = searchResult != null ? searchResult : emptyResult; res.put(searchResult, results); } @@ -515,12 +522,12 @@ public class TravelDbHelper implements TravelHelper { } @Nullable - public TravelArticle getArticle(long cityId, String lang) { + public TravelArticle getArticleById(String routeId, String lang) { TravelArticle res = null; SQLiteConnection conn = openConnection(); - if (conn != null) { + if (conn != null && !Algorithms.isEmpty(routeId)) { SQLiteCursor cursor = conn.rawQuery(ARTICLES_TABLE_SELECT + " WHERE " + ARTICLES_COL_TRIP_ID + " = ? AND " - + ARTICLES_COL_LANG + " = ?", new String[] { String.valueOf(cityId), lang }); + + ARTICLES_COL_LANG + " = ?", new String[] { routeId, lang }); if (cursor != null) { if (cursor.moveToFirst()) { res = readArticle(cursor); @@ -532,7 +539,7 @@ public class TravelDbHelper implements TravelHelper { } @Nullable - public TravelArticle getArticle(String title, String lang) { + public TravelArticle getArticleByTitle(String title, String lang) { TravelArticle res = null; SQLiteConnection conn = openConnection(); if (conn != null) { @@ -548,8 +555,8 @@ public class TravelDbHelper implements TravelHelper { return res; } - public long getArticleId(String title, String lang) { - long res = 0; + public String getArticleId(String title, String lang) { + String res = ""; SQLiteConnection conn = openConnection(); if (conn != null) { SQLiteCursor cursor = conn.rawQuery("SELECT " + ARTICLES_COL_TRIP_ID + " FROM " @@ -557,7 +564,7 @@ public class TravelDbHelper implements TravelHelper { + ARTICLES_COL_LANG + " = ?", new String[]{title, lang}); if (cursor != null) { if (cursor.moveToFirst()) { - res = cursor.getLong(0); + res = cursor.getLong(0) + ""; } cursor.close(); } @@ -566,12 +573,12 @@ public class TravelDbHelper implements TravelHelper { } @NonNull - public ArrayList getArticleLangs(long cityId) { + public ArrayList getArticleLangs(String routeId) { ArrayList res = new ArrayList<>(); SQLiteConnection conn = openConnection(); if (conn != null) { SQLiteCursor cursor = conn.rawQuery("SELECT " + ARTICLES_COL_LANG + " FROM " + ARTICLES_TABLE_NAME - + " WHERE " + ARTICLES_COL_TRIP_ID + " = ?", new String[]{String.valueOf(cityId)}); + + " WHERE " + ARTICLES_COL_TRIP_ID + " = ?", new String[]{routeId}); if (cursor != null) { if (cursor.moveToFirst()) { String baseLang = application.getLanguage(); @@ -610,7 +617,7 @@ public class TravelDbHelper implements TravelHelper { res.lat = cursor.isNull(3) ? Double.NaN : cursor.getDouble(3); res.lon = cursor.isNull(4) ? Double.NaN : cursor.getDouble(4); res.imageTitle = cursor.getString(5); - res.tripId = cursor.getLong(7); + res.routeId = cursor.getLong(7) + ""; res.originalId = cursor.isNull(8) ? 0 : cursor.getLong(8); res.lang = cursor.getString(9); res.contentsJson = cursor.getString(10); @@ -648,7 +655,7 @@ public class TravelDbHelper implements TravelHelper { } protected static class PopularArticle { - long tripId; + String tripId; String title; String lang; int popIndex; @@ -665,7 +672,7 @@ public class TravelDbHelper implements TravelHelper { res.title = cursor.getString(0); res.lat = cursor.isNull(1) ? Double.NaN : cursor.getDouble(1); res.lon = cursor.isNull(2) ? Double.NaN : cursor.getDouble(2); - res.tripId = cursor.getLong(3); + res.tripId = cursor.getLong(3) + ""; res.lang = cursor.getString(4); res.order = cursor.isNull(5) ? -1 : cursor.getInt(5); res.popIndex = cursor.isNull(6) ? 0 : cursor.getInt(6); @@ -677,7 +684,7 @@ public class TravelDbHelper implements TravelHelper { res.title = a.getName(lang); res.lat = a.getLocation().getLatitude(); res.lon = a.getLocation().getLongitude(); - res.tripId = a.getId(); + res.tripId = a.getId() + ""; res.lang = lang; res.order = -1; res.popIndex = 0; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java index 065aff9e3f..79df7bdfeb 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java @@ -13,17 +13,13 @@ import java.util.Map; public interface TravelHelper { - TravelLocalDataHelper getLocalDataHelper(); + TravelLocalDataHelper getBookmarksHelper(); - void initTravelBooks(); + void initializeDataOnAppStartup(); - void loadDataForSelectedTravelBook(); + void initializeDataToDisplay(); - File getSelectedTravelBook(); - - List getExistingTravelBooks(); - - void selectTravelBook(File f); + boolean isAnyTravelBookPresent(); @NonNull List search(final String searchQuery); @@ -31,23 +27,23 @@ public interface TravelHelper { @NonNull List getPopularArticles(); - @NonNull - List loadPopularArticles(); - - LinkedHashMap> getNavigationMap( + Map> getNavigationMap( final TravelArticle article); - TravelArticle getArticle(long cityId, String lang); + TravelArticle getArticleById(String routeId, String lang); - TravelArticle getArticle(String title, String lang); + TravelArticle getArticleByTitle(String title, String lang); - long getArticleId(String title, String lang); + String getArticleId(String title, String lang); - ArrayList getArticleLangs(long cityId); - - String formatTravelBookName(File tb); + ArrayList getArticleLangs(String articleId); String getGPXName(TravelArticle article); File createGpxFile(TravelArticle article); + + // TODO: this method should be deleted once TravelDBHelper is deleted + // For TravelOBFHelper it could always return "" and should be no problem + // Bookmarks should be refactored properly to support multiple files + String getSelectedTravelBookName(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index 68f2f7cc2c..5743041407 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -260,9 +260,9 @@ public class TravelLocalDataHelper { if (oldVersion < 3) { conn.execSQL("ALTER TABLE " + HISTORY_TABLE_NAME + " ADD " + HISTORY_COL_TRAVEL_BOOK + " TEXT"); conn.execSQL("ALTER TABLE " + BOOKMARKS_TABLE_NAME + " ADD " + BOOKMARKS_COL_TRAVEL_BOOK + " TEXT"); - File selectedTravelBook = context.getTravelHelper().getSelectedTravelBook(); - if (selectedTravelBook != null) { - Object[] args = new Object[]{selectedTravelBook.getName()}; + String selectedTravelBookName = getSelectedTravelBookName(); + if (selectedTravelBookName != null) { + Object[] args = new Object[]{selectedTravelBookName}; conn.execSQL("UPDATE " + HISTORY_TABLE_NAME + " SET " + HISTORY_COL_TRAVEL_BOOK + " = ?", args); conn.execSQL("UPDATE " + BOOKMARKS_TABLE_NAME + " SET " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?", args); } @@ -452,11 +452,7 @@ public class TravelLocalDataHelper { @Nullable private String getSelectedTravelBookName() { - File selectedTravelBook = context.getTravelHelper().getSelectedTravelBook(); - if (selectedTravelBook != null) { - return selectedTravelBook.getName(); - } - return null; + return context.getTravelHelper().getSelectedTravelBookName(); } private WikivoyageSearchHistoryItem readHistoryItem(SQLiteCursor cursor) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java deleted file mode 100644 index 9ccdc5f6c8..0000000000 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ /dev/null @@ -1,464 +0,0 @@ -package net.osmand.plus.wikivoyage.data; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import net.osmand.Collator; -import net.osmand.CollatorStringMatcher; -import net.osmand.GPXUtilities; -import net.osmand.IndexConstants; -import net.osmand.OsmAndCollator; -import net.osmand.PlatformUtil; -import net.osmand.ResultMatcher; -import net.osmand.binary.BinaryIndexPart; -import net.osmand.binary.BinaryMapIndexReader; -import net.osmand.binary.BinaryMapPoiReaderAdapter; -import net.osmand.data.Amenity; -import net.osmand.data.LatLon; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.util.Algorithms; -import net.osmand.util.MapUtils; - -import org.apache.commons.logging.Log; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; - -import gnu.trove.map.TLongObjectMap; -import gnu.trove.map.hash.TLongObjectHashMap; - - -public class TravelObfHelper implements TravelHelper { - - private static final Log LOG = PlatformUtil.getLog(TravelObfHelper.class); - - private static final String WIKIVOYAGE_OBF = "Wikivoyage.obf"; - public static final String ROUTE_ARTICLE = "route_article"; - - private final OsmandApplication application; - private Collator collator; - private TravelLocalDataHelper localDataHelper; - - private File selectedTravelBook = null; - private List existingTravelBooks = new ArrayList<>(); - private List popularArticles = new ArrayList(); - - private TLongObjectMap cachedArticles; - - - public TravelObfHelper(OsmandApplication application) { - this.application = application; - collator = OsmAndCollator.primaryCollator(); - localDataHelper = new TravelLocalDataHelper(application); - cachedArticles = new TLongObjectHashMap<>(); - } - - public static boolean checkIfObfFileExists(OsmandApplication app) { - File[] files = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles(); - if (files != null) { - for (File f : files) { - if (f.getName().equals(WIKIVOYAGE_OBF)) { - return true; - } - } - } - return false; - } - - @Override - public TravelLocalDataHelper getLocalDataHelper() { - return localDataHelper; - } - - /** - * TODO - * 1. implement regional travelbooks - * 2. check settings for default? - */ - public void initTravelBooks() { - List files = getPossibleFiles(); - String travelBook = application.getSettings().SELECTED_TRAVEL_BOOK.get(); - existingTravelBooks.clear(); - if (files != null && !files.isEmpty()) { - for (File f : files) { - existingTravelBooks.add(f); - if (selectedTravelBook == null) { - selectedTravelBook = f; - } else if (Algorithms.objectEquals(travelBook, f.getName())) { - selectedTravelBook = f; - } - } - selectedTravelBook = files.get(0); - } else { - selectedTravelBook = null; - } - - } - - /** - * todo: get all obf files from folder, may be we should add some suffix like 'wikivoyage' - * to filenames to distinguish from other maps? Or add some checks right there. - */ - @Nullable - private List getPossibleFiles() { - File[] files = application.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles(); - if (files != null) { - List res = new ArrayList<>(); - for (File file : files) { - if (file.getName().equals("Wikivoyage.obf")) { - res.add(file); - LOG.debug(String.format("FIle name: %s", file.getAbsolutePath())); - } - } - return res; - } - return null; - } - - public void loadDataForSelectedTravelBook() { - localDataHelper.refreshCachedData(); - loadPopularArticles(); - } - - @Override - public File getSelectedTravelBook() { - return selectedTravelBook; - } - - @Override - public List getExistingTravelBooks() { - return existingTravelBooks; - } - - @Override - public void selectTravelBook(File f) { - //todo - } - - @NonNull - @Override - public List search(String searchQuery) { - List res = new ArrayList<>(); - CollatorStringMatcher matcher = new CollatorStringMatcher(searchQuery, - CollatorStringMatcher.StringMatcherMode.CHECK_STARTS_FROM_SPACE); - - for (TravelArticle article : popularArticles) { - if (checkArticleMatches(matcher, article)) { - - WikivoyageSearchResult searchResult = convertArticleToSearchResult(article); - res.add(searchResult); - } - } - res = new ArrayList<>(groupSearchResultsByCityId(res)); - sortSearchResults(searchQuery, res); - return res; - } - - private WikivoyageSearchResult convertArticleToSearchResult(TravelArticle article) { - WikivoyageSearchResult searchResult = new WikivoyageSearchResult(); - searchResult.articleTitles = new ArrayList<>(Collections.singletonList(article.title)); - searchResult.isPartOf = new ArrayList<>(Collections.singletonList(article.isPartOf)); - searchResult.imageTitle = article.imageTitle; - searchResult.langs = new ArrayList<>(Collections.singletonList(article.lang)); - searchResult.tripId = article.tripId; - return searchResult; - } - - private Collection groupSearchResultsByCityId(List res) { - String baseLng = application.getLanguage(); - TLongObjectHashMap wikivoyage = new TLongObjectHashMap<>(); - for (WikivoyageSearchResult rs : res) { - WikivoyageSearchResult prev = wikivoyage.get(rs.tripId); - if (prev != null) { - int insInd = prev.langs.size(); - if (rs.langs.get(0).equals(baseLng)) { - insInd = 0; - } else if (rs.langs.get(0).equals("en")) { - if (!prev.langs.get(0).equals(baseLng)) { - insInd = 0; - } else { - insInd = 1; - } - } - prev.articleTitles.add(insInd, rs.articleTitles.get(0)); - prev.langs.add(insInd, rs.langs.get(0)); - prev.isPartOf.add(insInd, rs.isPartOf.get(0)); - } else { - wikivoyage.put(rs.tripId, rs); - } - } - return wikivoyage.valueCollection(); - } - - private void sortSearchResults(final String searchQuery, List list) { - Collections.sort(list, new Comparator() { - @Override - public int compare(WikivoyageSearchResult o1, WikivoyageSearchResult o2) { - boolean c1 = CollatorStringMatcher.cmatches(collator, searchQuery, o1.articleTitles.get(0), - CollatorStringMatcher.StringMatcherMode.CHECK_ONLY_STARTS_WITH); - boolean c2 = CollatorStringMatcher.cmatches(collator, searchQuery, o2.articleTitles.get(0), - CollatorStringMatcher.StringMatcherMode.CHECK_ONLY_STARTS_WITH); - if (c1 == c2) { - return collator.compare(o1.articleTitles.get(0), o2.articleTitles.get(0)); - } else if (c1) { - return -1; - } else if (c2) { - return 1; - } - return 0; - } - }); - } - - private boolean checkArticleMatches(CollatorStringMatcher matcher, TravelArticle article) { - return matcher.matches(article.getTitle()) - || matcher.matches(article.getContent()) - || matcher.matches(article.getContentsJson()); - } - - @NonNull - public List getPopularArticles() { - return popularArticles; - } - - //TODO for now it reads any articles, since we didn't have popular articles in the obf - @NonNull - public List loadPopularArticles() { - String language = application.getLanguage(); - final List articles = new ArrayList<>(); - try { - BinaryMapIndexReader bookIndexReader = getBookBinaryIndex(); - if (bookIndexReader == null) { - popularArticles = new ArrayList<>(); - return popularArticles; - } - LatLon ll = application.getMapViewTrackingUtilities().getMapLocation(); - float coeff = 2; - BinaryMapIndexReader.SearchRequest req = - BinaryMapIndexReader.buildSearchPoiRequest( - MapUtils.get31TileNumberX(ll.getLongitude() - coeff), - MapUtils.get31TileNumberX(ll.getLongitude() + coeff), - MapUtils.get31TileNumberY(ll.getLatitude() + coeff), - MapUtils.get31TileNumberY(ll.getLatitude() - coeff), - -1, - BinaryMapIndexReader.ACCEPT_ALL_POI_TYPE_FILTER, - new ResultMatcher() { - int count = 0; - - @Override - public boolean publish(Amenity object) { - //TODO need more logical way to filter results - if (object.getSubType().equals(ROUTE_ARTICLE)) { - articles.add(object); - } - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - }); - - bookIndexReader.searchPoi(req); - bookIndexReader.close(); - - if (articles.size() > 0) { - Iterator it = articles.iterator(); - while (it.hasNext()) { - Amenity a = it.next(); - if (!a.getName(language).equals("")) { - TravelArticle article = readArticle(a, language); - popularArticles.add(article); - writeToCache(article); - } - } - } - } catch (Exception e) { - LOG.error(e.getMessage()); - } - return popularArticles; - } - - private TravelArticle readArticle(Amenity amenity, String lang) { - TravelArticle res = new TravelArticle(); - - res.title = amenity.getName(lang).equals("") ? amenity.getName() : amenity.getName(lang); - res.content = amenity.getDescription(lang); - res.isPartOf = amenity.getTagContent(Amenity.IS_PART, lang) == null ? "" : amenity.getTagContent(Amenity.IS_PART, lang); - res.lat = amenity.getLocation().getLatitude(); - res.lon = amenity.getLocation().getLongitude(); - res.imageTitle = amenity.getTagContent(Amenity.IMAGE_TITLE, lang) == null ? "" : amenity.getTagContent(Amenity.IMAGE_TITLE, lang); - res.tripId = getTripId(amenity); - res.originalId = 0; //? - res.lang = lang; - res.contentsJson = amenity.getTagContent(Amenity.CONTENT_JSON, lang) == null ? "" : amenity.getTagContent(Amenity.CONTENT_JSON, lang); - res.aggregatedPartOf = amenity.getTagContent(Amenity.IS_AGGR_PART, lang) == null ? "" : amenity.getTagContent(Amenity.IS_AGGR_PART, lang); - -// occasional crashes -// try { -// String gpxContent = amenity.getAdditionalInfo("gpx_info"); -// res.gpxFile = GPXUtilities.loadGPXFile(new ByteArrayInputStream(gpxContent.getBytes("UTF-8"))); -// } catch (IOException e) { -// LOG.error(e.getMessage(), e); -// } - - return res; - } - - private long getTripId(Amenity amenity) { - long tripId = -1; - String val = amenity.getTagContent(Amenity.ROUTE_ID, null); - if (val != null && val.startsWith("Q")) { - try { - tripId = Long.parseLong(val.substring(1)); - } catch (NumberFormatException nfe) { - LOG.error(nfe.getMessage()); - } - } - return tripId; - } - - private BinaryMapIndexReader getBookBinaryIndex() throws IOException { - application.getSettings().SELECTED_TRAVEL_BOOK.set(selectedTravelBook.getName()); - try { - RandomAccessFile r = new RandomAccessFile(selectedTravelBook.getAbsolutePath(), "r"); - BinaryMapIndexReader index = new BinaryMapIndexReader(r, selectedTravelBook); - for (BinaryIndexPart p : index.getIndexes()) { - if (p instanceof BinaryMapPoiReaderAdapter.PoiRegion) { - return index; - } - } - } catch (IOException e) { - System.err.println("File doesn't have valid structure : " + selectedTravelBook.getName() + " " + e.getMessage()); - throw e; - } - return null; - } - - @Override - public LinkedHashMap> getNavigationMap(TravelArticle article) { - return null; - } - - private void writeToCache(TravelArticle article) { - cachedArticles.put(article.tripId, article); - } - - private TravelArticle getArticleFromCache(long tripId, String lang) { - - TravelArticle article = cachedArticles.get(tripId); -// if (aa != null) { -// article = readArticle(aa, lang); -// } - return article; - } - - @Override - public TravelArticle getArticle(long resId, String lang) { - TravelArticle article = getArticleFromCache(resId, lang); - if (article != null) { - return article; - } - String name = ""; //??? - return getArticle(name, lang); - } - - @Override - public TravelArticle getArticle(final String title, final String lang) { - TravelArticle res = null; - List amenities = Collections.emptyList(); - try { - BinaryMapIndexReader indexReader = getBookBinaryIndex(); - if (indexReader != null) { - int left = 0; - int top = 0; - int right = Integer.MAX_VALUE; - int bottom = Integer.MAX_VALUE; - LatLon ll = application.getMapViewTrackingUtilities().getMapLocation(); - BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - MapUtils.get31TileNumberX(ll.getLongitude()), - MapUtils.get31TileNumberY(ll.getLatitude()), title, - left, top, right, bottom, - new ResultMatcher() { - @Override - public boolean publish(Amenity object) { - if (object.getName(lang).equals(title)) { - return true; - } - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - }); - - amenities = indexReader.searchPoiByName(req); - } - } catch (IOException e) { - //todo - } - if (!amenities.isEmpty()) { - for (Amenity a : amenities) { - LOG.debug("searched article: " + a); - } - } - return res; - } - - @Override - public long getArticleId(String title, String lang) { - return 0; - } - - - //TODO finish stub - @Override - public ArrayList getArticleLangs(long cityId) { - ArrayList res = new ArrayList<>(); - res.add("en"); - - for (TravelArticle article : popularArticles) { - if (article.getTripId() == cityId) { - res.add(article.getLang()); - } - } - return res; - } - - @Override - public String formatTravelBookName(File tb) { - if (tb == null) { - return application.getString(R.string.shared_string_none); - } - String nm = tb.getName(); - return nm.substring(0, nm.indexOf('.')).replace('_', ' '); - } - - @Override - public String getGPXName(TravelArticle article) { - return article.getTitle().replace('/', '_').replace('\'', '_') - .replace('\"', '_') + IndexConstants.GPX_FILE_EXT; - } - - @Override - public File createGpxFile(TravelArticle article) { - final GPXUtilities.GPXFile gpx = article.getGpxFile(); - File file = application.getAppPath(IndexConstants.GPX_TRAVEL_DIR + getGPXName(article)); - if (!file.exists()) { - GPXUtilities.writeGpxFile(file, gpx); - } - return file; - } -} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageSearchResult.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageSearchResult.java index b7acea2e4b..7f3b7bfd49 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageSearchResult.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageSearchResult.java @@ -9,14 +9,14 @@ public class WikivoyageSearchResult { private static final int SHOW_LANGS = 3; - long tripId; + String routeId; List articleTitles = new ArrayList<>(); List langs = new ArrayList<>(); List isPartOf = new ArrayList<>(); String imageTitle; - public long getTripId() { - return tripId; + public String getRouteId() { + return routeId; } public List getArticleTitles() { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 2419f02636..22310e4292 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -28,7 +28,6 @@ import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.DownloadValidationManager; import net.osmand.plus.download.IndexItem; import net.osmand.plus.wikivoyage.data.TravelArticle; -import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.plus.wikivoyage.data.TravelHelper; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import net.osmand.plus.wikivoyage.explore.travelcards.ArticleTravelCard; @@ -39,7 +38,6 @@ import net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard; import net.osmand.plus.wikivoyage.explore.travelcards.TravelDownloadUpdateCard; import net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard; -import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -93,7 +91,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv super.onResume(); OsmandApplication app = getMyApplication(); if (app != null) { - app.getTravelHelper().getLocalDataHelper().addListener(this); + app.getTravelHelper().getBookmarksHelper().addListener(this); } WikivoyageExploreActivity exploreActivity = getExploreActivity(); if (exploreActivity != null) { @@ -106,7 +104,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv super.onPause(); OsmandApplication app = getMyApplication(); if (app != null) { - app.getTravelHelper().getLocalDataHelper().removeListener(this); + app.getTravelHelper().getBookmarksHelper().removeListener(this); } } @@ -137,8 +135,8 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv OsmandApplication app = getMyApplication(); if (app != null) { TravelHelper travelHelper = app.getTravelHelper(); - if (travelHelper.getSelectedTravelBook() == null) { - app.getTravelHelper().initTravelBooks(); + if (travelHelper.isAnyTravelBookPresent()) { + app.getTravelHelper().initializeDataOnAppStartup(); WikivoyageExploreActivity exploreActivity = getExploreActivity(); if (exploreActivity != null) { exploreActivity.populateData(); @@ -182,7 +180,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv if (!Version.isPaidVersion(app)) { items.add(new OpenBetaTravelCard(app, nightMode, fm)); } - if (app.getTravelHelper().getSelectedTravelBook() != null) { + if (app.getTravelHelper().isAnyTravelBookPresent()) { items.add(new HeaderTravelCard(app, nightMode, getString(R.string.popular_destinations))); List popularArticles = app.getTravelHelper().getPopularArticles(); @@ -239,9 +237,8 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv boolean outdated = mainIndexItem != null && mainIndexItem.isOutdated(); boolean needsDownloading = mainIndexItem != null && !mainIndexItem.isDownloaded(); - File selectedTravelBook = app.getTravelHelper().getSelectedTravelBook(); - if (selectedTravelBook == null || needsDownloading || (outdated && SHOW_TRAVEL_UPDATE_CARD)) { + if (!app.getTravelHelper().isAnyTravelBookPresent() || needsDownloading || (outdated && SHOW_TRAVEL_UPDATE_CARD)) { boolean showOtherMaps = false; if (needsDownloading) { List items = downloadThread.getIndexes().getWikivoyageItems(); @@ -390,7 +387,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv IndexItem mainItem = app.getDownloadThread().getIndexes().getWikivoyageItem(fileName); List neededItems = new ArrayList<>(); - for (TravelArticle article : app.getTravelHelper().getLocalDataHelper().getSavedArticles()) { + for (TravelArticle article : app.getTravelHelper().getBookmarksHelper().getSavedArticles()) { LatLon latLon = new LatLon(article.getLat(), article.getLon()); try { for (DownloadActivityType type : types) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 6a4864d147..77989b695b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -195,7 +195,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter 1) { - BaseBottomSheetItem selectTravelBook = new BottomSheetItemWithDescription.Builder() - .setDescription(travelHelper.formatTravelBookName(travelHelper.getSelectedTravelBook())) - .setDescriptionColorId(nightMode ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light) - .setIcon(getContentIcon(R.drawable.ic_action_travel)) - .setTitle(getString(R.string.shared_string_travel_book)) - .setLayoutId(R.layout.bottom_sheet_item_with_right_descr) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - selectTravelBookDialog(); - dismiss(); - } - }) - .create(); - items.add(selectTravelBook); - - items.add(new DividerHalfItem(getContext())); - } - BaseBottomSheetItem showImagesItem = new BottomSheetItemWithDescription.Builder() .setDescription(getString(showImagesPref.get().name)) .setDescriptionColorId(nightMode ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light) @@ -126,7 +98,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD public void onClick(View v) { OsmandApplication app = getMyApplication(); if (app != null) { - TravelLocalDataHelper ldh = app.getTravelHelper().getLocalDataHelper(); + TravelLocalDataHelper ldh = app.getTravelHelper().getBookmarksHelper(); ldh.clearHistory(); } dismiss(); @@ -143,30 +115,5 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD } } - private void selectTravelBookDialog() { - Context ctx = getContext(); - OsmandApplication app = getMyApplication(); - if (ctx == null || app == null) { - return; - } - final TravelHelper travelHelper = app.getTravelHelper(); - final List list = travelHelper.getExistingTravelBooks(); - String[] ls = new String[list.size()]; - for (int i = 0; i < ls.length; i++) { - ls[i] = travelHelper.formatTravelBookName(list.get(i)); - } - - new AlertDialog.Builder(ctx) - .setTitle(R.string.select_travel_book) - .setItems(ls, new OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - travelHelper.selectTravelBook(list.get(which)); - sendResult(TRAVEL_BOOK_CHANGED); - } - }) - .setNegativeButton(R.string.shared_string_dismiss, null) - .show(); - } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java index 084209674a..b9c5dbeb11 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java @@ -76,7 +76,7 @@ public class ArticleTravelCard extends BaseTravelCard { @Override public void onClick(View v) { if (fragmentManager != null) { - WikivoyageArticleDialogFragment.showInstance(app, fragmentManager, article.getTripId(), article.getLang()); + WikivoyageArticleDialogFragment.showInstance(app, fragmentManager, article.getRouteId(), article.getLang()); } } }; @@ -91,7 +91,7 @@ public class ArticleTravelCard extends BaseTravelCard { private void updateSaveButton(final ArticleTravelVH holder) { if (article != null) { - final TravelLocalDataHelper helper = app.getTravelHelper().getLocalDataHelper(); + final TravelLocalDataHelper helper = app.getTravelHelper().getBookmarksHelper(); final boolean saved = helper.isArticleSaved(article); Drawable icon = getActiveIcon(saved ? R.drawable.ic_action_read_later_fill : R.drawable.ic_action_read_later); holder.rightButton.setText(saved ? R.string.shared_string_remove : R.string.shared_string_bookmark); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/menu/WikivoyageWptPtMenuController.java b/OsmAnd/src/net/osmand/plus/wikivoyage/menu/WikivoyageWptPtMenuController.java index 9ad66116cb..947af0897a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/menu/WikivoyageWptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/menu/WikivoyageWptPtMenuController.java @@ -19,7 +19,7 @@ public class WikivoyageWptPtMenuController extends WptPtMenuController { private WikivoyageWptPtMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull WptPt wpt, @NonNull TravelArticle article) { super(new WikivoyageWptPtMenuBuilder(mapActivity, wpt), mapActivity, pointDescription, wpt); - final long tripId = article.getTripId(); + final String tripId = article.getRouteId(); final String lang = article.getLang(); leftTitleButtonController = new TitleButtonController() { @Override @@ -42,7 +42,7 @@ public class WikivoyageWptPtMenuController extends WptPtMenuController { String title = metadata != null ? metadata.getArticleTitle() : null; String lang = metadata != null ? metadata.getArticleLang() : null; if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(lang)) { - return mapActivity.getMyApplication().getTravelHelper().getArticle(title, lang); + return mapActivity.getMyApplication().getTravelHelper().getArticleByTitle(title, lang); } return null; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java index f0aafde679..f13d2752b3 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/WikivoyageSearchDialogFragment.java @@ -113,11 +113,11 @@ public class WikivoyageSearchDialogFragment extends WikiBaseDialogFragment { if (item instanceof WikivoyageSearchResult) { WikivoyageSearchResult res = (WikivoyageSearchResult) item; WikivoyageArticleDialogFragment - .showInstance(fm, res.getTripId(), new ArrayList<>(res.getLangs())); + .showInstance(fm, res.getRouteId(), new ArrayList<>(res.getLangs())); } else if (item instanceof WikivoyageSearchHistoryItem) { WikivoyageSearchHistoryItem historyItem = (WikivoyageSearchHistoryItem) item; WikivoyageArticleDialogFragment - .showInstance(app, fm, historyItem.getArticleTitle(), historyItem.getLang()); + .showInstanceByTitle(app, fm, historyItem.getArticleTitle(), historyItem.getLang()); } } } @@ -151,7 +151,7 @@ public class WikivoyageSearchDialogFragment extends WikiBaseDialogFragment { private void setAdapterItems(@Nullable List items) { if (items == null || items.isEmpty()) { - TravelLocalDataHelper ldh = getMyApplication().getTravelHelper().getLocalDataHelper(); + TravelLocalDataHelper ldh = getMyApplication().getTravelHelper().getBookmarksHelper(); adapter.setHistoryItems(ldh.getAllHistory()); } else { adapter.setItems(items);