Drop dependency upon EventBus library
Migrate to sharedflow instead which are built within kotlin to avoid an external dependency Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -167,9 +167,6 @@ dependencies {
|
|||||||
//HTTP Clients
|
//HTTP Clients
|
||||||
implementation(libs.squareup.okhttp)
|
implementation(libs.squareup.okhttp)
|
||||||
|
|
||||||
//EventBus
|
|
||||||
implementation(libs.greenrobot.eventbus)
|
|
||||||
|
|
||||||
//Lib-SU
|
//Lib-SU
|
||||||
implementation(libs.github.topjohnwu.libsu)
|
implementation(libs.github.topjohnwu.libsu)
|
||||||
|
|
||||||
|
|||||||
11
app/proguard-rules.pro
vendored
11
app/proguard-rules.pro
vendored
@@ -91,17 +91,6 @@
|
|||||||
-if interface * { @retrofit2.http.* <methods>; }
|
-if interface * { @retrofit2.http.* <methods>; }
|
||||||
-keep,allowobfuscation interface <1>
|
-keep,allowobfuscation interface <1>
|
||||||
|
|
||||||
#Event Bus
|
|
||||||
-keepattributes *Annotation*
|
|
||||||
-keepclassmembers class * {
|
|
||||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
|
||||||
}
|
|
||||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
|
||||||
|
|
||||||
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
|
||||||
<init>(java.lang.Throwable);
|
|
||||||
}
|
|
||||||
|
|
||||||
-keepclassmembers enum * { *; }
|
-keepclassmembers enum * { *; }
|
||||||
-keep class com.aurora.store.view.ui.preferences.**
|
-keep class com.aurora.store.view.ui.preferences.**
|
||||||
-dontwarn com.aurora.store.view.ui.preferences.**
|
-dontwarn com.aurora.store.view.ui.preferences.**
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.hilt.work.HiltWorkerFactory
|
import androidx.hilt.work.HiltWorkerFactory
|
||||||
import androidx.work.Configuration
|
import androidx.work.Configuration
|
||||||
import com.aurora.extensions.isPAndAbove
|
import com.aurora.extensions.isPAndAbove
|
||||||
|
import com.aurora.store.data.event.FlowEvent
|
||||||
import com.aurora.store.data.receiver.PackageManagerReceiver
|
import com.aurora.store.data.receiver.PackageManagerReceiver
|
||||||
import com.aurora.store.util.CommonUtil
|
import com.aurora.store.util.CommonUtil
|
||||||
import com.aurora.store.util.DownloadWorkerUtil
|
import com.aurora.store.util.DownloadWorkerUtil
|
||||||
@@ -57,6 +58,7 @@ class AuroraApp : Application(), Configuration.Provider {
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
val enqueuedInstalls: MutableSet<String> = mutableSetOf()
|
val enqueuedInstalls: MutableSet<String> = mutableSetOf()
|
||||||
|
val flowEvent = FlowEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
package com.aurora.store.data.event
|
package com.aurora.store.data.event
|
||||||
|
|
||||||
sealed class BusEvent {
|
abstract class Event
|
||||||
|
|
||||||
|
sealed class BusEvent: Event() {
|
||||||
data class InstallEvent(
|
data class InstallEvent(
|
||||||
var packageName: String,
|
var packageName: String,
|
||||||
var extra: String? = ""
|
var extra: String? = ""
|
||||||
@@ -47,7 +49,7 @@ sealed class BusEvent {
|
|||||||
) : BusEvent()
|
) : BusEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class InstallerEvent {
|
sealed class InstallerEvent: Event() {
|
||||||
data class Success(
|
data class Success(
|
||||||
var packageName: String? = "",
|
var packageName: String? = "",
|
||||||
var extra: String? = ""
|
var extra: String? = ""
|
||||||
|
|||||||
26
app/src/main/java/com/aurora/store/data/event/FlowEvent.kt
Normal file
26
app/src/main/java/com/aurora/store/data/event/FlowEvent.kt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package com.aurora.store.data.event
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
|
import kotlinx.coroutines.flow.asSharedFlow
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class FlowEvent {
|
||||||
|
|
||||||
|
private val TAG = FlowEvent::class.java.simpleName
|
||||||
|
|
||||||
|
private val _busEvent = MutableSharedFlow<BusEvent>(extraBufferCapacity = 1)
|
||||||
|
val busEvent = _busEvent.asSharedFlow()
|
||||||
|
|
||||||
|
private val _installerEvent = MutableSharedFlow<InstallerEvent>(extraBufferCapacity = 1)
|
||||||
|
val installerEvent = _installerEvent.asSharedFlow()
|
||||||
|
|
||||||
|
fun emitEvent(event: Event) {
|
||||||
|
when (event) {
|
||||||
|
is InstallerEvent -> _installerEvent.tryEmit(event)
|
||||||
|
is BusEvent -> _busEvent.tryEmit(event)
|
||||||
|
else -> Log.e(TAG, "Got an unhandled event")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,7 +30,6 @@ import com.aurora.store.util.Log
|
|||||||
import com.aurora.store.util.PathUtil
|
import com.aurora.store.util.PathUtil
|
||||||
import com.aurora.store.util.Preferences
|
import com.aurora.store.util.Preferences
|
||||||
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
|
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
abstract class InstallerBase(protected var context: Context) : IInstaller {
|
abstract class InstallerBase(protected var context: Context) : IInstaller {
|
||||||
@@ -73,7 +72,7 @@ abstract class InstallerBase(protected var context: Context) : IInstaller {
|
|||||||
extra
|
extra
|
||||||
)
|
)
|
||||||
|
|
||||||
EventBus.getDefault().post(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> {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
package com.aurora.store.data.installer
|
package com.aurora.store.data.installer
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.aurora.store.AuroraApp
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
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
|
||||||
@@ -28,7 +29,6 @@ import com.aurora.store.util.Log
|
|||||||
import com.aurora.store.util.PackageUtil.isSharedLibraryInstalled
|
import com.aurora.store.util.PackageUtil.isSharedLibraryInstalled
|
||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@@ -109,7 +109,7 @@ class RootInstaller @Inject constructor(
|
|||||||
context.getString(R.string.installer_status_failure),
|
context.getString(R.string.installer_status_failure),
|
||||||
parseError(shellResult)
|
parseError(shellResult)
|
||||||
)
|
)
|
||||||
EventBus.getDefault().post(event)
|
AuroraApp.flowEvent.emitEvent(event)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
removeFromInstallQueue(packageName)
|
removeFromInstallQueue(packageName)
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import com.aurora.store.data.room.download.Download
|
|||||||
import com.aurora.store.util.Log
|
import com.aurora.store.util.Log
|
||||||
import com.aurora.store.util.PackageUtil
|
import com.aurora.store.util.PackageUtil
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.concurrent.LinkedBlockingQueue
|
import java.util.concurrent.LinkedBlockingQueue
|
||||||
import java.util.concurrent.ThreadPoolExecutor
|
import java.util.concurrent.ThreadPoolExecutor
|
||||||
@@ -211,7 +210,7 @@ class ServiceInstaller @Inject constructor(
|
|||||||
try {
|
try {
|
||||||
when (returnCode) {
|
when (returnCode) {
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
EventBus.getDefault().post(
|
AuroraApp.flowEvent.emitEvent(
|
||||||
BusEvent.UninstallEvent(
|
BusEvent.UninstallEvent(
|
||||||
packageName,
|
packageName,
|
||||||
context.getString(R.string.installer_status_success)
|
context.getString(R.string.installer_status_success)
|
||||||
@@ -241,7 +240,7 @@ class ServiceInstaller @Inject constructor(
|
|||||||
try {
|
try {
|
||||||
when (returnCode) {
|
when (returnCode) {
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
EventBus.getDefault().post(
|
AuroraApp.flowEvent.emitEvent(
|
||||||
InstallerEvent.Success(
|
InstallerEvent.Success(
|
||||||
packageName,
|
packageName,
|
||||||
context.getString(R.string.installer_status_success)
|
context.getString(R.string.installer_status_success)
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import com.aurora.store.util.PathUtil
|
|||||||
import com.aurora.store.util.Preferences
|
import com.aurora.store.util.Preferences
|
||||||
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
|
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class InstallerStatusReceiver : BroadcastReceiver() {
|
class InstallerStatusReceiver : BroadcastReceiver() {
|
||||||
@@ -108,34 +107,25 @@ 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) {
|
||||||
when (status) {
|
val event = when (status) {
|
||||||
PackageInstaller.STATUS_SUCCESS -> {
|
PackageInstaller.STATUS_SUCCESS -> {
|
||||||
EventBus.getDefault().post(
|
|
||||||
InstallerEvent.Success(
|
InstallerEvent.Success(
|
||||||
packageName,
|
packageName, context.getString(R.string.installer_status_success)
|
||||||
context.getString(R.string.installer_status_success)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageInstaller.STATUS_FAILURE_ABORTED -> {
|
PackageInstaller.STATUS_FAILURE_ABORTED -> {
|
||||||
EventBus.getDefault().post(
|
|
||||||
InstallerEvent.Cancelled(
|
InstallerEvent.Cancelled(
|
||||||
packageName,
|
packageName, AppInstaller.getErrorString(context, status)
|
||||||
AppInstaller.getErrorString(context, status)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
EventBus.getDefault().post(
|
|
||||||
InstallerEvent.Failed(
|
InstallerEvent.Failed(
|
||||||
packageName,
|
packageName, AppInstaller.getErrorString(context, status), extra
|
||||||
AppInstaller.getErrorString(context, status),
|
|
||||||
extra
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AuroraApp.flowEvent.emitEvent(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ package com.aurora.store.data.receiver
|
|||||||
import android.content.BroadcastReceiver
|
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.data.event.BusEvent.InstallEvent
|
import com.aurora.store.data.event.BusEvent.InstallEvent
|
||||||
import com.aurora.store.data.event.BusEvent.UninstallEvent
|
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
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
open class PackageManagerReceiver : BroadcastReceiver() {
|
open class PackageManagerReceiver : BroadcastReceiver() {
|
||||||
@@ -41,11 +41,11 @@ open class PackageManagerReceiver : BroadcastReceiver() {
|
|||||||
|
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
Intent.ACTION_PACKAGE_ADDED -> {
|
Intent.ACTION_PACKAGE_ADDED -> {
|
||||||
EventBus.getDefault().post(InstallEvent(packageName, ""))
|
AuroraApp.flowEvent.emitEvent(InstallEvent(packageName, ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent.ACTION_PACKAGE_REMOVED -> {
|
Intent.ACTION_PACKAGE_REMOVED -> {
|
||||||
EventBus.getDefault().post(UninstallEvent(packageName, ""))
|
AuroraApp.flowEvent.emitEvent(UninstallEvent(packageName, ""))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,16 +31,16 @@ import android.widget.Toast
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
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.BusEvent
|
||||||
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.viewmodel.auth.AuthViewModel
|
import com.aurora.store.viewmodel.auth.AuthViewModel
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import org.greenrobot.eventbus.EventBus
|
import kotlinx.coroutines.launch
|
||||||
import org.greenrobot.eventbus.Subscribe
|
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class GoogleFragment : Fragment(R.layout.fragment_google) {
|
class GoogleFragment : Fragment(R.layout.fragment_google) {
|
||||||
@@ -113,6 +113,10 @@ class GoogleFragment : Fragment(R.layout.fragment_google) {
|
|||||||
}
|
}
|
||||||
loadUrl(EMBEDDED_SETUP_URL)
|
loadUrl(EMBEDDED_SETUP_URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
|
AuroraApp.flowEvent.busEvent.collect { onEventReceived(it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
@@ -120,18 +124,7 @@ class GoogleFragment : Fragment(R.layout.fragment_google) {
|
|||||||
_binding = null
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
private fun onEventReceived(event: BusEvent) {
|
||||||
super.onStart()
|
|
||||||
EventBus.getDefault().register(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStop() {
|
|
||||||
super.onStop()
|
|
||||||
EventBus.getDefault().unregister(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
fun onEventReceived(event: BusEvent) {
|
|
||||||
when (event) {
|
when (event) {
|
||||||
is BusEvent.GoogleAAS -> {
|
is BusEvent.GoogleAAS -> {
|
||||||
if (event.success) {
|
if (event.success) {
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ import android.os.Bundle
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
|
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.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.event.BusEvent
|
import com.aurora.store.data.event.BusEvent
|
||||||
import com.aurora.store.databinding.FragmentAppsBinding
|
import com.aurora.store.databinding.FragmentAppsBinding
|
||||||
@@ -33,9 +35,7 @@ import com.aurora.store.view.epoxy.views.shimmer.AppListViewShimmerModel_
|
|||||||
import com.aurora.store.view.ui.commons.BaseFragment
|
import com.aurora.store.view.ui.commons.BaseFragment
|
||||||
import com.aurora.store.viewmodel.all.InstalledViewModel
|
import com.aurora.store.viewmodel.all.InstalledViewModel
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import org.greenrobot.eventbus.EventBus
|
import kotlinx.coroutines.launch
|
||||||
import org.greenrobot.eventbus.Subscribe
|
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class InstalledAppsFragment : BaseFragment(R.layout.fragment_apps) {
|
class InstalledAppsFragment : BaseFragment(R.layout.fragment_apps) {
|
||||||
@@ -55,18 +55,7 @@ class InstalledAppsFragment : BaseFragment(R.layout.fragment_apps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
private fun onEvent(event: BusEvent) {
|
||||||
super.onStart()
|
|
||||||
EventBus.getDefault().register(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStop() {
|
|
||||||
EventBus.getDefault().unregister(this)
|
|
||||||
super.onStop()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
fun onEvent(event: BusEvent) {
|
|
||||||
when (event) {
|
when (event) {
|
||||||
is BusEvent.InstallEvent,
|
is BusEvent.InstallEvent,
|
||||||
is BusEvent.UninstallEvent,
|
is BusEvent.UninstallEvent,
|
||||||
@@ -91,6 +80,10 @@ class InstalledAppsFragment : BaseFragment(R.layout.fragment_apps) {
|
|||||||
updateController(null)
|
updateController(null)
|
||||||
|
|
||||||
viewModel.getInstalledApps(view.context)
|
viewModel.getInstalledApps(view.context)
|
||||||
|
|
||||||
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
|
AuroraApp.flowEvent.busEvent.collect { onEvent(it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|||||||
@@ -56,10 +56,12 @@ import com.aurora.gplayapi.data.models.App
|
|||||||
import com.aurora.gplayapi.data.models.Review
|
import com.aurora.gplayapi.data.models.Review
|
||||||
import com.aurora.gplayapi.data.models.StreamBundle
|
import com.aurora.gplayapi.data.models.StreamBundle
|
||||||
import com.aurora.gplayapi.data.models.StreamCluster
|
import com.aurora.gplayapi.data.models.StreamCluster
|
||||||
|
import com.aurora.store.AuroraApp
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.model.State
|
import com.aurora.store.data.model.State
|
||||||
import com.aurora.store.data.model.ViewState
|
import com.aurora.store.data.model.ViewState
|
||||||
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.data.event.InstallerEvent
|
||||||
import com.aurora.store.data.installer.AppInstaller
|
import com.aurora.store.data.installer.AppInstaller
|
||||||
import com.aurora.store.data.model.DownloadStatus
|
import com.aurora.store.data.model.DownloadStatus
|
||||||
@@ -90,9 +92,6 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
import org.greenrobot.eventbus.Subscribe
|
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -140,21 +139,7 @@ class AppDetailsFragment : BaseFragment(R.layout.fragment_details) {
|
|||||||
private var autoDownload: Boolean = false
|
private var autoDownload: Boolean = false
|
||||||
private var uninstallActionEnabled = false
|
private var uninstallActionEnabled = false
|
||||||
|
|
||||||
override fun onStart() {
|
private fun onEvent(event: Event) {
|
||||||
super.onStart()
|
|
||||||
EventBus.getDefault().register(this)
|
|
||||||
if (autoDownload) {
|
|
||||||
purchase()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStop() {
|
|
||||||
EventBus.getDefault().unregister(this)
|
|
||||||
super.onStop()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
fun onEventMainThread(event: Any) {
|
|
||||||
when (event) {
|
when (event) {
|
||||||
is BusEvent.InstallEvent -> {
|
is BusEvent.InstallEvent -> {
|
||||||
if (app.packageName == event.packageName) {
|
if (app.packageName == event.packageName) {
|
||||||
@@ -447,6 +432,13 @@ class AppDetailsFragment : BaseFragment(R.layout.fragment_details) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
|
AuroraApp.flowEvent.busEvent.collect { onEvent(it) }
|
||||||
|
}
|
||||||
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
|
AuroraApp.flowEvent.installerEvent.collect { onEvent(it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import androidx.fragment.app.viewModels
|
|||||||
import androidx.navigation.fragment.navArgs
|
import androidx.navigation.fragment.navArgs
|
||||||
import com.aurora.extensions.openInfo
|
import com.aurora.extensions.openInfo
|
||||||
import com.aurora.extensions.toast
|
import com.aurora.extensions.toast
|
||||||
|
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.BusEvent
|
||||||
import com.aurora.store.data.installer.AppInstaller
|
import com.aurora.store.data.installer.AppInstaller
|
||||||
@@ -37,7 +38,6 @@ import com.aurora.store.util.PackageUtil
|
|||||||
import com.aurora.store.viewmodel.sheets.SheetsViewModel
|
import com.aurora.store.viewmodel.sheets.SheetsViewModel
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class AppMenuSheet : BottomSheetDialogFragment(R.layout.sheet_app_menu) {
|
class AppMenuSheet : BottomSheetDialogFragment(R.layout.sheet_app_menu) {
|
||||||
@@ -99,8 +99,9 @@ class AppMenuSheet : BottomSheetDialogFragment(R.layout.sheet_app_menu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
EventBus.getDefault()
|
AuroraApp.flowEvent.emitEvent(
|
||||||
.post(BusEvent.Blacklisted(args.app.packageName, ""))
|
BusEvent.Blacklisted(args.app.packageName, "")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.action_local -> {
|
R.id.action_local -> {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import com.aurora.extensions.browse
|
|||||||
import com.aurora.extensions.isRAndAbove
|
import com.aurora.extensions.isRAndAbove
|
||||||
import com.aurora.extensions.toast
|
import com.aurora.extensions.toast
|
||||||
import com.aurora.gplayapi.data.models.App
|
import com.aurora.gplayapi.data.models.App
|
||||||
|
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.BusEvent
|
||||||
@@ -51,9 +52,6 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
import org.greenrobot.eventbus.Subscribe
|
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class UpdatesFragment : BaseFragment(R.layout.fragment_updates) {
|
class UpdatesFragment : BaseFragment(R.layout.fragment_updates) {
|
||||||
@@ -78,11 +76,6 @@ class UpdatesFragment : BaseFragment(R.layout.fragment_updates) {
|
|||||||
if (perm) viewModel.download(app) else toast(R.string.permissions_denied)
|
if (perm) viewModel.download(app) else toast(R.string.permissions_denied)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
EventBus.getDefault().register(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
_binding = FragmentUpdatesBinding.bind(view)
|
_binding = FragmentUpdatesBinding.bind(view)
|
||||||
@@ -151,6 +144,10 @@ class UpdatesFragment : BaseFragment(R.layout.fragment_updates) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateController(null)
|
updateController(null)
|
||||||
|
|
||||||
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
|
AuroraApp.flowEvent.busEvent.collect { onEvent(it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
@@ -158,13 +155,7 @@ class UpdatesFragment : BaseFragment(R.layout.fragment_updates) {
|
|||||||
_binding = null
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
private fun onEvent(event: BusEvent) {
|
||||||
EventBus.getDefault().unregister(this)
|
|
||||||
super.onStop()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
fun onEventMainThread(event: Any) {
|
|
||||||
when (event) {
|
when (event) {
|
||||||
is BusEvent.InstallEvent, is BusEvent.UninstallEvent -> {
|
is BusEvent.InstallEvent, is BusEvent.UninstallEvent -> {
|
||||||
viewModel.observe()
|
viewModel.observe()
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import com.aurora.gplayapi.data.models.AuthData
|
|||||||
import com.aurora.gplayapi.data.models.PlayResponse
|
import com.aurora.gplayapi.data.models.PlayResponse
|
||||||
import com.aurora.gplayapi.data.providers.DeviceInfoProvider
|
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.data.model.AccountType
|
import com.aurora.store.data.model.AccountType
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.model.AuthState
|
import com.aurora.store.data.model.AuthState
|
||||||
@@ -50,7 +51,6 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.supervisorScope
|
import kotlinx.coroutines.supervisorScope
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
import java.net.ConnectException
|
import java.net.ConnectException
|
||||||
import java.net.UnknownHostException
|
import java.net.UnknownHostException
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -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)
|
||||||
EventBus.getDefault().post(BusEvent.GoogleAAS(true, email, aasToken))
|
AuroraApp.flowEvent.emitEvent(BusEvent.GoogleAAS(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, "")
|
||||||
EventBus.getDefault().post(BusEvent.GoogleAAS(false))
|
AuroraApp.flowEvent.emitEvent(BusEvent.GoogleAAS(false))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EventBus.getDefault().post(BusEvent.GoogleAAS(false))
|
AuroraApp.flowEvent.emitEvent(BusEvent.GoogleAAS(false))
|
||||||
}
|
}
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Log.e(TAG, "Failed to build AuthData", exception)
|
Log.e(TAG, "Failed to build AuthData", exception)
|
||||||
EventBus.getDefault().post(BusEvent.GoogleAAS(false))
|
AuroraApp.flowEvent.emitEvent(BusEvent.GoogleAAS(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import androidx.lifecycle.ViewModel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.aurora.gplayapi.data.models.App
|
import com.aurora.gplayapi.data.models.App
|
||||||
import com.aurora.gplayapi.helpers.PurchaseHelper
|
import com.aurora.gplayapi.helpers.PurchaseHelper
|
||||||
|
import com.aurora.store.AuroraApp
|
||||||
import com.aurora.store.data.event.BusEvent
|
import com.aurora.store.data.event.BusEvent
|
||||||
import com.aurora.store.data.providers.AuthProvider
|
import com.aurora.store.data.providers.AuthProvider
|
||||||
import com.aurora.store.data.room.download.Download
|
import com.aurora.store.data.room.download.Download
|
||||||
@@ -17,7 +18,6 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.asSharedFlow
|
import kotlinx.coroutines.flow.asSharedFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class SheetsViewModel @Inject constructor(
|
class SheetsViewModel @Inject constructor(
|
||||||
@@ -35,8 +35,9 @@ 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()) {
|
||||||
EventBus.getDefault()
|
AuroraApp.flowEvent.emitEvent(
|
||||||
.post(BusEvent.ManualDownload(app.packageName, customVersion))
|
BusEvent.ManualDownload(app.packageName, customVersion)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
_purchaseStatus.emit(files.isNotEmpty())
|
_purchaseStatus.emit(files.isNotEmpty())
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ composeBom = "2024.06.00"
|
|||||||
coreVersion = "1.13.1"
|
coreVersion = "1.13.1"
|
||||||
epoxyVersion = "5.1.4"
|
epoxyVersion = "5.1.4"
|
||||||
espressoVersion = "3.6.1"
|
espressoVersion = "3.6.1"
|
||||||
eventbusVersion = "3.3.1"
|
|
||||||
gplayapiVersion = "3.2.12"
|
gplayapiVersion = "3.2.12"
|
||||||
gsonVersion = "2.10.1"
|
gsonVersion = "2.10.1"
|
||||||
hiddenapibypassVersion = "4.3"
|
hiddenapibypassVersion = "4.3"
|
||||||
@@ -70,7 +69,6 @@ github-topjohnwu-libsu = { module = "com.github.topjohnwu.libsu:core", version.r
|
|||||||
google-android-material = { module = "com.google.android.material:material", version.ref = "materialVersion" }
|
google-android-material = { module = "com.google.android.material:material", version.ref = "materialVersion" }
|
||||||
google-gson = { module = "com.google.code.gson:gson", version.ref = "gsonVersion" }
|
google-gson = { module = "com.google.code.gson:gson", version.ref = "gsonVersion" }
|
||||||
google-protobuf-javalite = { module = "com.google.protobuf:protobuf-javalite", version.ref = "protobufJavaliteVersion" }
|
google-protobuf-javalite = { module = "com.google.protobuf:protobuf-javalite", version.ref = "protobufJavaliteVersion" }
|
||||||
greenrobot-eventbus = { module = "org.greenrobot:eventbus", version.ref = "eventbusVersion" }
|
|
||||||
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hiltVersion" }
|
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hiltVersion" }
|
||||||
hilt-android-core = { module = "com.google.dagger:hilt-android", version.ref = "hiltVersion" }
|
hilt-android-core = { module = "com.google.dagger:hilt-android", version.ref = "hiltVersion" }
|
||||||
hilt-androidx-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hiltWorkVersion" }
|
hilt-androidx-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hiltWorkVersion" }
|
||||||
|
|||||||
Reference in New Issue
Block a user