package Ġcom . rock well its . rw _ plugins . rw _ speech _ re cognizer Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . app . Application Ċ import Ġandroid . content . Broadcast Receiver Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . content . Intent Filter Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . annotation . NonNull Ċ import Ġio . flutter . embedding . engine . plugins . Flutter Plugin Ċ import Ġio . flutter . embedding . engine . plugins . activity . Activity Aware Ċ import Ġio . flutter . embedding . engine . plugins . activity . Activity Plugin Binding Ċ import Ġio . flutter . plugin . common . MethodCall Ċ import Ġio . flutter . plugin . common . Method Channel Ċ import Ġio . flutter . plugin . common . Method Channel . MethodCall Handler Ċ import Ġio . flutter . plugin . common . Method Channel . Result Ċ import Ġio . flutter . plugin . common . Plugin Registry . Registrar ĊĊ Ċ class ĠR w Speech Recognizer Plugin Ġ: ĠFlutter Plugin , ĠMethod Call Handler , ĠActivity Aware , ĠApplication . Activity Lifecycle Callbacks Ġ{ ĊĠĠĠ Ġlateinit Ġvar Ġactivity : ĠActivity ĊĠĠĠ Ġlateinit Ġvar Ġchannel : ĠMethod Channel ĊĠĠĠ Ġprivate Ġvar Ġcommands : ĠArrayList < String >? Ġ= Ġnull ĊĊĠĠĠ Ġprivate Ġval Ġas r Broadcast Receiver Ġ= Ġobject Ġ: ĠBroadcast Receiver () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Receive ( context : ĠContext , Ġintent : ĠIntent ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġaction Ġ= Ġintent . action ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( action Ġ== ĠACTION _ SPE E CH _ EVENT ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġas r Command Ġ= Ġintent . getString Extra ( EXTRA _ RESULT ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġchannel . invoke Method (" on Speech Event ", Ġmap Of (" command " Ġto Ġas r Command )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠCHAN NEL Ġ= Ġ" com . rock well its . rw _ plugins / rw _ speech _ re cognizer " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠACTION _ OVERRIDE _ COMMAND S Ġ= Ġ" com . real we ar . we ar hf . intent . action . OVERRIDE _ COMMAND S " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠACTION _ SPE E CH _ EVENT Ġ= Ġ" com . real we ar . we ar hf . intent . action . SPE E CH _ EVENT " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠACTION _ REST ORE _ COMMAND S Ġ= Ġ" com . real we ar . we ar hf . intent . action . REST ORE _ COMMAND S " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠEX TRA _ SOURCE _ PACKAGE Ġ= Ġ" com . real we ar . we ar hf . intent . extra . SOURCE _ PACKAGE " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠEX TRA _ COMMAND S Ġ= Ġ" com . real we ar . we ar hf . intent . extra . COMMAND S " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠEX TRA _ RESULT Ġ= Ġ" command " ĊĊĠĠĠĠĠĠĠ Ġ@ Jvm Static ĊĠĠĠĠĠĠĠ Ġfun Ġregister With ( regist rar : ĠRegist rar ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġchannel Ġ= ĠMethod Channel ( regist rar . messenger (), ĠCHAN NEL ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġplugin Ġ= ĠR w Speech Recognizer Plugin () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġplugin . activity Ġ= Ġregist rar . activity () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġplugin . channel Ġ= Ġchannel ĊĠĠĠĠĠĠĠĠĠĠĠ Ġplugin . initialize () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġchannel . set MethodCall Handler ( plugin ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Attached To Engine (@ NonNull Ġflutter Plugin Binding : ĠFlutter Plugin . Flutter Plugin Binding ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchannel Ġ= ĠMethod Channel ( flutter Plugin Binding . get Flutter Engine (). dart Executor , ĠCHAN NEL ) ĊĊĠĠĠĠĠĠĠ Ġthis . channel Ġ= Ġchannel ĊĠĠĠĠĠĠĠ Ġchannel . set MethodCall Handler ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon MethodCall ( call : ĠMethod Call , Ġresult : ĠResult ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( call . method ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" set Commands " Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcall . argument < ArrayList < String >> (" commands ") ?. let Ġ{ Ġset Commands ( it ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġresult . success ( null ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" restore Commands " Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrestore Commands () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġresult . success ( null ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġresult . not Implemented () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Paused ( activity : ĠActivity ) Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity . unregister Receiver ( asr Broadcast Receiver ) ĊĠĠĠĠĠĠĠ Ġrestore Commands () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Res umed ( activity : ĠActivity ) Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity . register Receiver ( asr Broadcast Receiver , ĠIntent Filter ( ACTION _ SPE E CH _ EVENT )) ĊĠĠĠĠĠĠĠ Ġapply Commands () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Created ( activity : ĠActivity , Ġbundle : ĠBundle ?) Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Destroyed ( activity : ĠActivity ) Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Started ( activity : ĠActivity ) Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Save InstanceState ( activity : ĠActivity , Ġbundle : ĠBundle ?) Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Stopped ( activity : ĠActivity ) Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Detached From Engine (@ NonNull Ġbinding : ĠFlutter Plugin . Flutter Plugin Binding ) Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Attached To Activity ( binding : ĠActivity Plugin Binding ) Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . activity Ġ= Ġbinding . activity ĊĠĠĠĠĠĠĠ Ġthis . initialize () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Detached From Activity () Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Detached From Activity For Config Changes () Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Re attached To Activity For Config Changes ( binding : ĠActivity Plugin Binding ) Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġinitialize () Ġ{ ĊĠĠĠĠĠĠĠ Ġassert (:: activity . isInitialized ) ĊĊĠĠĠĠĠĠĠ Ġactivity . application . register Activity Lifecycle Callbacks ( this ) ĊĠĠĠĠĠĠĠ Ġactivity . register Receiver ( asr Broadcast Receiver , ĠIntent Filter ( ACTION _ SPE E CH _ EVENT )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġapply Commands () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( commands Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( ACTION _ OVERRIDE _ COMMAND S ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġintent . putExtra ( EXTRA _ SOURCE _ PACKAGE , Ġactivity . packageName ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġintent . putExtra ( EXTRA _ COMMAND S , Ġcommands ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity . send Broadcast ( intent ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġset Commands ( commands List : ĠArrayList < String >) Ġ{ ĊĠĠĠĠĠĠĠ Ġcommands Ġ= Ġcommands List ĊĠĠĠĠĠĠĠ Ġapply Commands () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġrestore Commands () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( ACTION _ REST ORE _ COMMAND S ) ĊĊĠĠĠĠĠĠĠ Ġintent . putExtra ( EXTRA _ SOURCE _ PACKAGE , Ġactivity . packageName ) ĊĠĠĠĠĠĠĠ Ġactivity . send Broadcast ( intent ) ĊĠĠĠ Ġ} Ċ } Ċ