Fix showing locations after OsmAnd initialised and improve settings ui

This commit is contained in:
Chumva 2019-05-27 17:48:33 +03:00
parent 0b69aa6d41
commit 2695acc122
4 changed files with 28 additions and 26 deletions

View file

@ -5,14 +5,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/content_padding_standard"
android:paddingRight="@dimen/content_padding_standard"
tools:background="@color/card_bg_light"> tools:background="@color/card_bg_light">
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding_standard"
android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginTop="@dimen/image_button_padding" android:layout_marginTop="@dimen/image_button_padding"
android:layout_marginEnd="@dimen/content_padding_big" android:layout_marginEnd="@dimen/content_padding_big"
android:layout_marginRight="@dimen/content_padding_big" android:layout_marginRight="@dimen/content_padding_big"
@ -53,10 +53,8 @@
<ImageView <ImageView
android:id="@+id/icon_right" android:id="@+id/icon_right"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:layout_gravity="center_vertical"
android:paddingLeft="@dimen/image_button_padding"
android:paddingRight="@dimen/image_button_padding"
android:visibility="gone" android:visibility="gone"
tools:src="@drawable/ic_action_additional_option" tools:src="@drawable/ic_action_additional_option"
tools:tint="@color/icon_light" tools:tint="@color/icon_light"
@ -65,10 +63,14 @@
<Switch <Switch
android:id="@+id/switcher" android:id="@+id/switcher"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:background="@null" android:background="@null"
android:clickable="false" android:clickable="false"
android:focusable="false" /> 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" />
</LinearLayout> </LinearLayout>

View file

@ -53,12 +53,10 @@ class TelegramApplication : Application(), OsmandHelperListener {
listOf(-1) listOf(-1)
) )
showLocationHelper.addDirectionContextMenuButton() showLocationHelper.addDirectionContextMenuButton()
if (settings.hasAnyChatToShowOnMap()) {
showLocationHelper.startShowingLocation() showLocationHelper.startShowingLocation()
} }
} }
} }
}
osmandAidlHelper.setUpdatesListener(object : UpdatesListener { osmandAidlHelper.setUpdatesListener(object : UpdatesListener {
override fun update() { override fun update() {
showLocationHelper.startUpdateMessagesTask() showLocationHelper.startUpdateMessagesTask()

View file

@ -912,8 +912,7 @@ class TelegramSettings(private val app: TelegramApplication) {
} }
inner class MinLocationDistance : NumericPref( inner class MinLocationDistance : NumericPref(
R.drawable.ic_action_location_history, 0, R.string.min_logging_distance,
R.string.min_logging_distance,
R.string.min_logging_distance_descr, R.string.min_logging_distance_descr,
MIN_LOCATION_DISTANCE MIN_LOCATION_DISTANCE
) { ) {
@ -934,8 +933,7 @@ class TelegramSettings(private val app: TelegramApplication) {
} }
inner class MinLocationAccuracy : NumericPref( inner class MinLocationAccuracy : NumericPref(
R.drawable.ic_action_location_history, 0, R.string.min_logging_accuracy,
R.string.min_logging_accuracy,
R.string.min_logging_accuracy_descr, R.string.min_logging_accuracy_descr,
MIN_LOCATION_ACCURACY MIN_LOCATION_ACCURACY
) { ) {
@ -956,8 +954,7 @@ class TelegramSettings(private val app: TelegramApplication) {
} }
inner class MinLocationSpeed : NumericPref( inner class MinLocationSpeed : NumericPref(
R.drawable.ic_action_location_history, 0, R.string.min_logging_speed,
R.string.min_logging_speed,
R.string.min_logging_speed_descr, R.string.min_logging_speed_descr,
MIN_LOCATION_SPEED MIN_LOCATION_SPEED
) { ) {

View file

@ -88,22 +88,21 @@ class SettingsDialogFragment : BaseDialogFragment() {
findViewById<ImageView>(R.id.icon_right).apply { findViewById<ImageView>(R.id.icon_right).apply {
visibility = View.VISIBLE visibility = View.VISIBLE
setImageDrawable(uiUtils.getThemedIcon(R.drawable.ic_action_additional_option)) setImageDrawable(uiUtils.getThemedIcon(R.drawable.ic_action_additional_option))
setOnClickListener {
activity?.supportFragmentManager?.also { ProxySettingsDialogFragment.showInstance(it, this@SettingsDialogFragment) }
}
} }
findViewById<TextView>(R.id.title).text = getText(R.string.proxy) findViewById<TextView>(R.id.title).text = getText(R.string.proxy)
val description = findViewById<TextView>(R.id.description).apply { val description = findViewById<TextView>(R.id.description).apply {
text = if (settings.proxyEnabled) getText(R.string.proxy_connected) else getText(R.string.proxy_disconnected) text = if (settings.proxyEnabled) getText(R.string.proxy_connected) else getText(R.string.proxy_disconnected)
} }
val switcher = findViewById<Switch>(R.id.switcher).apply { findViewById<Switch>(R.id.switcher).apply {
isClickable = true
isChecked = app.settings.proxyEnabled 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 { setOnClickListener {
val checked = !app.settings.proxyEnabled activity?.supportFragmentManager?.also { ProxySettingsDialogFragment.showInstance(it, this@SettingsDialogFragment) }
switcher.isChecked = checked
settings.updateProxySetting(checked)
description.text = if (checked) getText(R.string.proxy_connected) else getText(R.string.proxy_disconnected)
} }
container.addView(this) container.addView(this)
} }
@ -246,7 +245,13 @@ class SettingsDialogFragment : BaseDialogFragment() {
private fun createNumericPref(inflater: LayoutInflater, container: ViewGroup, pref: NumericPref) { private fun createNumericPref(inflater: LayoutInflater, container: ViewGroup, pref: NumericPref) {
inflater.inflate(R.layout.item_with_desc_and_right_value, container, false).apply { inflater.inflate(R.layout.item_with_desc_and_right_value, container, false).apply {
findViewById<ImageView>(R.id.icon).setImageDrawable(uiUtils.getThemedIcon(pref.iconId)) findViewById<ImageView>(R.id.icon).apply {
if (pref.iconId != 0) {
setImageDrawable(uiUtils.getThemedIcon(pref.iconId))
} else {
visibility = View.GONE
}
}
findViewById<TextView>(R.id.title).setText(pref.titleId) findViewById<TextView>(R.id.title).setText(pref.titleId)
findViewById<TextView>(R.id.description).setText(pref.descriptionId) findViewById<TextView>(R.id.description).setText(pref.descriptionId)
val valueView = findViewById<TextView>(R.id.value) val valueView = findViewById<TextView>(R.id.value)