Improve event data classes
This commit is contained in:
@@ -21,53 +21,27 @@ package com.aurora.store.data.event
|
|||||||
|
|
||||||
abstract class Event
|
abstract class Event
|
||||||
|
|
||||||
sealed class BusEvent: Event() {
|
sealed class BusEvent : Event() {
|
||||||
data class InstallEvent(
|
lateinit var extra: String
|
||||||
var packageName: String,
|
lateinit var error: String
|
||||||
var extra: String? = ""
|
|
||||||
) : BusEvent()
|
|
||||||
|
|
||||||
data class UninstallEvent(
|
data class Blacklisted(val packageName: String) : BusEvent()
|
||||||
var packageName: String,
|
data class ManualDownload(val packageName: String, val versionCode: Int) : BusEvent()
|
||||||
var extra: String? = ""
|
|
||||||
) : BusEvent()
|
|
||||||
|
|
||||||
data class Blacklisted(
|
|
||||||
var packageName: String,
|
|
||||||
var error: String? = ""
|
|
||||||
) : BusEvent()
|
|
||||||
|
|
||||||
data class GoogleAAS(
|
|
||||||
var success: Boolean,
|
|
||||||
var email: String = String(),
|
|
||||||
var aasToken: String = String()
|
|
||||||
) : BusEvent()
|
|
||||||
|
|
||||||
data class ManualDownload(
|
|
||||||
var packageName: String,
|
|
||||||
var versionCode: Int
|
|
||||||
) : BusEvent()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class InstallerEvent: Event() {
|
sealed class AuthEvent : Event() {
|
||||||
data class Success(
|
data class GoogleLogin(val success: Boolean, val email: String, val token: String) : AuthEvent()
|
||||||
var packageName: String? = "",
|
}
|
||||||
var extra: String? = ""
|
|
||||||
) : InstallerEvent()
|
sealed class InstallerEvent : Event() {
|
||||||
|
lateinit var extra: String
|
||||||
data class Installing(
|
lateinit var error: String
|
||||||
var packageName: String? = "",
|
|
||||||
var progress: Int = 0
|
var progress: Int = -1
|
||||||
) : InstallerEvent()
|
|
||||||
|
data class Installed(val packageName: String) : InstallerEvent()
|
||||||
data class Cancelled(
|
data class Uninstalled(val packageName: String) : InstallerEvent()
|
||||||
var packageName: String? = "",
|
data class Installing(val packageName: String) : InstallerEvent()
|
||||||
var extra: String? = ""
|
data class Cancelled(val packageName: String) : InstallerEvent()
|
||||||
) : InstallerEvent()
|
data class Failed(val packageName: String) : InstallerEvent()
|
||||||
|
|
||||||
data class Failed(
|
|
||||||
var packageName: String? = "",
|
|
||||||
var error: String? = "",
|
|
||||||
var extra: String? = ""
|
|
||||||
) : InstallerEvent()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,14 @@ class FlowEvent {
|
|||||||
private val _installerEvent = MutableSharedFlow<InstallerEvent>(extraBufferCapacity = 1)
|
private val _installerEvent = MutableSharedFlow<InstallerEvent>(extraBufferCapacity = 1)
|
||||||
val installerEvent = _installerEvent.asSharedFlow()
|
val installerEvent = _installerEvent.asSharedFlow()
|
||||||
|
|
||||||
|
private val _authEvent = MutableSharedFlow<AuthEvent>(extraBufferCapacity = 1)
|
||||||
|
val authEvent = _authEvent.asSharedFlow()
|
||||||
|
|
||||||
fun emitEvent(event: Event) {
|
fun emitEvent(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)
|
||||||
|
is AuthEvent -> _authEvent.tryEmit(event)
|
||||||
else -> Log.e(TAG, "Got an unhandled event")
|
else -> Log.e(TAG, "Got an unhandled event")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,16 +66,19 @@ abstract class InstallerBase(protected var context: Context) : IInstaller {
|
|||||||
open fun postError(packageName: String, error: String?, extra: String?) {
|
open fun postError(packageName: String, error: String?, extra: String?) {
|
||||||
Log.e("Service Error :$error")
|
Log.e("Service Error :$error")
|
||||||
|
|
||||||
val event = InstallerEvent.Failed(
|
val event = InstallerEvent.Failed(packageName).apply {
|
||||||
packageName,
|
this.error = error ?: ""
|
||||||
error,
|
this.extra = extra ?: ""
|
||||||
extra
|
}
|
||||||
)
|
|
||||||
|
|
||||||
AuroraApp.flowEvent.emitEvent(event)
|
AuroraApp.flowEvent.emitEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun getFiles(packageName: String, versionCode: Int, sharedLibPackageName: String = ""): List<File> {
|
open fun getFiles(
|
||||||
|
packageName: String,
|
||||||
|
versionCode: Int,
|
||||||
|
sharedLibPackageName: String = ""
|
||||||
|
): List<File> {
|
||||||
val downloadDir = if (sharedLibPackageName.isNotBlank()) {
|
val downloadDir = if (sharedLibPackageName.isNotBlank()) {
|
||||||
PathUtil.getLibDownloadDir(context, packageName, versionCode, sharedLibPackageName)
|
PathUtil.getLibDownloadDir(context, packageName, versionCode, sharedLibPackageName)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -104,11 +104,10 @@ class RootInstaller @Inject constructor(
|
|||||||
if (packageName == download?.packageName) onInstallationSuccess()
|
if (packageName == download?.packageName) onInstallationSuccess()
|
||||||
} else {
|
} else {
|
||||||
removeFromInstallQueue(packageName)
|
removeFromInstallQueue(packageName)
|
||||||
val event = InstallerEvent.Failed(
|
val event = InstallerEvent.Failed(packageName).apply {
|
||||||
packageName,
|
this.extra = context.getString(R.string.installer_status_failure)
|
||||||
context.getString(R.string.installer_status_failure),
|
this.error = parseError(shellResult)
|
||||||
parseError(shellResult)
|
}
|
||||||
)
|
|
||||||
AuroraApp.flowEvent.emitEvent(event)
|
AuroraApp.flowEvent.emitEvent(event)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import com.aurora.services.IPrivilegedService
|
|||||||
import com.aurora.store.AuroraApp
|
import com.aurora.store.AuroraApp
|
||||||
import com.aurora.store.BuildConfig
|
import com.aurora.store.BuildConfig
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.event.BusEvent
|
|
||||||
import com.aurora.store.data.event.InstallerEvent
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.data.model.InstallerInfo
|
import com.aurora.store.data.model.InstallerInfo
|
||||||
import com.aurora.store.data.room.download.Download
|
import com.aurora.store.data.room.download.Download
|
||||||
@@ -91,6 +90,7 @@ class ServiceInstaller @Inject constructor(
|
|||||||
fileList.map { it.absolutePath }
|
fileList.map { it.absolutePath }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
postError(
|
postError(
|
||||||
download.packageName,
|
download.packageName,
|
||||||
@@ -148,7 +148,11 @@ class ServiceInstaller @Inject constructor(
|
|||||||
)
|
)
|
||||||
} catch (e: RemoteException) {
|
} catch (e: RemoteException) {
|
||||||
removeFromInstallQueue(packageName)
|
removeFromInstallQueue(packageName)
|
||||||
postError(packageName, e.localizedMessage, e.stackTraceToString())
|
postError(
|
||||||
|
packageName,
|
||||||
|
e.localizedMessage,
|
||||||
|
e.stackTraceToString()
|
||||||
|
)
|
||||||
readyWithAction.set(true)
|
readyWithAction.set(true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -166,7 +170,11 @@ class ServiceInstaller @Inject constructor(
|
|||||||
)
|
)
|
||||||
} catch (e: RemoteException) {
|
} catch (e: RemoteException) {
|
||||||
removeFromInstallQueue(packageName)
|
removeFromInstallQueue(packageName)
|
||||||
postError(packageName, e.localizedMessage, e.stackTraceToString())
|
postError(
|
||||||
|
packageName,
|
||||||
|
e.localizedMessage,
|
||||||
|
e.stackTraceToString()
|
||||||
|
)
|
||||||
readyWithAction.set(true)
|
readyWithAction.set(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,12 +219,12 @@ class ServiceInstaller @Inject constructor(
|
|||||||
when (returnCode) {
|
when (returnCode) {
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
AuroraApp.flowEvent.emitEvent(
|
AuroraApp.flowEvent.emitEvent(
|
||||||
BusEvent.UninstallEvent(
|
InstallerEvent.Uninstalled(packageName).apply {
|
||||||
packageName,
|
this.extra = context.getString(R.string.action_uninstall_success)
|
||||||
context.getString(R.string.installer_status_success)
|
}
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
val error = AppInstaller.getErrorString(
|
val error = AppInstaller.getErrorString(
|
||||||
context,
|
context,
|
||||||
@@ -241,14 +249,14 @@ class ServiceInstaller @Inject constructor(
|
|||||||
when (returnCode) {
|
when (returnCode) {
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
AuroraApp.flowEvent.emitEvent(
|
AuroraApp.flowEvent.emitEvent(
|
||||||
InstallerEvent.Success(
|
InstallerEvent.Installed(packageName).apply {
|
||||||
packageName,
|
this.extra = context.getString(R.string.installer_status_success)
|
||||||
context.getString(R.string.installer_status_success)
|
}
|
||||||
)
|
|
||||||
)
|
)
|
||||||
// Installation is not yet finished if this is a shared library
|
// Installation is not yet finished if this is a shared library
|
||||||
if (packageName == download?.packageName) onInstallationSuccess()
|
if (packageName == download?.packageName) onInstallationSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
val error = AppInstaller.getErrorString(
|
val error = AppInstaller.getErrorString(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -80,10 +80,9 @@ class SessionInstaller @Inject constructor(
|
|||||||
|
|
||||||
if (packageName != null && progress > 0.0) {
|
if (packageName != null && progress > 0.0) {
|
||||||
AuroraApp.flowEvent.emitEvent(
|
AuroraApp.flowEvent.emitEvent(
|
||||||
InstallerEvent.Installing(
|
InstallerEvent.Installing(packageName).apply {
|
||||||
packageName = packageName,
|
this.progress = (progress * 100).toInt()
|
||||||
progress = (progress * 100).toInt()
|
}
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,12 @@ class InstallerStatusReceiver : BroadcastReceiver() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun notifyUser(context: Context, packageName: String, displayName: String, status: Int) {
|
private fun notifyUser(
|
||||||
|
context: Context,
|
||||||
|
packageName: String,
|
||||||
|
displayName: String,
|
||||||
|
status: Int
|
||||||
|
) {
|
||||||
val notificationManager =
|
val notificationManager =
|
||||||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
val notification = NotificationUtil.getInstallerStatusNotification(
|
val notification = NotificationUtil.getInstallerStatusNotification(
|
||||||
@@ -109,21 +114,22 @@ class InstallerStatusReceiver : BroadcastReceiver() {
|
|||||||
private fun postStatus(status: Int, packageName: String?, extra: String?, context: Context) {
|
private fun postStatus(status: Int, packageName: String?, extra: String?, context: Context) {
|
||||||
val event = when (status) {
|
val event = when (status) {
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
InstallerEvent.Success(
|
InstallerEvent.Installed(packageName!!).apply {
|
||||||
packageName, context.getString(R.string.installer_status_success)
|
this.extra = context.getString(R.string.installer_status_success)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageInstaller.STATUS_FAILURE_ABORTED -> {
|
PackageInstaller.STATUS_FAILURE_ABORTED -> {
|
||||||
InstallerEvent.Cancelled(
|
InstallerEvent.Cancelled(packageName!!).apply {
|
||||||
packageName, AppInstaller.getErrorString(context, status)
|
this.extra = AppInstaller.getErrorString(context, status)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
InstallerEvent.Failed(
|
InstallerEvent.Failed(packageName!!).apply {
|
||||||
packageName, AppInstaller.getErrorString(context, status), extra
|
this.error = AppInstaller.getErrorString(context, status)
|
||||||
)
|
this.extra = extra ?: ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AuroraApp.flowEvent.emitEvent(event)
|
AuroraApp.flowEvent.emitEvent(event)
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import com.aurora.store.AuroraApp
|
import com.aurora.store.AuroraApp
|
||||||
import com.aurora.store.data.event.BusEvent.InstallEvent
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.data.event.BusEvent.UninstallEvent
|
|
||||||
import com.aurora.store.data.installer.AppInstaller
|
import com.aurora.store.data.installer.AppInstaller
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -41,11 +40,11 @@ open class PackageManagerReceiver : BroadcastReceiver() {
|
|||||||
|
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
Intent.ACTION_PACKAGE_ADDED -> {
|
Intent.ACTION_PACKAGE_ADDED -> {
|
||||||
AuroraApp.flowEvent.emitEvent(InstallEvent(packageName, ""))
|
AuroraApp.flowEvent.emitEvent(InstallerEvent.Installed(packageName))
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent.ACTION_PACKAGE_REMOVED -> {
|
Intent.ACTION_PACKAGE_REMOVED -> {
|
||||||
AuroraApp.flowEvent.emitEvent(UninstallEvent(packageName, ""))
|
AuroraApp.flowEvent.emitEvent(InstallerEvent.Uninstalled(packageName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import androidx.lifecycle.lifecycleScope
|
|||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.aurora.store.AuroraApp
|
import com.aurora.store.AuroraApp
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.event.BusEvent
|
import com.aurora.store.data.event.AuthEvent
|
||||||
import com.aurora.store.databinding.FragmentGoogleBinding
|
import com.aurora.store.databinding.FragmentGoogleBinding
|
||||||
import com.aurora.store.util.AC2DMUtil
|
import com.aurora.store.util.AC2DMUtil
|
||||||
import com.aurora.store.view.ui.commons.BaseFragment
|
import com.aurora.store.view.ui.commons.BaseFragment
|
||||||
@@ -110,15 +110,15 @@ class GoogleFragment : BaseFragment<FragmentGoogleBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
AuroraApp.flowEvent.busEvent.collect { onEventReceived(it) }
|
AuroraApp.flowEvent.authEvent.collect { onEventReceived(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onEventReceived(event: BusEvent) {
|
private fun onEventReceived(event: AuthEvent) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is BusEvent.GoogleAAS -> {
|
is AuthEvent.GoogleLogin -> {
|
||||||
if (event.success) {
|
if (event.success) {
|
||||||
viewModel.buildGoogleAuthData(event.email, event.aasToken)
|
viewModel.buildGoogleAuthData(event.email, event.token)
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import androidx.lifecycle.lifecycleScope
|
|||||||
import com.aurora.gplayapi.data.models.App
|
import com.aurora.gplayapi.data.models.App
|
||||||
import com.aurora.store.AuroraApp
|
import com.aurora.store.AuroraApp
|
||||||
import com.aurora.store.data.event.BusEvent
|
import com.aurora.store.data.event.BusEvent
|
||||||
|
import com.aurora.store.data.event.Event
|
||||||
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.databinding.FragmentAppsBinding
|
import com.aurora.store.databinding.FragmentAppsBinding
|
||||||
import com.aurora.store.view.epoxy.views.HeaderViewModel_
|
import com.aurora.store.view.epoxy.views.HeaderViewModel_
|
||||||
import com.aurora.store.view.epoxy.views.app.AppListViewModel_
|
import com.aurora.store.view.epoxy.views.app.AppListViewModel_
|
||||||
@@ -49,10 +51,10 @@ class InstalledAppsFragment : BaseFragment<FragmentAppsBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onEvent(event: BusEvent) {
|
private fun onEvent(event: Event) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is BusEvent.InstallEvent,
|
is InstallerEvent.Installed,
|
||||||
is BusEvent.UninstallEvent,
|
is InstallerEvent.Uninstalled,
|
||||||
is BusEvent.Blacklisted -> {
|
is BusEvent.Blacklisted -> {
|
||||||
viewModel.fetchApps()
|
viewModel.fetchApps()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
|
|
||||||
private fun onEvent(event: Event) {
|
private fun onEvent(event: Event) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is BusEvent.InstallEvent -> {
|
is InstallerEvent.Installed -> {
|
||||||
if (app.packageName == event.packageName) {
|
if (app.packageName == event.packageName) {
|
||||||
attachActions()
|
attachActions()
|
||||||
binding.layoutDetailsToolbar.toolbar.menu.apply {
|
binding.layoutDetailsToolbar.toolbar.menu.apply {
|
||||||
@@ -148,7 +148,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is BusEvent.UninstallEvent -> {
|
is InstallerEvent.Uninstalled -> {
|
||||||
if (app.packageName == event.packageName) {
|
if (app.packageName == event.packageName) {
|
||||||
attachActions()
|
attachActions()
|
||||||
binding.layoutDetailsToolbar.toolbar.menu.apply {
|
binding.layoutDetailsToolbar.toolbar.menu.apply {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class AppMenuSheet : BaseDialogSheet<SheetAppMenuBinding>() {
|
|||||||
|
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
AuroraApp.flowEvent.emitEvent(
|
AuroraApp.flowEvent.emitEvent(
|
||||||
BusEvent.Blacklisted(args.app.packageName, "")
|
BusEvent.Blacklisted(args.app.packageName)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ import com.aurora.gplayapi.data.models.App
|
|||||||
import com.aurora.store.AuroraApp
|
import com.aurora.store.AuroraApp
|
||||||
import com.aurora.store.MobileNavigationDirections
|
import com.aurora.store.MobileNavigationDirections
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.event.BusEvent
|
import com.aurora.store.data.event.Event
|
||||||
|
import com.aurora.store.data.event.InstallerEvent
|
||||||
import com.aurora.store.data.room.download.Download
|
import com.aurora.store.data.room.download.Download
|
||||||
import com.aurora.store.databinding.FragmentUpdatesBinding
|
import com.aurora.store.databinding.FragmentUpdatesBinding
|
||||||
import com.aurora.store.util.PackageUtil
|
import com.aurora.store.util.PackageUtil
|
||||||
@@ -147,9 +148,9 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onEvent(event: BusEvent) {
|
private fun onEvent(event: Event) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is BusEvent.InstallEvent, is BusEvent.UninstallEvent -> {
|
is InstallerEvent.Installed, is InstallerEvent.Uninstalled -> {
|
||||||
viewModel.fetchUpdates()
|
viewModel.fetchUpdates()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import com.aurora.gplayapi.data.providers.DeviceInfoProvider
|
|||||||
import com.aurora.gplayapi.helpers.AuthHelper
|
import com.aurora.gplayapi.helpers.AuthHelper
|
||||||
import com.aurora.store.AuroraApp
|
import com.aurora.store.AuroraApp
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.event.BusEvent
|
import com.aurora.store.data.event.AuthEvent
|
||||||
import com.aurora.store.data.model.AccountType
|
import com.aurora.store.data.model.AccountType
|
||||||
import com.aurora.store.data.model.AuthState
|
import com.aurora.store.data.model.AuthState
|
||||||
import com.aurora.store.data.model.InsecureAuth
|
import com.aurora.store.data.model.InsecureAuth
|
||||||
@@ -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(BusEvent.GoogleAAS(true, email, aasToken))
|
AuroraApp.flowEvent.emitEvent(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(BusEvent.GoogleAAS(false))
|
AuroraApp.flowEvent.emitEvent(AuthEvent.GoogleLogin(false, "", ""))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
AuroraApp.flowEvent.emitEvent(BusEvent.GoogleAAS(false))
|
AuroraApp.flowEvent.emitEvent(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(BusEvent.GoogleAAS(false))
|
AuroraApp.flowEvent.emitEvent(AuthEvent.GoogleLogin(false, "", ""))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,6 +238,7 @@ class AuthViewModel @Inject constructor(
|
|||||||
)
|
)
|
||||||
buildGoogleAuthData(email, aasToken)
|
buildGoogleAuthData(email, aasToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountType.ANONYMOUS -> {
|
AccountType.ANONYMOUS -> {
|
||||||
buildAnonymousAuthData()
|
buildAnonymousAuthData()
|
||||||
}
|
}
|
||||||
@@ -248,9 +249,11 @@ class AuthViewModel @Inject constructor(
|
|||||||
is UnknownHostException -> {
|
is UnknownHostException -> {
|
||||||
context.getString(R.string.title_no_network)
|
context.getString(R.string.title_no_network)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ConnectException -> {
|
is ConnectException -> {
|
||||||
context.getString(R.string.server_unreachable)
|
context.getString(R.string.server_unreachable)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
context.getString(R.string.bad_request)
|
context.getString(R.string.bad_request)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@
|
|||||||
<string name="action_search">"Search"</string>
|
<string name="action_search">"Search"</string>
|
||||||
<string name="action_share">"Share"</string>
|
<string name="action_share">"Share"</string>
|
||||||
<string name="action_uninstall">"Uninstall"</string>
|
<string name="action_uninstall">"Uninstall"</string>
|
||||||
|
<string name="action_uninstall_success">"Successfully uninstalled"</string>
|
||||||
<string name="action_home_screen">Add to Home screen</string>
|
<string name="action_home_screen">Add to Home screen</string>
|
||||||
<string name="action_uninstall_confirmation">"Do you want to uninstall this app ?"</string>
|
<string name="action_uninstall_confirmation">"Do you want to uninstall this app ?"</string>
|
||||||
<string name="action_info">"App Info"</string>
|
<string name="action_info">"App Info"</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user