diff --git a/OsmAnd-telegram/res/drawable-hdpi/ic_world_globe_dark.png b/OsmAnd-telegram/res/drawable-hdpi/ic_world_globe_dark.png new file mode 100644 index 0000000000..0acdc07e7a Binary files /dev/null and b/OsmAnd-telegram/res/drawable-hdpi/ic_world_globe_dark.png differ diff --git a/OsmAnd-telegram/res/drawable-mdpi/ic_world_globe_dark.png b/OsmAnd-telegram/res/drawable-mdpi/ic_world_globe_dark.png new file mode 100644 index 0000000000..15554f2444 Binary files /dev/null and b/OsmAnd-telegram/res/drawable-mdpi/ic_world_globe_dark.png differ diff --git a/OsmAnd-telegram/res/drawable-xhdpi/ic_world_globe_dark.png b/OsmAnd-telegram/res/drawable-xhdpi/ic_world_globe_dark.png new file mode 100644 index 0000000000..0255f1b883 Binary files /dev/null and b/OsmAnd-telegram/res/drawable-xhdpi/ic_world_globe_dark.png differ diff --git a/OsmAnd-telegram/res/drawable-xxhdpi/ic_world_globe_dark.png b/OsmAnd-telegram/res/drawable-xxhdpi/ic_world_globe_dark.png new file mode 100644 index 0000000000..97d6b3b781 Binary files /dev/null and b/OsmAnd-telegram/res/drawable-xxhdpi/ic_world_globe_dark.png differ diff --git a/OsmAnd-telegram/res/values/strings.xml b/OsmAnd-telegram/res/values/strings.xml index 1e54c2477f..05b27552e7 100644 --- a/OsmAnd-telegram/res/values/strings.xml +++ b/OsmAnd-telegram/res/values/strings.xml @@ -1,5 +1,7 @@ + Select time zone to show in your location messages. + Time zone Units & formats Change what distance is measured in. Units of length diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt index 9228cb232e..f22650f63b 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt @@ -11,9 +11,7 @@ import net.osmand.PlatformUtil import net.osmand.telegram.helpers.OsmandAidlHelper import net.osmand.telegram.helpers.ShowLocationHelper import net.osmand.telegram.helpers.TelegramHelper -import net.osmand.telegram.utils.AndroidUtils -import net.osmand.telegram.utils.OsmandApiUtils -import net.osmand.telegram.utils.OsmandFormatter +import net.osmand.telegram.utils.* import net.osmand.telegram.utils.OsmandFormatter.MetricsConstants import net.osmand.telegram.utils.OsmandFormatter.SpeedConstants import net.osmand.telegram.utils.OsmandLocationUtils @@ -72,6 +70,7 @@ private const val SHARING_MODE_KEY = "current_sharing_mode" private const val METRICS_CONSTANTS_KEY = "metrics_constants" private const val SPEED_CONSTANTS_KEY = "speed_constants" +private const val UTC_OFFSET_CONSTANTS_KEY = "utc_offset_constants" private const val SEND_MY_LOC_INTERVAL_KEY = "send_my_loc_interval" private const val STALE_LOC_TIME_KEY = "stale_loc_time" @@ -125,6 +124,7 @@ class TelegramSettings(private val app: TelegramApplication) { var metricsConstants = MetricsConstants.KILOMETERS_AND_METERS var speedConstants = SpeedConstants.KILOMETERS_PER_HOUR + var utcOffset = DataConstants.UTC_FORMAT var sendMyLocInterval = SEND_MY_LOC_VALUES_SEC[SEND_MY_LOC_DEFAULT_INDEX] var staleLocTime = STALE_LOC_VALUES_SEC[STALE_LOC_DEFAULT_INDEX] @@ -142,7 +142,7 @@ class TelegramSettings(private val app: TelegramApplication) { val gpsAndLocPrefs = listOf(SendMyLocPref(), StaleLocPref(), LocHistoryPref(), ShareTypePref()) val gpxLoggingPrefs = listOf(MinLocationDistance(), MinLocationAccuracy(), MinLocationSpeed()) - val unitsAndFormatsPrefs = listOf(UnitsOfSpeed(), UnitsOfLength()) + val unitsAndFormatsPrefs = listOf(UnitsOfSpeed(), UnitsOfLength(), UtcOffset()) var batteryOptimisationAsked = false @@ -607,6 +607,7 @@ class TelegramSettings(private val app: TelegramApplication) { edit.putString(METRICS_CONSTANTS_KEY, metricsConstants.name) edit.putString(SPEED_CONSTANTS_KEY, speedConstants.name) + edit.putString(UTC_OFFSET_CONSTANTS_KEY, utcOffset) edit.putLong(SEND_MY_LOC_INTERVAL_KEY, sendMyLocInterval) edit.putLong(STALE_LOC_TIME_KEY, staleLocTime) @@ -669,6 +670,7 @@ class TelegramSettings(private val app: TelegramApplication) { speedConstants = SpeedConstants.valueOf( prefs.getString(SPEED_CONSTANTS_KEY, SpeedConstants.KILOMETERS_PER_HOUR.name) ) + utcOffset = prefs.getString(UTC_OFFSET_CONSTANTS_KEY, DataConstants.UTC_FORMAT) try { parseShareChatsInfo(JSONArray(prefs.getString(SHARE_CHATS_INFO_KEY, ""))) @@ -1071,6 +1073,20 @@ class TelegramSettings(private val app: TelegramApplication) { override fun getMenuItems() = MetricsConstants.values().map { it.toHumanString(app) } } + inner class UtcOffset : ListPreference( + R.drawable.ic_world_globe_dark, R.string.time_zone, + R.string.time_zone_descr + ) { + + override fun getCurrentValue() = utcOffset + + override fun setCurrentValue(index: Int) { + utcOffset = DataConstants.utcOffsets[index] + } + + override fun getMenuItems() = DataConstants.utcOffsets + } + abstract inner class ListPreference( @DrawableRes val iconId: Int, @StringRes val titleId: Int, diff --git a/OsmAnd-telegram/src/net/osmand/telegram/utils/DataConstants.kt b/OsmAnd-telegram/src/net/osmand/telegram/utils/DataConstants.kt index 7532206e51..2b94978e9a 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/utils/DataConstants.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/utils/DataConstants.kt @@ -2,6 +2,8 @@ package net.osmand.telegram.utils object DataConstants { + const val UTC_FORMAT = "UTC" + val countryPhoneCodes = mapOf("AB" to "+7840,+7940,+99544", "AF" to "+93", "AX" to "+35818", "AL" to "+355","DZ" to "+213", "AS" to "+1684", "AD" to "+376", "AO" to "+244","AI" to "+1264", "AG" to "+1268", "AR" to "+54", "AM" to "+374","AW" to "+297", "SH" to "+247", "AU" to "+61", @@ -44,4 +46,46 @@ object DataConstants { "TM" to "+993", "TC" to "+1649", "TV" to "+688", "UG" to "+256","UA" to "+380", "AE" to "+971", "UK" to "+44", "US" to "+1","UY" to "+598", "VI" to "+1340", "UZ" to "+998", "VU" to "+678", "VE" to "+58", "VA" to "+3906698,+379", "VN" to "+84", "WF" to "+681","YE" to "+967", "ZM" to "+260", "ZW" to "+263") + + val utcOffsets = listOf( + "$UTC_FORMAT−12", + "$UTC_FORMAT−11", + "$UTC_FORMAT−10", + "$UTC_FORMAT−09:30", + "$UTC_FORMAT−9", + "$UTC_FORMAT−8", + "$UTC_FORMAT−7", + "$UTC_FORMAT−6", + "$UTC_FORMAT−5", + "$UTC_FORMAT−4", + "$UTC_FORMAT−03:30", + "$UTC_FORMAT−3", + "$UTC_FORMAT−2", + "$UTC_FORMAT−1", + UTC_FORMAT, + "$UTC_FORMAT+1", + "$UTC_FORMAT+2", + "$UTC_FORMAT+3", + "$UTC_FORMAT+03:30", + "$UTC_FORMAT+4", + "$UTC_FORMAT+04:30", + "$UTC_FORMAT+5", + "$UTC_FORMAT+05:30", + "$UTC_FORMAT+05:45", + "$UTC_FORMAT+6", + "$UTC_FORMAT+06:30", + "$UTC_FORMAT+7", + "$UTC_FORMAT+8", + "$UTC_FORMAT+08:45", + "$UTC_FORMAT+9", + "$UTC_FORMAT+09:30", + "$UTC_FORMAT+10", + "$UTC_FORMAT+10:30", + "$UTC_FORMAT+11", + "$UTC_FORMAT+12", + "$UTC_FORMAT+12:45", + "$UTC_FORMAT+13", + "$UTC_FORMAT+13:45", + "$UTC_FORMAT+14" + ) } \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt b/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt index 8b585185dc..5c55451fd4 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt @@ -42,7 +42,7 @@ object OsmandLocationUtils { const val SECONDS_AGO_SUFFIX = " seconds ago" const val MINUTES_AGO_SUFFIX = " minutes ago" const val HOURS_AGO_SUFFIX = " hours ago" - const val UTC_FORMAT_SUFFIX = " UTC" + const val UTC_FORMAT_SUFFIX = " ${DataConstants.UTC_FORMAT}" val UTC_DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC")