Improved call hsitory detail page
This commit is contained in:
parent
cadd5a84b2
commit
0e20fff7e3
7 changed files with 29 additions and 41 deletions
|
@ -61,15 +61,17 @@ class DetailCallLogFragment : Fragment() {
|
||||||
ViewModelProvider(this).get(SharedMainViewModel::class.java)
|
ViewModelProvider(this).get(SharedMainViewModel::class.java)
|
||||||
} ?: throw Exception("Invalid Activity")
|
} ?: throw Exception("Invalid Activity")
|
||||||
|
|
||||||
val callLog = sharedViewModel.selectedCallLog.value
|
val callLogGroup = sharedViewModel.selectedCallLogGroup.value
|
||||||
callLog ?: return
|
callLogGroup ?: return
|
||||||
|
|
||||||
viewModel = ViewModelProvider(
|
viewModel = ViewModelProvider(
|
||||||
this,
|
this,
|
||||||
CallLogViewModelFactory(callLog)
|
CallLogViewModelFactory(callLogGroup.lastCallLog)
|
||||||
)[CallLogViewModel::class.java]
|
)[CallLogViewModel::class.java]
|
||||||
binding.viewModel = viewModel
|
binding.viewModel = viewModel
|
||||||
|
|
||||||
|
viewModel.relatedCallLogs.value = callLogGroup.callLogs
|
||||||
|
|
||||||
binding.setBackClickListener {
|
binding.setBackClickListener {
|
||||||
findNavController().popBackStack()
|
findNavController().popBackStack()
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ class MasterCallLogsFragment : MasterFragment() {
|
||||||
|
|
||||||
adapter.selectedCallLogEvent.observe(viewLifecycleOwner, Observer {
|
adapter.selectedCallLogEvent.observe(viewLifecycleOwner, Observer {
|
||||||
it.consume { callLog ->
|
it.consume { callLog ->
|
||||||
sharedViewModel.selectedCallLog.value = callLog.lastCallLog
|
sharedViewModel.selectedCallLogGroup.value = callLog
|
||||||
if (!resources.getBoolean(R.bool.isTablet)) {
|
if (!resources.getBoolean(R.bool.isTablet)) {
|
||||||
if (findNavController().currentDestination?.id == R.id.masterCallLogsFragment) {
|
if (findNavController().currentDestination?.id == R.id.masterCallLogsFragment) {
|
||||||
findNavController().navigate(R.id.action_masterCallLogsFragment_to_detailCallLogFragment)
|
findNavController().navigate(R.id.action_masterCallLogsFragment_to_detailCallLogFragment)
|
||||||
|
|
|
@ -25,7 +25,6 @@ import androidx.lifecycle.ViewModelProvider
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.contact.GenericContactViewModel
|
import org.linphone.contact.GenericContactViewModel
|
||||||
import org.linphone.core.*
|
import org.linphone.core.*
|
||||||
|
@ -86,14 +85,14 @@ class CallLogViewModel(val callLog: CallLog) : GenericContactViewModel(callLog.r
|
||||||
}
|
}
|
||||||
|
|
||||||
val duration: String by lazy {
|
val duration: String by lazy {
|
||||||
val dateFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
val dateFormat = SimpleDateFormat(if (callLog.duration >= 3600) "HH:mm:ss" else "mm:ss", Locale.getDefault())
|
||||||
val cal = Calendar.getInstance()
|
val cal = Calendar.getInstance()
|
||||||
cal[0, 0, 0, 0, 0] = callLog.duration
|
cal[0, 0, 0, 0, 0] = callLog.duration
|
||||||
dateFormat.format(cal.time)
|
dateFormat.format(cal.time)
|
||||||
}
|
}
|
||||||
|
|
||||||
val date: String by lazy {
|
val date: String by lazy {
|
||||||
TimestampUtils.toString(callLog.startDate)
|
TimestampUtils.toString(callLog.startDate, shortDate = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val startCallEvent: MutableLiveData<Event<Address>> by lazy {
|
val startCallEvent: MutableLiveData<Event<Address>> by lazy {
|
||||||
|
@ -108,6 +107,8 @@ class CallLogViewModel(val callLog: CallLog) : GenericContactViewModel(callLog.r
|
||||||
|
|
||||||
val secureChatAllowed = contact.value?.friend?.getPresenceModelForUriOrTel(peerSipUri)?.hasCapability(FriendCapability.LimeX3Dh) ?: false
|
val secureChatAllowed = contact.value?.friend?.getPresenceModelForUriOrTel(peerSipUri)?.hasCapability(FriendCapability.LimeX3Dh) ?: false
|
||||||
|
|
||||||
|
val relatedCallLogs = MutableLiveData<ArrayList<CallLog>>()
|
||||||
|
|
||||||
private val chatRoomListener = object : ChatRoomListenerStub() {
|
private val chatRoomListener = object : ChatRoomListenerStub() {
|
||||||
override fun onStateChanged(chatRoom: ChatRoom, state: ChatRoom.State) {
|
override fun onStateChanged(chatRoom: ChatRoom, state: ChatRoom.State) {
|
||||||
if (state == ChatRoom.State.Created) {
|
if (state == ChatRoom.State.Created) {
|
||||||
|
@ -146,9 +147,8 @@ class CallLogViewModel(val callLog: CallLog) : GenericContactViewModel(callLog.r
|
||||||
|
|
||||||
fun getCallsHistory(): ArrayList<CallLogViewModel> {
|
fun getCallsHistory(): ArrayList<CallLogViewModel> {
|
||||||
val callsHistory = ArrayList<CallLogViewModel>()
|
val callsHistory = ArrayList<CallLogViewModel>()
|
||||||
val logs = coreContext.core.getCallHistory(callLog.remoteAddress, coreContext.core.defaultProxyConfig?.identityAddress)
|
for (callLog in relatedCallLogs.value.orEmpty()) {
|
||||||
for (log in logs) {
|
callsHistory.add(CallLogViewModel(callLog))
|
||||||
callsHistory.add(CallLogViewModel(log))
|
|
||||||
}
|
}
|
||||||
return callsHistory
|
return callsHistory
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.linphone.activities.main.viewmodels
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import org.linphone.activities.main.history.viewmodels.GroupedCallLogViewModel
|
||||||
import org.linphone.contact.Contact
|
import org.linphone.contact.Contact
|
||||||
import org.linphone.core.*
|
import org.linphone.core.*
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
@ -30,7 +31,7 @@ class SharedMainViewModel : ViewModel() {
|
||||||
|
|
||||||
/* Call history */
|
/* Call history */
|
||||||
|
|
||||||
val selectedCallLog = MutableLiveData<CallLog>()
|
val selectedCallLogGroup = MutableLiveData<GroupedCallLogViewModel>()
|
||||||
|
|
||||||
/* Chat */
|
/* Chat */
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ class TimestampUtils {
|
||||||
if (isSameYear(timestamp, timestampInSecs)) {
|
if (isSameYear(timestamp, timestampInSecs)) {
|
||||||
// Remove the year part of the format
|
// Remove the year part of the format
|
||||||
dateFormat.applyPattern(
|
dateFormat.applyPattern(
|
||||||
dateFormat.toPattern().replace("/?y+/?|\\s?y+\\s?".toRegex(), "")
|
dateFormat.toPattern().replace("/?y+/?|\\s?y+\\s?".toRegex(), if (shortDate) "" else " ")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/select"
|
android:id="@+id/select"
|
||||||
android:onClick="@{() -> selectionListViewModel.onToggleSelect(position)}"
|
android:onClick="@{() -> selectionListViewModel.onToggleSelect(position)}"
|
||||||
android:visibility="@{selectionListViewModel.isEditionEnabled ? View.VISIBLE : View.GONE}"
|
android:visibility="@{selectionListViewModel.isEditionEnabled ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:checked="@{selectionListViewModel.selectedItems.contains(position)}"
|
android:checked="@{selectionListViewModel.selectedItems.contains(position)}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
android:paddingBottom="5dp">
|
android:paddingBottom="5dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:visibility="@{viewModel.chatMessage.forward ? View.VISIBLE : View.GONE}"
|
android:visibility="@{viewModel.chatMessage.forward ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -110,7 +110,8 @@
|
||||||
android:fontFamily="sans-serif"
|
android:fontFamily="sans-serif"
|
||||||
android:textStyle="normal"
|
android:textStyle="normal"
|
||||||
android:lineSpacingExtra="3.3sp"
|
android:lineSpacingExtra="3.3sp"
|
||||||
android:text="@string/chat_message_forwarded" />
|
android:text="@string/chat_message_forwarded"
|
||||||
|
tools:ignore="SmallSp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@
|
||||||
android:lineSpacingExtra="-1.7sp"/>
|
android:lineSpacingExtra="-1.7sp"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:visibility="@{viewModel.chatMessage.ephemeral ? View.VISIBLE : View.GONE}"
|
android:visibility="@{viewModel.chatMessage.ephemeral ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -178,7 +179,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/time"
|
android:id="@+id/time"
|
||||||
android:text="@{viewModel.chatMessage.outgoing ? viewModel.time : viewModel.time + ` - ` + (viewModel.contact.fullName ?? viewModel.displayName), default=Wednesday}"
|
android:text="@{viewModel.chatMessage.outgoing ? viewModel.time : viewModel.time + ` - ` + (viewModel.contact.fullName ?? viewModel.displayName)}"
|
||||||
android:visibility="@{viewModel.hideTime ? View.GONE : View.VISIBLE}"
|
android:visibility="@{viewModel.hideTime ? View.GONE : View.VISIBLE}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -9,11 +9,9 @@
|
||||||
type="org.linphone.activities.main.history.viewmodels.CallLogViewModel" />
|
type="org.linphone.activities.main.history.viewmodels.CallLogViewModel" />
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<LinearLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="10dp">
|
android:padding="10dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -21,32 +19,18 @@
|
||||||
android:contentDescription="@{data.iconContentDescription}"
|
android:contentDescription="@{data.iconContentDescription}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp" />
|
android:paddingRight="10dp" />
|
||||||
|
|
||||||
<com.google.android.flexbox.FlexboxLayout
|
<org.linphone.views.MarqueeTextView
|
||||||
|
android:text="@{data.date + ` - ` + data.duration}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:flexWrap="wrap"
|
android:layout_centerHorizontal="true"
|
||||||
app:justifyContent="center">
|
android:layout_centerVertical="true" />
|
||||||
|
|
||||||
<TextView
|
</RelativeLayout>
|
||||||
android:text="@{data.duration}"
|
|
||||||
android:textColor="?attr/primarySubtextDarkColor"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingRight="10dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:text="@{data.date}"
|
|
||||||
android:textColor="?attr/primarySubtextDarkColor"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</com.google.android.flexbox.FlexboxLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in a new issue