From c54dc6c526d8a8507261c6af3af6873258cd34da Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 5 Dec 2019 18:55:34 +0200 Subject: [PATCH] Add units and formats preferences to ui --- .../drawable-hdpi/ic_action_ruler_unit.png | Bin 0 -> 336 bytes .../res/drawable-hdpi/ic_action_speed.png | Bin 0 -> 1509 bytes .../drawable-mdpi/ic_action_ruler_unit.png | Bin 0 -> 186 bytes .../res/drawable-mdpi/ic_action_speed.png | Bin 0 -> 1353 bytes .../drawable-xhdpi/ic_action_ruler_unit.png | Bin 0 -> 294 bytes .../res/drawable-xhdpi/ic_action_speed.png | Bin 0 -> 1784 bytes .../drawable-xxhdpi/ic_action_ruler_unit.png | Bin 0 -> 417 bytes .../res/drawable-xxhdpi/ic_action_speed.png | Bin 0 -> 2276 bytes .../drawable-xxxhdpi/ic_action_ruler_unit.png | Bin 0 -> 681 bytes .../res/layout/fragement_settings_dialog.xml | 29 ++++++++++++++++ OsmAnd-telegram/res/values/strings.xml | 5 +++ .../net/osmand/telegram/TelegramSettings.kt | 31 ++++++++++++++++++ .../telegram/ui/SettingsDialogFragment.kt | 7 +++- 13 files changed, 71 insertions(+), 1 deletion(-) create mode 100755 OsmAnd-telegram/res/drawable-hdpi/ic_action_ruler_unit.png create mode 100644 OsmAnd-telegram/res/drawable-hdpi/ic_action_speed.png create mode 100755 OsmAnd-telegram/res/drawable-mdpi/ic_action_ruler_unit.png create mode 100644 OsmAnd-telegram/res/drawable-mdpi/ic_action_speed.png create mode 100755 OsmAnd-telegram/res/drawable-xhdpi/ic_action_ruler_unit.png create mode 100644 OsmAnd-telegram/res/drawable-xhdpi/ic_action_speed.png create mode 100755 OsmAnd-telegram/res/drawable-xxhdpi/ic_action_ruler_unit.png create mode 100644 OsmAnd-telegram/res/drawable-xxhdpi/ic_action_speed.png create mode 100755 OsmAnd-telegram/res/drawable-xxxhdpi/ic_action_ruler_unit.png diff --git a/OsmAnd-telegram/res/drawable-hdpi/ic_action_ruler_unit.png b/O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8$15dHDG MvvQp6_JXQ^0FK5i-T(jq literal 0 HcmV?d00001 diff --git a/OsmAnd-telegram/res/drawable-mdpi/ic_action_ruler_unit.png b/OsmAnd-telegram/res/drawable-mdpi/ic_action_ruler_unit.png new file mode 100755 index 0000000000000000000000000000000000000000..fe4ff5840261d43867f3fc609c71059818be0762 GIT binary patch literal 186 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gjjh-%!As*hzDGLk}mTdgVqal`( zmX@cK^6<;c%YQjmI!=?9;NGxP=$ZAZ9}Vlo798ikTI*2EouHXy!goNiQCFfZOlHaQ z<^R=}N*q{P_Uz2e4?;{!S1g##Y9M|Vj_5un?Cl(Xu!N&8Q~Ji2RAm;*3C+DO&|3$ zpf_C#^9}CmRbNnYU=hR6c!EeI66S=(tm@4K#c>=#(gaQ8Py>&*DTa{5m3T$gf*Zs| zUDga)RnUw@A*8k%4h%-Rl0r=L`PK|8@l~QAWkgcY2+B+nu~;UrW$n1p0R9bQUF~>d zn+Avm5La7u5!NGIkp)BU9`7il2&3Wm=`t*e(Bf9b))-I>uiJsa8?z)!JR7#!XwquO z0mITbXSZ5#J3~o0V__*k1A$~jDr;vwyo+W$G)Gps+z>{2tQ=cKxvUna%j2Y~Xe*n= zdX=~#C?d%EmZ9%etn;y0-lYS=Eq9%yw-Qps+SfK!Fpa!%?|;5BUp0a%8XD*_ixs?(B`%a-F5`{UVjs zMz^Cs^wr2fOjVJ+TTZ-cni|83w`|+Kt1EqNaBv~VUBbi+Xa4b=q0u)d$I809mLww7 zm%FWC>E6c|e(F!{7#~xgn*Vj?%0|=h2ph=#HfXvy`m{ZFwrjkC(XQoR{BUmJ&Y}7} zru0yGNB4#bEw4P-X)S$r;Dzu9soTMk^rpO#9!qTxQ*!joP~o9t=bwyBlw6kwUre8h z^p13^-|a;EACw)vyyKng1NYxP7091EQ4sxN>(!}qg>@el(qG*jWuluudt+p=Q|e7! z`Mr2LkNA4w%bcc9(-S`j=*6HuCHxV-uv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`ctSFD&A z*H)BTFqtgACis}?O7Xs3Rri?7T4EG90)lhOV;G$q*r({8cpPdc#rV`?uLDcPo>T71 z3uIP`cQEva|9nx%_^NBw{9PgYuO1iNFzd%Uc_x7Zp9b9(KYb&79at0`&Q5$`@x6f~ zKCY)>PT~{;J%_g+U%k4se!W)y*Fu&xYX9=yGp=DMX46P`H*LYED=&Bc4Y~K~agO8a z&dsd6!tM-AaU2Ew2I?(LVYR_Ach4UYECV!Q|2qlZf5hcdj3EOx996fprgVL+z&kvd?C;O#XY9u+ZR0izGTPW zm+u)38y_;TC@Adi+5aqj`bg&FuqET`+a=Jvy@{ERu zbQl;V_wSIx!rB$FVdQ&MBb@ E0Bj!~qyPW_ literal 0 HcmV?d00001 diff --git a/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml b/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml index 6b4af3e0e8..43c521ed2a 100644 --- a/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml +++ b/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml @@ -75,6 +75,35 @@ + + + + + + + + + + + Units & formats + Change what distance is measured in. + Units of length + Define unit of speed. + Unit of speed Saved messages End Start diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt index ac68e16384..167564f20d 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt @@ -142,6 +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()) var batteryOptimisationAsked = false @@ -1054,6 +1055,36 @@ class TelegramSettings(private val app: TelegramApplication) { } } + inner class UnitsOfSpeed : NumericPref( + R.drawable.ic_action_speed, R.string.unit_of_speed_system, + R.string.unit_of_speed_system_descr, + emptyList() + ) { + + override fun getCurrentValue() = speedConstants.toShortString(app) + + override fun setCurrentValue(index: Int) { + speedConstants = SpeedConstants.values()[index] + } + + override fun getMenuItems() = SpeedConstants.values().map { it.toShortString(app) } + } + + inner class UnitsOfLength : NumericPref( + R.drawable.ic_action_ruler_unit, R.string.unit_of_length, + R.string.unit_of_length_descr, + emptyList() + ) { + + override fun getCurrentValue() = metricsConstants.toHumanString(app) + + override fun setCurrentValue(index: Int) { + metricsConstants = MetricsConstants.values()[index] + } + + override fun getMenuItems() = MetricsConstants.values().map { it.toHumanString(app) } + } + abstract inner class NumericPref( @DrawableRes val iconId: Int, @StringRes val titleId: Int, diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt index a20a5a14e2..1b7ffd2422 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt @@ -66,6 +66,11 @@ class SettingsDialogFragment : BaseDialogFragment() { } } + container = mainView.findViewById(R.id.units_and_formats_container) + settings.unitsAndFormatsPrefs.forEach { + createNumericPref(inflater, container, it) + } + container = mainView.findViewById(R.id.gps_points_container) inflater.inflate(R.layout.item_with_descr_and_right_switch, container, false).apply { findViewById(R.id.icon).setImageDrawable(uiUtils.getThemedIcon(R.drawable.ic_action_connect)) @@ -291,7 +296,7 @@ class SettingsDialogFragment : BaseDialogFragment() { isModal = true anchorView = valueView setContentWidth(AndroidUtils.getPopupMenuWidth(ctx, menuList)) - height = if (menuList.size < 6) { + height = if (menuList.size <= 6) { ListPopupWindow.WRAP_CONTENT } else { AndroidUtils.getPopupMenuHeight(ctx)