Merge pull request #6986 from osmandapp/TrackerImprovements

Tracker improvements
This commit is contained in:
Alexey 2019-05-28 11:22:57 +03:00 committed by GitHub
commit b14152ce74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 36 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,12 +53,10 @@ class TelegramApplication : Application(), OsmandHelperListener {
listOf(-1)
)
showLocationHelper.addDirectionContextMenuButton()
if (settings.hasAnyChatToShowOnMap()) {
showLocationHelper.startShowingLocation()
}
}
}
}
osmandAidlHelper.setUpdatesListener(object : UpdatesListener {
override fun update() {
showLocationHelper.startUpdateMessagesTask()

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)

View file

@ -136,9 +136,9 @@ public class AMapPointMenuController extends MenuController {
public CharSequence getAdditionalInfoStr() {
MapActivity activity = getMapActivity();
if (activity != null) {
float bearing = getPointBearing();
if (bearing != NO_VALUE) {
return OsmAndFormatter.getFormattedAzimuth(bearing, activity.getMyApplication());
float speed = getPointSpeed();
if (speed != NO_VALUE) {
return OsmAndFormatter.getFormattedSpeed(speed, activity.getMyApplication());
}
}
return super.getAdditionalInfoStr();
@ -149,9 +149,9 @@ public class AMapPointMenuController extends MenuController {
public String getSubtypeStr() {
MapActivity activity = getMapActivity();
if (activity != null) {
float speed = getPointSpeed();
if (speed != NO_VALUE) {
return OsmAndFormatter.getFormattedSpeed(speed, activity.getMyApplication());
float bearing = getPointBearing();
if (bearing != NO_VALUE) {
return OsmAndFormatter.getFormattedAzimuth(bearing, activity.getMyApplication());
}
}
return super.getSubtypeStr();
@ -160,16 +160,16 @@ public class AMapPointMenuController extends MenuController {
@Nullable
@Override
public Drawable getSubtypeIcon() {
if (getPointSpeed() != NO_VALUE) {
return getIcon(R.drawable.ic_action_speed_16);
if (getPointBearing() != NO_VALUE) {
return getIcon(R.drawable.ic_action_bearing_16);
}
return super.getSubtypeIcon();
}
@Override
public int getAdditionalInfoIconRes() {
if (getPointBearing() != NO_VALUE) {
return R.drawable.ic_action_bearing;
if (getPointSpeed() != NO_VALUE) {
return R.drawable.ic_action_speed_16;
}
return super.getAdditionalInfoIconRes();
}