package Ġca . log ar itm . de zel . application . keyboard Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . graphics . Point Ċ import Ġandroid . graphics . Rect Ċ import Ġandroid . graphics . drawable . Color Drawable Ċ import Ġandroid . view . Gravity Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . view . WindowManager Ċ import Ġandroid . widget . LinearLayout Ċ import Ġandroid . widget . Popup Window Ċ import Ġca . log ar itm . de zel . view . graphic . Color Ċ Ċ /** Ċ Ġ* ĠThe Ġkeyboard Ġstate Ġreceiver . Ċ Ġ* Ġ@ class ĠKeyboard Observer Ċ Ġ* Ġ@ since Ġ 0 . 1 . 0 Ċ Ġ*/ Ċ open Ġclass ĠKeyboard Observer ( val Ġactivity : ĠActivity , Ġview : ĠView ) Ġ: ĠPopup Window ( activity ) Ġ{ ĊĊ ĉ //-------------------------------------------------------------------------- Ċ ĉ // ĠProperties Ċ ĉ //-------------------------------------------------------------------------- ĊĊ ĉ /** Ċĉ Ġ* ĠThe Ġobserver 's Ġreceiver . Ċĉ Ġ* Ġ@ property Ġlistener Ċĉ Ġ* Ġ@ since Ġ 0 . 1 . 0 Ċĉ Ġ*/ Ċ ĉ open Ġvar Ġlistener : ĠKeyboard Observer Listener ? Ġ= Ġnull ĊĊ ĉ /** Ċĉ Ġ* Ġ@ property Ġorientation Ċĉ Ġ* Ġ@ since Ġ 0 . 1 . 0 Ċĉ Ġ* Ġ@ hidden Ċĉ Ġ*/ Ċ ĉ private Ġval Ġorientation : ĠInt Ċĉ ĉ get () Ġ= Ġthis . activity . resources . configuration . orientation ĊĊ ĉ /** Ċĉ Ġ* Ġ@ property Ġparent View Ċĉ Ġ* Ġ@ since Ġ 0 . 1 . 0 Ċĉ Ġ* Ġ@ hidden Ċĉ Ġ*/ Ċ ĉ private Ġval Ġparent View : ĠView ĊĊ ĉ /** Ċĉ Ġ* Ġ@ property Ġlayout View Ċĉ Ġ* Ġ@ since Ġ 0 . 1 . 0 Ċĉ Ġ* Ġ@ hidden Ċĉ Ġ*/ Ċ ĉ private Ġval Ġlayout View : ĠView ĊĊ ĉ //-------------------------------------------------------------------------- Ċ ĉ // ĠMethods Ċ ĉ //-------------------------------------------------------------------------- ĊĊ ĉ /** Ċĉ Ġ* Ġ@ constructor Ċĉ Ġ* Ġ@ since Ġ 0 . 1 . 0 Ċĉ Ġ*/ Ċ ĉ init Ġ{ ĊĊĉ ĉ this . soft Input Mode Ġ= ĠWindow Manager . LayoutParams . SOFT _ INPUT _ ADJ UST _ RE SIZE Ġor ĠWindow Manager . LayoutParams . SOFT _ INPUT _ STATE _ ALWAYS _ VISIBLE Ċĉ ĉ this . input Method Mode Ġ= ĠPopup Window . INPUT _ METHOD _ NE EDED ĊĊĉ ĉ this . width Ġ= Ġ 0 Ċĉ ĉ this . height Ġ= ĠWindow Manager . LayoutParams . MATCH _ PARENT ĊĊĉ ĉ this . setBackground Drawable ( Color Drawable ( Color . TRANSP ARENT )) ĊĊĉ ĉ this . parent View Ġ= Ġthis . activity . findViewById ( android . R . id . content ) Ċĉ ĉ this . layout View Ġ= ĠLinearLayout ( activity ) Ċĉ ĉ this . layout View . background Ġ= ĠColor Drawable ( Color . TRANSP ARENT ) Ċĉ ĉ this . layout View . layout Params Ġ= ĠLinearLayout . LayoutParams ( Ċĉĉ ĉ ViewGroup . LayoutParams . MATCH _ PARENT , Ċĉĉ ĉ ViewGroup . LayoutParams . MATCH _ PARENT Ċĉ ĉ ) ĊĊĉ ĉ this . content View Ġ= Ġthis . layout View ĊĊĉ ĉ this . layout View . view Tree Observer . add On Global Layout Listener Ġ{ Ċĉĉ ĉ this . handle Global Layout () Ċĉ ĉ } ĊĊĉ ĉ view . post Ġ{ Ċĉĉ ĉ this . start () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* Ġ@ method Ġstart Ċĉ Ġ* Ġ@ since Ġ 0 . 1 . 0 Ċĉ Ġ*/ Ċ ĉ open Ġfun Ġstart () Ġ{ Ċĉ ĉ this . show At Location ( this . parent View , ĠGr avity . NO _ GR AV ITY , Ġ 0 , Ġ 0 ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* Ġ@ method Ġclose Ċĉ Ġ* Ġ@ since Ġ 0 . 1 . 0 Ċĉ Ġ*/ Ċ ĉ open Ġfun Ġclose () Ġ{ Ċĉ ĉ this . dismiss () Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* Ġ@ method Ġhandle Global Layout Ċĉ Ġ* Ġ@ since Ġ 0 . 1 . 0 Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġhandle Global Layout () Ġ{ ĊĊĉ ĉ val Ġscreen Size Ġ= ĠPoint () Ċĉ ĉ val Ġlayout Size Ġ= ĠRect () Ċĉ ĉ this . activity . window Manager . default Display . getSize ( screen Size ) Ċĉ ĉ this . layout View . getWindow Visible Display Frame ( layout Size ) ĊĊĉ ĉ this . listener ?. on Keyboard Height Changed ( screen Size . y Ġ- Ġlayout Size . bottom , Ġthis . orientation ) Ċ ĉ } Ċ }