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