Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
Linhome-Android
Commits
4e2b57ee
Commit
4e2b57ee
authored
Jul 16, 2020
by
Christophe Deschamps
Browse files
Refacto
Former-commit-id: 3a9421210ffe871198e9ead7d727a294dda1c4ae
parent
a20690f4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
6 deletions
+102
-6
app/src/main/java/org/lindoor/ui/history/HistoryEventViewModel.kt
...main/java/org/lindoor/ui/history/HistoryEventViewModel.kt
+98
-0
app/src/main/java/org/lindoor/ui/history/HistoryEventsAdapter.kt
.../main/java/org/lindoor/ui/history/HistoryEventsAdapter.kt
+1
-3
app/src/main/res/layout-sw533dp-land/item_history.xml
app/src/main/res/layout-sw533dp-land/item_history.xml
+1
-1
app/src/main/res/layout-sw533dp/item_history.xml
app/src/main/res/layout-sw533dp/item_history.xml
+1
-1
app/src/main/res/layout/item_history.xml
app/src/main/res/layout/item_history.xml
+1
-1
No files found.
app/src/main/java/org/lindoor/ui/history/HistoryEventViewModel.kt
0 → 100644
View file @
4e2b57ee
package
org.lindoor.ui.history
import
androidx.lifecycle.MutableLiveData
import
org.lindoor.customisation.Texts
import
org.lindoor.entities.Device
import
org.lindoor.entities.HistoryEvent
import
org.lindoor.linphonecore.extensions.isNew
import
org.lindoor.store.DeviceStore
import
org.lindoor.store.HistoryEventStore
import
org.lindoor.utils.DateUtil
import
org.lindoor.utils.databindings.ViewModelWithTools
import
org.linphone.core.Call
import
org.linphone.core.CallLog
import
java.text.SimpleDateFormat
import
java.util.*
class
HistoryEventViewModel
(
val
callLog
:
CallLog
,
val
showDate
:
Boolean
,
val
historyViewModel
:
HistoryViewModel
,
val
device
:
Device
?
=
DeviceStore
.
findDeviceByAddress
(
callLog
.
remoteAddress
)
)
:
ViewModelWithTools
()
{
val
viewMedia
=
MutableLiveData
(
false
)
var
historyEvent
:
HistoryEvent
?
=
callLog
.
callId
?.
let
{
HistoryEventStore
.
findHistoryEventByCallId
(
it
)
}
companion
object
{
val
historyTimePattern
=
"HH:mm:ss"
}
override
fun
onCleared
()
{
historyEvent
?.
viewedByUser
=
true
historyEvent
?.
let
{
HistoryEventStore
.
persistHistoryEvent
(
it
)
}
super
.
onCleared
()
}
fun
callTypeIcon
():
String
{
return
when
(
callLog
.
status
)
{
Call
.
Status
.
Missed
->
"icons/missed"
Call
.
Status
.
Declined
,
Call
.
Status
.
DeclinedElsewhere
->
"icons/declined"
Call
.
Status
.
Aborted
,
Call
.
Status
.
EarlyAborted
->
"icons/declined"
Call
.
Status
.
Success
,
Call
.
Status
.
AcceptedElsewhere
->
{
if
(
callLog
.
dir
==
Call
.
Dir
.
Incoming
)
"icons/accepted"
else
"icons/called"
}
}
}
fun
callTypeAndDate
():
String
{
val
simpleDateFormat
=
SimpleDateFormat
(
historyTimePattern
,
Locale
.
getDefault
())
val
callTime
=
simpleDateFormat
.
format
(
Date
(
callLog
.
startDate
*
1000
))
val
typeText
=
when
(
callLog
.
status
)
{
Call
.
Status
.
Missed
->
"history_list_call_type_missed"
Call
.
Status
.
Declined
,
Call
.
Status
.
DeclinedElsewhere
->
"history_list_call_type_declined"
Call
.
Status
.
Aborted
,
Call
.
Status
.
EarlyAborted
->
"history_list_call_type_aborted"
Call
.
Status
.
Success
,
Call
.
Status
.
AcceptedElsewhere
->
{
if
(
callLog
.
dir
==
Call
.
Dir
.
Incoming
)
"history_list_call_type_accepted"
else
"history_list_call_type_called"
}
}
return
Texts
.
get
(
"history_list_call_date_type"
,
Texts
.
get
(
typeText
),
callTime
)
}
fun
dayText
():
String
{
return
DateUtil
.
todayYesterdayRealDay
(
callLog
.
startDate
/
86400
)
}
fun
toggleSelect
()
{
if
(
historyViewModel
.
selectedForDeletion
.
value
!!
.
contains
(
callLog
.
callId
))
historyViewModel
.
selectedForDeletion
.
value
!!
.
remove
(
callLog
.
callId
)
else
historyViewModel
.
selectedForDeletion
.
value
!!
.
add
(
callLog
.
callId
)
historyViewModel
.
notifyDeleteSelectionListUpdated
()
}
fun
viewMedia
()
{
viewMedia
.
value
=
true
}
fun
isNew
():
Boolean
{
return
callLog
.
isNew
()
}
}
\ No newline at end of file
app/src/main/java/org/lindoor/ui/history/HistoryEventsAdapter.kt
View file @
4e2b57ee
...
...
@@ -10,9 +10,7 @@ import org.lindoor.BR
import
org.lindoor.GenericFragment
import
org.lindoor.R
import
org.lindoor.databinding.ItemHistoryBinding
import
org.lindoor.linphonecore.extensions.historyEvent
import
org.lindoor.ui.player.PlayerActivity
import
org.lindoor.utils.DialogUtil
import
org.linphone.core.CallLog
class
HistoryEventsAdapter
(
...
...
@@ -47,7 +45,7 @@ class HistoryEventsAdapter(
historyViewModel
:
HistoryViewModel
,
lindoorFragment
:
GenericFragment
)
{
val
entryViewModel
=
HistoryEvent
s
ViewModel
(
callLog
,
showDate
,
historyViewModel
)
val
entryViewModel
=
HistoryEventViewModel
(
callLog
,
showDate
,
historyViewModel
)
binding
.
lifecycleOwner
=
lindoorFragment
binding
.
setVariable
(
BR
.
model
,
entryViewModel
)
binding
.
setVariable
(
BR
.
historymodel
,
historyViewModel
)
...
...
app/src/main/res/layout-sw533dp-land/item_history.xml
View file @
4e2b57ee
...
...
@@ -4,7 +4,7 @@
<data>
<import
type=
"android.view.View"
/>
<variable
name=
"model"
type=
"org.lindoor.ui.history.HistoryEvent
s
ViewModel"
/>
<variable
name=
"model"
type=
"org.lindoor.ui.history.HistoryEventViewModel"
/>
<variable
name=
"historymodel"
type=
"org.lindoor.ui.history.HistoryViewModel"
/>
</data>
...
...
app/src/main/res/layout-sw533dp/item_history.xml
View file @
4e2b57ee
...
...
@@ -4,7 +4,7 @@
<data>
<import
type=
"android.view.View"
/>
<variable
name=
"model"
type=
"org.lindoor.ui.history.HistoryEvent
s
ViewModel"
/>
<variable
name=
"model"
type=
"org.lindoor.ui.history.HistoryEventViewModel"
/>
<variable
name=
"historymodel"
type=
"org.lindoor.ui.history.HistoryViewModel"
/>
</data>
...
...
app/src/main/res/layout/item_history.xml
View file @
4e2b57ee
...
...
@@ -4,7 +4,7 @@
<data>
<import
type=
"android.view.View"
/>
<variable
name=
"model"
type=
"org.lindoor.ui.history.HistoryEvent
s
ViewModel"
/>
<variable
name=
"model"
type=
"org.lindoor.ui.history.HistoryEventViewModel"
/>
<variable
name=
"historymodel"
type=
"org.lindoor.ui.history.HistoryViewModel"
/>
</data>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment