Fix tests

This commit is contained in:
Lucas Lima 2020-08-20 00:29:47 -03:00
parent 8b0f8cae1f
commit 272b76156e
No known key found for this signature in database
GPG key ID: C5EEF4C30BFBF8D7
6 changed files with 8 additions and 26 deletions

View file

@ -96,7 +96,7 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
loadGameFragment()
}
if (instantAppManager.isEnabled()) {
if (instantAppManager.isEnabled(applicationContext)) {
bindInstantApp()
savesRepository.setLimit(1)
} else {
@ -185,7 +185,7 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
drawer.closeDrawer(GravityCompat.START)
gameViewModel.resumeGame()
}
status == Status.Running && instantAppManager.isEnabled() -> showQuitConfirmation {
status == Status.Running && instantAppManager.isEnabled(applicationContext) -> showQuitConfirmation {
super.onBackPressed()
}
else -> super.onBackPressed()
@ -344,7 +344,7 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
handled
}
navigationView.menu.findItem(R.id.share_now).isVisible = !instantAppManager.isEnabled()
navigationView.menu.findItem(R.id.share_now).isVisible = !instantAppManager.isEnabled(applicationContext)
if (!playGamesManager.hasGooglePlayGames()) {
navigationView.menu.removeGroup(R.id.play_games_group)

View file

@ -68,7 +68,7 @@ class EndGameDialogFragment : AppCompatDialogFragment() {
}
when {
instantAppManager.isEnabled() -> {
instantAppManager.isEnabled(context) -> {
setNeutralButton(R.string.install) { _, _ ->
activity?.run {
instantAppManager.showInstallPrompt(this, null, 0, null)

View file

@ -15,11 +15,7 @@ import org.koin.dsl.module
val AppModule = module {
single {
object : IInstantAppManager {
override fun isEnabled(): Boolean = false
override fun isInstantAppSupported(context: Context): Boolean = false
override fun isInAppPaymentsSupported(context: Context): Boolean = false
override fun isEnabled(context: Context): Boolean = false
override fun showInstallPrompt(
activity: Activity,

View file

@ -5,8 +5,6 @@ import android.content.Context
import android.content.Intent
interface IInstantAppManager {
fun isEnabled(): Boolean
fun isInstantAppSupported(context: Context): Boolean
fun isInAppPaymentsSupported(context: Context): Boolean
fun isEnabled(context: Context): Boolean
fun showInstallPrompt(activity: Activity, intent: Intent?, requestCode: Int, referrer: String?): Boolean
}

View file

@ -5,15 +5,7 @@ import android.content.Context
import android.content.Intent
class InstantAppManager : IInstantAppManager {
override fun isEnabled(): Boolean {
return false
}
override fun isInstantAppSupported(context: Context): Boolean {
return false
}
override fun isInAppPaymentsSupported(context: Context): Boolean {
override fun isEnabled(context: Context): Boolean {
return false
}

View file

@ -6,14 +6,10 @@ import android.content.Intent
import com.google.android.gms.instantapps.InstantApps
class InstantAppManager : IInstantAppManager {
override fun isInstantAppSupported(context: Context): Boolean {
override fun isEnabled(context: Context): Boolean {
return InstantApps.getPackageManagerCompat(context).isInstantApp
}
override fun isInAppPaymentsSupported(context: Context): Boolean {
return true
}
override fun showInstallPrompt(activity: Activity, intent: Intent?, requestCode: Int, referrer: String?): Boolean =
InstantApps.showInstallPrompt(activity, intent, requestCode, referrer)
}