package Ġcom . oasis f eng . ne vo . decorators . wechat Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . pm . Shortcut Manager Ċ import Ġandroid . graphics . Bitmap Ċ import Ġandroid . graphics . Canvas Ċ import Ġandroid . graphics . drawable . Adaptive Icon Drawable Ċ import Ġandroid . graphics . drawable . Icon Ċ import Ġandroid . os . Build . VERSION . SDK _ INT Ċ import Ġandroid . os . Build . VERSION _ CODES . O Ċ import Ġandroidx . annotation . Requires Api Ċ import Ġandroidx . core . content . getSystem Service Ċ import Ġandroidx . core . graphics . drawable . Icon Compat Ċ Ċ @ Requires Api ( O ) Ġobject ĠIcon Helper Ġ{ ĊĊ ĉ @ Jvm Static Ġfun ĠconvertTo Adaptive Icon ( context : ĠContext , Ġsource : ĠIcon Compat ): ĠIcon Ċĉĉ ĉ = Ġif Ġ( source . type Ġ== ĠIcon . TYPE _ RESOURCE ) Ġsource . to Icon ( null ) Ċĉĉ ĉ else Ġsource . to Local Adaptive Icon ( context , Ġcontext . getSystem Service () !! ) ĊĊ ĉ fun Ġdrawable To Bitmap ( context : ĠContext , Ġsm : ĠShort cut Manager , Ġicon : ĠIcon Compat ): ĠBitmap Ġ{ Ċĉ ĉ val Ġextra Inset Fraction Ġ= ĠAdapt ive Icon Drawable . get Extra Inset Fraction () Ċĉ ĉ val Ġwidth Ġ= Ġsm . icon Max Width ; Ġval Ġheight Ġ= Ġsm . icon Max Height Ċĉ ĉ val Ġx Inset Ġ= Ġ( width Ġ* Ġextra Inset Fraction ). toInt (); Ġval Ġy Inset Ġ= Ġ( height Ġ* Ġextra Inset Fraction ). toInt () Ċĉ ĉ return ĠBitmap . create Bitmap ( width Ġ+ Ġx Inset Ġ* Ġ 2 , Ġheight Ġ+ Ġy Inset Ġ* Ġ 2 , ĠBitmap . Config . ARGB _ 8 8 8 8 ). also Ġ{ Ġbitmap Ġ-> Ċĉĉ ĉ icon . load Drawable ( context )?. apply Ġ{ Ċĉĉĉ ĉ setBounds ( x Inset , Ġy Inset , Ġwidth Ġ+ Ġx Inset , Ġheight Ġ+ Ġy Inset ) Ċĉĉĉ ĉ draw ( Canvas ( bitmap )) Ġ}} Ċ ĉ } Ċ } Ċ Ċ fun ĠIcon Compat . to Local Adaptive Icon ( context : ĠContext , Ġsm : ĠShort cut Manager ): ĠIcon Ċĉ ĉ = Ġ@ Suppress (" Cascade If ") Ġif Ġ( SDK _ INT Ġ< ĠO ) Ġto Icon ( null ) Ċĉ ĉ else Ġif Ġ( type Ġ== ĠIcon . TYPE _ ADAP TI VE _ BITMAP ) Ġto Icon ( null ) Ċĉ ĉ else ĠIcon . create With Adaptive Bitmap ( Icon Helper . drawable To Bitmap ( context , Ġsm , Ġthis ))