diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/SavingTracksDbHelper.java b/OsmAnd-telegram/src/net/osmand/telegram/helpers/SavingTracksDbHelper.java index b3c1faf20d..feac28fe39 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/SavingTracksDbHelper.java +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/SavingTracksDbHelper.java @@ -238,13 +238,14 @@ public class SavingTracksDbHelper extends SQLiteOpenHelper { + " AND " + TRACK_COL_CHAT_ID + " = ?" + " AND " + TRACK_COL_DATE + " BETWEEN " + start + " AND " + end + " ORDER BY " + TRACK_COL_DATE + " ASC ", new String[]{String.valueOf(userId), String.valueOf(chatId)}); - GPXFile gpxFile = new GPXFile(); - gpxFile.chatId = chatId; - gpxFile.userId = userId; + GPXFile gpxFile = null; long previousTime = 0; TrkSegment segment = null; Track track = null; if (query.moveToFirst()) { + gpxFile = new GPXFile(); + gpxFile.chatId = chatId; + gpxFile.userId = userId; do { long time = query.getLong(7); WptPt pt = new WptPt(); @@ -289,12 +290,13 @@ public class SavingTracksDbHelper extends SQLiteOpenHelper { + " AND " + TRACK_COL_DATE + " BETWEEN " + start + " AND " + end + " ORDER BY " + TRACK_COL_DATE + " ASC ", new String[]{String.valueOf(userId)}); - GPXFile gpxFile = new GPXFile(); - gpxFile.userId = userId; + GPXFile gpxFile = null; long previousTime = 0; TrkSegment segment = null; Track track = null; if (query.moveToFirst()) { + gpxFile = new GPXFile(); + gpxFile.userId = userId; do { long time = query.getLong(7); WptPt pt = new WptPt(); diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/TimelineTabFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/TimelineTabFragment.kt index 6ddd564e8d..608e9e5fde 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/TimelineTabFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/TimelineTabFragment.kt @@ -21,6 +21,7 @@ import net.osmand.telegram.helpers.TelegramUiHelper import net.osmand.telegram.helpers.TelegramUiHelper.ListItem import net.osmand.telegram.ui.TimelineTabFragment.LiveNowListAdapter.BaseViewHolder import net.osmand.telegram.utils.AndroidUtils +import net.osmand.telegram.utils.GPXUtilities import net.osmand.telegram.utils.OsmandFormatter import java.util.* @@ -103,6 +104,10 @@ class TimelineTabFragment : Fragment() { from.set(Calendar.YEAR, year) from.set(Calendar.MONTH, monthOfYear) from.set(Calendar.DAY_OF_MONTH, dayOfMonth) + from.set(Calendar.HOUR_OF_DAY, 0) + from.clear(Calendar.MINUTE) + from.clear(Calendar.SECOND) + from.clear(Calendar.MILLISECOND) start = from.timeInMillis updateList() updateDateButtons() @@ -123,6 +128,10 @@ class TimelineTabFragment : Fragment() { from.set(Calendar.YEAR, year) from.set(Calendar.MONTH, monthOfYear) from.set(Calendar.DAY_OF_MONTH, dayOfMonth) + from.set(Calendar.HOUR_OF_DAY, 23) + from.set(Calendar.MINUTE, 59) + from.set(Calendar.SECOND, 59) + from.set(Calendar.MILLISECOND, 999) end = from.timeInMillis updateList() updateDateButtons() @@ -156,13 +165,15 @@ class TimelineTabFragment : Fragment() { private fun updateList() { val res = mutableListOf() val s = System.currentTimeMillis() - log.debug("updateList $start") + log.debug("updateList $s") val ignoredUsersIds = ArrayList() val currentUserId = telegramHelper.getCurrentUser()?.id if (currentUserId != null) { - val currentUserGpx = app.savingTracksDbHelper.collectRecordedDataForUser(currentUserId, 0, start, end) - TelegramUiHelper.gpxToChatItem(telegramHelper, currentUserGpx, true)?.also { - res.add(it) + val currentUserGpx:GPXUtilities.GPXFile? = app.savingTracksDbHelper.collectRecordedDataForUser(currentUserId, 0, start, end) + if (currentUserGpx != null) { + TelegramUiHelper.gpxToChatItem(telegramHelper, currentUserGpx, true)?.also { + res.add(it) + } } ignoredUsersIds.add(currentUserId) } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt index a411d80b7d..cbfa2e8f46 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt @@ -182,7 +182,6 @@ class UserGpxInfoFragment : BaseDialogFragment() { val fileUri = AndroidUtils.getUriForFile(app, File(path)) val openGpxIntent = Intent(Intent.ACTION_VIEW) openGpxIntent.setDataAndType(fileUri, "application/gpx+xml") -// openGpxIntent.type = "application/gpx+xml" openGpxIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) val resolved = activity?.packageManager?.resolveActivity(openGpxIntent, PackageManager.MATCH_DEFAULT_ONLY) if (resolved != null) {