package Ġcom . world tur tle media . wh ales ay . features . on boarding . ui Ċ Ċ import Ġcom . et ien nel enh art . e iff el . inter ception . inter ception s Ċ import Ġcom . et ien nel enh art . e iff el . state . Action Ċ import Ġcom . et ien nel enh art . e iff el . state . State Ċ import Ġcom . et ien nel enh art . e iff el . state . View Event Ċ import Ġcom . et ien nel enh art . e iff el . state . update Ċ import Ġcom . et ien nel enh art . e iff el . view model . E iff el ViewModel Ċ import Ġcom . world tur tle media . wh ales ay . core . view . state . Mic Permission State Ċ import Ġcom . world tur tle media . wh ales ay . core . view . state . Mic Permission State . Denied Ċ import Ġcom . world tur tle media . wh ales ay . core . view . state . Mic Permission State . Granted Ċ import Ġcom . world tur tle media . wh ales ay . core . view . state . Mic Permission State . Pending Ċ import Ġcom . world tur tle media . wh ales ay . core . view . state . Mic Permission State . Per manently Denied Ċ import Ġcom . world tur tle media . wh ales ay . core . view . util . k tx . currentState Ċ import Ġcom . world tur tle media . wh ales ay . data . db . prefs . Prefs Ċ import Ġcom . world tur tle media . wh ales ay . features . on boarding . ui . On boarding Action . Dispatch Event Ċ import Ġcom . world tur tle media . wh ales ay . features . on boarding . ui . On boarding Action . Update Mic Permission Ċ import Ġjavax . inject . Inject Ċ Ċ sealed Ġclass ĠOn boarding Events Ġ: ĠView Event () Ġ{ ĊĠĠĠ Ġclass ĠNavigate Home Ġ: ĠOn boarding Events () ĊĠĠĠ Ġclass ĠRequest Audio Permissions Ġ: ĠOn boarding Events () Ċ } Ċ Ċ data Ġclass ĠOn boarding State ( ĊĠĠĠ Ġval Ġmic State : ĠM ic Permission State Ġ= ĠPending , ĊĠĠĠ Ġval Ġshow Rational Message : ĠBoolean Ġ= Ġfalse , ĊĠĠĠ Ġval Ġevent : ĠOn boarding Events ? Ġ= Ġnull Ċ ) Ġ: ĠState Ċ Ċ sealed Ġclass ĠOn boarding Action Ġ: ĠAction Ġ{ ĊĠĠĠ Ġdata Ġclass ĠUpdate Mic Permission ( val Ġstate : ĠM ic Permission State ) Ġ: ĠOn boarding Action () ĊĠĠĠ Ġobject ĠToggle Rational Ġ: ĠOn boarding Action () ĊĠĠĠ Ġdata Ġclass ĠDispatch Event ( val Ġevent : ĠOn boarding Events ) Ġ: ĠOn boarding Action () Ċ } Ċ Ċ class ĠOn boarding ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprefs : ĠP refs Ċ ) Ġ: ĠE iff el ViewModel < On boarding State , ĠOn boarding Action >( On boarding State ()) Ġ{ ĊĊĠĠĠ Ġoverride Ġval Ġinter ception s Ġ= Ġinter ception s < On boarding State , ĠOn boarding Action > Ġ{ ĊĠĠĠĠĠĠĠ Ġon < Dispatch Event > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpipe Ġ{ Ġ_, Ġ_ Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprefs . has Seen On boarding Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġval Ġupdate Ġ= Ġupdate < On boarding State , ĠOn boarding Action > Ġ{ Ġaction Ġ-> ĊĠĠĠĠĠĠĠ Ġwhen Ġ( action ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠUpdate Mic Permission Ġ-> Ġcopy ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmic State Ġ= Ġaction . state , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġshow Rational Message Ġ= Ġaction . state Ġis ĠDen ied ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠOn boarding Action . Toggle Rational Ġ-> Ġcopy ( show Rational Message Ġ= Ġ! show Rational Message ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠDispatch Event Ġ-> Ġcopy ( event Ġ= Ġaction . event ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġon Button Clicked () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġevent Ġ= Ġwhen Ġ( currentState . mic State ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPending , ĠDen ied Ġ-> ĠOn boarding Events . Request Audio Permissions () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠGr anted , ĠPer manently Denied Ġ-> ĠOn boarding Events . Navigate Home () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġdispatch ( Dispatch Event ( event )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠInitialize Ġthe ĠM ic Ġstate . ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* ĠBy Ġdefault Ġwith ĠAndroid Ġthe Ġpermission Ġis Ġset Ġto Ġdenied , Ġbut Ġthe Ġuser Ġhas Ġnever ĊĠĠĠĠ Ġ* Ġactually Ġbeen Ġpromp ted . ĠSo Ġthis Ġwill Ġinitialize Ġthe Ġstate Ġwith Ġ[ Pending ] Ġif Ġits Ġ[ Denied ], ĊĠĠĠĠ Ġ* Ġor Ġelse Ġwith Ġthe Ġpassed Ġin Ġstatus ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ param [ status ] ĠInitial Ġstate Ġof Ġthe Ġmicro phone Ġpermission ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġfun Ġinit Mic Permissions Status ( status : ĠM ic Permission State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( currentState . mic State Ġ! is ĠPending ) Ġreturn Ġ// ĠAlready Ġinitialized ĊĊĠĠĠĠĠĠĠ Ġval Ġpermission Ġ= Ġif Ġ( status Ġis ĠDen ied ) ĠPending Ġelse Ġstatus ĊĠĠĠĠĠĠĠ Ġupdate Mic Permission Status ( permission ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate Mic Permission Status ( status : ĠM ic Permission State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġdispatch ( Update Mic Permission ( status )) ĊĠĠĠ Ġ} Ċ } Ċ