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

View file

@ -53,9 +53,7 @@ class TelegramApplication : Application(), OsmandHelperListener {
listOf(-1)
)
showLocationHelper.addDirectionContextMenuButton()
if (settings.hasAnyChatToShowOnMap()) {
showLocationHelper.startShowingLocation()
}
showLocationHelper.startShowingLocation()
}
}
}

View file

@ -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
) {

View file

@ -88,22 +88,21 @@ class SettingsDialogFragment : BaseDialogFragment() {
findViewById<ImageView>(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<TextView>(R.id.title).text = getText(R.string.proxy)
val description = findViewById<TextView>(R.id.description).apply {
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
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<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.description).setText(pref.descriptionId)
val valueView = findViewById<TextView>(R.id.value)