Add utc offset preference
This commit is contained in:
parent
d78d28cd43
commit
562e4251eb
8 changed files with 67 additions and 5 deletions
BIN
OsmAnd-telegram/res/drawable-hdpi/ic_world_globe_dark.png
Normal file
BIN
OsmAnd-telegram/res/drawable-hdpi/ic_world_globe_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd-telegram/res/drawable-mdpi/ic_world_globe_dark.png
Normal file
BIN
OsmAnd-telegram/res/drawable-mdpi/ic_world_globe_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd-telegram/res/drawable-xhdpi/ic_world_globe_dark.png
Normal file
BIN
OsmAnd-telegram/res/drawable-xhdpi/ic_world_globe_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
OsmAnd-telegram/res/drawable-xxhdpi/ic_world_globe_dark.png
Normal file
BIN
OsmAnd-telegram/res/drawable-xxhdpi/ic_world_globe_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
|
@ -1,5 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="time_zone_descr">Select time zone to show in your location messages.</string>
|
||||
<string name="time_zone">Time zone</string>
|
||||
<string name="units_and_formats">Units & formats</string>
|
||||
<string name="unit_of_length_descr">Change what distance is measured in.</string>
|
||||
<string name="unit_of_length">Units of length</string>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
}
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue