package Ġai . rot or . mobile . ui . welcome Ċ Ċ import Ġai . rot or . mobile . R Ċ import Ġai . rot or . mobile . services . Connect BT Device Intent Service Ċ import Ġai . rot or . mobile . ui . Base Activity Ċ import Ġai . rot or . mobile . ui . welcome . Welcome Fragment . Welcome Fragment Host Ċ import Ġai . rot or . mobile . ui . welcome . Welcome ViewModel . Companion . REQUEST _ ENABLE _ LOCATION _ PERMISSION Ċ import Ġai . rot or . mobile . ui . welcome . Welcome ViewModel . Companion . REQUEST _ T URN _ BT _ ON Ċ import Ġandroid . bluetooth . Bluetooth Adapter Ċ import Ġandroid . bluetooth . Bluetooth Device Ċ import Ġandroid . content . Broadcast Receiver Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . content . Intent Filter Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . core . app . Activity Compat Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠWelcome Activity Ġ: ĠBase Activity (), ĠWelcome Fragment Host Ġ{ ĊĠĠĠ Ġ@ Inject Ġlateinit Ġvar ĠviewModel : ĠWelcome ViewModel ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠWelcome Activity Binding ĊĊĠĠĠ Ġprivate Ġval Ġbt Filter Ġ= ĠIntent Filter () ĊĠĠĠ Ġval Ġbr Ġ= Ġobject : ĠBroadcast Receiver () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Receive ( context : ĠContext ?, Ġintent : ĠIntent ?) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . on Receive Broadcast ( intent ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġpublic Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġapp Component . inject ( this ) ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĊĠĠĠĠĠĠĠ ĠviewModel Ġ= Ġget ViewModel ( Welcome ViewModel :: class ) ĊĠĠĠĠĠĠĠ ĠviewModel . restore State ( savedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠData Binding Util . set ContentView ( this , ĠR . layout . activity _ welcome ) ĊĠĠĠĠĠĠĠ Ġbinding . vm Ġ= ĠviewModel ĊĠĠĠĠĠĠĠ Ġbinding . execute Pending Bindings () ĊĊĠĠĠĠĠĠĠ Ġset Support ActionBar ( binding . toolbar ) ĊĠĠĠĠĠĠĠ Ġsupport ActionBar !!. title Ġ= ĠgetString ( R . string . app _ name ) ĊĊĠĠĠĠĠĠĠ Ġ// Add Ġm ah Ġintent Ġfilters ĊĠĠĠĠĠĠĠ Ġbt Filter . addAction ( Bluetooth Adapter . ACTION _ STATE _ CHANGED ) ĊĠĠĠĠĠĠĠ Ġbt Filter . addAction ( Bluetooth Device . ACTION _ FOUND ) ĊĠĠĠĠĠĠĠ Ġregister Receiver ( br , Ġbt Filter ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . should Show B TD ialog . observe ( this , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġenable Bt Intent Ġ= ĠIntent ( Bluetooth Adapter . ACTION _ REQUEST _ ENABLE ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠstartActivity For Result ( enable Bt Intent , ĠREQUEST _ T URN _ BT _ ON ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ ĠviewModel . should Ask For Location Dialog . observe ( this , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠActivity Compat . request Permissions ( this , ĠarrayOf ( android . Manifest . permission . ACCESS _ CO AR SE _ LOCATION ), ĠREQUEST _ ENABLE _ LOCATION _ PERMISSION ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ ĠviewModel . ready To Start Remote Control . observe ( this , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstart Service ( Connect BT Device Intent Service . make Intent ( this , Ġit )) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Save InstanceState ( out State : ĠBundle ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Save InstanceState ( out State ) ĊĠĠĠĠĠĠĠ ĠviewModel . save State ( out State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Resume () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Resume () ĊĠĠĠĠĠĠĠ ĠviewModel . on Resume () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Request Permissions Result ( request Code : ĠInt , Ġpermissions : ĠArray < out ĠString >, Ġgrant Results : ĠInt Array ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Request Permissions Result ( request Code , Ġpermissions , Ġgrant Results ) ĊĠĠĠĠĠĠĠ ĠviewModel . on Request Permission Result ( request Code , Ġpermissions , Ġgrant Results ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy () ĊĠĠĠĠĠĠĠ Ġunregister Receiver ( br ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġbuild Intent ( context : ĠContext ): ĠIntent Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠIntent ( context , ĠWelcome Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ