package Ġcom . m ct ech . library . keyboard . visibility monitor . extent ions Ċ Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġcom . m ct ech . library . keyboard . visibility monitor . Keyboard Change Ċ import Ġcom . m ct ech . library . keyboard . visibility monitor . Keyboard Observable Settings Ċ import Ġcom . m ct ech . library . keyboard . visibility monitor . Keyboard Visibility Monitor Ċ Ċ fun ĠAppCompatActivity . observe Keyboard Changes ( ĊĠĠĠ Ġsettings : ĠKeyboard Observable Settings Ġ= ĠKeyboard Observable Settings (), ĊĠĠĠ Ġon Key Board Change Block : Ġ( change : ĠKeyboard Change ) Ġ-> ĠUnit Ċ ) Ġ{ ĊĠĠĠ ĠKeyboard Visibility Monitor ( ĊĠĠĠĠĠĠĠ Ġlifecycle Owner Ġ= Ġthis . find Life Cycle Owner (), ĊĠĠĠĠĠĠĠ Ġactivity Ġ= Ġthis , ĊĠĠĠĠĠĠĠ Ġkeyboard Observable Settings Ġ= Ġsettings , ĊĠĠĠĠĠĠĠ ĠonChange Callback Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Key Board Change Block . invoke ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) Ċ } Ċ Ċ fun ĠAppCompatActivity . observe Keyboard When Opened ( ĊĠĠĠ Ġsettings : ĠKeyboard Observable Settings Ġ= ĠKeyboard Observable Settings (), ĊĠĠĠ Ġon Key Board Change Block : Ġ( change : ĠKeyboard Change ) Ġ-> ĠUnit Ċ ) Ġ= Ġobserve Keyboard Changes ( settings ) Ġ{ ĊĠĠĠ Ġif ( it . is Opened ){ ĊĠĠĠĠĠĠĠ Ġon Key Board Change Block . invoke ( it ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun ĠAppCompatActivity . observe Keyboard When Closed ( ĊĠĠĠ Ġsettings : ĠKeyboard Observable Settings Ġ= ĠKeyboard Observable Settings (), ĊĠĠĠ Ġon Key Board Change Block : Ġ( change : ĠKeyboard Change ) Ġ-> ĠUnit Ċ ) Ġ= Ġobserve Keyboard Changes ( settings ) Ġ{ ĊĠĠĠ Ġif (! it . is Opened ){ ĊĠĠĠĠĠĠĠ Ġon Key Board Change Block . invoke ( it ) ĊĠĠĠ Ġ} Ċ }