Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f9078dc authored by Hasib Prince's avatar Hasib Prince
Browse files

resolved conflict: merging release-1.8-rc to main

parents 214e5355 89920c78
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ plugins {

def versionMajor = 2
def versionMinor = 4
def versionPatch = 5
def versionPatch = 6

def getGitHash = { ->
    def stdOut = new ByteArrayOutputStream()
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
                UpdatesWorkManager.enqueueWork(
                    it,
                    newValue.toString().toLong(),
                    ExistingPeriodicWorkPolicy.KEEP
                    ExistingPeriodicWorkPolicy.REPLACE
                )
            }
            true
+13 −3
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), FusedAPIInte
    private fun handleStateNoUpdates(list: List<FusedApp>?) {
        if (!list.isNullOrEmpty()) {
            binding.button.isEnabled = true
            initUpdataAllButton()
            binding.noUpdates.visibility = View.GONE
        } else {
            binding.noUpdates.visibility = View.VISIBLE
@@ -177,7 +178,9 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), FusedAPIInte
            (
                workInfoList.isNullOrEmpty() ||
                    (
                        !updatesViewModel.checkWorkInfoListHasAnyUpdatableWork(workInfoList) &&
                        !updatesViewModel.checkWorkInfoListHasAnyUpdatableWork(
                            workInfoList
                        ) &&
                            updatesViewModel.hasAnyUpdatableApp()
                        )
                )
@@ -270,8 +273,13 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), FusedAPIInte
            clearAndRestartGPlayLogin()
            true
        }
        initUpdataAllButton()
    }

    private fun initUpdataAllButton() {
        binding.button.setOnClickListener {
            UpdatesWorkManager.startUpdateAllWork(requireContext().applicationContext)
            val interval = updatesViewModel.getUpdateInterval()
            UpdatesWorkManager.startUpdateAllWork(requireContext())
            observeUpdateWork()
            binding.button.isEnabled = false
        }
@@ -279,7 +287,7 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), FusedAPIInte

    private fun observeUpdateWork() {
        WorkManager.getInstance(requireContext())
            .getWorkInfosByTagLiveData(UpdatesWorkManager.UPDATES_WORK_NAME)
            .getWorkInfosByTagLiveData(UpdatesWorkManager.TAG)
            .observe(viewLifecycleOwner) {
                binding.button.isEnabled = hasAnyPendingUpdates(it)
            }
@@ -353,6 +361,8 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), FusedAPIInte
    }

    override fun onDestroyView() {
        mainActivityViewModel.downloadList.removeObservers(viewLifecycleOwner)
        isDownloadObserverAdded = false
        super.onDestroyView()
        _binding = null
    }
+5 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import foundation.e.apps.utils.enums.ResultStatus
import foundation.e.apps.utils.enums.Status
import foundation.e.apps.utils.exceptions.CleanApkException
import foundation.e.apps.utils.exceptions.GPlayException
import foundation.e.apps.utils.modules.PreferenceManagerModule
import foundation.e.apps.utils.parentFragment.LoadingViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject
@@ -38,7 +39,8 @@ import javax.inject.Inject
@HiltViewModel
class UpdatesViewModel @Inject constructor(
    private val updatesManagerRepository: UpdatesManagerRepository,
    private val fusedAPIRepository: FusedAPIRepository
    private val fusedAPIRepository: FusedAPIRepository,
    private val preferenceManagerModule: PreferenceManagerModule
) : LoadingViewModel() {

    val updatesList: MutableLiveData<Pair<List<FusedApp>, ResultStatus?>> = MutableLiveData()
@@ -133,4 +135,6 @@ class UpdatesViewModel @Inject constructor(
        )
        return updatesList.value?.first?.any { pendingStatesForUpdate.contains(it.status) } == true
    }

    fun getUpdateInterval() = preferenceManagerModule.getUpdateInterval()
}
+4 −9
Original line number Diff line number Diff line
@@ -20,9 +20,8 @@ package foundation.e.apps.updates.manager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import androidx.preference.PreferenceManager
import androidx.work.ExistingPeriodicWorkPolicy
import foundation.e.apps.R
import foundation.e.apps.utils.modules.PreferenceManagerModule
import timber.log.Timber

class UpdatesBroadcastReceiver : BroadcastReceiver() {
@@ -33,13 +32,9 @@ class UpdatesBroadcastReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        Timber.d("onReceive: ${intent.action}")
        if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
            val preferences = PreferenceManager.getDefaultSharedPreferences(context)
            val interval =
                preferences.getString(
                    context.getString(R.string.update_check_intervals),
                    context.getString(R.string.preference_update_interval_default)
                )!!.toLong()
            UpdatesWorkManager.enqueueWork(context, interval, ExistingPeriodicWorkPolicy.KEEP)
            val preferenceManagerModule = PreferenceManagerModule(context)
            val interval = preferenceManagerModule.getUpdateInterval()
            UpdatesWorkManager.enqueueWork(context, interval, ExistingPeriodicWorkPolicy.REPLACE)
        }
    }
}
Loading