mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-05-01 12:26:26 +00:00
Refresh lists content when going back from background after at least 1 hour (when keep alive service is enabled)
This commit is contained in:
parent
903aaad6fe
commit
80eaf08fbf
4 changed files with 32 additions and 0 deletions
|
|
@ -346,6 +346,11 @@ class ConversationsListFragment : AbstractMainFragment() {
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
Log.e("$TAG Failed to unregister data observer to adapter: $e")
|
Log.e("$TAG Failed to unregister data observer to adapter: $e")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldRefreshDataInOnResume()) {
|
||||||
|
Log.i("$TAG Keep app alive setting is enabled, refreshing view just in case")
|
||||||
|
listViewModel.filter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import androidx.navigation.fragment.findNavController
|
||||||
import androidx.slidingpanelayout.widget.SlidingPaneLayout
|
import androidx.slidingpanelayout.widget.SlidingPaneLayout
|
||||||
import androidx.slidingpanelayout.widget.SlidingPaneLayout.PanelSlideListener
|
import androidx.slidingpanelayout.widget.SlidingPaneLayout.PanelSlideListener
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.databinding.BottomNavBarBinding
|
import org.linphone.databinding.BottomNavBarBinding
|
||||||
|
|
@ -55,6 +56,8 @@ import org.linphone.utils.showKeyboard
|
||||||
abstract class AbstractMainFragment : GenericMainFragment() {
|
abstract class AbstractMainFragment : GenericMainFragment() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "[Abstract Main Fragment]"
|
private const val TAG = "[Abstract Main Fragment]"
|
||||||
|
|
||||||
|
private const val TIME_MS_AFTER_WHICH_REFRESH_DATA_ON_RESUME = 3600000 // 1 hour
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val outlineProvider = object : ViewOutlineProvider() {
|
protected val outlineProvider = object : ViewOutlineProvider() {
|
||||||
|
|
@ -65,6 +68,8 @@ abstract class AbstractMainFragment : GenericMainFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected var lastOnPauseTimestamp: Long = -1L
|
||||||
|
|
||||||
private var currentFragmentId: Int = 0
|
private var currentFragmentId: Int = 0
|
||||||
|
|
||||||
private lateinit var viewModel: AbstractMainViewModel
|
private lateinit var viewModel: AbstractMainViewModel
|
||||||
|
|
@ -96,9 +101,21 @@ abstract class AbstractMainFragment : GenericMainFragment() {
|
||||||
backPressedCallback
|
backPressedCallback
|
||||||
)
|
)
|
||||||
|
|
||||||
|
lastOnPauseTimestamp = -1
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
lastOnPauseTimestamp = System.currentTimeMillis()
|
||||||
|
super.onPause()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun shouldRefreshDataInOnResume(): Boolean {
|
||||||
|
if (lastOnPauseTimestamp == -1L) return false
|
||||||
|
if (!corePreferences.keepServiceAlive) return false
|
||||||
|
return System.currentTimeMillis() - lastOnPauseTimestamp > TIME_MS_AFTER_WHICH_REFRESH_DATA_ON_RESUME
|
||||||
|
}
|
||||||
|
|
||||||
fun setViewModel(abstractMainViewModel: AbstractMainViewModel) {
|
fun setViewModel(abstractMainViewModel: AbstractMainViewModel) {
|
||||||
(view?.parent as? ViewGroup)?.doOnPreDraw {
|
(view?.parent as? ViewGroup)?.doOnPreDraw {
|
||||||
startPostponedEnterTransition()
|
startPostponedEnterTransition()
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,11 @@ class HistoryListFragment : AbstractMainFragment() {
|
||||||
Log.i("$TAG Fragment is resumed, resetting missed calls count")
|
Log.i("$TAG Fragment is resumed, resetting missed calls count")
|
||||||
sharedViewModel.resetMissedCallsCountEvent.value = Event(true)
|
sharedViewModel.resetMissedCallsCountEvent.value = Event(true)
|
||||||
sharedViewModel.refreshDrawerMenuAccountsListEvent.value = Event(false)
|
sharedViewModel.refreshDrawerMenuAccountsListEvent.value = Event(false)
|
||||||
|
|
||||||
|
if (shouldRefreshDataInOnResume()) {
|
||||||
|
Log.i("$TAG Keep app alive setting is enabled, refreshing view just in case")
|
||||||
|
listViewModel.filter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun copyNumberOrAddressToClipboard(value: String) {
|
private fun copyNumberOrAddressToClipboard(value: String) {
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,11 @@ class MeetingsListFragment : AbstractMainFragment() {
|
||||||
Log.e("$TAG Failed to register data observer to adapter: $e")
|
Log.e("$TAG Failed to register data observer to adapter: $e")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldRefreshDataInOnResume()) {
|
||||||
|
Log.i("$TAG Keep app alive setting is enabled, refreshing view just in case")
|
||||||
|
listViewModel.filter()
|
||||||
|
}
|
||||||
|
|
||||||
goToContactsIfMeetingsAreDisabledForCurrentlyDefaultAccount()
|
goToContactsIfMeetingsAreDisabledForCurrentlyDefaultAccount()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue