mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-25 22:08:38 +00:00
Added thread annotations to constructors + some missing other ones
This commit is contained in:
parent
9e259f02d8
commit
8bba5ea2b6
41 changed files with 86 additions and 40 deletions
|
|
@ -21,6 +21,7 @@ package org.linphone
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import androidx.annotation.MainThread
|
||||||
import coil.ImageLoader
|
import coil.ImageLoader
|
||||||
import coil.ImageLoaderFactory
|
import coil.ImageLoaderFactory
|
||||||
import coil.decode.GifDecoder
|
import coil.decode.GifDecoder
|
||||||
|
|
@ -39,6 +40,7 @@ import org.linphone.core.LogCollectionState
|
||||||
import org.linphone.core.LogLevel
|
import org.linphone.core.LogLevel
|
||||||
import org.linphone.mediastream.Version
|
import org.linphone.mediastream.Version
|
||||||
|
|
||||||
|
@MainThread
|
||||||
class LinphoneApplication : Application(), ImageLoaderFactory {
|
class LinphoneApplication : Application(), ImageLoaderFactory {
|
||||||
companion object {
|
companion object {
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,6 @@ import org.linphone.databinding.ContactSelectionCellBinding
|
||||||
class ContactsSelectionAdapter(
|
class ContactsSelectionAdapter(
|
||||||
private val viewLifecycleOwner: LifecycleOwner
|
private val viewLifecycleOwner: LifecycleOwner
|
||||||
) : ListAdapter<ContactData, RecyclerView.ViewHolder>(ContactDataDiffCallback()) {
|
) : ListAdapter<ContactData, RecyclerView.ViewHolder>(ContactDataDiffCallback()) {
|
||||||
init {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||||
val binding: ContactSelectionCellBinding = DataBindingUtil.inflate(
|
val binding: ContactSelectionCellBinding = DataBindingUtil.inflate(
|
||||||
LayoutInflater.from(parent.context),
|
LayoutInflater.from(parent.context),
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import org.linphone.ui.voip.VoipActivity
|
||||||
import org.linphone.utils.ActivityMonitor
|
import org.linphone.utils.ActivityMonitor
|
||||||
import org.linphone.utils.LinphoneUtils
|
import org.linphone.utils.LinphoneUtils
|
||||||
|
|
||||||
class CoreContext(val context: Context) : HandlerThread("Core Thread") {
|
class CoreContext @UiThread constructor(val context: Context) : HandlerThread("Core Thread") {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Core Context]"
|
const val TAG = "[Core Context]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import org.linphone.core.RegistrationState
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class AssistantViewModel : ViewModel() {
|
class AssistantViewModel @UiThread constructor() : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Assistant ViewModel]"
|
const val TAG = "[Assistant ViewModel]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import org.linphone.ui.main.contacts.viewmodel.ContactsListViewModel
|
||||||
import org.linphone.ui.main.fragment.GenericFragment
|
import org.linphone.ui.main.fragment.GenericFragment
|
||||||
import org.linphone.utils.DialogUtils
|
import org.linphone.utils.DialogUtils
|
||||||
|
|
||||||
|
@UiThread
|
||||||
class StartCallFragment : GenericFragment() {
|
class StartCallFragment : GenericFragment() {
|
||||||
private lateinit var binding: CallStartFragmentBinding
|
private lateinit var binding: CallStartFragmentBinding
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.linphone.ui.main.calls.model
|
package org.linphone.ui.main.calls.model
|
||||||
|
|
||||||
import androidx.annotation.IntegerRes
|
import androidx.annotation.IntegerRes
|
||||||
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import org.linphone.core.Call
|
import org.linphone.core.Call
|
||||||
import org.linphone.core.Call.Dir
|
import org.linphone.core.Call.Dir
|
||||||
|
|
@ -8,7 +9,7 @@ import org.linphone.core.CallLog
|
||||||
import org.linphone.utils.LinphoneUtils
|
import org.linphone.utils.LinphoneUtils
|
||||||
import org.linphone.utils.TimestampUtils
|
import org.linphone.utils.TimestampUtils
|
||||||
|
|
||||||
class CallLogHistoryModel(val callLog: CallLog) {
|
class CallLogHistoryModel @WorkerThread constructor(val callLog: CallLog) {
|
||||||
val isOutgoing = MutableLiveData<Boolean>()
|
val isOutgoing = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
val isSuccessful = MutableLiveData<Boolean>()
|
val isSuccessful = MutableLiveData<Boolean>()
|
||||||
|
|
@ -21,7 +22,6 @@ class CallLogHistoryModel(val callLog: CallLog) {
|
||||||
val iconResId = MutableLiveData<Int>()
|
val iconResId = MutableLiveData<Int>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Core thread
|
|
||||||
isOutgoing.postValue(callLog.dir == Dir.Outgoing)
|
isOutgoing.postValue(callLog.dir == Dir.Outgoing)
|
||||||
|
|
||||||
val startDate = callLog.startDate
|
val startDate = callLog.startDate
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package org.linphone.ui.main.calls.model
|
||||||
|
|
||||||
import androidx.annotation.IntegerRes
|
import androidx.annotation.IntegerRes
|
||||||
import androidx.annotation.UiThread
|
import androidx.annotation.UiThread
|
||||||
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.core.Call.Dir
|
import org.linphone.core.Call.Dir
|
||||||
|
|
@ -10,7 +11,7 @@ import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||||
import org.linphone.utils.LinphoneUtils
|
import org.linphone.utils.LinphoneUtils
|
||||||
import org.linphone.utils.TimestampUtils
|
import org.linphone.utils.TimestampUtils
|
||||||
|
|
||||||
class CallLogModel(private val callLog: CallLog) {
|
class CallLogModel @WorkerThread constructor(private val callLog: CallLog) {
|
||||||
val id = callLog.callId ?: callLog.refKey
|
val id = callLog.callId ?: callLog.refKey
|
||||||
|
|
||||||
val address = if (callLog.dir == Dir.Outgoing) callLog.remoteAddress else callLog.fromAddress
|
val address = if (callLog.dir == Dir.Outgoing) callLog.remoteAddress else callLog.fromAddress
|
||||||
|
|
@ -31,7 +32,6 @@ class CallLogModel(private val callLog: CallLog) {
|
||||||
var friendExists: Boolean = false
|
var friendExists: Boolean = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Core thread
|
|
||||||
isOutgoing.postValue(callLog.dir == Dir.Outgoing)
|
isOutgoing.postValue(callLog.dir == Dir.Outgoing)
|
||||||
|
|
||||||
val timestamp = callLog.startDate
|
val timestamp = callLog.startDate
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import androidx.annotation.UiThread
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class ConfirmationDialogModel() {
|
class ConfirmationDialogModel @UiThread constructor() {
|
||||||
val dismissEvent = MutableLiveData<Event<Boolean>>()
|
val dismissEvent = MutableLiveData<Event<Boolean>>()
|
||||||
|
|
||||||
val confirmRemovalEvent = MutableLiveData<Event<Boolean>>()
|
val confirmRemovalEvent = MutableLiveData<Event<Boolean>>()
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import org.linphone.ui.main.calls.model.CallLogHistoryModel
|
||||||
import org.linphone.ui.main.calls.model.CallLogModel
|
import org.linphone.ui.main.calls.model.CallLogModel
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class CallLogViewModel : ViewModel() {
|
class CallLogViewModel @UiThread constructor() : ViewModel() {
|
||||||
val showBackButton = MutableLiveData<Boolean>()
|
val showBackButton = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
val callLogModel = MutableLiveData<CallLogModel>()
|
val callLogModel = MutableLiveData<CallLogModel>()
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.linphone.core.CoreListenerStub
|
||||||
import org.linphone.ui.main.calls.model.CallLogModel
|
import org.linphone.ui.main.calls.model.CallLogModel
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class CallsListViewModel : ViewModel() {
|
class CallsListViewModel @UiThread constructor() : ViewModel() {
|
||||||
val callLogs = MutableLiveData<ArrayList<CallLogModel>>()
|
val callLogs = MutableLiveData<ArrayList<CallLogModel>>()
|
||||||
|
|
||||||
val historyDeletedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
val historyDeletedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,11 @@
|
||||||
*/
|
*/
|
||||||
package org.linphone.ui.main.calls.viewmodel
|
package org.linphone.ui.main.calls.viewmodel
|
||||||
|
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
|
||||||
class StartCallViewModel : ViewModel() {
|
class StartCallViewModel @UiThread constructor() : ViewModel() {
|
||||||
val searchFilter = MutableLiveData<String>()
|
val searchFilter = MutableLiveData<String>()
|
||||||
|
|
||||||
val emptyContactsList = MutableLiveData<Boolean>()
|
val emptyContactsList = MutableLiveData<Boolean>()
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import org.linphone.core.SearchResult
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||||
|
|
||||||
class SuggestionsListViewModel : ViewModel() {
|
class SuggestionsListViewModel @UiThread constructor() : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Suggestions List ViewModel]"
|
const val TAG = "[Suggestions List ViewModel]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.linphone.core.FriendListenerStub
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.utils.LinphoneUtils
|
import org.linphone.utils.LinphoneUtils
|
||||||
|
|
||||||
class ContactAvatarModel(val friend: Friend) {
|
class ContactAvatarModel @WorkerThread constructor(val friend: Friend) {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Contact Avatar Model]"
|
const val TAG = "[Contact Avatar Model]"
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +62,6 @@ class ContactAvatarModel(val friend: Friend) {
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Core thread
|
|
||||||
friend.addListener(friendListener)
|
friend.addListener(friendListener)
|
||||||
|
|
||||||
name.postValue(friend.name)
|
name.postValue(friend.name)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ package org.linphone.ui.main.contacts.model
|
||||||
|
|
||||||
import androidx.annotation.UiThread
|
import androidx.annotation.UiThread
|
||||||
|
|
||||||
class ContactDeviceModel(
|
class ContactDeviceModel @UiThread constructor(
|
||||||
val name: String,
|
val name: String,
|
||||||
val trusted: Boolean
|
val trusted: Boolean
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import androidx.annotation.UiThread
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import org.linphone.core.Address
|
import org.linphone.core.Address
|
||||||
|
|
||||||
class ContactNumberOrAddressModel(
|
class ContactNumberOrAddressModel @UiThread constructor(
|
||||||
val address: Address?,
|
val address: Address?,
|
||||||
val displayedValue: String,
|
val displayedValue: String,
|
||||||
private val listener: ContactNumberOrAddressClickListener,
|
private val listener: ContactNumberOrAddressClickListener,
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,10 @@
|
||||||
package org.linphone.ui.main.contacts.model
|
package org.linphone.ui.main.contacts.model
|
||||||
|
|
||||||
import androidx.annotation.UiThread
|
import androidx.annotation.UiThread
|
||||||
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
|
||||||
class NewOrEditNumberOrAddressModel(
|
class NewOrEditNumberOrAddressModel @WorkerThread constructor(
|
||||||
defaultValue: String,
|
defaultValue: String,
|
||||||
val isSip: Boolean,
|
val isSip: Boolean,
|
||||||
private val onValueNoLongerEmpty: (() -> Unit)? = null,
|
private val onValueNoLongerEmpty: (() -> Unit)? = null,
|
||||||
|
|
@ -33,7 +34,6 @@ class NewOrEditNumberOrAddressModel(
|
||||||
val showRemoveButton = MutableLiveData<Boolean>()
|
val showRemoveButton = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Core thread
|
|
||||||
value.postValue(defaultValue)
|
value.postValue(defaultValue)
|
||||||
showRemoveButton.postValue(defaultValue.isNotEmpty())
|
showRemoveButton.postValue(defaultValue.isNotEmpty())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,9 @@ import androidx.annotation.UiThread
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class NumberOrAddressPickerDialogModel(list: List<ContactNumberOrAddressModel>) {
|
class NumberOrAddressPickerDialogModel @UiThread constructor(
|
||||||
|
list: List<ContactNumberOrAddressModel>
|
||||||
|
) {
|
||||||
val sipAddressesAndPhoneNumbers = MutableLiveData<List<ContactNumberOrAddressModel>>()
|
val sipAddressesAndPhoneNumbers = MutableLiveData<List<ContactNumberOrAddressModel>>()
|
||||||
|
|
||||||
val dismissEvent = MutableLiveData<Event<Boolean>>()
|
val dismissEvent = MutableLiveData<Event<Boolean>>()
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import org.linphone.ui.main.contacts.model.NewOrEditNumberOrAddressModel
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
import org.linphone.utils.FileUtils
|
import org.linphone.utils.FileUtils
|
||||||
|
|
||||||
class ContactNewOrEditViewModel() : ViewModel() {
|
class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Contact New/Edit View Model]"
|
const val TAG = "[Contact New/Edit View Model]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import org.linphone.ui.main.contacts.model.ContactNumberOrAddressModel
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
import org.linphone.utils.FileUtils
|
import org.linphone.utils.FileUtils
|
||||||
|
|
||||||
class ContactViewModel : ViewModel() {
|
class ContactViewModel @UiThread constructor() : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Contact ViewModel]"
|
const val TAG = "[Contact ViewModel]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import org.linphone.core.SearchResult
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||||
|
|
||||||
class ContactsListViewModel : ViewModel() {
|
class ContactsListViewModel @UiThread constructor() : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Contacts List ViewModel]"
|
const val TAG = "[Contacts List ViewModel]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import org.linphone.core.tools.Log
|
||||||
import org.linphone.ui.main.conversations.data.EventLogData
|
import org.linphone.ui.main.conversations.data.EventLogData
|
||||||
import org.linphone.utils.LinphoneUtils
|
import org.linphone.utils.LinphoneUtils
|
||||||
|
|
||||||
class ConversationViewModel : ViewModel() {
|
class ConversationViewModel @WorkerThread constructor(): ViewModel() {
|
||||||
private lateinit var chatRoom: ChatRoom
|
private lateinit var chatRoom: ChatRoom
|
||||||
|
|
||||||
val events = MutableLiveData<ArrayList<EventLogData>>()
|
val events = MutableLiveData<ArrayList<EventLogData>>()
|
||||||
|
|
@ -86,7 +86,6 @@ class ConversationViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Core thread
|
|
||||||
coreContext.contactsManager.addListener(contactsListener)
|
coreContext.contactsManager.addListener(contactsListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.linphone.core.RegistrationState
|
||||||
import org.linphone.utils.FileUtils
|
import org.linphone.utils.FileUtils
|
||||||
import org.linphone.utils.LinphoneUtils
|
import org.linphone.utils.LinphoneUtils
|
||||||
|
|
||||||
class AccountModel(
|
class AccountModel @WorkerThread constructor(
|
||||||
private val account: Account,
|
private val account: Account,
|
||||||
private val onMenuClicked: ((view: View, account: Account) -> Unit)? = null
|
private val onMenuClicked: ((view: View, account: Account) -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
|
|
@ -58,7 +58,6 @@ class AccountModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Core thread
|
|
||||||
account.addListener(accountListener)
|
account.addListener(accountListener)
|
||||||
|
|
||||||
avatar.postValue(account.getPicturePath())
|
avatar.postValue(account.getPicturePath())
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import org.linphone.databinding.RecordingsFragmentBinding
|
import org.linphone.databinding.RecordingsFragmentBinding
|
||||||
import org.linphone.ui.main.fragment.GenericFragment
|
import org.linphone.ui.main.fragment.GenericFragment
|
||||||
|
|
||||||
|
@UiThread
|
||||||
class RecordingsFragment : GenericFragment() {
|
class RecordingsFragment : GenericFragment() {
|
||||||
private lateinit var binding: RecordingsFragmentBinding
|
private lateinit var binding: RecordingsFragmentBinding
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.activity.result.PickVisualMediaRequest
|
import androidx.activity.result.PickVisualMediaRequest
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.navigation.fragment.navArgs
|
import androidx.navigation.fragment.navArgs
|
||||||
|
|
@ -21,6 +22,7 @@ import org.linphone.ui.main.fragment.GenericFragment
|
||||||
import org.linphone.ui.main.settings.viewmodel.AccountProfileViewModel
|
import org.linphone.ui.main.settings.viewmodel.AccountProfileViewModel
|
||||||
import org.linphone.utils.FileUtils
|
import org.linphone.utils.FileUtils
|
||||||
|
|
||||||
|
@UiThread
|
||||||
class AccountProfileFragment : GenericFragment() {
|
class AccountProfileFragment : GenericFragment() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Account Profile Fragment]"
|
const val TAG = "[Account Profile Fragment]"
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import org.linphone.databinding.HelpFragmentBinding
|
import org.linphone.databinding.HelpFragmentBinding
|
||||||
import org.linphone.ui.main.fragment.GenericFragment
|
import org.linphone.ui.main.fragment.GenericFragment
|
||||||
|
|
||||||
|
@UiThread
|
||||||
class HelpFragment : GenericFragment() {
|
class HelpFragment : GenericFragment() {
|
||||||
private lateinit var binding: HelpFragmentBinding
|
private lateinit var binding: HelpFragmentBinding
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import org.linphone.databinding.SettingsFragmentBinding
|
import org.linphone.databinding.SettingsFragmentBinding
|
||||||
import org.linphone.ui.main.fragment.GenericFragment
|
import org.linphone.ui.main.fragment.GenericFragment
|
||||||
|
|
||||||
|
@UiThread
|
||||||
class SettingsFragment : GenericFragment() {
|
class SettingsFragment : GenericFragment() {
|
||||||
private lateinit var binding: SettingsFragmentBinding
|
private lateinit var binding: SettingsFragmentBinding
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import org.linphone.ui.main.model.getPicturePath
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
import org.linphone.utils.FileUtils
|
import org.linphone.utils.FileUtils
|
||||||
|
|
||||||
class AccountProfileViewModel : ViewModel() {
|
class AccountProfileViewModel @UiThread constructor() : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Account Profile ViewModel]"
|
const val TAG = "[Account Profile ViewModel]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.linphone.core.tools.Log
|
||||||
import org.linphone.ui.main.model.AccountModel
|
import org.linphone.ui.main.model.AccountModel
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class DrawerMenuViewModel : ViewModel() {
|
class DrawerMenuViewModel @UiThread constructor() : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Drawer Menu ViewModel]"
|
const val TAG = "[Drawer Menu ViewModel]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,12 @@
|
||||||
*/
|
*/
|
||||||
package org.linphone.ui.main.viewmodel
|
package org.linphone.ui.main.viewmodel
|
||||||
|
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class SharedMainViewModel : ViewModel() {
|
class SharedMainViewModel @UiThread constructor() : ViewModel() {
|
||||||
/* Sliding Pane & navigation related */
|
/* Sliding Pane & navigation related */
|
||||||
|
|
||||||
val isSlidingPaneSlideable = MutableLiveData<Boolean>()
|
val isSlidingPaneSlideable = MutableLiveData<Boolean>()
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import org.linphone.core.tools.Log
|
||||||
import org.linphone.ui.main.model.AccountModel
|
import org.linphone.ui.main.model.AccountModel
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class TopBarViewModel : ViewModel() {
|
class TopBarViewModel @UiThread constructor() : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Top Bar ViewModel]"
|
const val TAG = "[Top Bar ViewModel]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import java.util.Random
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class ZrtpSasConfirmationDialogModel(
|
class ZrtpSasConfirmationDialogModel @UiThread constructor(
|
||||||
private val authTokenToRead: String,
|
private val authTokenToRead: String,
|
||||||
private val authTokenToListen: String
|
private val authTokenToListen: String
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.linphone.core.CoreListenerStub
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
class CallsViewModel : ViewModel() {
|
class CallsViewModel @UiThread constructor() : ViewModel() {
|
||||||
val goToActiveCallEvent = MutableLiveData<Event<Boolean>>()
|
val goToActiveCallEvent = MutableLiveData<Event<Boolean>>()
|
||||||
|
|
||||||
val showIncomingCallEvent = MutableLiveData<Event<Boolean>>()
|
val showIncomingCallEvent = MutableLiveData<Event<Boolean>>()
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
import org.linphone.utils.LinphoneUtils
|
import org.linphone.utils.LinphoneUtils
|
||||||
|
|
||||||
class CurrentCallViewModel() : ViewModel() {
|
class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "[Current Call ViewModel]"
|
const val TAG = "[Current Call ViewModel]"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,11 @@ package org.linphone.utils
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.Application.ActivityLifecycleCallbacks
|
import android.app.Application.ActivityLifecycleCallbacks
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.core.tools.service.AndroidDispatcher
|
import org.linphone.core.tools.service.AndroidDispatcher
|
||||||
|
|
||||||
|
@UiThread
|
||||||
class ActivityMonitor : ActivityLifecycleCallbacks {
|
class ActivityMonitor : ActivityLifecycleCallbacks {
|
||||||
private val activities = ArrayList<Activity>()
|
private val activities = ArrayList<Activity>()
|
||||||
private var mActive = false
|
private var mActive = false
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ package org.linphone.utils
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import androidx.lifecycle.LifecycleCoroutineScope
|
import androidx.lifecycle.LifecycleCoroutineScope
|
||||||
import androidx.transition.Slide
|
import androidx.transition.Slide
|
||||||
import androidx.transition.Transition
|
import androidx.transition.Transition
|
||||||
|
|
@ -31,6 +32,7 @@ import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
@UiThread
|
||||||
fun View.slideInToastFromTop(
|
fun View.slideInToastFromTop(
|
||||||
root: ViewGroup,
|
root: ViewGroup,
|
||||||
visible: Boolean
|
visible: Boolean
|
||||||
|
|
@ -45,6 +47,7 @@ fun View.slideInToastFromTop(
|
||||||
view.visibility = if (visible) View.VISIBLE else View.GONE
|
view.visibility = if (visible) View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiThread
|
||||||
fun View.slideInToastFromTopForDuration(
|
fun View.slideInToastFromTopForDuration(
|
||||||
root: ViewGroup,
|
root: ViewGroup,
|
||||||
lifecycleScope: LifecycleCoroutineScope,
|
lifecycleScope: LifecycleCoroutineScope,
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import android.graphics.drawable.Drawable
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
|
|
@ -39,6 +40,7 @@ import org.linphone.ui.voip.model.ZrtpSasConfirmationDialogModel
|
||||||
|
|
||||||
class DialogUtils {
|
class DialogUtils {
|
||||||
companion object {
|
companion object {
|
||||||
|
@UiThread
|
||||||
fun getNumberOrAddressPickerDialog(
|
fun getNumberOrAddressPickerDialog(
|
||||||
context: Context,
|
context: Context,
|
||||||
viewModel: NumberOrAddressPickerDialogModel
|
viewModel: NumberOrAddressPickerDialogModel
|
||||||
|
|
@ -68,6 +70,7 @@ class DialogUtils {
|
||||||
return dialog
|
return dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiThread
|
||||||
fun getRemoveAllCallLogsConfirmationDialog(
|
fun getRemoveAllCallLogsConfirmationDialog(
|
||||||
context: Context,
|
context: Context,
|
||||||
model: ConfirmationDialogModel
|
model: ConfirmationDialogModel
|
||||||
|
|
@ -97,6 +100,7 @@ class DialogUtils {
|
||||||
return dialog
|
return dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiThread
|
||||||
fun getCancelContactChangesConfirmationDialog(
|
fun getCancelContactChangesConfirmationDialog(
|
||||||
context: Context,
|
context: Context,
|
||||||
model: ConfirmationDialogModel
|
model: ConfirmationDialogModel
|
||||||
|
|
@ -126,6 +130,7 @@ class DialogUtils {
|
||||||
return dialog
|
return dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiThread
|
||||||
fun getZrtpSasConfirmationDialog(
|
fun getZrtpSasConfirmationDialog(
|
||||||
context: Context,
|
context: Context,
|
||||||
viewModel: ZrtpSasConfirmationDialogModel
|
viewModel: ZrtpSasConfirmationDialogModel
|
||||||
|
|
|
||||||
|
|
@ -19,19 +19,18 @@
|
||||||
*/
|
*/
|
||||||
package org.linphone.utils
|
package org.linphone.utils
|
||||||
|
|
||||||
|
import androidx.annotation.AnyThread
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class allows to limit the number of notification for an event.
|
* This class allows to limit the number of notification for an event.
|
||||||
* The first one to consume the event will stop the dispatch.
|
* The first one to consume the event will stop the dispatch.
|
||||||
*/
|
*/
|
||||||
open class Event<out T>(private val content: T) {
|
open class Event<out T> @AnyThread constructor(private val content: T) {
|
||||||
private val handled = AtomicBoolean(false)
|
private val handled = AtomicBoolean(false)
|
||||||
|
|
||||||
fun consumed(): Boolean {
|
@UiThread
|
||||||
return handled.get()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun consume(handleContent: (T) -> Unit) {
|
fun consume(handleContent: (T) -> Unit) {
|
||||||
if (!handled.get()) {
|
if (!handled.get()) {
|
||||||
handled.set(true)
|
handled.set(true)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import android.bluetooth.BluetoothAdapter
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
|
import androidx.annotation.AnyThread
|
||||||
import androidx.annotation.IntegerRes
|
import androidx.annotation.IntegerRes
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.emoji2.text.EmojiCompat
|
import androidx.emoji2.text.EmojiCompat
|
||||||
|
|
@ -38,10 +39,12 @@ import org.linphone.core.tools.Log
|
||||||
|
|
||||||
class LinphoneUtils {
|
class LinphoneUtils {
|
||||||
companion object {
|
companion object {
|
||||||
|
@AnyThread
|
||||||
fun getFirstLetter(displayName: String): String {
|
fun getFirstLetter(displayName: String): String {
|
||||||
return getInitials(displayName, 1)
|
return getInitials(displayName, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun getInitials(displayName: String, limit: Int = 2): String {
|
fun getInitials(displayName: String, limit: Int = 2): String {
|
||||||
if (displayName.isEmpty()) return ""
|
if (displayName.isEmpty()) return ""
|
||||||
|
|
||||||
|
|
@ -96,6 +99,7 @@ class LinphoneUtils {
|
||||||
return address.displayName ?: address.username ?: address.asString()
|
return address.displayName ?: address.username ?: address.asString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun isCallOutgoing(callState: Call.State): Boolean {
|
fun isCallOutgoing(callState: Call.State): Boolean {
|
||||||
return when (callState) {
|
return when (callState) {
|
||||||
Call.State.OutgoingInit, Call.State.OutgoingProgress, Call.State.OutgoingRinging, Call.State.OutgoingEarlyMedia -> true
|
Call.State.OutgoingInit, Call.State.OutgoingProgress, Call.State.OutgoingRinging, Call.State.OutgoingEarlyMedia -> true
|
||||||
|
|
@ -103,6 +107,7 @@ class LinphoneUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
@IntegerRes
|
@IntegerRes
|
||||||
fun getIconResId(callStatus: Status, callDir: Dir): Int {
|
fun getIconResId(callStatus: Status, callDir: Dir): Int {
|
||||||
return when (callStatus) {
|
return when (callStatus) {
|
||||||
|
|
@ -146,6 +151,7 @@ class LinphoneUtils {
|
||||||
return getChatRoomId(chatRoom.localAddress, chatRoom.peerAddress)
|
return getChatRoomId(chatRoom.localAddress, chatRoom.peerAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun getDeviceName(context: Context): String {
|
fun getDeviceName(context: Context): String {
|
||||||
var name = Settings.Global.getString(
|
var name = Settings.Global.getString(
|
||||||
context.contentResolver,
|
context.contentResolver,
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,11 @@ package org.linphone.utils
|
||||||
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
|
import androidx.annotation.AnyThread
|
||||||
|
|
||||||
class PhoneNumberUtils {
|
class PhoneNumberUtils {
|
||||||
companion object {
|
companion object {
|
||||||
|
@AnyThread
|
||||||
fun addressBookLabelTypeToVcardParamString(type: Int, default: String?): String {
|
fun addressBookLabelTypeToVcardParamString(type: Int, default: String?): String {
|
||||||
return when (type) {
|
return when (type) {
|
||||||
ContactsContract.CommonDataKinds.Phone.TYPE_ASSISTANT -> "assistant"
|
ContactsContract.CommonDataKinds.Phone.TYPE_ASSISTANT -> "assistant"
|
||||||
|
|
@ -51,12 +53,14 @@ class PhoneNumberUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun vcardParamStringToAddressBookLabel(resources: Resources, label: String): String {
|
fun vcardParamStringToAddressBookLabel(resources: Resources, label: String): String {
|
||||||
if (label.isEmpty()) return label
|
if (label.isEmpty()) return label
|
||||||
val type = labelToType(label)
|
val type = labelToType(label)
|
||||||
return ContactsContract.CommonDataKinds.Phone.getTypeLabel(resources, type, label).toString()
|
return ContactsContract.CommonDataKinds.Phone.getTypeLabel(resources, type, label).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
private fun labelToType(label: String): Int {
|
private fun labelToType(label: String): Int {
|
||||||
return when (label) {
|
return when (label) {
|
||||||
"assistant" -> ContactsContract.CommonDataKinds.Phone.TYPE_ASSISTANT
|
"assistant" -> ContactsContract.CommonDataKinds.Phone.TYPE_ASSISTANT
|
||||||
|
|
@ -84,10 +88,12 @@ class PhoneNumberUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun arePhoneNumberWeakEqual(number1: String, number2: String): Boolean {
|
fun arePhoneNumberWeakEqual(number1: String, number2: String): Boolean {
|
||||||
return trimPhoneNumber(number1) == trimPhoneNumber(number2)
|
return trimPhoneNumber(number1) == trimPhoneNumber(number2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
private fun trimPhoneNumber(phoneNumber: String): String {
|
private fun trimPhoneNumber(phoneNumber: String): String {
|
||||||
return phoneNumber.replace(" ", "")
|
return phoneNumber.replace(" ", "")
|
||||||
.replace("-", "")
|
.replace("-", "")
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,10 @@ package org.linphone.utils
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
|
import androidx.annotation.UiThread
|
||||||
import androidx.slidingpanelayout.widget.SlidingPaneLayout
|
import androidx.slidingpanelayout.widget.SlidingPaneLayout
|
||||||
|
|
||||||
|
@UiThread
|
||||||
class SlidingPaneBackPressedCallback(private val slidingPaneLayout: SlidingPaneLayout) :
|
class SlidingPaneBackPressedCallback(private val slidingPaneLayout: SlidingPaneLayout) :
|
||||||
OnBackPressedCallback(
|
OnBackPressedCallback(
|
||||||
slidingPaneLayout.isSlideable && slidingPaneLayout.isOpen
|
slidingPaneLayout.isSlideable && slidingPaneLayout.isOpen
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
package org.linphone.utils
|
package org.linphone.utils
|
||||||
|
|
||||||
|
import androidx.annotation.AnyThread
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.Format
|
import java.text.Format
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
|
@ -27,12 +28,14 @@ import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
|
|
||||||
class TimestampUtils {
|
class TimestampUtils {
|
||||||
companion object {
|
companion object {
|
||||||
|
@AnyThread
|
||||||
fun isToday(timestamp: Long, timestampInSecs: Boolean = true): Boolean {
|
fun isToday(timestamp: Long, timestampInSecs: Boolean = true): Boolean {
|
||||||
val cal = Calendar.getInstance()
|
val cal = Calendar.getInstance()
|
||||||
cal.timeInMillis = if (timestampInSecs) timestamp * 1000 else timestamp
|
cal.timeInMillis = if (timestampInSecs) timestamp * 1000 else timestamp
|
||||||
return isSameDay(cal, Calendar.getInstance())
|
return isSameDay(cal, Calendar.getInstance())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun isYesterday(timestamp: Long, timestampInSecs: Boolean = true): Boolean {
|
fun isYesterday(timestamp: Long, timestampInSecs: Boolean = true): Boolean {
|
||||||
val yesterday = Calendar.getInstance()
|
val yesterday = Calendar.getInstance()
|
||||||
yesterday.roll(Calendar.DAY_OF_MONTH, -1)
|
yesterday.roll(Calendar.DAY_OF_MONTH, -1)
|
||||||
|
|
@ -41,6 +44,7 @@ class TimestampUtils {
|
||||||
return isSameDay(cal, yesterday)
|
return isSameDay(cal, yesterday)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun isSameDay(timestamp1: Long, timestamp2: Long, timestampInSecs: Boolean = true): Boolean {
|
fun isSameDay(timestamp1: Long, timestamp2: Long, timestampInSecs: Boolean = true): Boolean {
|
||||||
val cal1 = Calendar.getInstance()
|
val cal1 = Calendar.getInstance()
|
||||||
cal1.timeInMillis = if (timestampInSecs) timestamp1 * 1000 else timestamp1
|
cal1.timeInMillis = if (timestampInSecs) timestamp1 * 1000 else timestamp1
|
||||||
|
|
@ -49,6 +53,7 @@ class TimestampUtils {
|
||||||
return isSameDay(cal1, cal2)
|
return isSameDay(cal1, cal2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun isSameDay(
|
fun isSameDay(
|
||||||
cal1: Date,
|
cal1: Date,
|
||||||
cal2: Date
|
cal2: Date
|
||||||
|
|
@ -56,6 +61,7 @@ class TimestampUtils {
|
||||||
return isSameDay(cal1.time, cal2.time, false)
|
return isSameDay(cal1.time, cal2.time, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun dateToString(date: Long, timestampInSecs: Boolean = true): String {
|
fun dateToString(date: Long, timestampInSecs: Boolean = true): String {
|
||||||
val dateFormat: Format = android.text.format.DateFormat.getDateFormat(
|
val dateFormat: Format = android.text.format.DateFormat.getDateFormat(
|
||||||
coreContext.context
|
coreContext.context
|
||||||
|
|
@ -71,6 +77,7 @@ class TimestampUtils {
|
||||||
return dateFormatter.format(calendar.time)
|
return dateFormatter.format(calendar.time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun timeToString(hour: Int, minutes: Int): String {
|
fun timeToString(hour: Int, minutes: Int): String {
|
||||||
val use24hFormat = android.text.format.DateFormat.is24HourFormat(
|
val use24hFormat = android.text.format.DateFormat.is24HourFormat(
|
||||||
coreContext.context
|
coreContext.context
|
||||||
|
|
@ -86,6 +93,7 @@ class TimestampUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun timeToString(time: Long, timestampInSecs: Boolean = true): String {
|
fun timeToString(time: Long, timestampInSecs: Boolean = true): String {
|
||||||
val use24hFormat = android.text.format.DateFormat.is24HourFormat(
|
val use24hFormat = android.text.format.DateFormat.is24HourFormat(
|
||||||
coreContext.context
|
coreContext.context
|
||||||
|
|
@ -100,6 +108,7 @@ class TimestampUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun durationToString(duration: Int): String {
|
fun durationToString(duration: Int): String {
|
||||||
val dateFormat = SimpleDateFormat(
|
val dateFormat = SimpleDateFormat(
|
||||||
if (duration >= 3600) "HH:mm:ss" else "mm:ss",
|
if (duration >= 3600) "HH:mm:ss" else "mm:ss",
|
||||||
|
|
@ -110,6 +119,7 @@ class TimestampUtils {
|
||||||
return dateFormat.format(cal.time)
|
return dateFormat.format(cal.time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun durationToString(hours: Int, minutes: Int): String {
|
fun durationToString(hours: Int, minutes: Int): String {
|
||||||
val calendar = Calendar.getInstance()
|
val calendar = Calendar.getInstance()
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, hours)
|
calendar.set(Calendar.HOUR_OF_DAY, hours)
|
||||||
|
|
@ -124,12 +134,14 @@ class TimestampUtils {
|
||||||
return SimpleDateFormat(pattern, Locale.getDefault()).format(calendar.time)
|
return SimpleDateFormat(pattern, Locale.getDefault()).format(calendar.time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
private fun isSameYear(timestamp: Long, timestampInSecs: Boolean = true): Boolean {
|
private fun isSameYear(timestamp: Long, timestampInSecs: Boolean = true): Boolean {
|
||||||
val cal = Calendar.getInstance()
|
val cal = Calendar.getInstance()
|
||||||
cal.timeInMillis = if (timestampInSecs) timestamp * 1000 else timestamp
|
cal.timeInMillis = if (timestampInSecs) timestamp * 1000 else timestamp
|
||||||
return isSameYear(cal, Calendar.getInstance())
|
return isSameYear(cal, Calendar.getInstance())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
fun toString(
|
fun toString(
|
||||||
timestamp: Long,
|
timestamp: Long,
|
||||||
onlyDate: Boolean = false,
|
onlyDate: Boolean = false,
|
||||||
|
|
@ -164,6 +176,7 @@ class TimestampUtils {
|
||||||
return dateFormat.format(Date(millis)).capitalize(Locale.getDefault())
|
return dateFormat.format(Date(millis)).capitalize(Locale.getDefault())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
private fun isSameDay(
|
private fun isSameDay(
|
||||||
cal1: Calendar,
|
cal1: Calendar,
|
||||||
cal2: Calendar
|
cal2: Calendar
|
||||||
|
|
@ -173,6 +186,7 @@ class TimestampUtils {
|
||||||
cal1[Calendar.DAY_OF_YEAR] == cal2[Calendar.DAY_OF_YEAR]
|
cal1[Calendar.DAY_OF_YEAR] == cal2[Calendar.DAY_OF_YEAR]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
private fun isSameYear(
|
private fun isSameYear(
|
||||||
cal1: Calendar,
|
cal1: Calendar,
|
||||||
cal2: Calendar
|
cal2: Calendar
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue