Rename several methods and add check for time
This commit is contained in:
parent
c7ec07ebde
commit
09472edbc1
6 changed files with 29 additions and 21 deletions
|
@ -87,7 +87,7 @@
|
|||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/list_item_description_text_size"
|
||||
app:firstBaselineToTopHeight="@dimen/list_item_baseline_to_top_height"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
app:typeface="@string/font_roboto_regular"
|
||||
tools:text="213 m" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -85,11 +85,11 @@ class TelegramApplication : Application(), OsmandHelperListener {
|
|||
telegramHelper.stopSendingLiveLocationMessages(settings.getChatsShareInfo())
|
||||
}
|
||||
|
||||
fun isOsmAndInstalled() = TelegramSettings.AppConnect.getInstalledApps(this).isNotEmpty()
|
||||
fun isAnyOsmAndInstalled() = TelegramSettings.AppConnect.getInstalledApps(this).isNotEmpty()
|
||||
|
||||
fun isConnectedOsmAndChosen() = settings.appToConnectPackage.isNotEmpty()
|
||||
fun isOsmAndChosen() = settings.appToConnectPackage.isNotEmpty()
|
||||
|
||||
fun isConnectedOsmAndInstalled() = AndroidUtils.isAppInstalled(this, settings.appToConnectPackage)
|
||||
fun isOsmAndInstalled() = AndroidUtils.isAppInstalled(this, settings.appToConnectPackage)
|
||||
|
||||
val isWifiConnected: Boolean
|
||||
get() {
|
||||
|
|
|
@ -78,5 +78,5 @@ class LocationNotification(app: TelegramApplication) : TelegramNotification(app,
|
|||
}
|
||||
|
||||
private fun isShowingChatsNotificationEnabled() = (!app.showLocationHelper.isUseOsmandCallback() || app.settings.monitoringEnabled)
|
||||
&& app.isOsmAndInstalled() && app.settings.hasAnyChatToShowOnMap()
|
||||
&& app.isAnyOsmAndInstalled() && app.settings.hasAnyChatToShowOnMap()
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
|||
|
||||
openOsmAndBtn = mainView.findViewById<TextView>(R.id.open_osmand_btn).apply {
|
||||
setOnClickListener {
|
||||
if (app.isConnectedOsmAndInstalled()) {
|
||||
if (app.isOsmAndInstalled()) {
|
||||
activity?.packageManager?.getLaunchIntentForPackage(settings.appToConnectPackage)?.also { intent ->
|
||||
startActivity(intent)
|
||||
}
|
||||
|
@ -450,11 +450,11 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
|||
openOnMapView?.isEnabled = canBeOpenedOnMap
|
||||
if (canBeOpenedOnMap) {
|
||||
openOnMapView?.setOnClickListener {
|
||||
if (!app.isOsmAndInstalled()) {
|
||||
if (!app.isAnyOsmAndInstalled()) {
|
||||
showOsmAndMissingDialog()
|
||||
} else if (!app.isConnectedOsmAndChosen()) {
|
||||
} else if (!app.isOsmAndChosen() || (app.isOsmAndChosen() && !app.isOsmAndInstalled())) {
|
||||
fragmentManager?.also { ChooseOsmAndBottomSheet.showInstance(it, this@LiveNowTabFragment) }
|
||||
} else if(app.isConnectedOsmAndInstalled()){
|
||||
} else if(app.isOsmAndInstalled()){
|
||||
app.showLocationHelper.showLocationOnMap(item, staleLocation)
|
||||
}
|
||||
}
|
||||
|
@ -547,15 +547,14 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
|||
|
||||
settings.showChatOnMap(chatId, allSelected)
|
||||
if (settings.hasAnyChatToShowOnMap()) {
|
||||
if (!app.isOsmAndInstalled()) {
|
||||
if (!app.isAnyOsmAndInstalled()) {
|
||||
if (allSelected) {
|
||||
showOsmAndMissingDialog()
|
||||
}
|
||||
} else if (!app.isConnectedOsmAndChosen()) {
|
||||
fragmentManager?.also { ChooseOsmAndBottomSheet.showInstance(it, this@LiveNowTabFragment)
|
||||
}
|
||||
} else if (!app.isOsmAndChosen() || (app.isOsmAndChosen() && !app.isOsmAndInstalled())) {
|
||||
fragmentManager?.also { ChooseOsmAndBottomSheet.showInstance(it, this@LiveNowTabFragment) }
|
||||
} else {
|
||||
if (app.isConnectedOsmAndInstalled()) {
|
||||
if (app.isOsmAndInstalled()) {
|
||||
if (allSelected) {
|
||||
app.showLocationHelper.showChatMessages(chatId)
|
||||
} else {
|
||||
|
|
|
@ -165,7 +165,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
if (AndroidUtils.isLocationPermissionAvailable(this)) {
|
||||
app.locationProvider.resumeAllUpdates()
|
||||
}
|
||||
if (settings.hasAnyChatToShowOnMap() && !app.isOsmAndInstalled()) {
|
||||
if (settings.hasAnyChatToShowOnMap() && !app.isAnyOsmAndInstalled()) {
|
||||
showOsmandMissingDialog()
|
||||
}
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
settings.stopSharingLocationToChats()
|
||||
app.shareLocationHelper.stopSharingLocation()
|
||||
}
|
||||
if (settings.hasAnyChatToShowOnMap() && !app.isOsmAndInstalled()) {
|
||||
if (settings.hasAnyChatToShowOnMap() && !app.isAnyOsmAndInstalled()) {
|
||||
showOsmandMissingDialog()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ class UserGpxInfoFragment : BaseDialogFragment() {
|
|||
|
||||
updateGPXStatisticRow()
|
||||
|
||||
val imageRes = if (app.isConnectedOsmAndInstalled()) {
|
||||
val imageRes = if (app.isOsmAndInstalled()) {
|
||||
TelegramSettings.AppConnect.getIconId(settings.appToConnectPackage)
|
||||
} else {
|
||||
R.drawable.ic_logo_osmand_free
|
||||
|
@ -199,7 +199,7 @@ class UserGpxInfoFragment : BaseDialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun isOsmandCreateBitmap(): Boolean {
|
||||
private fun canOsmandCreateBitmap(): Boolean {
|
||||
val version = AndroidUtils.getAppVersionCode(app, app.settings.appToConnectPackage)
|
||||
return version >= MIN_OSMAND_BITMAP_VERSION_CODE
|
||||
}
|
||||
|
@ -247,6 +247,7 @@ class UserGpxInfoFragment : BaseDialogFragment() {
|
|||
}
|
||||
|
||||
private fun updateGpxInfo() {
|
||||
checkTime()
|
||||
locationMessages = app.locationMessages.getMessagesForUserInChat(userId, chatId, startCalendar.timeInMillis, endCalendar.timeInMillis)
|
||||
|
||||
gpxFile = OsmandLocationUtils.convertLocationMessagesToGpxFiles(locationMessages).firstOrNull()?:GPXUtilities.GPXFile()
|
||||
|
@ -255,6 +256,14 @@ class UserGpxInfoFragment : BaseDialogFragment() {
|
|||
updateGPXMap()
|
||||
}
|
||||
|
||||
private fun checkTime() {
|
||||
if (startCalendar.timeInMillis > endCalendar.timeInMillis) {
|
||||
val time = startCalendar.timeInMillis
|
||||
startCalendar.timeInMillis = endCalendar.timeInMillis
|
||||
endCalendar.timeInMillis = time
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateDateAndTimeButtons() {
|
||||
dateStartBtn.text = SimpleDateFormat("dd MMM", Locale.getDefault()).format(startCalendar.timeInMillis)
|
||||
dateEndBtn.text = SimpleDateFormat("dd MMM", Locale.getDefault()).format(endCalendar.timeInMillis)
|
||||
|
@ -273,13 +282,13 @@ class UserGpxInfoFragment : BaseDialogFragment() {
|
|||
}
|
||||
|
||||
private fun updateGPXMap() {
|
||||
if (!app.isOsmAndInstalled()) {
|
||||
if (!app.isAnyOsmAndInstalled()) {
|
||||
activity?.let {
|
||||
MainActivity.OsmandMissingDialogFragment().show(it.supportFragmentManager, null)
|
||||
}
|
||||
} else if (!app.isConnectedOsmAndChosen()) {
|
||||
} else if (!app.isOsmAndChosen() || (app.isOsmAndChosen() && !app.isOsmAndInstalled())) {
|
||||
fragmentManager?.also { ChooseOsmAndBottomSheet.showInstance(it, this) }
|
||||
} else if (!isOsmandCreateBitmap()) {
|
||||
} else if (!canOsmandCreateBitmap()) {
|
||||
val snackbar = Snackbar.make(mainView, R.string.please_update_osmand, Snackbar.LENGTH_LONG).setAction(R.string.shared_string_update) {
|
||||
val packageName = if (app.settings.appToConnectPackage == OsmandAidlHelper.OSMAND_NIGHTLY_PACKAGE_NAME)
|
||||
OsmandAidlHelper.OSMAND_FREE_PACKAGE_NAME else app.settings.appToConnectPackage
|
||||
|
|
Loading…
Reference in a new issue