Add check for osmand version for gpx import to custom folder and improve ui
This commit is contained in:
parent
b404ab9397
commit
66b345e634
3 changed files with 46 additions and 33 deletions
|
@ -81,42 +81,44 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/date_time_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dialog_button_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/content_padding_standard"
|
||||
android:layout_marginLeft="@dimen/content_padding_standard"
|
||||
android:background="@drawable/btn_round"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/content_padding_half"
|
||||
android:paddingRight="@dimen/content_padding_half"
|
||||
android:textSize="@dimen/hint_text_size"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
tools:text="15 Feb, 12:20 — 30 Jul, 23:59"
|
||||
tools:textColor="?attr/ctrl_active_color"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<View
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
android:layout_weight="1"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/date_time_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/btn_round"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:minHeight="@dimen/dialog_button_height"
|
||||
android:paddingLeft="@dimen/content_padding_half"
|
||||
android:paddingRight="@dimen/content_padding_half"
|
||||
android:textSize="@dimen/hint_text_size"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
tools:text="15 Feb, 12:20 — 30 Jul, 23:59"
|
||||
tools:textColor="?attr/ctrl_active_color"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/live_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dialog_button_height"
|
||||
android:layout_marginStart="@dimen/content_padding_half"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@dimen/content_padding_standard"
|
||||
android:background="@drawable/btn_round"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:minHeight="@dimen/dialog_button_height"
|
||||
android:paddingLeft="@dimen/content_padding_half"
|
||||
android:paddingRight="@dimen/content_padding_half"
|
||||
android:text="@string/shared_string_live"
|
||||
|
|
|
@ -33,6 +33,7 @@ class ShowLocationHelper(private val app: TelegramApplication) {
|
|||
const val MAP_LAYER_ID = "telegram_layer"
|
||||
|
||||
const val MIN_OSMAND_CALLBACK_VERSION_CODE = 320
|
||||
const val MIN_OSMAND_CREATE_IMPORT_DIRS_VERSION_CODE = 340
|
||||
|
||||
const val MAP_CONTEXT_MENU_BUTTON_ID = 1
|
||||
const val MAP_CONTEXT_MENU_BUTTONS_PARAMS_ID = "DIRECTION"
|
||||
|
@ -278,7 +279,7 @@ class ShowLocationHelper(private val app: TelegramApplication) {
|
|||
override fun onSavingGpxFinish(path: String) {
|
||||
log.debug("LiveTracks onSavingGpxFinish $path time ${startTime - System.currentTimeMillis()}")
|
||||
val uri = AndroidUtils.getUriForFile(app, File(path))
|
||||
val destinationPath = "$LIVE_TRACKS_DIR/${it.metadata.name}.gpx"
|
||||
val destinationPath = if (canOsmandCreateGpxDirs()) "$LIVE_TRACKS_DIR/${it.metadata.name}.gpx" else "${it.metadata.name}.gpx"
|
||||
val color = it.extensionsToRead["color"] ?: ""
|
||||
osmandAidlHelper.importGpxFromUri(uri, destinationPath, color, true)
|
||||
log.debug("LiveTracks importGpxFromUri finish time ${startTime - System.currentTimeMillis()}")
|
||||
|
@ -388,6 +389,11 @@ class ShowLocationHelper(private val app: TelegramApplication) {
|
|||
return version >= 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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue