Rename osmandHelper with osmandAidlHelper
This commit is contained in:
parent
2aa0060feb
commit
6be07a1e7a
4 changed files with 20 additions and 20 deletions
|
@ -24,7 +24,7 @@ class TelegramApplication : Application(), OsmandHelperListener {
|
|||
lateinit var shareLocationHelper: ShareLocationHelper private set
|
||||
lateinit var showLocationHelper: ShowLocationHelper private set
|
||||
lateinit var notificationHelper: NotificationHelper private set
|
||||
lateinit var osmandHelper: OsmandAidlHelper private set
|
||||
lateinit var osmandAidlHelper: OsmandAidlHelper private set
|
||||
lateinit var locationProvider: TelegramLocationProvider private set
|
||||
|
||||
var telegramService: TelegramService? = null
|
||||
|
@ -40,7 +40,7 @@ class TelegramApplication : Application(), OsmandHelperListener {
|
|||
|
||||
settings = TelegramSettings(this)
|
||||
uiUtils = UiUtils(this)
|
||||
osmandHelper = OsmandAidlHelper(this)
|
||||
osmandAidlHelper = OsmandAidlHelper(this)
|
||||
shareLocationHelper = ShareLocationHelper(this)
|
||||
showLocationHelper = ShowLocationHelper(this)
|
||||
notificationHelper = NotificationHelper(this)
|
||||
|
@ -55,7 +55,7 @@ class TelegramApplication : Application(), OsmandHelperListener {
|
|||
}
|
||||
|
||||
fun cleanupResources() {
|
||||
osmandHelper.cleanupResources()
|
||||
osmandAidlHelper.cleanupResources()
|
||||
telegramHelper.close()
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@ private const val MAP_LAYER_ID = "telegram_layer"
|
|||
class ShowLocationHelper(private val app: TelegramApplication) {
|
||||
|
||||
private val telegramHelper = app.telegramHelper
|
||||
private val osmandHelper = app.osmandHelper
|
||||
private val osmandAidlHelper = app.osmandAidlHelper
|
||||
|
||||
var showingLocation: Boolean = false
|
||||
private set
|
||||
|
||||
fun setupMapLayer() {
|
||||
execOsmandApi {
|
||||
osmandHelper.addMapLayer(MAP_LAYER_ID, "Telegram", 5.5f, null)
|
||||
osmandAidlHelper.addMapLayer(MAP_LAYER_ID, "Telegram", 5.5f, null)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,12 +72,12 @@ class ShowLocationHelper(private val app: TelegramApplication) {
|
|||
if (photoUri != null) {
|
||||
params[AMapPoint.POINT_IMAGE_URI_PARAM] = photoUri.toString()
|
||||
}
|
||||
osmandHelper.addMapPoint(MAP_LAYER_ID, "${chatTitle}_${message.senderUserId}", userName, userName,
|
||||
osmandAidlHelper.addMapPoint(MAP_LAYER_ID, "${chatTitle}_${message.senderUserId}", userName, userName,
|
||||
chatTitle, Color.RED, ALatLon(content.location.latitude, content.location.longitude), null, params)
|
||||
} else if (chatTitle != null && content is MessageOsmAndBotLocation && content.isValid()) {
|
||||
val name = content.name
|
||||
setupMapLayer()
|
||||
osmandHelper.addMapPoint(MAP_LAYER_ID, "${chatTitle}_$name", name, name,
|
||||
osmandAidlHelper.addMapPoint(MAP_LAYER_ID, "${chatTitle}_$name", name, name,
|
||||
chatTitle, Color.RED, ALatLon(content.lat, content.lon), null, null)
|
||||
}
|
||||
}
|
||||
|
@ -121,17 +121,17 @@ class ShowLocationHelper(private val app: TelegramApplication) {
|
|||
private fun removeMapPoint(chatTitle: String, message: TdApi.Message) {
|
||||
val content = message.content
|
||||
if (content is TdApi.MessageLocation) {
|
||||
osmandHelper.removeMapPoint(MAP_LAYER_ID, "${chatTitle}_${message.senderUserId}")
|
||||
osmandAidlHelper.removeMapPoint(MAP_LAYER_ID, "${chatTitle}_${message.senderUserId}")
|
||||
} else if (content is MessageOsmAndBotLocation) {
|
||||
osmandHelper.removeMapPoint(MAP_LAYER_ID, "${chatTitle}_${content.name}")
|
||||
osmandAidlHelper.removeMapPoint(MAP_LAYER_ID, "${chatTitle}_${content.name}")
|
||||
}
|
||||
}
|
||||
|
||||
private fun execOsmandApi(action: (() -> Unit)) {
|
||||
if (osmandHelper.isOsmandConnected()) {
|
||||
if (osmandAidlHelper.isOsmandConnected()) {
|
||||
action.invoke()
|
||||
} else if (osmandHelper.isOsmandBound()) {
|
||||
osmandHelper.connectOsmand()
|
||||
} else if (osmandAidlHelper.isOsmandBound()) {
|
||||
osmandAidlHelper.connectOsmand()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
|||
get() = activity?.application as TelegramApplication
|
||||
|
||||
private val telegramHelper get() = app.telegramHelper
|
||||
private val osmandHelper get() = app.osmandHelper
|
||||
private val osmandAidlHelper get() = app.osmandAidlHelper
|
||||
private val settings get() = app.settings
|
||||
|
||||
private lateinit var adapter: LiveNowListAdapter
|
||||
|
@ -295,7 +295,7 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
|||
|
||||
settings.showChatOnMap(chatTitle, allSelected)
|
||||
if (settings.hasAnyChatToShowOnMap()) {
|
||||
if (osmandHelper.isOsmandNotInstalled()) {
|
||||
if (osmandAidlHelper.isOsmandNotInstalled()) {
|
||||
if (allSelected) {
|
||||
activity?.let {
|
||||
MainActivity.OsmandMissingDialogFragment()
|
||||
|
|
|
@ -52,7 +52,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
get() = application as TelegramApplication
|
||||
|
||||
private val telegramHelper get() = app.telegramHelper
|
||||
private val osmandHelper get() = app.osmandHelper
|
||||
private val osmandAidlHelper get() = app.osmandAidlHelper
|
||||
private val settings get() = app.settings
|
||||
|
||||
private val listeners: MutableList<WeakReference<TelegramListener>> = mutableListOf()
|
||||
|
@ -131,8 +131,8 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
telegramHelper.init()
|
||||
}
|
||||
|
||||
if (osmandHelper.isOsmandBound() && !osmandHelper.isOsmandConnected()) {
|
||||
osmandHelper.connectOsmand()
|
||||
if (osmandAidlHelper.isOsmandBound() && !osmandAidlHelper.isOsmandConnected()) {
|
||||
osmandAidlHelper.connectOsmand()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
} else {
|
||||
requestLocationPermission()
|
||||
}
|
||||
if (settings.hasAnyChatToShowOnMap() && osmandHelper.isOsmandNotInstalled()) {
|
||||
if (settings.hasAnyChatToShowOnMap() && osmandAidlHelper.isOsmandNotInstalled()) {
|
||||
showOsmandMissingDialog()
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
settings.stopSharingLocationToChats()
|
||||
app.shareLocationHelper.stopSharingLocation()
|
||||
}
|
||||
if (settings.hasAnyChatToShowOnMap() && osmandHelper.isOsmandNotInstalled()) {
|
||||
if (settings.hasAnyChatToShowOnMap() && osmandAidlHelper.isOsmandNotInstalled()) {
|
||||
showOsmandMissingDialog()
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
holder.showOnMapSwitch?.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.showChatOnMap(chatTitle, isChecked)
|
||||
if (settings.hasAnyChatToShowOnMap()) {
|
||||
if (osmandHelper.isOsmandNotInstalled()) {
|
||||
if (osmandAidlHelper.isOsmandNotInstalled()) {
|
||||
if (isChecked) {
|
||||
showOsmandMissingDialog()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue