Add units and formats preferences to ui
BIN
OsmAnd-telegram/res/drawable-hdpi/ic_action_ruler_unit.png
Executable file
After Width: | Height: | Size: 336 B |
BIN
OsmAnd-telegram/res/drawable-hdpi/ic_action_speed.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd-telegram/res/drawable-mdpi/ic_action_ruler_unit.png
Executable file
After Width: | Height: | Size: 186 B |
BIN
OsmAnd-telegram/res/drawable-mdpi/ic_action_speed.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd-telegram/res/drawable-xhdpi/ic_action_ruler_unit.png
Executable file
After Width: | Height: | Size: 294 B |
BIN
OsmAnd-telegram/res/drawable-xhdpi/ic_action_speed.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
OsmAnd-telegram/res/drawable-xxhdpi/ic_action_ruler_unit.png
Executable file
After Width: | Height: | Size: 417 B |
BIN
OsmAnd-telegram/res/drawable-xxhdpi/ic_action_speed.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
OsmAnd-telegram/res/drawable-xxxhdpi/ic_action_ruler_unit.png
Executable file
After Width: | Height: | Size: 681 B |
|
@ -75,6 +75,35 @@
|
||||||
|
|
||||||
<include layout="@layout/list_item_divider"/>
|
<include layout="@layout/list_item_divider"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/card_bg_color"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<net.osmand.telegram.ui.views.TextViewEx
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/list_header_height"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingLeft="@dimen/content_padding_standard"
|
||||||
|
android:paddingRight="@dimen/content_padding_standard"
|
||||||
|
android:text="@string/units_and_formats"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/list_item_title_text_size"
|
||||||
|
app:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/units_and_formats_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/list_item_divider"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<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>
|
||||||
|
<string name="unit_of_speed_system_descr">Define unit of speed.</string>
|
||||||
|
<string name="unit_of_speed_system">Unit of speed</string>
|
||||||
<string name="saved_messages">Saved messages</string>
|
<string name="saved_messages">Saved messages</string>
|
||||||
<string name="shared_string_end">End</string>
|
<string name="shared_string_end">End</string>
|
||||||
<string name="shared_string_start">Start</string>
|
<string name="shared_string_start">Start</string>
|
||||||
|
|
|
@ -142,6 +142,7 @@ class TelegramSettings(private val app: TelegramApplication) {
|
||||||
|
|
||||||
val gpsAndLocPrefs = listOf(SendMyLocPref(), StaleLocPref(), LocHistoryPref(), ShareTypePref())
|
val gpsAndLocPrefs = listOf(SendMyLocPref(), StaleLocPref(), LocHistoryPref(), ShareTypePref())
|
||||||
val gpxLoggingPrefs = listOf(MinLocationDistance(), MinLocationAccuracy(), MinLocationSpeed())
|
val gpxLoggingPrefs = listOf(MinLocationDistance(), MinLocationAccuracy(), MinLocationSpeed())
|
||||||
|
val unitsAndFormatsPrefs = listOf(UnitsOfSpeed(), UnitsOfLength())
|
||||||
|
|
||||||
var batteryOptimisationAsked = false
|
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(
|
abstract inner class NumericPref(
|
||||||
@DrawableRes val iconId: Int,
|
@DrawableRes val iconId: Int,
|
||||||
@StringRes val titleId: Int,
|
@StringRes val titleId: Int,
|
||||||
|
|
|
@ -66,6 +66,11 @@ class SettingsDialogFragment : BaseDialogFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container = mainView.findViewById<ViewGroup>(R.id.units_and_formats_container)
|
||||||
|
settings.unitsAndFormatsPrefs.forEach {
|
||||||
|
createNumericPref(inflater, container, it)
|
||||||
|
}
|
||||||
|
|
||||||
container = mainView.findViewById<ViewGroup>(R.id.gps_points_container)
|
container = mainView.findViewById<ViewGroup>(R.id.gps_points_container)
|
||||||
inflater.inflate(R.layout.item_with_descr_and_right_switch, container, false).apply {
|
inflater.inflate(R.layout.item_with_descr_and_right_switch, container, false).apply {
|
||||||
findViewById<ImageView>(R.id.icon).setImageDrawable(uiUtils.getThemedIcon(R.drawable.ic_action_connect))
|
findViewById<ImageView>(R.id.icon).setImageDrawable(uiUtils.getThemedIcon(R.drawable.ic_action_connect))
|
||||||
|
@ -291,7 +296,7 @@ class SettingsDialogFragment : BaseDialogFragment() {
|
||||||
isModal = true
|
isModal = true
|
||||||
anchorView = valueView
|
anchorView = valueView
|
||||||
setContentWidth(AndroidUtils.getPopupMenuWidth(ctx, menuList))
|
setContentWidth(AndroidUtils.getPopupMenuWidth(ctx, menuList))
|
||||||
height = if (menuList.size < 6) {
|
height = if (menuList.size <= 6) {
|
||||||
ListPopupWindow.WRAP_CONTENT
|
ListPopupWindow.WRAP_CONTENT
|
||||||
} else {
|
} else {
|
||||||
AndroidUtils.getPopupMenuHeight(ctx)
|
AndroidUtils.getPopupMenuHeight(ctx)
|
||||||
|
|