Use simpler names for event handling methods

This commit is contained in:
Rahul Patel
2024-07-12 21:52:05 +05:30
parent 0af93474ed
commit e49d838377
15 changed files with 21 additions and 22 deletions

View File

@@ -58,7 +58,7 @@ class AuroraApp : Application(), Configuration.Provider {
private set
val enqueuedInstalls: MutableSet<String> = mutableSetOf()
val flowEvent = FlowEvent()
val events = FlowEvent()
}
override fun onCreate() {

View File

@@ -19,7 +19,7 @@ class FlowEvent {
private val _authEvent = MutableSharedFlow<AuthEvent>(extraBufferCapacity = 1)
val authEvent = _authEvent.asSharedFlow()
fun emitEvent(event: Event) {
fun send(event: Event) {
when (event) {
is InstallerEvent -> _installerEvent.tryEmit(event)
is BusEvent -> _busEvent.tryEmit(event)

View File

@@ -71,7 +71,7 @@ abstract class InstallerBase(protected var context: Context) : IInstaller {
this.extra = extra ?: ""
}
AuroraApp.flowEvent.emitEvent(event)
AuroraApp.events.send(event)
}
open fun getFiles(

View File

@@ -108,7 +108,7 @@ class RootInstaller @Inject constructor(
this.extra = context.getString(R.string.installer_status_failure)
this.error = parseError(shellResult)
}
AuroraApp.flowEvent.emitEvent(event)
AuroraApp.events.send(event)
}
} else {
removeFromInstallQueue(packageName)

View File

@@ -218,7 +218,7 @@ class ServiceInstaller @Inject constructor(
try {
when (returnCode) {
PackageInstaller.STATUS_SUCCESS -> {
AuroraApp.flowEvent.emitEvent(
AuroraApp.events.send(
InstallerEvent.Uninstalled(packageName).apply {
this.extra = context.getString(R.string.action_uninstall_success)
}
@@ -248,7 +248,7 @@ class ServiceInstaller @Inject constructor(
try {
when (returnCode) {
PackageInstaller.STATUS_SUCCESS -> {
AuroraApp.flowEvent.emitEvent(
AuroraApp.events.send(
InstallerEvent.Installed(packageName).apply {
this.extra = context.getString(R.string.installer_status_success)
}

View File

@@ -79,7 +79,7 @@ class SessionInstaller @Inject constructor(
?.packageName
if (packageName != null && progress > 0.0) {
AuroraApp.flowEvent.emitEvent(
AuroraApp.events.send(
InstallerEvent.Installing(packageName).apply {
this.progress = (progress * 100).toInt()
}

View File

@@ -132,6 +132,6 @@ class InstallerStatusReceiver : BroadcastReceiver() {
}
}
}
AuroraApp.flowEvent.emitEvent(event)
AuroraApp.events.send(event)
}
}

View File

@@ -40,11 +40,11 @@ open class PackageManagerReceiver : BroadcastReceiver() {
when (intent.action) {
Intent.ACTION_PACKAGE_ADDED -> {
AuroraApp.flowEvent.emitEvent(InstallerEvent.Installed(packageName))
AuroraApp.events.send(InstallerEvent.Installed(packageName))
}
Intent.ACTION_PACKAGE_REMOVED -> {
AuroraApp.flowEvent.emitEvent(InstallerEvent.Uninstalled(packageName))
AuroraApp.events.send(InstallerEvent.Uninstalled(packageName))
}
}

View File

@@ -110,7 +110,7 @@ class GoogleFragment : BaseFragment<FragmentGoogleBinding>() {
}
viewLifecycleOwner.lifecycleScope.launch {
AuroraApp.flowEvent.authEvent.collect { onEventReceived(it) }
AuroraApp.events.authEvent.collect { onEventReceived(it) }
}
}

View File

@@ -75,7 +75,7 @@ class InstalledAppsFragment : BaseFragment<FragmentAppsBinding>() {
}
viewLifecycleOwner.lifecycleScope.launch {
AuroraApp.flowEvent.busEvent.collect { onEvent(it) }
AuroraApp.events.busEvent.collect { onEvent(it) }
}
}

View File

@@ -69,7 +69,6 @@ import com.aurora.store.data.model.ViewState.Loading.getDataAs
import com.aurora.store.data.providers.AuthProvider
import com.aurora.store.databinding.FragmentDetailsBinding
import com.aurora.store.util.CommonUtil
import com.aurora.store.util.Log
import com.aurora.store.util.PackageUtil
import com.aurora.store.util.PathUtil
import com.aurora.store.util.Preferences
@@ -366,10 +365,10 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
}
viewLifecycleOwner.lifecycleScope.launch {
AuroraApp.flowEvent.busEvent.collect { onEvent(it) }
AuroraApp.events.busEvent.collect { onEvent(it) }
}
viewLifecycleOwner.lifecycleScope.launch {
AuroraApp.flowEvent.installerEvent.collect { onEvent(it) }
AuroraApp.events.installerEvent.collect { onEvent(it) }
}
}

View File

@@ -94,7 +94,7 @@ class AppMenuSheet : BaseDialogSheet<SheetAppMenuBinding>() {
}
dismissAllowingStateLoss()
AuroraApp.flowEvent.emitEvent(
AuroraApp.events.send(
BusEvent.Blacklisted(args.app.packageName)
)
}

View File

@@ -144,7 +144,7 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
}
viewLifecycleOwner.lifecycleScope.launch {
AuroraApp.flowEvent.busEvent.collect { onEvent(it) }
AuroraApp.events.busEvent.collect { onEvent(it) }
}
}

View File

@@ -201,18 +201,18 @@ class AuthViewModel @Inject constructor(
if (aasToken != null) {
Preferences.putString(context, Constants.ACCOUNT_EMAIL_PLAIN, email)
Preferences.putString(context, Constants.ACCOUNT_AAS_PLAIN, aasToken)
AuroraApp.flowEvent.emitEvent(AuthEvent.GoogleLogin(true, email, aasToken))
AuroraApp.events.send(AuthEvent.GoogleLogin(true, email, aasToken))
} else {
Preferences.putString(context, Constants.ACCOUNT_EMAIL_PLAIN, "")
Preferences.putString(context, Constants.ACCOUNT_AAS_PLAIN, "")
AuroraApp.flowEvent.emitEvent(AuthEvent.GoogleLogin(false, "", ""))
AuroraApp.events.send(AuthEvent.GoogleLogin(false, "", ""))
}
} else {
AuroraApp.flowEvent.emitEvent(AuthEvent.GoogleLogin(false, "", ""))
AuroraApp.events.send(AuthEvent.GoogleLogin(false, "", ""))
}
} catch (exception: Exception) {
Log.e(TAG, "Failed to build AuthData", exception)
AuroraApp.flowEvent.emitEvent(AuthEvent.GoogleLogin(false, "", ""))
AuroraApp.events.send(AuthEvent.GoogleLogin(false, "", ""))
}
}
}

View File

@@ -35,7 +35,7 @@ class SheetsViewModel @Inject constructor(
val purchaseHelper = PurchaseHelper(authProvider.authData)
val files = purchaseHelper.purchase(app.packageName, customVersion, app.offerType)
if (files.isNotEmpty()) {
AuroraApp.flowEvent.emitEvent(
AuroraApp.events.send(
BusEvent.ManualDownload(app.packageName, customVersion)
)
}