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

Commit 7a3c76fe authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

App lounge: Properly show PWA installation status and allow PWA to be started from App Lounge

parent 39a36280
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -68,6 +68,19 @@
            </intent-filter>
        </receiver>

        <receiver android:name=".receiver.PWAPlayerStatusReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="foundation.e.pwaplayer.PWA_ADDED" />
            </intent-filter>
            <intent-filter>
                <action android:name="foundation.e.pwaplayer.PWA_CHANGED" />
            </intent-filter>
            <intent-filter>
                <action android:name="foundation.e.pwaplayer.PWA_REMOVED" />
            </intent-filter>
        </receiver>

        <!-- If you want to disable android.startup completely. -->
        <provider
            android:name="androidx.startup.InitializationProvider"
+7 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import foundation.e.apps.manager.pkg.PkgManagerModule
import foundation.e.apps.utils.enums.Origin
import foundation.e.apps.utils.enums.Status
import foundation.e.apps.utils.enums.Type
import foundation.e.apps.utils.modules.PWAManagerModule
import foundation.e.apps.utils.modules.PreferenceManagerModule
import javax.inject.Inject
import javax.inject.Singleton
@@ -53,6 +54,7 @@ class FusedAPIImpl @Inject constructor(
    private val cleanAPKRepository: CleanAPKRepository,
    private val gPlayAPIRepository: GPlayAPIRepository,
    private val pkgManagerModule: PkgManagerModule,
    private val pwaManagerModule: PWAManagerModule,
    private val preferenceManagerModule: PreferenceManagerModule,
    @ApplicationContext private val context: Context
) {
@@ -643,10 +645,14 @@ class FusedAPIImpl @Inject constructor(

    private fun FusedApp.updateStatus() {
        if (this.status != Status.INSTALLATION_ISSUE) {
            this.status =
            this.status = if (this.is_pwa) {
                pwaManagerModule.getPwaStatus(this)
            }
            else {
                pkgManagerModule.getPackageStatus(this.package_name, this.latest_version_code)
            }
        }
    }

    private fun FusedApp.updateType() {
        this.type = if (this.is_pwa) Type.PWA else Type.NATIVE
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ data class FusedApp(
    val price: String = String(),
    val isFree: Boolean = true,
    val is_pwa: Boolean = false,
    var pwaPlayerDbId: Long = -1,
    val url: String = String(),
    var type: Type = Type.NATIVE,
    var privacyScore: Int = -1
+9 −1
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import foundation.e.apps.manager.pkg.PkgManagerModule
import foundation.e.apps.utils.enums.Origin
import foundation.e.apps.utils.enums.Status
import foundation.e.apps.utils.enums.User
import foundation.e.apps.utils.modules.PWAManagerModule
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject
@@ -74,6 +75,9 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) {
    @Inject
    lateinit var pkgManagerModule: PkgManagerModule

    @Inject
    lateinit var pwaManagerModule: PWAManagerModule

    private val applicationViewModel: ApplicationViewModel by viewModels()
    private val privacyInfoViewModel: PrivacyInfoViewModel by viewModels()
    private val fdroidFetchViewModel: FdroidFetchViewModel by viewModels()
@@ -462,10 +466,14 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) {
            backgroundTintList =
                ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                if (fusedApp.is_pwa) {
                    pwaManagerModule.launchPwa(fusedApp)
                } else {
                    startActivity(pkgManagerModule.getLaunchIntent(fusedApp.package_name))
                }
            }
        }
    }

    private suspend fun updateProgress(
        downloadProgress: DownloadProgress,
+5 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import foundation.e.apps.manager.download.data.DownloadProgress
import foundation.e.apps.manager.pkg.PkgManagerModule
import foundation.e.apps.utils.enums.Status
import foundation.e.apps.utils.enums.User
import foundation.e.apps.utils.modules.PWAManagerModule
import kotlinx.coroutines.launch
import javax.inject.Inject

@@ -56,6 +57,9 @@ class ApplicationListFragment : Fragment(R.layout.fragment_application_list), Fu
    @Inject
    lateinit var pkgManagerModule: PkgManagerModule

    @Inject
    lateinit var pwaManagerModule: PWAManagerModule

    private val viewModel: ApplicationListViewModel by viewModels()
    private val privacyInfoViewModel: PrivacyInfoViewModel by viewModels()
    private val fdroidFetchViewModel: FdroidFetchViewModel by viewModels()
@@ -111,6 +115,7 @@ class ApplicationListFragment : Fragment(R.layout.fragment_application_list), Fu
                    fdroidFetchViewModel,
                    it,
                    pkgManagerModule,
                    pwaManagerModule,
                    User.valueOf(mainActivityViewModel.userType.value ?: User.UNAVAILABLE.name),
                    viewLifecycleOwner
                ) { fusedApp ->
Loading