@ -9,6 +9,8 @@ import android.app.Application
import android.content.Context
import android.content.Context
import android.content.Context.MODE_PRIVATE
import android.content.Context.MODE_PRIVATE
import android.content.SharedPreferences
import android.content.SharedPreferences
import android.content.pm.ShortcutManager
import android.os.Build
import android.view.accessibility.AccessibilityManager
import android.view.accessibility.AccessibilityManager
import androidx.annotation.VisibleForTesting
import androidx.annotation.VisibleForTesting
import androidx.annotation.VisibleForTesting.PRIVATE
import androidx.annotation.VisibleForTesting.PRIVATE
@ -454,10 +456,34 @@ class Settings private constructor(
default = false
default = false
)
)
var shouldShowFirstTimePwaFragment by booleanPreference (
var shouldShowFirstTimePwaFragment : Boolean
appContext . getPreferenceKey ( R . string . pref _key _show _first _time _pwa ) ,
get ( ) {
default = true
val alreadyShownPwaOnboarding = preferences . getBoolean (
)
appContext . getPreferenceKey ( R . string . pref _key _show _first _time _pwa ) , false )
// ShortcutManager::pinnedShortcuts is only available on Oreo+
if ( ! alreadyShownPwaOnboarding && Build . VERSION . SDK _INT >= Build . VERSION_CODES . O ) {
val alreadyHavePWaInstalled =
appContext . getSystemService ( ShortcutManager :: class . java )
. pinnedShortcuts . size > 0
// Users don't need to be shown the PWA onboarding if they already have PWAs installed.
preferences . edit ( )
. putBoolean (
appContext . getPreferenceKey ( R . string . pref _key _show _first _time _pwa ) ,
alreadyHavePWaInstalled )
. apply ( )
return ! alreadyHavePWaInstalled
}
return ! alreadyShownPwaOnboarding
}
set ( value ) {
preferences . edit ( )
. putBoolean ( appContext . getPreferenceKey ( R . string . pref _key _show _first _time _pwa ) , value )
. apply ( )
}
@VisibleForTesting ( otherwise = PRIVATE )
@VisibleForTesting ( otherwise = PRIVATE )
internal val trackingProtectionOnboardingCount by intPreference (
internal val trackingProtectionOnboardingCount by intPreference (