Loading app/src/main/java/foundation/e/apps/install/workmanager/AppInstallProcessor.kt +17 −4 Original line number Diff line number Diff line Loading @@ -23,16 +23,16 @@ import com.aurora.gplayapi.exceptions.InternalException import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.R import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.Type import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.UpdatesDao import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.Type import foundation.e.apps.data.enums.User import foundation.e.apps.data.install.AppManager import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.playstore.utils.GplayHttpRequestException import foundation.e.apps.data.preference.AppLoungeDataStore import foundation.e.apps.domain.ValidateAppAgeLimitUseCase Loading Loading @@ -67,6 +67,9 @@ class AppInstallProcessor @Inject constructor( @Inject lateinit var downloadManager: DownloadManagerUtils @Inject lateinit var appManager: AppManager private var isItUpdateWork = false companion object { Loading Loading @@ -202,6 +205,10 @@ class AppInstallProcessor @Inject constructor( try { updateFusedDownloadWithAppDownloadLink(appInstall) } catch (e: InternalException.AppNotPurchased) { if (appInstall.isFree) { handleAppRestricted(appInstall) return false } appInstallComponents.appManagerWrapper.addFusedDownloadPurchaseNeeded(appInstall) EventBus.invokeEvent(AppEvent.AppPurchaseEvent(appInstall)) return false Loading @@ -225,6 +232,12 @@ class AppInstallProcessor @Inject constructor( return true } private suspend fun handleAppRestricted(appInstall: AppInstall) { EventBus.invokeEvent(AppEvent.AppRestrictedOrUnavailable(appInstall)) appManager.addDownload(appInstall) appManager.updateUnavailable(appInstall) } private suspend fun handleUpdateDownloadError( appInstall: AppInstall, message: String, Loading app/src/main/java/foundation/e/apps/ui/MainActivity.kt +14 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import foundation.e.apps.data.login.exceptions.GPlayValidationException import foundation.e.apps.databinding.ActivityMainBinding import foundation.e.apps.install.updates.UpdatesNotifier import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment import foundation.e.apps.ui.error.AppUnavailableDialogDirections import foundation.e.apps.ui.purchase.AppPurchaseFragmentDirections import foundation.e.apps.ui.settings.SettingsFragment import foundation.e.apps.ui.setup.signin.SignInViewModel Loading Loading @@ -227,6 +228,10 @@ class MainActivity : AppCompatActivity() { observeInvalidAuth() } launch { observeAppUnavailable() } launch { observeTooManyRequests() } Loading Loading @@ -508,6 +513,15 @@ class MainActivity : AppCompatActivity() { } } private suspend fun observeAppUnavailable() { EventBus.events.filterIsInstance<AppEvent.AppRestrictedOrUnavailable>() .collectLatest { event -> val appName = event.appInstall.name val action = AppUnavailableDialogDirections.actionGlobalAppUnavailable(appName) findNavController(R.id.fragment).navigate(action) } } private fun validatedAuthObject(appEvent: AppEvent) { val data = appEvent.data as String if (data.isNotBlank()) { Loading app/src/main/java/foundation/e/apps/ui/error/AppUnavailableDialog.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line package foundation.e.apps.ui.error import android.app.Dialog import android.os.Bundle import androidx.fragment.app.DialogFragment import com.google.android.material.dialog.MaterialAlertDialogBuilder import foundation.e.apps.R class AppUnavailableDialog : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return MaterialAlertDialogBuilder(requireContext()) .setTitle(R.string.app_unavailable_title) .setMessage(R.string.app_unavailable_description) .setCancelable(false) .setPositiveButton( android.R.string.ok, { dialog, _ -> dialog.dismiss() } ) .create() } } app/src/main/java/foundation/e/apps/utils/eventBus/AppEvent.kt +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ sealed class AppEvent(val data: Any) { class ErrorMessageEvent(stringResourceId: Int) : AppEvent(stringResourceId) class ErrorMessageDialogEvent(stringResourceId: Int) : AppEvent(stringResourceId) class AppPurchaseEvent(appInstall: AppInstall) : AppEvent(appInstall) class AppRestrictedOrUnavailable(val appInstall: AppInstall) : AppEvent(appInstall) class NoInternetEvent(isInternetAvailable: Boolean) : AppEvent(isInternetAvailable) class TooManyRequests : AppEvent(Unit) class AgeLimitRestrictionEvent( Loading app/src/main/res/navigation/navigation_resource.xml +12 −0 Original line number Diff line number Diff line Loading @@ -252,4 +252,16 @@ android:id="@+id/action_global_appPurchaseFragment" app:destination="@id/appPurchaseFragment" /> <dialog android:id="@+id/appUnavailable" android:name="foundation.e.apps.ui.error.AppUnavailableDialog" tools:label="app_unavailable"> <argument android:name="app_name" app:argType="string" /> </dialog> <action android:id="@+id/action_global_app_unavailable" app:destination="@id/appUnavailable" /> </navigation> Loading
app/src/main/java/foundation/e/apps/install/workmanager/AppInstallProcessor.kt +17 −4 Original line number Diff line number Diff line Loading @@ -23,16 +23,16 @@ import com.aurora.gplayapi.exceptions.InternalException import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.R import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.Type import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.UpdatesDao import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.Type import foundation.e.apps.data.enums.User import foundation.e.apps.data.install.AppManager import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.playstore.utils.GplayHttpRequestException import foundation.e.apps.data.preference.AppLoungeDataStore import foundation.e.apps.domain.ValidateAppAgeLimitUseCase Loading Loading @@ -67,6 +67,9 @@ class AppInstallProcessor @Inject constructor( @Inject lateinit var downloadManager: DownloadManagerUtils @Inject lateinit var appManager: AppManager private var isItUpdateWork = false companion object { Loading Loading @@ -202,6 +205,10 @@ class AppInstallProcessor @Inject constructor( try { updateFusedDownloadWithAppDownloadLink(appInstall) } catch (e: InternalException.AppNotPurchased) { if (appInstall.isFree) { handleAppRestricted(appInstall) return false } appInstallComponents.appManagerWrapper.addFusedDownloadPurchaseNeeded(appInstall) EventBus.invokeEvent(AppEvent.AppPurchaseEvent(appInstall)) return false Loading @@ -225,6 +232,12 @@ class AppInstallProcessor @Inject constructor( return true } private suspend fun handleAppRestricted(appInstall: AppInstall) { EventBus.invokeEvent(AppEvent.AppRestrictedOrUnavailable(appInstall)) appManager.addDownload(appInstall) appManager.updateUnavailable(appInstall) } private suspend fun handleUpdateDownloadError( appInstall: AppInstall, message: String, Loading
app/src/main/java/foundation/e/apps/ui/MainActivity.kt +14 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import foundation.e.apps.data.login.exceptions.GPlayValidationException import foundation.e.apps.databinding.ActivityMainBinding import foundation.e.apps.install.updates.UpdatesNotifier import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment import foundation.e.apps.ui.error.AppUnavailableDialogDirections import foundation.e.apps.ui.purchase.AppPurchaseFragmentDirections import foundation.e.apps.ui.settings.SettingsFragment import foundation.e.apps.ui.setup.signin.SignInViewModel Loading Loading @@ -227,6 +228,10 @@ class MainActivity : AppCompatActivity() { observeInvalidAuth() } launch { observeAppUnavailable() } launch { observeTooManyRequests() } Loading Loading @@ -508,6 +513,15 @@ class MainActivity : AppCompatActivity() { } } private suspend fun observeAppUnavailable() { EventBus.events.filterIsInstance<AppEvent.AppRestrictedOrUnavailable>() .collectLatest { event -> val appName = event.appInstall.name val action = AppUnavailableDialogDirections.actionGlobalAppUnavailable(appName) findNavController(R.id.fragment).navigate(action) } } private fun validatedAuthObject(appEvent: AppEvent) { val data = appEvent.data as String if (data.isNotBlank()) { Loading
app/src/main/java/foundation/e/apps/ui/error/AppUnavailableDialog.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line package foundation.e.apps.ui.error import android.app.Dialog import android.os.Bundle import androidx.fragment.app.DialogFragment import com.google.android.material.dialog.MaterialAlertDialogBuilder import foundation.e.apps.R class AppUnavailableDialog : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return MaterialAlertDialogBuilder(requireContext()) .setTitle(R.string.app_unavailable_title) .setMessage(R.string.app_unavailable_description) .setCancelable(false) .setPositiveButton( android.R.string.ok, { dialog, _ -> dialog.dismiss() } ) .create() } }
app/src/main/java/foundation/e/apps/utils/eventBus/AppEvent.kt +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ sealed class AppEvent(val data: Any) { class ErrorMessageEvent(stringResourceId: Int) : AppEvent(stringResourceId) class ErrorMessageDialogEvent(stringResourceId: Int) : AppEvent(stringResourceId) class AppPurchaseEvent(appInstall: AppInstall) : AppEvent(appInstall) class AppRestrictedOrUnavailable(val appInstall: AppInstall) : AppEvent(appInstall) class NoInternetEvent(isInternetAvailable: Boolean) : AppEvent(isInternetAvailable) class TooManyRequests : AppEvent(Unit) class AgeLimitRestrictionEvent( Loading
app/src/main/res/navigation/navigation_resource.xml +12 −0 Original line number Diff line number Diff line Loading @@ -252,4 +252,16 @@ android:id="@+id/action_global_appPurchaseFragment" app:destination="@id/appPurchaseFragment" /> <dialog android:id="@+id/appUnavailable" android:name="foundation.e.apps.ui.error.AppUnavailableDialog" tools:label="app_unavailable"> <argument android:name="app_name" app:argType="string" /> </dialog> <action android:id="@+id/action_global_app_unavailable" app:destination="@id/appUnavailable" /> </navigation>