package Ġcom . fre el app . location fetcher . compose Ċ Ċ import Ġandroid . Manifest Ċ import Ġandroid . app . Activity Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . pm . PackageManager Ċ import Ġandroidx . activity . compose . Managed Activity Result Launcher Ċ import Ġandroidx . activity . compose . remember Launcher For Activity Result Ċ import Ġandroidx . activity . result . contract . Activity Result Contracts Ċ import Ġandroidx . compose . runtime .* Ċ import Ġandroidx . compose . ui . platform . Local Context Ċ import Ġandroidx . core . app . Activity Compat Ċ import Ġandroidx . core . content . Context Compat Ċ Ċ @ Composable Ċ internal Ġfun ĠPermission Request ( ĊĠĠĠ Ġpermissions Granted : ĠBoolean , ĊĠĠĠ Ġset Permissions Granted : Ġ( Boolean ) Ġ-> ĠUnit , ĊĠĠĠ Ġr ationale Dis missed : ĠBoolean , ĊĠĠĠ Ġr ationale : Ġ@ Composable Ġ() Ġ-> ĠUnit , Ċ ) Ġ{ ĊĠĠĠ Ġval Ġcontext Ġ= ĠLocal Context . current ĊĠĠĠ Ġval Ġactivity Ġ= Ġcontext . getActivity () ĊĊĠĠĠ Ġval Ġrequest er Ġ= Ġremember Permission Request er Ġ{ Ġresult Ġ-> ĊĠĠĠĠĠĠĠ Ġval Ġhas All Permissions Ġ= Ġresult . values . all Ġ{ Ġit Ġ} ĊĠĠĠĠĠĠĠ Ġset Permissions Granted ( has All Permissions ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġshould Show R ationale Ġ= Ġactivity ?. should Show Location Permissions R ationale () Ġ== Ġtrue ĊĠĠĠ Ġif Ġ(! permissions Granted ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( should Show R ationale Ġ&& Ġ! ration ale Dis missed ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġr ationale () ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSide Effect Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrequest er . launch ( LOCATION _ PERMISSION S ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġtype alias ĠPermission Request er Ġ= ĠManaged Activity Result Launcher < Array < String >, ĠMap < String , ĠBoolean >> Ċ Ċ @ Composable Ċ private Ġfun Ġremember Permission Request er ( ĊĠĠĠ Ġon Result : Ġ( Map < String , ĠBoolean >) Ġ-> ĠUnit Ċ ): ĠPermission Request er Ġ= Ġremember Launcher For Activity Result ( ĊĠĠĠ ĠActivity Result Contracts . Request Multiple Permissions (), ĊĠĠĠ Ġon Result Ċ ) Ċ Ċ internal Ġfun ĠContext . has Location Permissions () Ġ= Ġhas Permissions ( LOCATION _ PERMISSION S ) Ċ Ċ private Ġfun ĠContext . has Permissions ( permissions : ĠArray < String >) Ġ= ĊĠĠĠ Ġpermissions . all Ġ{ Ġhas Permission ( it ) Ġ} Ċ Ċ private Ġfun ĠContext . has Permission ( permission : ĠString ) Ġ= ĊĠĠĠ ĠContext Compat . check Self Permission ( ĊĠĠĠĠĠĠĠ Ġthis , ĊĠĠĠĠĠĠĠ Ġpermission ĊĠĠĠ Ġ) Ġ== ĠPackage Manager . PERMISSION _ GRAN TED Ċ Ċ private Ġfun ĠActivity . should Show Location Permissions R ationale () Ġ= ĊĠĠĠ Ġshould Show R ationale ( LOCATION _ PERMISSION S ) Ċ Ċ private Ġfun ĠActivity . should Show R ationale ( permissions : ĠArray < String >) Ġ= ĊĠĠĠ Ġpermissions . any Ġ{ Ġshould Show R ationale ( it ) Ġ} Ċ Ċ private Ġfun ĠActivity . should Show R ationale ( permission : ĠString ) Ġ= ĊĠĠĠ ĠActivity Compat . should Show Request Permission R ationale ( this , Ġpermission ) Ċ Ċ private Ġval ĠLOC ATION _ PERMISSION S Ġ= ĠarrayOf ( ĊĠĠĠ ĠManifest . permission . ACCESS _ CO AR SE _ LOCATION , ĊĠĠĠ ĠManifest . permission . ACCESS _ F INE _ LOCATION Ċ ) Ċ