diff --git a/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt b/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt index b24cc558..30ab0b71 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt @@ -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) diff --git a/app/src/main/java/dev/lucasnlm/antimine/level/view/EndGameDialogFragment.kt b/app/src/main/java/dev/lucasnlm/antimine/level/view/EndGameDialogFragment.kt index 4b325f72..fdba8949 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/level/view/EndGameDialogFragment.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/level/view/EndGameDialogFragment.kt @@ -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) diff --git a/app/src/test/java/dev/lucasnlm/antimine/di/TestAppModule.kt b/app/src/test/java/dev/lucasnlm/antimine/di/TestAppModule.kt index 076bd4ad..30314598 100644 --- a/app/src/test/java/dev/lucasnlm/antimine/di/TestAppModule.kt +++ b/app/src/test/java/dev/lucasnlm/antimine/di/TestAppModule.kt @@ -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, diff --git a/external/src/main/java/dev/lucasnlm/external/IInstantAppManager.kt b/external/src/main/java/dev/lucasnlm/external/IInstantAppManager.kt index b5cf9c97..d9c722a0 100644 --- a/external/src/main/java/dev/lucasnlm/external/IInstantAppManager.kt +++ b/external/src/main/java/dev/lucasnlm/external/IInstantAppManager.kt @@ -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 } diff --git a/foss/src/main/java/dev/lucasnlm/external/InstantAppManager.kt b/foss/src/main/java/dev/lucasnlm/external/InstantAppManager.kt index bba2e71e..d016d444 100644 --- a/foss/src/main/java/dev/lucasnlm/external/InstantAppManager.kt +++ b/foss/src/main/java/dev/lucasnlm/external/InstantAppManager.kt @@ -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 } diff --git a/proprietary/src/main/java/dev/lucasnlm/external/InstantAppManager.kt b/proprietary/src/main/java/dev/lucasnlm/external/InstantAppManager.kt index e73dd10b..438bc0ee 100644 --- a/proprietary/src/main/java/dev/lucasnlm/external/InstantAppManager.kt +++ b/proprietary/src/main/java/dev/lucasnlm/external/InstantAppManager.kt @@ -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) }