package Ġcom . rad ik al . pc notifications . model . service . impl Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroid . app . Pending Intent Ċ import Ġandroid . content . Intent Ċ import Ġandroid . tele phony . Sms Manager Ċ import Ġandroid . util . Log Ċ import Ġcom . rad ik al . pc notifications . model . domain . Contact Ċ import Ġcom . rad ik al . pc notifications . model . domain . Sms Ċ import Ġcom . rad ik al . pc notifications . model . persistence . Sms Dao Ċ import Ġcom . rad ik al . pc notifications . model . service . Sms Service Ċ import Ġjavax . inject . Inject Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġt ud or Ġon Ġ 5 / 1 / 1 7 . Ċ Ġ*/ Ċ class ĠS ms ServiceImpl Ġ@ Inject Ġconstructor () Ġ: ĠS ms Service Ġ{ ĊĠĠĠ Ġval ĠTAG : ĠString Ġ= Ġjava Class . simple Name ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġsms Dao : ĠS ms Dao ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġcontext : ĠApplication ĊĊĠĠĠ Ġoverride Ġfun ĠgetAll Threads (): ĠMap < String , ĠList < Sms >> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsms Threads Map : ĠMutable Map < String , ĠList < Sms >> Ġ= ĠHashMap () ĊĊĠĠĠĠĠĠĠ Ġval Ġall Received Ġ= Ġsms Dao . getAll Received () ĊĠĠĠĠĠĠĠ Ġval Ġall Sent Ġ= Ġsms Dao . getAll Sent () ĊĊĠĠĠĠĠĠĠ Ġval Ġreceived Addresses : ĠList < String > Ġ= Ġall Received . map Ġ{ Ġit . contact . displayName Ġ}. distinct () ĊĠĠĠĠĠĠĠ Ġval Ġsent Addresses : ĠList < String > Ġ= Ġall Sent . map Ġ{ Ġit . contact . displayName Ġ}. distinct () ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( received Address Ġin Ġreceived Addresses ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfilter Received Ġ= Ġall Received . filter Ġ{ Ġit . contact . displayName Ġ== Ġreceived Address Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfilter Sent Ġ= Ġall Sent . filter Ġ{ Ġit . contact . displayName Ġ== Ġreceived Address Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsms Threads Map . put ( received Address , Ġ( filter Received Ġ+ Ġfilter Sent ). sorted By Ġ{ Ġit . date Ġ}) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġnot Resp on ded Ġ= Ġsent Addresses . filter Ġ{ Ġ! received Addresses . contains ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġfor Ġ( not Resp on ded Addr Ġin Ġnot Resp on ded ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfilter Sent Ġ= Ġall Sent . filter Ġ{ Ġit . contact . displayName Ġ== Ġnot Resp on ded Addr Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsms Threads Map . put ( not Resp on ded Addr , Ġfilter Sent . sorted By Ġ{ Ġit . date Ġ}) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġsms Threads Map ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsend Sms ( sms : ĠS ms ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġsms . toString ()) ĊĠĠĠĠĠĠĠ Ġval Ġsent Pi Ġ= ĠPending Intent . get Broadcast ( context , Ġ 0 , ĠIntent (" SMS _ SENT "), Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġ// Sms Manager . getDefault (). send Text Message ( sms . contact . phoneNumber , Ġnull , Ġsms . message , Ġsent Pi , Ġnull ) ĊĠĠĠ Ġ} Ċ }