package Ġcom . deep ak . kont acts . ui Ċ Ċ import Ġandroid . Manifest Ċ import Ġandroid . content . pm . PackageManager Ċ import Ġandroid . os . Build Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . core . content . Context Compat Ċ import Ġandroidx . navigation . find Nav Controller Ċ import Ġandroidx . navigation . ui . AppBar Configuration Ċ import Ġandroidx . navigation . ui . setup ActionBar With Nav Controller Ċ import Ġandroidx . navigation . ui . setup With Nav Controller Ċ import Ġcom . deep ak . kont acts . R Ċ import Ġcom . deep ak . kont acts . util . PERMISSION _ READ _ CONTACT Ċ import Ġcom . google . android . material . bottomnavigation . Bottom Navigation View Ċ Ċ class ĠKont acts Activity Ġ: ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ kont acts ) ĊĊĠĠĠĠĠĠĠ Ġcheck Permission () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Request Permissions Result ( request Code : ĠInt , Ġpermissions : ĠArray < String >, Ġgrant Results : ĠInt Array ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( request Code Ġ== ĠPER MISSION _ READ _ CONTACT Ġ&& Ġgrant Results [ 0 ] Ġ== ĠPackage Manager . PERMISSION _ GRAN TED ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinit Nav View () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcheck Permission () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontact Read Permission Ġ= ĠContext Compat . check Self Permission ( this , ĠManifest . permission . READ _ CONTACT S ) Ġ== ĠPackage Manager . PERMISSION _ GRAN TED ĊĠĠĠĠĠĠĠ Ġval Ġcall Phone Permission Ġ= ĠContext Compat . check Self Permission ( this , ĠManifest . permission . READ _ CALL _ LOG ) Ġ== ĠPackage Manager . PERMISSION _ GRAN TED ĊĠĠĠĠĠĠĠ Ġval Ġcall Log Permission Ġ= ĠContext Compat . check Self Permission ( this , ĠManifest . permission . CALL _ PHONE ) Ġ== ĠPackage Manager . PERMISSION _ GRAN TED ĊĠĠĠĠĠĠĠ Ġif Ġ( contact Read Permission Ġ&& Ġcall Phone Permission Ġ&& Ġcall Log Permission ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinit Nav View () ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( Build . VERSION . SDK _ INT Ġ>= ĠBuild . VERSION _ CODES . M ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrequest Permissions ( array Of ( Manifest . permission . READ _ CONTACT S , ĠManifest . permission . CALL _ PHONE , ĠManifest . permission . READ _ CALL _ LOG ), ĠPER MISSION _ READ _ CONTACT ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinit Nav View () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnav View : ĠBottom Navigation View Ġ= ĠfindViewById ( R . id . nav _ view ) ĊĊĠĠĠĠĠĠĠ Ġval Ġnav Controller Ġ= Ġfind Nav Controller ( R . id . nav _ host _ fragment ) ĊĠĠĠĠĠĠĠ Ġ// ĠPass ing Ġeach Ġmenu ĠID Ġas Ġa Ġset Ġof ĠI ds Ġbecause Ġeach ĊĠĠĠĠĠĠĠ Ġ// Ġmenu Ġshould Ġbe Ġconsidered Ġas Ġtop Ġlevel Ġdest inations . ĊĠĠĠĠĠĠĠ Ġval Ġapp Bar Configuration Ġ= ĠApp Bar Configuration ( set Of ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . navigation _ contacts , ĠR . id . navigation _ fav our ite , ĠR . id . navigation _ calls )) ĊĠĠĠĠĠĠĠ Ġsetup ActionBar With Nav Controller ( nav Controller , Ġapp Bar Configuration ) ĊĠĠĠĠĠĠĠ Ġnav View . setup With Nav Controller ( nav Controller ) ĊĠĠĠ Ġ} Ċ } Ċ