package Ġcom . sensor berg . notifications . sdk . sample Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . core . content . File Provider . get Uri For File Ċ import Ġandroidx . appcompat . app . AlertDialog Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . TextView Ċ import Ġcom . sensor berg . notifications . sdk . Action Ċ import Ġcom . sensor berg . notifications . sdk . Conversion Ċ import Ġcom . sensor berg . notifications . sdk . Notifications Sdk Ċ import Ġcom . sensor berg . permission bit te . Bit te Bit te Ċ import Ġcom . sensor berg . permission bit te . Permission Bit te Ċ import Ġtim ber . log . Tim ber Ċ import Ġjava . io . File Ċ import Ġjava . util .* Ċ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity (), ĠBit te Bit te Ġ{ ĊĊ ĉ private Ġlateinit Ġvar Ġnotifications Sdk : ĠNotifications Sdk ĊĊ ĉ override Ġfun Ġask N icer () Ġ{ Ċĉ ĉ AlertDialog . Builder ( this ) Ċĉĉ ĉ . setTitle (" Do Ġit ") Ċĉĉ ĉ . setMessage (" You Ġreally Ġhave Ġto Ġaccept Ġthe Ġpermission ") Ċĉĉ ĉ . set Positive Button (" S ure ") Ġ{ Ġ_, Ġ_ Ġ-> ĠPermission Bit te . ask ( this , Ġthis ) Ġ} Ċĉĉ ĉ . set Negative Button (" OK ") Ġ{ Ġ_, Ġ_ Ġ-> ĠPermission Bit te . ask ( this , Ġthis ) Ġ} Ċĉĉ ĉ . set Cancel able ( false ) Ċĉĉ ĉ . show () Ċ ĉ } ĊĊ ĉ override Ġfun Ġno You C ant () Ġ{ Ċĉ ĉ Permission Bit te . goTo Settings ( this ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġyes You Can () Ġ{ ĊĊ ĉ } ĊĊ ĉ override Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . onCreate ( savedInstanceState ) Ċĉ ĉ set ContentView ( R . layout . activity _ main ) Ċĉ ĉ Permission Bit te . ask ( this , Ġthis ) Ċĉ ĉ notifications Sdk Ġ= Ġ( application Ġas ĠApp ). sdk Ċĉ ĉ update Enabled Text () Ċĉ ĉ check Action Conversion ( intent ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon New Intent ( intent : ĠIntent ) Ġ{ Ċĉ ĉ super . on New Intent ( intent ) Ċĉ ĉ check Action Conversion ( intent ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġcheck Action Conversion ( intent : ĠIntent ?) Ġ{ Ċĉ ĉ intent ?. extras ?. get Parcelable < Action >(" action ") ?. let Ġ{ Ċĉĉ ĉ notifications Sdk . set Conversion ( it , ĠConversion . Success ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġon Share Logs (@ Suppress (" UNUSED _ PARAMETER ") Ġview : ĠView ) Ġ{ Ċĉ ĉ File ( files Dir , Ġ" logs / "). list Files (). toList (). sorted By Ġ{ Ġit . absolute Path Ġ}. last OrNull ()?. let Ġ{ Ċĉĉ ĉ val Ġcontent Uri Ġ= Ġget Uri For File ( this , Ġ" com . sensor berg . notifications . sdk . sample . file provider ", Ġit ) Ċĉĉ ĉ val Ġshare Intent : ĠIntent Ġ= ĠIntent (). apply Ġ{ Ċĉĉĉ ĉ action Ġ= ĠIntent . ACTION _ SEND Ċĉĉĉ ĉ putExtra ( Intent . EXTRA _ STREAM , Ġcontent Uri ) Ċĉĉĉ ĉ type Ġ= Ġ"* /* " Ċĉĉ ĉ } Ċĉĉ ĉ startActivity ( Intent . create Chooser ( share Intent , Ġ" Share Ġto :" )) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun ĠonClick Print (@ Suppress (" UNUSED _ PARAMETER ") Ġview : ĠView ) Ġ{ Ċĉ ĉ Notifications Sdk . print All Sdk Worker States () Ċ ĉ } ĊĊ ĉ fun ĠonChange Attrs (@ Suppress (" UNUSED _ PARAMETER ") Ġview : ĠView ) Ġ{ Ċĉ ĉ val Ġmap Ġ= Ġmutable Map Of < String , ĠString >(). apply Ġ{ Ċĉĉ ĉ put (" bl z ", ĠUUID . randomUUID (). toString (). replace ("- ", Ġ"_ ")) Ċĉ ĉ } Ċĉ ĉ Tim ber . d (" Adding Ġbl z Ġ= Ġ${ map [" bl z "] }") Ċĉ ĉ notifications Sdk . set Attributes ( map ) Ċ ĉ } ĊĊ ĉ fun ĠonChange Ad Id (@ Suppress (" UNUSED _ PARAMETER ") Ġview : ĠView ) Ġ{ Ċĉ ĉ val Ġad Ġ= ĠUUID . randomUUID (). toString () Ċĉ ĉ Tim ber . d (" Adding Ġad Ġ= Ġ$ ad ") Ċĉ ĉ notifications Sdk . set Ad vertisement Id ( ad ) Ċ ĉ } ĊĊ ĉ fun Ġon Enabled Change (@ Suppress (" UNUSED _ PARAMETER ") Ġview : ĠView ) Ġ{ Ċĉ ĉ if Ġ( notifications Sdk . isEnabled ()) Ġ{ Ċĉĉ ĉ notifications Sdk . setEnabled ( false ) Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ notifications Sdk . setEnabled ( true ) Ċĉ ĉ } Ċĉ ĉ update Enabled Text () Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate Enabled Text () Ġ{ Ċĉ ĉ findViewById < TextView >( R . id . btn _ enable ). text Ġ= Ġif Ġ( notifications Sdk . isEnabled ()) Ġ" SDK Ġenabled " Ġelse Ġ" SDK Ġdisabled " Ċ ĉ } Ċ } Ċ