From 2695acc122c85d1b22d053049f0dab64fcbea2fd Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 27 May 2019 17:48:33 +0300 Subject: [PATCH] Fix showing locations after OsmAnd initialised and improve settings ui --- .../item_with_descr_and_right_switch.xml | 18 ++++++++------- .../osmand/telegram/TelegramApplication.kt | 4 +--- .../net/osmand/telegram/TelegramSettings.kt | 9 +++----- .../telegram/ui/SettingsDialogFragment.kt | 23 +++++++++++-------- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/OsmAnd-telegram/res/layout/item_with_descr_and_right_switch.xml b/OsmAnd-telegram/res/layout/item_with_descr_and_right_switch.xml index 9f716ffc61..8e884d270c 100644 --- a/OsmAnd-telegram/res/layout/item_with_descr_and_right_switch.xml +++ b/OsmAnd-telegram/res/layout/item_with_descr_and_right_switch.xml @@ -5,14 +5,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" - android:paddingLeft="@dimen/content_padding_standard" - android:paddingRight="@dimen/content_padding_standard" tools:background="@color/card_bg_light"> + android:focusable="false" + android:paddingStart="@dimen/image_button_padding" + android:paddingLeft="@dimen/image_button_padding" + android:paddingEnd="@dimen/content_padding_standard" + android:paddingRight="@dimen/content_padding_standard" /> diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt index 3841899fd3..594c2c8501 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt @@ -53,9 +53,7 @@ class TelegramApplication : Application(), OsmandHelperListener { listOf(-1) ) showLocationHelper.addDirectionContextMenuButton() - if (settings.hasAnyChatToShowOnMap()) { - showLocationHelper.startShowingLocation() - } + showLocationHelper.startShowingLocation() } } } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt index a78702a6bb..fe0c5f2bf1 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt @@ -912,8 +912,7 @@ class TelegramSettings(private val app: TelegramApplication) { } inner class MinLocationDistance : NumericPref( - R.drawable.ic_action_location_history, - R.string.min_logging_distance, + 0, R.string.min_logging_distance, R.string.min_logging_distance_descr, MIN_LOCATION_DISTANCE ) { @@ -934,8 +933,7 @@ class TelegramSettings(private val app: TelegramApplication) { } inner class MinLocationAccuracy : NumericPref( - R.drawable.ic_action_location_history, - R.string.min_logging_accuracy, + 0, R.string.min_logging_accuracy, R.string.min_logging_accuracy_descr, MIN_LOCATION_ACCURACY ) { @@ -956,8 +954,7 @@ class TelegramSettings(private val app: TelegramApplication) { } inner class MinLocationSpeed : NumericPref( - R.drawable.ic_action_location_history, - R.string.min_logging_speed, + 0, R.string.min_logging_speed, R.string.min_logging_speed_descr, MIN_LOCATION_SPEED ) { diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt index 66697bff9e..a20a5a14e2 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt @@ -88,22 +88,21 @@ class SettingsDialogFragment : BaseDialogFragment() { findViewById(R.id.icon_right).apply { visibility = View.VISIBLE setImageDrawable(uiUtils.getThemedIcon(R.drawable.ic_action_additional_option)) - setOnClickListener { - activity?.supportFragmentManager?.also { ProxySettingsDialogFragment.showInstance(it, this@SettingsDialogFragment) } - } } findViewById(R.id.title).text = getText(R.string.proxy) val description = findViewById(R.id.description).apply { text = if (settings.proxyEnabled) getText(R.string.proxy_connected) else getText(R.string.proxy_disconnected) } - val switcher = findViewById(R.id.switcher).apply { + findViewById(R.id.switcher).apply { + isClickable = true isChecked = app.settings.proxyEnabled + setOnCheckedChangeListener { _, isChecked -> + settings.updateProxySetting(isChecked) + description.text = if (isChecked) getText(R.string.proxy_connected) else getText(R.string.proxy_disconnected) + } } setOnClickListener { - val checked = !app.settings.proxyEnabled - switcher.isChecked = checked - settings.updateProxySetting(checked) - description.text = if (checked) getText(R.string.proxy_connected) else getText(R.string.proxy_disconnected) + activity?.supportFragmentManager?.also { ProxySettingsDialogFragment.showInstance(it, this@SettingsDialogFragment) } } container.addView(this) } @@ -246,7 +245,13 @@ class SettingsDialogFragment : BaseDialogFragment() { private fun createNumericPref(inflater: LayoutInflater, container: ViewGroup, pref: NumericPref) { inflater.inflate(R.layout.item_with_desc_and_right_value, container, false).apply { - findViewById(R.id.icon).setImageDrawable(uiUtils.getThemedIcon(pref.iconId)) + findViewById(R.id.icon).apply { + if (pref.iconId != 0) { + setImageDrawable(uiUtils.getThemedIcon(pref.iconId)) + } else { + visibility = View.GONE + } + } findViewById(R.id.title).setText(pref.titleId) findViewById(R.id.description).setText(pref.descriptionId) val valueView = findViewById(R.id.value)