package Ġcom . fab irt . weather forecast . presentation . settings Ċ Ċ import Ġandroid . Manifest Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . pm . PackageManager Ċ import Ġandroid . location . Location Manager Ċ import Ġandroidx . core . content . Context Compat Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ Ċ class ĠSettings ViewModel ( private Ġval Ġapplication Context : ĠContext ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ location Enabled Ġ= ĠMutable LiveData < Boolean >() ĊĠĠĠ Ġval Ġlocation Enabled : ĠLive Data < Boolean > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ location Enabled ĊĊĠĠĠ Ġprivate Ġval Ġ_ location Permissions Granted Ġ= ĠMutable LiveData < Boolean >() ĊĠĠĠ Ġval Ġlocation Permissions Granted : ĠLive Data < Boolean > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ location Permissions Granted ĊĊĠĠĠ Ġfun Ġcheck Settings () Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ location Enabled . value Ġ= Ġis G ps Provider Enabled () ĊĠĠĠĠĠĠĠ Ġ_ location Permissions Granted . value Ġ= Ġhas Location Permission () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġhas Location Permission (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠContext Compat . check Self Permission ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication Context , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠManifest . permission . ACCESS _ CO AR SE _ LOCATION ĊĠĠĠĠĠĠĠ Ġ) Ġ== ĠPackage Manager . PERMISSION _ GRAN TED ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġis G ps Provider Enabled (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlocation Manager Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication Context . getSystem Service ( Context . LOCATION _ SERVICE ) Ġas ĠLocation Manager ĊĠĠĠĠĠĠĠ Ġreturn Ġlocation Manager . is Provider Enabled ( Location Manager . GPS _ PROVIDER ) ĊĠĠĠ Ġ} Ċ } Ċ