From 66b345e63485aad558524c21f7bf3a4868672c30 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 24 Jul 2019 17:57:02 +0300 Subject: [PATCH] Add check for osmand version for gpx import to custom folder and improve ui --- .../res/layout/fragment_user_gpx_info.xml | 50 ++++++++++--------- .../telegram/helpers/ShowLocationHelper.kt | 8 ++- .../osmand/telegram/ui/UserGpxInfoFragment.kt | 21 +++++--- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/OsmAnd-telegram/res/layout/fragment_user_gpx_info.xml b/OsmAnd-telegram/res/layout/fragment_user_gpx_info.xml index 3a1b3d71be..4f5f6ffa96 100644 --- a/OsmAnd-telegram/res/layout/fragment_user_gpx_info.xml +++ b/OsmAnd-telegram/res/layout/fragment_user_gpx_info.xml @@ -81,42 +81,44 @@ android:layout_height="wrap_content" android:orientation="horizontal"> - - - + android:layout_weight="1" + android:paddingLeft="@dimen/content_padding_standard" + android:paddingRight="@dimen/content_padding_standard"> + + + + = MIN_OSMAND_CALLBACK_VERSION_CODE } + fun canOsmandCreateGpxDirs(): Boolean { + val version = AndroidUtils.getAppVersionCode(app, app.settings.appToConnectPackage) + return version >= MIN_OSMAND_CREATE_IMPORT_DIRS_VERSION_CODE + } + fun startShowMessagesTask(chatId: Long, vararg messages: TdApi.Message) { if (app.settings.isShowingChatOnMap(chatId)) { ShowMessagesTask(app).executeOnExecutor(executor, *messages) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt index 1bc9a721df..44f7b95b0a 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt @@ -69,7 +69,8 @@ class UserGpxInfoFragment : BaseDialogFragment() { private var handler: Handler = Handler() - private var endTimeChanged: Boolean = false + private var endTimeChanged = false + private var snackbarShown = false override fun onCreateView( inflater: LayoutInflater, @@ -391,13 +392,17 @@ class UserGpxInfoFragment : BaseDialogFragment() { } else if (!app.isOsmAndChosen() || (app.isOsmAndChosen() && !app.isOsmAndInstalled())) { fragmentManager?.also { ChooseOsmAndBottomSheet.showInstance(it, this) } } 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 - startActivity(AndroidUtils.getPlayMarketIntent(app, packageName)) - } - AndroidUtils.setSnackbarTextColor(snackbar, R.color.ctrl_active_dark) - snackbar.show() + if (!snackbarShown) { + 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 + startActivity(AndroidUtils.getPlayMarketIntent(app, packageName)) + } + AndroidUtils.setSnackbarTextColor(snackbar, R.color.ctrl_active_dark) + snackbar.show() + snackbarShown = true + } } else { saveCurrentGpxToFile(object : OsmandLocationUtils.SaveGpxListener {