From 562e4251eb6659b3d28f1d1acc62407d800da443 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 6 Dec 2019 14:41:42 +0200 Subject: [PATCH] Add utc offset preference --- .../res/drawable-hdpi/ic_world_globe_dark.png | Bin 0 -> 1585 bytes .../res/drawable-mdpi/ic_world_globe_dark.png | Bin 0 -> 1374 bytes .../drawable-xhdpi/ic_world_globe_dark.png | Bin 0 -> 1808 bytes .../drawable-xxhdpi/ic_world_globe_dark.png | Bin 0 -> 2412 bytes OsmAnd-telegram/res/values/strings.xml | 2 + .../net/osmand/telegram/TelegramSettings.kt | 24 ++++++++-- .../osmand/telegram/utils/DataConstants.kt | 44 ++++++++++++++++++ .../telegram/utils/OsmandLocationUtils.kt | 2 +- 8 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 OsmAnd-telegram/res/drawable-hdpi/ic_world_globe_dark.png create mode 100644 OsmAnd-telegram/res/drawable-mdpi/ic_world_globe_dark.png create mode 100644 OsmAnd-telegram/res/drawable-xhdpi/ic_world_globe_dark.png create mode 100644 OsmAnd-telegram/res/drawable-xxhdpi/ic_world_globe_dark.png 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 0000000000000000000000000000000000000000..0acdc07e7ae4f40005fe9f98a1b2ddbf774d304e GIT binary patch literal 1585 zcmbVMeM}Q)7%w11MZl3R5lr+vm8tW3*X!q<6mn~eRBS1=N|_pW?Y%&Q?UlR3R!}3= znTTR^lF`f!0SAh@DNLMEGSCg2#Elv81E&r%r_MRQb?Tzo6{*`F#y@t+-TOZ8`~04d z-}5}T-fEehFgkU#L?THrWgBebIwky$j1#|CB%zSFqzFcbFpn)1{4@t76vH|JWb)8O zzy@e$dFcs|E|J76bK4z)!#tOCu^t&6){zA~J`pXEq-O?vw5tRNkP{TSy*l{Lkxm$L zGdeh5WyZ`tJt%f(mvdlVxy9}(FL4nJoS6Zo2T0L?2M9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HcmV?d00001 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 0000000000000000000000000000000000000000..15554f2444462090e7c5d7296bae8e82b26e82dd GIT binary patch literal 1374 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gjk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n9DLlB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxOgGuU&_u!9QqR!T z%-qskN5Kfl*Eg`xH!{#Qu(UEYwlXkMfC43;ZAB?*RzWUqP`iLUTcwPWk^(Dz{qpj1 zy>er{{GxPyLrY6beFGzXBO_g)3fZE`@j@x4_pIZg5^PG@yV%reBd*pl_&Wpr4xy@)uZjaY;}r!Wmdq7l%|9r0NHy z7U!21B?IFlO&O*c7&4a6BsFpIWGChrManjC7v#}N6VsHG zq$D#lT_ZCy6J1LK6H8r7%M>GBvsA-W)8r(R)U>1&m^s+=8#p_=nHZayJ6f2V7#g~o zIGGw4J6pIpJ32Z!TACQT!1Q|N6_+IDC8xsd&IH;G)oX@Vua$FAYGO%#QAmD%4lES} zWaO9R7iZ)bC^$QVV_iWbJTosPzr0uz6ipCcyQCInmZhe+73JqDfWz4;6N?*6OjC_4 zQw&XYQ_WJ6b<;rpw=lOz)U`-4PclzUG&TeVfD%-H3c2B@4|J41D6t?V9+(g?MS_^{ ztN`S|GgE3FFb5R@v&uVPj@=9ljCGzajv*Ddu1wqS#q20>EPpYZ%Lm39=2}MXXl~K} z0_WB2no^}$XK%iAE9Bd)*Uk|dW=bj@3p}T|Z18?6c;=UE4g2A{Z|4gK?fCHc#GA7< zvuEDD865R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WLH>3uS}ld((h zcSA3emTWH^e$nP9&UH0S?_DYSj{9%?8lG!or2dEIhS}|X51v0rss))^^?(M@G#^ym z)$22EENcudh&xczru`>W^HJk6$K?8>;lbY#-J0Fx+j(u@AAj70r3!C>t+p|B%?*NH z_qNyDFPWTlH3uhp?4-_5Ze;$+%sliKh$#~kLFF%Ei9w5pjl6Ezztd9AMJw8SEebl$ z>UiAyt6g=bi)l0BThZ@vJVfkr;W7_-p>Ji(uWOBljCvy+_SN8xly=N4t@y91sN#)xw3eP#54V*B^?S5?TXf8~*^wP!X;8ct_lSQ8Ds zjlUdm;Bcg6=<=rzzy-3R)5q@C9zVBq=bYf-PFI8L&d(@OYYKiW)Kzsq&ds`X=&@b| zm{VWSWkzxyObYR}<8|yeC@vbyFBwBl9-X_iV>u|!h+Etg_1DnciB;`53VvCo_7Rxz z$;v9D!TimDmE~UF`~!v)DvGYkdGIHf*Gob=11@vgZ(8j#E0jLFuGiB%&c;)FH`eA|HFyw3gFjKj^gPVLUU`k)H44vUy0zYTt1x zKQ&@(tChSjQ)JpH*&FGfkRhy8cwOu~_G(gbW(T8EanwQyQr5PS|Nty4v>czISjR+8OTzHqps z51ETFGQRn+&wl%0RLt^<9#v_}f*~2(lv~++;!5MnOrk(OKdk$ltwuk))dY86wK)du6;F;RQV z_XMZpoulQ)q?v0rK^E03o;K{aPDrs1Um|q4QYflroXvZKH`?my)c6Wnp za%$49@z6M4^GA)HHfcsY1-NO1|uT@9lP^@ME9fCQ`$*JnPgh!(EU`y(?{$ z_eYWS4)*Ktai3Nc&!bZJ{>0`krwewA9-Of*7Mlcesz{Y5kCfBcfs-U;?Ys$6)7Yu} yc)1r$HXRJ+`Izo=accM!Y8o~(_i;Z&t920DSO^Xx1{pW~{$cwDvCeqMWc&wM80zr= literal 0 HcmV?d00001 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")