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

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

App Lounge: handled declined purchase

parent 5076760a
Loading
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -203,9 +203,9 @@ class MainActivity : AppCompatActivity() {
            if (it.isNotEmpty()) {
                startInstallationOfPurchasedApp(viewModel, it)
                ApplicationDialogFragment(
                    title = "Purchase complete!",
                    message = "Your app will automatically be downloaded in this device",
                    positiveButtonText = "OK"
                    title = getString(R.string.purchase_complete),
                    message = getString(R.string.download_automatically_message),
                    positiveButtonText = getString(R.string.ok)
                ).show(supportFragmentManager, TAG)
            }
        }
@@ -253,7 +253,11 @@ class MainActivity : AppCompatActivity() {
            if (fusedDownload != null) {
                InstallWorkManager.enqueueWork(fusedDownload)
            } else {
                showSnackbarMessage(getString(R.string.paid_app_anonymous_message))
                ApplicationDialogFragment(
                    title = getString(R.string.purchase_error),
                    message = getString(R.string.something_went_wrong),
                    positiveButtonText = getString(R.string.ok)
                ).show(supportFragmentManager, TAG)
            }
        }
    }
+19 −4
Original line number Diff line number Diff line
@@ -188,12 +188,20 @@ class MainActivityViewModel @Inject constructor(
     *
     * Issue: https://gitlab.e.foundation/e/os/backlog/-/issues/178
     */
    fun checkUnsupportedApplication(fusedApp: FusedApp, alertDialogContext: Context? = null): Boolean {
    fun checkUnsupportedApplication(
        fusedApp: FusedApp,
        alertDialogContext: Context? = null
    ): Boolean {
        if (!fusedApp.isFree && fusedApp.price.isBlank()) {
            alertDialogContext?.let { context ->
                AlertDialog.Builder(context).apply {
                    setTitle(R.string.unsupported_app_title)
                    setMessage(context.getString(R.string.unsupported_app_unreleased, fusedApp.name))
                    setMessage(
                        context.getString(
                            R.string.unsupported_app_unreleased,
                            fusedApp.name
                        )
                    )
                    setPositiveButton(android.R.string.ok, null)
                }.show()
            }
@@ -288,6 +296,9 @@ class MainActivityViewModel @Inject constructor(
                        Origin.GPLAY,
                        fusedDownload
                    )
                } catch (e: ApiException.AppNotPurchased) {
                    Log.e(TAG, e.stackTraceToString())
                    return null
                } catch (e: Exception) {
                    Log.e(TAG, e.stackTraceToString())
                    _errorMessage.value = e
@@ -344,12 +355,16 @@ class MainActivityViewModel @Inject constructor(
        emitSource(ReactiveNetwork().observeInternetConnectivity().asLiveData(Dispatchers.Default))
    }

    fun updateStatusOfFusedApps(fusedAppList: List<FusedApp>, fusedDownloadList: List<FusedDownload>) {
    fun updateStatusOfFusedApps(
        fusedAppList: List<FusedApp>,
        fusedDownloadList: List<FusedDownload>
    ) {
        fusedAppList.forEach {
            val downloadingItem = fusedDownloadList.find { fusedDownload ->
                fusedDownload.origin == it.origin && (fusedDownload.packageName == it.package_name || fusedDownload.id == it._id)
            }
            it.status = downloadingItem?.status ?: fusedAPIRepository.getFusedAppInstallationStatus(it)
            it.status =
                downloadingItem?.status ?: fusedAPIRepository.getFusedAppInstallationStatus(it)
        }
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -105,6 +105,8 @@
    <string name="unknown_error">Unknown Error!</string>
    <string name="not_enough_storage">There is not enough space available to download this application!</string>
    <string name="app_not_found">Your application was not found.</string>
    <string name="something_went_wrong">Something went wrong!</string>


    <!-- Updates Fragment -->
    <string name="update_all">Update All</string>
@@ -160,6 +162,9 @@
    <string name="dialog_confirm">CONFIRM</string>
    <string name="dialog_cancel">CANCEL</string>
    <string name="paid_app_anonymous_message">Paid apps cannot be installed in anonymous mode. Please log into your Google account to install paid apps.</string>
    <string name="purchase_complete">Purchase complete!</string>
    <string name="download_automatically_message">Your app will automatically be downloaded in this device</string>
    <string name="purchase_error">Purchase error!</string>

    <!--Unsupported app-->
    <string name="unsupported_app_title">Unsupported app!</string>