Use simpler names for event handling methods
This commit is contained in:
@@ -58,7 +58,7 @@ class AuroraApp : Application(), Configuration.Provider {
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
val enqueuedInstalls: MutableSet<String> = mutableSetOf()
|
val enqueuedInstalls: MutableSet<String> = mutableSetOf()
|
||||||
val flowEvent = FlowEvent()
|
val events = FlowEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class FlowEvent {
|
|||||||
private val _authEvent = MutableSharedFlow<AuthEvent>(extraBufferCapacity = 1)
|
private val _authEvent = MutableSharedFlow<AuthEvent>(extraBufferCapacity = 1)
|
||||||
val authEvent = _authEvent.asSharedFlow()
|
val authEvent = _authEvent.asSharedFlow()
|
||||||
|
|
||||||
fun emitEvent(event: Event) {
|
fun send(event: Event) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is InstallerEvent -> _installerEvent.tryEmit(event)
|
is InstallerEvent -> _installerEvent.tryEmit(event)
|
||||||
is BusEvent -> _busEvent.tryEmit(event)
|
is BusEvent -> _busEvent.tryEmit(event)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ abstract class InstallerBase(protected var context: Context) : IInstaller {
|
|||||||
this.extra = extra ?: ""
|
this.extra = extra ?: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
AuroraApp.flowEvent.emitEvent(event)
|
AuroraApp.events.send(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun getFiles(
|
open fun getFiles(
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class RootInstaller @Inject constructor(
|
|||||||
this.extra = context.getString(R.string.installer_status_failure)
|
this.extra = context.getString(R.string.installer_status_failure)
|
||||||
this.error = parseError(shellResult)
|
this.error = parseError(shellResult)
|
||||||
}
|
}
|
||||||
AuroraApp.flowEvent.emitEvent(event)
|
AuroraApp.events.send(event)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
removeFromInstallQueue(packageName)
|
removeFromInstallQueue(packageName)
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ class ServiceInstaller @Inject constructor(
|
|||||||
try {
|
try {
|
||||||
when (returnCode) {
|
when (returnCode) {
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
AuroraApp.flowEvent.emitEvent(
|
AuroraApp.events.send(
|
||||||
InstallerEvent.Uninstalled(packageName).apply {
|
InstallerEvent.Uninstalled(packageName).apply {
|
||||||
this.extra = context.getString(R.string.action_uninstall_success)
|
this.extra = context.getString(R.string.action_uninstall_success)
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,7 @@ class ServiceInstaller @Inject constructor(
|
|||||||
try {
|
try {
|
||||||
when (returnCode) {
|
when (returnCode) {
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
AuroraApp.flowEvent.emitEvent(
|
AuroraApp.events.send(
|
||||||
InstallerEvent.Installed(packageName).apply {
|
InstallerEvent.Installed(packageName).apply {
|
||||||
this.extra = context.getString(R.string.installer_status_success)
|
this.extra = context.getString(R.string.installer_status_success)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class SessionInstaller @Inject constructor(
|
|||||||
?.packageName
|
?.packageName
|
||||||
|
|
||||||
if (packageName != null && progress > 0.0) {
|
if (packageName != null && progress > 0.0) {
|
||||||
AuroraApp.flowEvent.emitEvent(
|
AuroraApp.events.send(
|
||||||
InstallerEvent.Installing(packageName).apply {
|
InstallerEvent.Installing(packageName).apply {
|
||||||
this.progress = (progress * 100).toInt()
|
this.progress = (progress * 100).toInt()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,6 @@ class InstallerStatusReceiver : BroadcastReceiver() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AuroraApp.flowEvent.emitEvent(event)
|
AuroraApp.events.send(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ open class PackageManagerReceiver : BroadcastReceiver() {
|
|||||||
|
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
Intent.ACTION_PACKAGE_ADDED -> {
|
Intent.ACTION_PACKAGE_ADDED -> {
|
||||||
AuroraApp.flowEvent.emitEvent(InstallerEvent.Installed(packageName))
|
AuroraApp.events.send(InstallerEvent.Installed(packageName))
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent.ACTION_PACKAGE_REMOVED -> {
|
Intent.ACTION_PACKAGE_REMOVED -> {
|
||||||
AuroraApp.flowEvent.emitEvent(InstallerEvent.Uninstalled(packageName))
|
AuroraApp.events.send(InstallerEvent.Uninstalled(packageName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class GoogleFragment : BaseFragment<FragmentGoogleBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
AuroraApp.flowEvent.authEvent.collect { onEventReceived(it) }
|
AuroraApp.events.authEvent.collect { onEventReceived(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class InstalledAppsFragment : BaseFragment<FragmentAppsBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
AuroraApp.flowEvent.busEvent.collect { onEvent(it) }
|
AuroraApp.events.busEvent.collect { onEvent(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ import com.aurora.store.data.model.ViewState.Loading.getDataAs
|
|||||||
import com.aurora.store.data.providers.AuthProvider
|
import com.aurora.store.data.providers.AuthProvider
|
||||||
import com.aurora.store.databinding.FragmentDetailsBinding
|
import com.aurora.store.databinding.FragmentDetailsBinding
|
||||||
import com.aurora.store.util.CommonUtil
|
import com.aurora.store.util.CommonUtil
|
||||||
import com.aurora.store.util.Log
|
|
||||||
import com.aurora.store.util.PackageUtil
|
import com.aurora.store.util.PackageUtil
|
||||||
import com.aurora.store.util.PathUtil
|
import com.aurora.store.util.PathUtil
|
||||||
import com.aurora.store.util.Preferences
|
import com.aurora.store.util.Preferences
|
||||||
@@ -366,10 +365,10 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
AuroraApp.flowEvent.busEvent.collect { onEvent(it) }
|
AuroraApp.events.busEvent.collect { onEvent(it) }
|
||||||
}
|
}
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
AuroraApp.flowEvent.installerEvent.collect { onEvent(it) }
|
AuroraApp.events.installerEvent.collect { onEvent(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class AppMenuSheet : BaseDialogSheet<SheetAppMenuBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
AuroraApp.flowEvent.emitEvent(
|
AuroraApp.events.send(
|
||||||
BusEvent.Blacklisted(args.app.packageName)
|
BusEvent.Blacklisted(args.app.packageName)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
AuroraApp.flowEvent.busEvent.collect { onEvent(it) }
|
AuroraApp.events.busEvent.collect { onEvent(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -201,18 +201,18 @@ class AuthViewModel @Inject constructor(
|
|||||||
if (aasToken != null) {
|
if (aasToken != null) {
|
||||||
Preferences.putString(context, Constants.ACCOUNT_EMAIL_PLAIN, email)
|
Preferences.putString(context, Constants.ACCOUNT_EMAIL_PLAIN, email)
|
||||||
Preferences.putString(context, Constants.ACCOUNT_AAS_PLAIN, aasToken)
|
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 {
|
} else {
|
||||||
Preferences.putString(context, Constants.ACCOUNT_EMAIL_PLAIN, "")
|
Preferences.putString(context, Constants.ACCOUNT_EMAIL_PLAIN, "")
|
||||||
Preferences.putString(context, Constants.ACCOUNT_AAS_PLAIN, "")
|
Preferences.putString(context, Constants.ACCOUNT_AAS_PLAIN, "")
|
||||||
AuroraApp.flowEvent.emitEvent(AuthEvent.GoogleLogin(false, "", ""))
|
AuroraApp.events.send(AuthEvent.GoogleLogin(false, "", ""))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
AuroraApp.flowEvent.emitEvent(AuthEvent.GoogleLogin(false, "", ""))
|
AuroraApp.events.send(AuthEvent.GoogleLogin(false, "", ""))
|
||||||
}
|
}
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Log.e(TAG, "Failed to build AuthData", exception)
|
Log.e(TAG, "Failed to build AuthData", exception)
|
||||||
AuroraApp.flowEvent.emitEvent(AuthEvent.GoogleLogin(false, "", ""))
|
AuroraApp.events.send(AuthEvent.GoogleLogin(false, "", ""))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class SheetsViewModel @Inject constructor(
|
|||||||
val purchaseHelper = PurchaseHelper(authProvider.authData)
|
val purchaseHelper = PurchaseHelper(authProvider.authData)
|
||||||
val files = purchaseHelper.purchase(app.packageName, customVersion, app.offerType)
|
val files = purchaseHelper.purchase(app.packageName, customVersion, app.offerType)
|
||||||
if (files.isNotEmpty()) {
|
if (files.isNotEmpty()) {
|
||||||
AuroraApp.flowEvent.emitEvent(
|
AuroraApp.events.send(
|
||||||
BusEvent.ManualDownload(app.packageName, customVersion)
|
BusEvent.ManualDownload(app.packageName, customVersion)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user