Loading app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerBR.kt +9 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,9 @@ import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.api.faultyApps.FaultyAppRepository import foundation.e.apps.manager.fused.FusedManagerRepository import foundation.e.apps.utils.enums.Status import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.* import timber.log.Timber import javax.inject.Inject import javax.inject.Named Loading Loading @@ -68,10 +67,16 @@ open class PkgManagerBR : BroadcastReceiver() { Intent.ACTION_PACKAGE_ADDED -> { updateDownloadStatus(pkgName) removeFaultyAppByPackageName(pkgName) MainScope().launch { EventBus.invokeEvent(AppEvent.AppStatusUpdated()) } } Intent.ACTION_PACKAGE_REMOVED -> { if (!isUpdating) deleteDownload(pkgName) removeFaultyAppByPackageName(pkgName) MainScope().launch { EventBus.invokeEvent(AppEvent.AppStatusUpdated()) } } PkgManagerModule.ERROR_PACKAGE_INSTALL -> { Timber.e("Installation failed due to error: $extra") Loading app/src/main/java/foundation/e/apps/utils/eventBus/AppEvent.kt +1 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,5 @@ package foundation.e.apps.utils.eventBus sealed class AppEvent(val data: Any) { class SignatureMissMatchError(packageName: String) : AppEvent(packageName) class AppStatusUpdated: AppEvent("") } app/src/main/java/foundation/e/apps/utils/parentFragment/TimeoutFragment.kt +22 −2 Original line number Diff line number Diff line Loading @@ -18,13 +18,21 @@ package foundation.e.apps.utils.parentFragment import android.app.Activity import android.os.Bundle import android.view.KeyEvent import android.view.View import androidx.annotation.LayoutRes import androidx.appcompat.app.AlertDialog import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.MainActivityViewModel import foundation.e.apps.R import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.filter import timber.log.Timber /* * Parent class (extending fragment) for fragments which can display a timeout dialog Loading @@ -40,6 +48,16 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { */ private var timeoutAlertDialog: AlertDialog? = null override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) lifecycleScope.launchWhenResumed { EventBus.events.filter { appEvent -> appEvent is AppEvent.AppStatusUpdated } .collectLatest { Timber.d("@@@ app status updated") } } } abstract fun onTimeout() /* Loading Loading @@ -182,7 +200,8 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { */ try { timeoutAlertDialog?.dismiss() } catch (_: Exception) {} } catch (_: Exception) { } timeoutAlertDialog = timeoutAlertDialogBuilder.create() timeoutAlertDialog?.show() Loading Loading @@ -210,7 +229,8 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { if (isTimeoutDialogDisplayed()) { try { timeoutAlertDialog?.dismiss() } catch (_: Exception) {} } catch (_: Exception) { } } } } Loading
app/src/main/java/foundation/e/apps/manager/pkg/PkgManagerBR.kt +9 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,9 @@ import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.api.faultyApps.FaultyAppRepository import foundation.e.apps.manager.fused.FusedManagerRepository import foundation.e.apps.utils.enums.Status import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.* import timber.log.Timber import javax.inject.Inject import javax.inject.Named Loading Loading @@ -68,10 +67,16 @@ open class PkgManagerBR : BroadcastReceiver() { Intent.ACTION_PACKAGE_ADDED -> { updateDownloadStatus(pkgName) removeFaultyAppByPackageName(pkgName) MainScope().launch { EventBus.invokeEvent(AppEvent.AppStatusUpdated()) } } Intent.ACTION_PACKAGE_REMOVED -> { if (!isUpdating) deleteDownload(pkgName) removeFaultyAppByPackageName(pkgName) MainScope().launch { EventBus.invokeEvent(AppEvent.AppStatusUpdated()) } } PkgManagerModule.ERROR_PACKAGE_INSTALL -> { Timber.e("Installation failed due to error: $extra") Loading
app/src/main/java/foundation/e/apps/utils/eventBus/AppEvent.kt +1 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,5 @@ package foundation.e.apps.utils.eventBus sealed class AppEvent(val data: Any) { class SignatureMissMatchError(packageName: String) : AppEvent(packageName) class AppStatusUpdated: AppEvent("") }
app/src/main/java/foundation/e/apps/utils/parentFragment/TimeoutFragment.kt +22 −2 Original line number Diff line number Diff line Loading @@ -18,13 +18,21 @@ package foundation.e.apps.utils.parentFragment import android.app.Activity import android.os.Bundle import android.view.KeyEvent import android.view.View import androidx.annotation.LayoutRes import androidx.appcompat.app.AlertDialog import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.MainActivityViewModel import foundation.e.apps.R import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.filter import timber.log.Timber /* * Parent class (extending fragment) for fragments which can display a timeout dialog Loading @@ -40,6 +48,16 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { */ private var timeoutAlertDialog: AlertDialog? = null override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) lifecycleScope.launchWhenResumed { EventBus.events.filter { appEvent -> appEvent is AppEvent.AppStatusUpdated } .collectLatest { Timber.d("@@@ app status updated") } } } abstract fun onTimeout() /* Loading Loading @@ -182,7 +200,8 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { */ try { timeoutAlertDialog?.dismiss() } catch (_: Exception) {} } catch (_: Exception) { } timeoutAlertDialog = timeoutAlertDialogBuilder.create() timeoutAlertDialog?.show() Loading Loading @@ -210,7 +229,8 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { if (isTimeoutDialogDisplayed()) { try { timeoutAlertDialog?.dismiss() } catch (_: Exception) {} } catch (_: Exception) { } } } }