Merge branch 'master' of https://github.com/osmandapp/Osmand into test_voice_exit

This commit is contained in:
veliymolfar 2020-01-17 19:00:53 +02:00
commit 58afb660a2
399 changed files with 3200 additions and 1226 deletions

View file

@ -42,6 +42,8 @@ public class IndexConstants {
public static final String OSMAND_SETTINGS_FILE_EXT = ".osf";
public static final String ROUTING_FILE_EXT = ".xml";
public static final String RENDERER_INDEX_EXT = ".render.xml"; //$NON-NLS-1$
public final static String POI_TABLE = "poi"; //$NON-NLS-1$

View file

@ -133,6 +133,17 @@ public class RoutingConfiguration {
}
public String getRoutingProfileKeyByFileName(String fileName) {
if (fileName != null && routers != null) {
for (Map.Entry<String, GeneralRouter> router : routers.entrySet()) {
if (fileName.equals(router.getValue().getFilename())) {
return router.getKey();
}
}
}
return null;
}
public Map<String, GeneralRouter> getAllRouters() {
return routers;
}

View file

@ -14,7 +14,7 @@ import net.osmand.telegram.notifications.NotificationHelper
import net.osmand.telegram.utils.AndroidUtils
import net.osmand.telegram.utils.UiUtils
class TelegramApplication : Application(), OsmandHelperListener {
class TelegramApplication : Application() {
val telegramHelper = TelegramHelper.instance
lateinit var settings: TelegramSettings private set
@ -54,6 +54,7 @@ class TelegramApplication : Application(), OsmandHelperListener {
listOf("ic_action_location_sharing_app"),
listOf(-1)
)
showLocationHelper.setupMapLayer()
showLocationHelper.addDirectionContextMenuButton()
showLocationHelper.startShowingLocation()
showLocationHelper.addOrUpdateStatusWidget(-1, false)
@ -141,13 +142,6 @@ class TelegramApplication : Application(), OsmandHelperListener {
return internetConnectionAvailable
}
override fun onOsmandConnectionStateChanged(connected: Boolean) {
if (connected) {
showLocationHelper.setupMapLayer()
showLocationHelper.addDirectionContextMenuButton()
}
}
private fun startTelegramService(intent: Int, serviceOffInterval: Long = 0) {
var i = intent
var interval = serviceOffInterval

View file

@ -851,22 +851,7 @@ class TelegramSettings(private val app: TelegramApplication) {
lastChatsInfo.forEach { lastInfo ->
val obj = JSONObject()
obj.put(LastChatInfo.CHAT_ID_KEY, lastInfo.chatId)
obj.put(LastChatInfo.PERIODS_KEY, convertPeriodsToJson(lastInfo.periods))
jArray.put(obj)
}
jArray
} catch (e: JSONException) {
log.error(e)
null
}
}
private fun convertPeriodsToJson(periods: LinkedList<Long>): JSONArray? {
return try {
val jArray = JSONArray()
for (i in 0 until periods.count()) {
val obj = JSONObject()
obj.put(i.toString(), periods[i])
obj.put(LastChatInfo.PERIOD_KEY, lastInfo.period)
jArray.put(obj)
}
jArray
@ -947,12 +932,7 @@ class TelegramSettings(private val app: TelegramApplication) {
val obj = json.getJSONObject(i)
val lastInfo = LastChatInfo().apply {
chatId = obj.optLong(LastChatInfo.CHAT_ID_KEY)
periods = LinkedList<Long>()
val jsonArray = obj.getJSONArray(LastChatInfo.PERIODS_KEY)
for (j in 0 until jsonArray.length()) {
val o = jsonArray.get(j) as JSONObject
periods.addLast(o.optLong(j.toString()))
}
period = obj.optLong(LastChatInfo.PERIOD_KEY)
}
lastChatsInfo.addLast(lastInfo)
}
@ -964,16 +944,14 @@ class TelegramSettings(private val app: TelegramApplication) {
addItemToSuggested(id, time)
} else {
val index = lastChatsInfo.indexOf(lastInfo)
lastChatsInfo[index].periods = addTimeToPeriods(lastChatsInfo[index].periods, time)
lastChatsInfo[index].period = time
}
}
private fun addItemToSuggested(id: Long, time: Long) {
val newLastInfo = LastChatInfo().apply {
chatId = id
periods = LinkedList<Long>().apply {
addFirst(time)
}
period = time
}
if (lastChatsInfo.size < 5) {
lastChatsInfo.addFirst(newLastInfo)
@ -983,30 +961,6 @@ class TelegramSettings(private val app: TelegramApplication) {
}
}
private fun addTimeToPeriods(periods: LinkedList<Long>?, time: Long): LinkedList<Long> {
if (periods?.isNotEmpty() != null) {
return if (periods.size < 5) {
periods.addFirst(time)
periods
} else {
periods.removeLast()
periods.addFirst(time)
periods
}
}
return LinkedList<Long>().apply { addFirst(time) }
}
fun calcLivePeriod(periods: LinkedList<Long>): Long {
val sortedPeriods = periods.toLongArray()
sortedPeriods.sort()
return if (sortedPeriods.size % 2 == 0) {
(sortedPeriods[sortedPeriods.size / 2] + sortedPeriods[sortedPeriods.size / 2 - 1]) / 2
} else {
sortedPeriods[sortedPeriods.size / 2]
}
}
private fun getLiveNowChats() = app.telegramHelper.getMessagesByChatIds(locHistoryTime).keys
private fun updatePrefs() {
@ -1512,11 +1466,11 @@ class TelegramSettings(private val app: TelegramApplication) {
class LastChatInfo {
var chatId = -1L
var periods = LinkedList<Long>()
var period = -1L
companion object {
internal const val CHAT_ID_KEY = "chatId"
internal const val PERIODS_KEY = "periods"
internal const val PERIOD_KEY = "period"
}
}
}

View file

@ -35,6 +35,7 @@ class ShowLocationHelper(private val app: TelegramApplication) {
const val MIN_OSMAND_CALLBACK_VERSION_CODE = 320
const val MIN_OSMAND_CREATE_IMPORT_DIRS_VERSION_CODE = 340
const val MIN_OSMAND_SHARE_WIDGET_ICON_VERSION_CODE = 356
const val MAP_CONTEXT_MENU_BUTTON_ID = 1
const val MAP_CONTEXT_MENU_BUTTONS_PARAMS_ID = "DIRECTION"
@ -46,6 +47,8 @@ class ShowLocationHelper(private val app: TelegramApplication) {
private const val STATUS_WIDGET_ID = "status_widget"
private const val STATUS_WIDGET_MENU_ICON = "widget_location_sharing_night"
private const val STATUS_WIDGET_MENU_ICON_OLD = "ic_action_relative_bearing"
private const val STATUS_WIDGET_ICON_OLD = "widget_relative_bearing_day"
private const val STATUS_WIDGET_ANIM_ICON_DAY = "anim_widget_location_sharing_day"
private const val STATUS_WIDGET_ANIM_ICON_NIGHT = "anim_widget_location_sharing_night"
private const val STATUS_WIDGET_ON_ANIM_ICON_DAY = "anim_widget_location_sharing_on_day"
@ -209,8 +212,13 @@ class ShowLocationHelper(private val app: TelegramApplication) {
}
fun addOrUpdateStatusWidget(time: Long, isSending: Boolean) {
val iconDay: String
val iconNight: String
var iconDay: String
var iconNight: String
val menuIcon = if (isOsmandHasStatusWidgetIcon()) {
STATUS_WIDGET_MENU_ICON
} else {
STATUS_WIDGET_MENU_ICON_OLD
}
val text = when {
time > 0L -> {
iconDay = STATUS_WIDGET_ANIM_ICON_DAY
@ -234,6 +242,10 @@ class ShowLocationHelper(private val app: TelegramApplication) {
app.getString(R.string.shared_string_start)
}
}
if (!isOsmandHasStatusWidgetIcon()) {
iconDay = STATUS_WIDGET_ICON_OLD
iconNight = STATUS_WIDGET_ICON_OLD
}
val subText = when {
time > 0 -> {
if (text.length > 2) {
@ -246,7 +258,7 @@ class ShowLocationHelper(private val app: TelegramApplication) {
}
osmandAidlHelper.addMapWidget(
STATUS_WIDGET_ID,
STATUS_WIDGET_MENU_ICON,
menuIcon,
app.getString(R.string.status_widget_title),
iconDay,
iconNight,
@ -456,6 +468,11 @@ class ShowLocationHelper(private val app: TelegramApplication) {
return version >= MIN_OSMAND_CREATE_IMPORT_DIRS_VERSION_CODE
}
fun isOsmandHasStatusWidgetIcon(): Boolean {
val version = AndroidUtils.getAppVersionCode(app, app.settings.appToConnectPackage)
return version >= MIN_OSMAND_SHARE_WIDGET_ICON_VERSION_CODE
}
fun startShowMessagesTask(chatId: Long, vararg messages: TdApi.Message) {
if (app.settings.isShowingChatOnMap(chatId)) {
ShowMessagesTask(app).executeOnExecutor(executor, *messages)

View file

@ -580,7 +580,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
val lastInfo = lastChatsInfo.find { it.chatId == chatId }
if (chat != null && lastInfo != null) {
val index = lastChatsInfo.indexOf(lastInfo)
lastItems.add(LastChat(chat, settings.calcLivePeriod(lastChatsInfo[index].periods)))
lastItems.add(LastChat(chat, lastChatsInfo[index].period))
}
}
return lastItems

View file

@ -323,6 +323,39 @@
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.osf" />
</intent-filter>
<intent-filter
android:label="@string/app_name"
android:priority="50">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file"/>
<data android:host="*"/>
<data android:pathPattern=".*\\.xml" />
<data android:pathPattern=".*\\..*\\.xml" />
<data android:pathPattern=".*\\..*\\..*\\.xml" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.xml" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.xml" />
</intent-filter>
<intent-filter
android:label="@string/app_name"
android:priority="50">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content"/>
<data android:scheme="file"/>
<data android:scheme="data"/>
<data android:host="*"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.xml" />
<data android:pathPattern=".*\\..*\\.xml" />
<data android:pathPattern=".*\\..*\\..*\\.xml" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.xml" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.xml" />
</intent-filter>
<!--trying to handle emails-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View file

@ -45,10 +45,10 @@ android {
defaultConfig {
minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15
targetSdkVersion 28
versionCode 350
versionCode 356
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
multiDexEnabled true
versionName "3.5.0"
versionName "3.5.6"
versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName
versionName System.getenv("APK_VERSION_SUFFIX")? versionName + System.getenv("APK_VERSION_SUFFIX").toString(): versionName

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,011 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 951 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View file

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 6 KiB

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

View file

Before

Width:  |  Height:  |  Size: 935 B

After

Width:  |  Height:  |  Size: 935 B

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

Some files were not shown because too many files have changed in this diff Show more