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

Commit b5d181fc authored by Hasib Prince's avatar Hasib Prince
Browse files

App Lounge: Merging 5459-show_percentage -> main

parents be68e73d f8448a52
Loading
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -277,8 +277,6 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
            if (appInfoFetchViewModel.isAppInBlockedList(it)) {
                binding.snackbarLayout.visibility = View.VISIBLE
            }

            observeDownloadStatus(view)
            fetchAppTracker(it)
        }

@@ -373,6 +371,11 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        }
    }

    override fun onResume() {
        super.onResume()
        observeDownloadStatus(binding.root)
    }

    private fun handleInstallingIssue(
        installButton: MaterialButton,
        fusedApp: FusedApp,
+4 −4
Original line number Diff line number Diff line
@@ -150,10 +150,6 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li
            layoutManager = LinearLayoutManager(view?.context)
        }

        appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) {
            updateProgressOfDownloadingItems(recyclerView, it)
        }

        viewModel.appListLiveData.observe(viewLifecycleOwner) {
            listAdapter?.setData(it.first)
            if (!isDownloadObserverAdded) {
@@ -226,6 +222,10 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li
                }
            })
        }

        appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) {
            updateProgressOfDownloadingItems(binding.recyclerView, it)
        }
    }

    private fun showLoadingUI() {
+5 −5
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import javax.inject.Inject
@AndroidEntryPoint
class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface {

    private lateinit var homeParentRVAdapter: HomeParentRVAdapter
    private var _binding: FragmentHomeBinding? = null
    private val binding get() = _binding!!

@@ -126,7 +127,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface
            refreshDataOrRefreshToken(mainActivityViewModel)
        }

        val homeParentRVAdapter = HomeParentRVAdapter(
        homeParentRVAdapter = HomeParentRVAdapter(
            this,
            pkgManagerModule,
            pwaManagerModule,
@@ -160,10 +161,6 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface
                onTimeout()
            }
        }

        appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) {
            updateProgressOfDownloadingAppItemViews(homeParentRVAdapter, it)
        }
    }

    override fun onTimeout() {
@@ -259,6 +256,9 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), FusedAPIInterface
        super.onResume()
        resetTimeoutDialogLock()
        binding.shimmerLayout.startShimmer()
        appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) {
            updateProgressOfDownloadingAppItemViews(homeParentRVAdapter, it)
        }
    }

    override fun onPause() {
+3 −5
Original line number Diff line number Diff line
@@ -31,12 +31,11 @@ class DownloadProgressLD @Inject constructor(
    override fun observe(owner: LifecycleOwner, observer: Observer<in DownloadProgress>) {
        job = Job()
        super.observe(owner, observer)
    }

    override fun onActive() {
        super.onActive()
        val hasActiveObservers = hasActiveObservers()

        launch {
            while (isActive) {
            while (hasActiveObservers) {
                val downloads = fusedManagerRepository.getDownloadList()
                val downloadingList =
                    downloads.map { it.downloadIdMap }.filter { it.values.contains(false) }
@@ -80,7 +79,6 @@ class DownloadProgressLD @Inject constructor(
                                }

                                if (downloadingIds.isEmpty()) {
                                    clearDownload()
                                    cancel()
                                }
                                cursor.moveToNext()
+27 −21
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import foundation.e.apps.api.fused.data.FusedApp
import foundation.e.apps.application.subFrags.ApplicationDialogFragment
import foundation.e.apps.applicationlist.model.ApplicationListRVAdapter
import foundation.e.apps.databinding.FragmentSearchBinding
import foundation.e.apps.manager.download.data.DownloadProgress
import foundation.e.apps.manager.pkg.PkgManagerModule
import foundation.e.apps.utils.enums.ResultStatus
import foundation.e.apps.utils.enums.Status
@@ -159,28 +160,9 @@ class SearchFragment :
            layoutManager = LinearLayoutManager(view.context)
        }

        appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) {
            val adapter = recyclerView?.adapter as ApplicationListRVAdapter
            lifecycleScope.launch {
                adapter.currentList.forEach { fusedApp ->
                    if (fusedApp.status == Status.DOWNLOADING) {
                        val progress = appProgressViewModel.calculateProgress(fusedApp, it)
                        val downloadProgress =
                            ((progress.second / progress.first.toDouble()) * 100).toInt()
                        val viewHolder = recyclerView?.findViewHolderForAdapterPosition(
                            adapter.currentList.indexOf(fusedApp)
                        )
                        viewHolder?.let {
                            (viewHolder as ApplicationListRVAdapter.ViewHolder).binding.installButton.text =
                                "$downloadProgress%"
                        }
                    }
                }
            }
        }

        mainActivityViewModel.downloadList.observe(viewLifecycleOwner) { list ->
            val searchList = searchViewModel.searchResult.value?.first?.toMutableList() ?: emptyList()
            val searchList =
                searchViewModel.searchResult.value?.first?.toMutableList() ?: emptyList()
            searchList.let {
                mainActivityViewModel.updateStatusOfFusedApps(searchList, list)
            }
@@ -269,10 +251,34 @@ class SearchFragment :
        binding.recyclerView.visibility = View.VISIBLE
    }

    private fun updateProgressOfInstallingApps(downloadProgress: DownloadProgress) {
        val adapter = recyclerView?.adapter as ApplicationListRVAdapter
        lifecycleScope.launch {
            adapter.currentList.forEach { fusedApp ->
                if (fusedApp.status == Status.DOWNLOADING) {
                    val progress =
                        appProgressViewModel.calculateProgress(fusedApp, downloadProgress)
                    val downloadProgress =
                        ((progress.second / progress.first.toDouble()) * 100).toInt()
                    val viewHolder = recyclerView?.findViewHolderForAdapterPosition(
                        adapter.currentList.indexOf(fusedApp)
                    )
                    viewHolder?.let {
                        (viewHolder as ApplicationListRVAdapter.ViewHolder).binding.installButton.text =
                            "$downloadProgress%"
                    }
                }
            }
        }
    }

    override fun onResume() {
        super.onResume()
        resetTimeoutDialogLock()
        binding.shimmerLayout.startShimmer()
        appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) {
            updateProgressOfInstallingApps(it)
        }
    }

    override fun onPause() {
Loading