package Ġopen food facts . github . scr ach x . open food . utils Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . SharedPreferences Ċ import Ġandroidx . preference . Preference Ċ import Ġandroidx . preference . Preference Screen Ċ import Ġopen food facts . github . scr ach x . open food . features . preferences . Preferences Fragment Ċ Ċ fun Ġ< T Ġ: ĠPreference ?> ĠPreferences Fragment . require Preference ( key : ĠString ): ĠT Ġ= ĊĠĠĠ Ġfind Preference ( key ) Ġ?: Ġerror ("$ key Ġpreference Ġdoes Ġnot Ġexist .") Ċ Ċ fun Ġ< T Ġ: ĠPreference ?> ĠPreference Screen . require Preference ( key : ĠString ): ĠT Ġ= ĊĠĠĠ Ġfind Preference ( key ) Ġ?: Ġerror ("$ key Ġpreference Ġdoes Ġnot Ġexist .") Ċ Ċ inline Ġfun Ġ< T Ġ: ĠPreference ?> ĠPreferences Fragment . require Preference ( key : ĠString , Ġaction : ĠT . () Ġ-> ĠUnit ) Ġ{ ĊĠĠĠ Ġrequire Preference < T >( key ). run ( action ) Ċ } Ċ Ċ fun ĠContext . get Login Preferences ( mode : ĠInt Ġ= ĠContext . MODE _ PRIVATE ): ĠSharedPreferences Ġ= ĊĠĠĠ Ġget SharedPreferences ( Preferences Fragment . LOGIN _ SHARED _ PRE F , Ġmode ) Ċ Ċ fun ĠContext . getApp Preferences ( mode : ĠInt Ġ= ĠContext . MODE _ PRIVATE ): ĠSharedPreferences Ġ= ĊĠĠĠ Ġget SharedPreferences ( Preferences Fragment . APP _ SHARED _ PRE F , Ġmode ) Ċ Ċ fun ĠContext . is User Set () Ġ= Ġ! get Login Preferences (). getString (" user ", Ġnull ). isNull Or Blank () Ċ