From e42a8f5fa2b91263550144da3ef63cb94fc3c228 Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Wed, 12 Aug 2020 12:00:09 -0700 Subject: [PATCH] For #11531: Fixes some issues with default event not firing --- app/src/main/java/org/mozilla/fenix/HomeActivity.kt | 9 +++------ app/src/main/java/org/mozilla/fenix/utils/Settings.kt | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index 479e168c97..f30d021a6e 100644 --- a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -252,10 +252,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { lifecycleScope.launch(IO) { if ( settings().isDefaultBrowser() && - settings().wasDefaultBrowserOnLastPause != settings().isDefaultBrowser() + settings().wasDefaultBrowserOnLastResume != settings().isDefaultBrowser() ) { metrics.track(Event.ChangedToDefaultBrowser) } + + settings().wasDefaultBrowserOnLastResume = settings().isDefaultBrowser() } } @@ -264,11 +266,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { window.addFlags(WindowManager.LayoutParams.FLAG_SECURE) } - if (settings().wasDefaultBrowserOnLastPause != settings().isDefaultBrowser() - ) { - settings().wasDefaultBrowserOnLastPause = settings().isDefaultBrowser() - } - super.onPause() // Every time the application goes into the background, it is possible that the user diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index 8ab5be5ec6..ba2390b3f2 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -340,7 +340,7 @@ class Settings(private val appContext: Context) : PreferencesHolder { * Caches the last known "is default browser" state when the app was paused. * For an up to do date state use `isDefaultBrowser` instead. */ - var wasDefaultBrowserOnLastPause by booleanPreference( + var wasDefaultBrowserOnLastResume by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_default_browser), default = isDefaultBrowser() )