Merge pull request #6186 from osmandapp/TelegramImprovements
Telegram status improvements
This commit is contained in:
commit
bc764165b8
5 changed files with 41 additions and 21 deletions
|
@ -79,8 +79,8 @@
|
|||
android:id="@+id/last_location_line_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/content_padding_half"
|
||||
android:paddingRight="@dimen/content_padding_half"
|
||||
android:paddingLeft="@dimen/content_padding_small"
|
||||
android:paddingRight="@dimen/content_padding_small"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/list_item_description_text_size"
|
||||
app:firstBaselineToTopHeight="22dp"
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<resources>
|
||||
<string name="not_sent_yet">Not sent yet</string>
|
||||
<string name="not_found_yet">Not found yet</string>
|
||||
<string name="re_send_location">Re-send location</string>
|
||||
<string name="last_sent_location">Last sent location</string>
|
||||
<string name="last_available_location">Last available location</string>
|
||||
|
|
|
@ -191,7 +191,6 @@ class TelegramSettings(private val app: TelegramApplication) {
|
|||
val shareChatInfo = shareChatsInfo[message.chatId]
|
||||
val content = message.content
|
||||
if (shareChatInfo != null && content is TdApi.MessageLocation) {
|
||||
shareChatInfo.start = message.date.toLong()
|
||||
shareChatInfo.currentMessageId = message.id
|
||||
shareChatInfo.lastSuccessfulLocation = LatLon(content.location.latitude, content.location.longitude)
|
||||
shareChatInfo.lastSuccessfulSendTimeMs = Math.max(message.editDate, message.date) * 1000L
|
||||
|
@ -210,7 +209,7 @@ class TelegramSettings(private val app: TelegramApplication) {
|
|||
} else {
|
||||
var sendChatsErrors = false
|
||||
shareChatsInfo.forEach { _, shareInfo ->
|
||||
if (shareInfo.hasSharingError) {
|
||||
if (shareInfo.hasSharingError || shareInfo.lastSuccessfulSendTimeMs == -1L) {
|
||||
sendChatsErrors = true
|
||||
locationTime = shareInfo.lastSuccessfulSendTimeMs
|
||||
val title = app.telegramHelper.getChat(shareInfo.chatId)?.title
|
||||
|
|
|
@ -60,6 +60,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
private lateinit var searchBox: FrameLayout
|
||||
private lateinit var stopSharingSwitcher: Switch
|
||||
private lateinit var sharingStatusDescription: TextView
|
||||
private lateinit var sharingStatusIcon: ImageView
|
||||
private lateinit var startSharingBtn: View
|
||||
|
||||
private lateinit var searchBoxBg: GradientDrawable
|
||||
|
@ -143,7 +144,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
text = spannable
|
||||
}
|
||||
|
||||
mainView.findViewById<ImageView>(R.id.sharing_status_icon).setImageDrawable(app.uiUtils.getActiveIcon(R.drawable.ic_action_live_now))
|
||||
sharingStatusIcon = mainView.findViewById<ImageView>(R.id.sharing_status_icon)
|
||||
|
||||
textContainer = mainView.findViewById<LinearLayout>(R.id.text_container).apply {
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
|
@ -195,6 +196,8 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
}
|
||||
|
||||
mainView.findViewById<View>(R.id.sharing_status_container).setOnClickListener {
|
||||
settings.updateSharingStatusHistory()
|
||||
updateSharingStatus()
|
||||
fragmentManager?.also { fm ->
|
||||
SharingStatusBottomSheet.showInstance(fm, this)
|
||||
}
|
||||
|
@ -433,8 +436,11 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
}
|
||||
|
||||
private fun updateSharingStatus() {
|
||||
if (sharingMode && settings.sharingStatusChanges.isNotEmpty()) {
|
||||
sharingStatusDescription.text = settings.sharingStatusChanges.last().getDescription(app)
|
||||
if (sharingMode) {
|
||||
settings.updateSharingStatusHistory()
|
||||
val sharingStatus = settings.sharingStatusChanges.last()
|
||||
sharingStatusDescription.text = sharingStatus.getDescription(app)
|
||||
sharingStatusIcon.setImageDrawable(app.uiUtils.getIcon(sharingStatus.statusType.iconId, sharingStatus.statusType.iconColorRes))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,7 +595,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
|
||||
holder.stopSharingFirstPart?.apply {
|
||||
visibility = getStopSharingVisibility(expiresIn)
|
||||
text = OsmandFormatter.getFormattedTime(expiresIn)
|
||||
text = OsmandFormatter.getFormattedTime(expiresIn * 1000)
|
||||
}
|
||||
|
||||
holder.stopSharingSecondPart?.apply {
|
||||
|
|
|
@ -5,14 +5,15 @@ import android.support.design.widget.BottomSheetBehavior
|
|||
import android.support.v4.app.DialogFragment
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import net.osmand.telegram.R
|
||||
import net.osmand.telegram.TelegramApplication
|
||||
import net.osmand.telegram.TelegramSettings
|
||||
import net.osmand.telegram.ui.views.BottomSheetDialog
|
||||
import net.osmand.telegram.utils.OsmandFormatter
|
||||
|
||||
|
@ -42,7 +43,9 @@ class SharingStatusBottomSheet : DialogFragment() {
|
|||
})
|
||||
|
||||
val itemsCont = mainView.findViewById<ViewGroup>(R.id.items_container)
|
||||
settings.sharingStatusChanges.reversed().forEach { sharingStatus ->
|
||||
val items = settings.sharingStatusChanges.toArray().reversed()
|
||||
for (i in items.indices) {
|
||||
val sharingStatus = items[i] as TelegramSettings.SharingStatus
|
||||
inflater.inflate(R.layout.item_with_three_text_lines, itemsCont, false).apply {
|
||||
val sharingStatusType = sharingStatus.statusType
|
||||
val time = sharingStatus.locationTime
|
||||
|
@ -52,20 +55,30 @@ class SharingStatusBottomSheet : DialogFragment() {
|
|||
findViewById<TextView>(R.id.status_change_time).text = OsmandFormatter.getFormattedTime(sharingStatus.statusChangeTime, false)
|
||||
findViewById<TextView>(R.id.last_location_line).text = getString(sharingStatusType.descriptionId)
|
||||
|
||||
if (time > 0) {
|
||||
findViewById<TextView>(R.id.last_location_line_time).text = OsmandFormatter.getFormattedTime(time, false)
|
||||
} else {
|
||||
findViewById<LinearLayout>(R.id.description_container).visibility = View.INVISIBLE
|
||||
val descriptionTime = when {
|
||||
time > 0 -> OsmandFormatter.getFormattedTime(time, false)
|
||||
sharingStatusType == TelegramSettings.SharingStatusType.NO_GPS -> getString(R.string.not_found_yet)
|
||||
else -> getString(R.string.not_sent_yet)
|
||||
}
|
||||
if (sharingStatusType.canResendLocation) {
|
||||
findViewById<TextView>(R.id.re_send_location).apply {
|
||||
setOnClickListener {
|
||||
app.forceUpdateMyLocation()
|
||||
dismiss()
|
||||
|
||||
findViewById<TextView>(R.id.last_location_line_time).text = descriptionTime
|
||||
|
||||
findViewById<TextView>(R.id.re_send_location).apply {
|
||||
if (sharingStatusType.canResendLocation) {
|
||||
if (i == 0) {
|
||||
setOnClickListener {
|
||||
app.forceUpdateMyLocation()
|
||||
dismiss()
|
||||
}
|
||||
} else {
|
||||
setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light))
|
||||
}
|
||||
} else {
|
||||
visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
findViewById<TextView>(R.id.re_send_location).visibility = View.GONE
|
||||
}
|
||||
if (i == items.size - 1) {
|
||||
findViewById<View>(R.id.bottom_divider).visibility = View.GONE
|
||||
}
|
||||
itemsCont.addView(this)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue