package Ġnet . os mand . telegram . ui Ċ Ċ import Ġandroid . animation .* Ċ import Ġandroid . annotation . Suppress Lint Ċ import Ġandroid . content . Intent Ċ import Ġandroid . graphics . Color Matrix Ċ import Ġandroid . graphics . Color Matrix Color Filter Ċ import Ġandroid . graphics . Type face Ċ import Ġandroid . graphics . drawable . Gradient Drawable Ċ import Ġandroid . os . Build Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . os . Handler Ċ import Ġandroid . text . Sp ann able String Ċ import Ġandroid . text . Sp ann able StringBuilder Ċ import Ġandroid . text . style . ForegroundColor Span Ċ import Ġandroid . text . style . Style Span Ċ import Ġandroid . util . Typed Value Ċ import Ġandroid . view .* Ċ import Ġandroid . view . animation . Linear Interpolator Ċ import Ġandroid . widget .* Ċ import Ġandroidx . core . content . Context Compat Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġcom . google . android . material . app bar . AppBar Layout Ċ import Ġnet . os mand . Platform Util Ċ import Ġnet . os mand . telegram .* Ċ import Ġnet . os mand . telegram . helpers . Location Messages Ċ import Ġnet . os mand . telegram . helpers . Telegram Helper Ċ import Ġnet . os mand . telegram . helpers . Telegram Helper . Telegram Listener Ċ import Ġnet . os mand . telegram . helpers . Telegram Ui Helper Ċ import Ġnet . os mand . telegram . utils . Android Utils Ċ import Ġnet . os mand . telegram . utils . Os mand Formatter Ċ import Ġorg . dr ink less . td . lib core . telegram . Td Api Ċ import Ġjava . util .* Ċ import Ġkotlin . Comparator Ċ import Ġkotlin . collections . HashSet Ċ Ċ private Ġconst Ġval ĠSELECT ED _ CHAT S _ KEY Ġ= Ġ" selected _ ch ats " Ċ private Ġconst Ġval ĠSELECT ED _ CHAT S _ USERS Ġ= Ġ" selected _ users " Ċ private Ġconst Ġval ĠSU G GEST ED Ġ= Ġ 2 Ċ private Ġconst Ġval ĠSHARE _ LOCATION _ CHAT Ġ= Ġ 1 Ċ private Ġconst Ġval ĠDEFAULT _ CHAT Ġ= Ġ 0 Ċ Ċ private Ġconst Ġval ĠAD AP TER _ UPDATE _ INTERVAL _ MS Ġ= Ġ 5 Ġ* Ġ 1 0 0 0 L Ġ// Ġ 5 Ġsec Ċ Ċ class ĠMy Location Tab Fragment Ġ: ĠFragment (), ĠTelegram Listener Ġ{ ĊĊ ĉ private Ġval Ġlog Ġ= ĠPlatform Util . getLog ( My Location Tab Fragment :: class . java ) ĊĊ ĉ private Ġvar Ġtext Margin Small : ĠInt Ġ= Ġ 0 Ċ ĉ private Ġvar Ġtext Margin Big : ĠInt Ġ= Ġ 0 Ċ ĉ private Ġvar Ġsearch Box Height : ĠInt Ġ= Ġ 0 Ċ ĉ private Ġvar Ġsearch Box Side s Margin : ĠInt Ġ= Ġ 0 Ċ ĉ private Ġvar Ġtitle Padding Small : ĠInt Ġ= Ġ 0 Ċ ĉ private Ġvar Ġtitle Padding Big : ĠInt Ġ= Ġ 0 ĊĊ ĉ private Ġvar Ġapp Bar Scroll Range : ĠInt Ġ= Ġ- 1 ĊĊ ĉ private Ġval Ġapp : ĠTelegram Application Ċĉ ĉ get () Ġ= Ġactivity ?. application Ġas ĠTelegram Application ĊĊ ĉ private Ġval Ġtele gram Helper Ġget () Ġ= Ġapp . telegram Helper Ċ ĉ private Ġval Ġshare Location Helper Ġget () Ġ= Ġapp . share Location Helper Ċ ĉ private Ġval Ġsettings Ġget () Ġ= Ġapp . settings ĊĊ ĉ private Ġlateinit Ġvar Ġapp Bar Layout : ĠApp Bar Layout Ċ ĉ private Ġlateinit Ġvar Ġimage Container : ĠFrame Layout Ċ ĉ private Ġlateinit Ġvar ĠcurrentUser Icon : ĠImageView Ċ ĉ private Ġlateinit Ġvar Ġtext Container : ĠLinearLayout Ċ ĉ private Ġlateinit Ġvar Ġtitle Container : ĠLinearLayout Ċ ĉ private Ġlateinit Ġvar Ġoptions Btn : ĠImageView Ċ ĉ private Ġlateinit Ġvar Ġtitle : ĠTextView Ċ ĉ private Ġlateinit Ġvar Ġdescription : ĠTextView Ċ ĉ private Ġlateinit Ġvar Ġsearch Box : ĠFrame Layout Ċ ĉ private Ġlateinit Ġvar Ġstop Sharing Switch er : ĠSwitch Ċ ĉ private Ġlateinit Ġvar Ġsharing Status Title : ĠTextView Ċ ĉ private Ġlateinit Ġvar Ġsharing Status Icon : ĠImageView Ċ ĉ private Ġlateinit Ġvar Ġstart Sharing Btn : ĠView Ċ ĉ private Ġlateinit Ġvar Ġback To O sm And Btn : ĠTextView ĊĊ ĉ private Ġlateinit Ġvar Ġsearch Box Bg : ĠGradient Drawable ĊĊ ĉ private Ġval Ġadapter Ġ= ĠMy Location ListAdapter () ĊĊ ĉ private Ġvar Ġapp Bar Collapsed Ġ= Ġfalse Ċ ĉ private Ġlateinit Ġvar Ġapp Bar Outline Provider : ĠView Outline Provider ĊĊ ĉ private Ġval Ġselected Ch ats Ġ= ĠHashSet < Long >() Ċ ĉ private Ġval Ġselected Users Ġ= ĠHashSet < Long >() ĊĊ ĉ private Ġvar Ġaction Buttons Listener : ĠAction Buttons Listener ? Ġ= Ġnull ĊĊ ĉ private Ġvar Ġsharing Mode Ġ= Ġfalse ĊĊ ĉ private Ġvar Ġupdate Enable : ĠBoolean Ġ= Ġfalse ĊĊ ĉ private Ġlateinit Ġvar Ġlast Ch ats Info : ĠLinkedList < Telegram Settings . Last Chat Info > ĊĊ ĉ override Ġfun ĠonCreate View ( Ċĉ ĉ in flater : ĠLayoutInflater , Ċĉ ĉ container : ĠViewGroup ?, Ċĉ ĉ savedInstanceState : ĠBundle ? Ċ ĉ ): ĠView ? Ġ{ Ċĉ ĉ val Ġactivity Ġ= Ġactivity Ċĉ ĉ if Ġ( activity Ġis ĠAction Buttons Listener ) Ġ{ Ċĉĉ ĉ action Buttons Listener Ġ= Ġactivity Ċĉ ĉ } ĊĊĉ ĉ text Margin Small Ġ= Ġresources . get Dimension Pixel Size ( R . dim en . content _ padding _ standard ) Ċĉ ĉ text Margin Big Ġ= Ġresources . get Dimension Pixel Size ( R . dim en . my _ location _ text _ sides _ margin ) Ċĉ ĉ search Box Height Ġ= Ġresources . get Dimension Pixel Size ( R . dim en . search _ box _ height ) Ċĉ ĉ search Box Side s Margin Ġ= Ġresources . get Dimension Pixel Size ( R . dim en . content _ padding _ half ) Ċĉ ĉ title Padding Small Ġ= Ġresources . get Dimension Pixel Size ( R . dim en . app _ bar _ title _ padding _ small ) Ċĉ ĉ title Padding Big Ġ= Ġresources . get Dimension Pixel Size ( R . dim en . app _ bar _ title _ padding _ big ) ĊĊĉ ĉ sharing Mode Ġ= Ġsettings . has Any Chat To Share Location () ĊĊĉ ĉ savedInstanceState ?. apply Ġ{ Ċĉĉ ĉ val Ġch ats Array Ġ= Ġget Long Array ( SELECTED _ CHAT S _ KEY ) Ċĉĉ ĉ val Ġusers Array Ġ= Ġget Long Array ( SELECTED _ CHAT S _ KEY ) Ċĉĉ ĉ if Ġ( ch ats Array Ġ!= Ġnull ) Ġ{ Ċĉĉĉ ĉ selected Ch ats . addAll ( ch ats Array . toSet ()) Ċĉĉ ĉ } Ċĉĉ ĉ if Ġ( users Array Ġ!= Ġnull ) Ġ{ Ċĉĉĉ ĉ selected Users . addAll ( users Array . toSet ()) Ċĉĉ ĉ } Ċĉĉ ĉ action Buttons Listener ?. switch Buttons Visibility (( selected Users . isNotEmpty () Ġ|| Ġselected Ch ats . isNotEmpty ())) Ċĉ ĉ } ĊĊĉ ĉ val Ġmain View Ġ= Ġinflater . inflate ( R . layout . fragment _ my _ location _ tab , Ġcontainer , Ġfalse ) ĊĊĉ ĉ app Bar Layout Ġ= Ġmain View . findViewById < AppBar Layout >( R . id . app _ bar _ layout ). apply Ġ{ Ċĉĉ ĉ if Ġ( Build . VERSION . SDK _ INT Ġ>= Ġ 2 1 ) Ġ{ Ċĉĉĉ ĉ app Bar Outline Provider Ġ= Ġoutline Provider Ċĉĉĉ ĉ outline Provider Ġ= Ġnull Ċĉĉ ĉ } Ċĉĉ ĉ add On Offset Changed Listener ( AppBar Layout . On Offset Changed Listener Ġ{ Ġapp Bar , Ġoffset Ġ-> Ċĉĉĉ ĉ if Ġ( app Bar Scroll Range Ġ== Ġ- 1 ) Ġ{ Ċĉĉĉĉ ĉ app Bar Scroll Range Ġ= Ġapp Bar . total Scroll Range Ċĉĉĉ ĉ } Ċĉĉĉ ĉ val Ġcollapsed Ġ= ĠMath . abs ( offset ) Ġ== Ġapp Bar Scroll Range Ċĉĉĉ ĉ if Ġ( collapsed Ġ!= Ġapp Bar Collapsed ) Ġ{ Ċĉĉĉĉ ĉ app Bar Collapsed Ġ= Ġcollapsed Ċĉĉĉĉ ĉ adjust Text () Ċĉĉĉĉ ĉ adjust App bar () Ċĉĉĉĉ ĉ adjust Search Box () Ċĉĉĉĉ ĉ options Btn . visibility Ġ= Ġif Ġ( collapsed ) ĠView . VISIBLE Ġelse ĠView . GONE Ċĉĉĉ ĉ } Ċĉĉ ĉ }) Ċĉ ĉ } ĊĊĉ ĉ currentUser Icon Ġ= Ġmain View . findViewById ( R . id . user _ icon ) ĊĊĉ ĉ options Btn Ġ= Ġmain View . findViewById < ImageView >( R . id . options ) Ċĉ ĉ with ( activity Ġas ĠMainActivity ) Ġ{ Ċĉĉ ĉ setup Options Btn ( options Btn ) Ċĉĉ ĉ setup Options Btn ( main View . findViewById < ImageView >( R . id . options _ title )) Ċĉ ĉ } ĊĊĉ ĉ image Container Ġ= Ġmain View . findViewById < Frame Layout >( R . id . image _ container ) Ċĉ ĉ title Container Ġ= Ġmain View . findViewById < LinearLayout >( R . id . title _ container ). apply Ġ{ Ċĉĉ ĉ Android Utils . add StatusBar Padding 1 9 v ( context , Ġthis ) Ċĉ ĉ } ĊĊĉ ĉ main View . findViewById < TextView >( R . id . status _ title ). apply Ġ{ Ċĉĉ ĉ val Ġenabled Ġ= ĠgetString ( R . string . shared _ string _ enabled ) Ċĉĉ ĉ val Ġsharing Status Ġ= ĠgetString ( R . string . location _ sharing _ status , Ġenabled ) Ċĉĉ ĉ val Ġsp ann able Ġ= ĠSp ann able String ( sharing Status ) Ċĉĉ ĉ val Ġstart Ġ= Ġsharing Status . indexOf ( enabled ) Ċĉĉ ĉ if Ġ( start Ġ!= Ġ- 1 ) Ġ{ Ċĉĉĉ ĉ span nable . set Span ( ForegroundColor Span ( app . ui Utils . getActive Color ()), Ġstart , Ġstart Ġ+ Ġenabled . length , Ġ 0 ) Ċĉĉ ĉ } Ċĉĉ ĉ text Ġ= Ġsp ann able Ċĉ ĉ } ĊĊĉ ĉ sharing Status Icon Ġ= Ġmain View . findViewById < ImageView >( R . id . sharing _ status _ icon ) ĊĊĉ ĉ text Container Ġ= Ġmain View . findViewById < LinearLayout >( R . id . text _ container ). apply Ġ{ Ċĉĉ ĉ if Ġ( Build . VERSION . SDK _ INT Ġ>= Ġ 1 6 ) Ġ{ Ċĉĉĉ ĉ layout Transition . enable Transition Type ( Layout Transition . CHANG ING ) Ċĉĉ ĉ } Ċĉĉ ĉ title Ġ= ĠfindViewById ( R . id . title ) Ċĉĉ ĉ description Ġ= ĠfindViewById ( R . id . description ) Ċĉ ĉ } ĊĊĉ ĉ search Box Bg Ġ= ĠGradient Drawable (). apply Ġ{ Ċĉĉ ĉ shape Ġ= ĠGradient Drawable . RECT ANGLE Ċĉĉ ĉ setColor ( Context Compat . getColor ( app , ĠR . color . screen _ bg _ light )) Ċĉĉ ĉ corner Radius Ġ= Ġ( search Box Height Ġ/ Ġ 2 ). toFloat () Ċĉ ĉ } ĊĊĉ ĉ search Box Ġ= Ġmain View . findViewById < Frame Layout >( R . id . search _ box ). apply Ġ{ Ċĉĉ ĉ if Ġ( Build . VERSION . SDK _ INT Ġ>= Ġ 1 6 ) Ġ{ Ċĉĉĉ ĉ background Ġ= Ġsearch Box Bg Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ @ Suppress (" DE PREC ATION ") Ċĉĉĉ ĉ setBackground Drawable ( search Box Bg ) Ċĉĉ ĉ } Ċĉĉ ĉ findViewById < View >( R . id . search _ button ). setOnClickListener Ġ{ Ċĉĉĉ ĉ activity . support FragmentManager ?. also Ġ{ Ċĉĉĉĉ ĉ Search Dialog Fragment . show Instance ( it , Ġthis @ My Location Tab Fragment , Ġselected Ch ats , Ġselected Users ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ findViewById < ImageView >( R . id . search _ icon ) Ċĉĉĉ ĉ . setImage Drawable ( app . ui Utils . get The med Icon ( R . drawable . ic _ action _ search _ dark )) Ċĉ ĉ } ĊĊĉ ĉ main View . findViewById < android x . recyclerview . widget . RecyclerView >( R . id . recycler _ view ). apply Ġ{ Ċĉĉ ĉ layout Manager Ġ= ĠLinearLayoutManager ( context ) Ċĉĉ ĉ adapter Ġ= Ġthis @ My Location Tab Fragment . adapter Ċĉĉ ĉ add On Scroll Listener ( object Ġ: Ġandroidx . recyclerview . widget . RecyclerView . On Scroll Listener () Ġ{ Ċĉĉĉ ĉ override Ġfun Ġon Scroll StateChanged ( re cyclerView : Ġandroidx . recyclerview . widget . RecyclerView , ĠnewState : ĠInt ) Ġ{ Ċĉĉĉĉ ĉ super . on Scroll StateChanged ( re cyclerView , ĠnewState ) Ċĉĉĉĉ ĉ when Ġ( newState ) Ġ{ Ċĉĉĉĉĉ ĉ android x . recyclerview . widget . RecyclerView . SCROLL _ STATE _ DR AG GING Ġ-> Ġanimate Start Sharing Btn ( false ) Ċĉĉĉĉĉ ĉ android x . recyclerview . widget . RecyclerView . SCROLL _ STATE _ IDLE Ġ-> Ġanimate Start Sharing Btn ( true ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ }) Ċĉ ĉ } ĊĊĉ ĉ main View . findViewById < View >( R . id . stop _ all _ sharing _ row ). setOnClickListener Ġ{ Ċĉĉ ĉ fragment Manager ?. also Ġ{ Ġfm Ġ-> Ċĉĉĉ ĉ Disable Sharing Bottom Sheet . show Instance ( fm , Ġthis , Ġadapter . items . size ) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ main View . findViewById < View >( R . id . sharing _ status _ container ). setOnClickListener Ġ{ Ċĉĉ ĉ settings . update Sharing Status History () Ċĉĉ ĉ update Sharing Status () Ċĉĉ ĉ fragment Manager ?. also Ġ{ Ġfm Ġ-> Ċĉĉĉ ĉ Sharing Status Bottom Sheet . show Instance ( fm , Ġthis ) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ stop Sharing Switch er Ġ= Ġmain View . findViewById ( R . id . stop _ all _ sharing _ switch er ) ĊĊĉ ĉ sharing Status Title Ġ= Ġmain View . findViewById ( R . id . sharing _ status _ title ) ĊĊĉ ĉ start Sharing Btn Ġ= Ġmain View . findViewById < View >( R . id . start _ sharing _ btn ). apply Ġ{ Ċĉĉ ĉ visibility Ġ= Ġif Ġ( sharing Mode ) ĠView . VISIBLE Ġelse ĠView . GONE Ċĉĉ ĉ setOnClickListener Ġ{ Ċĉĉĉ ĉ sharing Mode Ġ= Ġfalse Ċĉĉĉ ĉ action Buttons Listener ?. switch Buttons Visibility ( true ) Ċĉĉĉ ĉ update Content () Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ back To O sm And Btn Ġ= Ġmain View . findViewById < TextView >( R . id . back _ to _ os mand ) Ċĉ ĉ last Ch ats Info Ġ= Ġsettings . last Ch ats Info ĊĊĉ ĉ return Ġmain View Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Resume () Ġ{ Ċĉ ĉ super . on Resume () Ċĉ ĉ update CurrentUser Photo () Ċĉ ĉ update Content () Ċĉ ĉ update Enable Ġ= Ġtrue Ċĉ ĉ start Handler () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Pause () Ġ{ Ċĉ ĉ super . on Pause () Ċĉ ĉ update Enable Ġ= Ġfalse Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Save InstanceState ( out State : ĠBundle ) Ġ{ Ċĉ ĉ super . on Save InstanceState ( out State ) Ċĉ ĉ out State . put Long Array ( SELECTED _ CHAT S _ KEY , Ġselected Ch ats . to Long Array ()) Ċĉ ĉ out State . put Long Array ( SELECTED _ CHAT S _ USERS , Ġselected Users . to Long Array ()) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Activity Result ( request Code : ĠInt , ĠresultCode : ĠInt , Ġdata : ĠIntent ?) Ġ{ Ċĉ ĉ super . on Activity Result ( request Code , ĠresultCode , Ġdata ) Ċĉ ĉ when Ġ( request Code ) Ġ{ Ċĉĉ ĉ Set Time Dialog Fragment . LOCATION _ SHARED _ REQUEST _ CODE , ĠSearch Dialog Fragment . SEARCH _ ITEMS _ REQUEST _ CODE Ġ-> Ġ{ Ċĉĉĉ ĉ sharing Mode Ġ= Ġsettings . has Any Chat To Share Location () Ċĉĉĉ ĉ clear Selection () Ċĉĉĉ ĉ update Content () Ċĉĉĉ ĉ if Ġ( result Code Ġ== ĠSet Time Dialog Fragment . LOCATION _ SHARED _ REQUEST _ CODE ) Ġ{ Ċĉĉĉĉ ĉ ask Battery Optim isation () Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ Disable Sharing Bottom Sheet . SH AR ING _ DISABLED _ REQUEST _ CODE Ġ-> Ġ{ Ċĉĉĉ ĉ save Ch ats To Last Ch ats Info () Ċĉĉĉ ĉ sharing Mode Ġ= Ġfalse Ċĉĉĉ ĉ app . stop Sharing Location () Ċĉĉĉ ĉ update Content () Ċĉĉ ĉ } Ċĉĉ ĉ Sharing Status Bottom Sheet . SH AR ING _ STATUS _ REQUEST _ CODE Ġ-> Ġ{ Ċĉĉĉ ĉ update Sharing Status () Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Telegram Status Changed ( Ċĉ ĉ prev Telegram Authorization State : ĠTelegram Helper . Telegram Authorization State , Ċĉ ĉ new Telegram Authorization State : ĠTelegram Helper . Telegram Authorization State Ċ ĉ ) Ġ{ Ċĉ ĉ when Ġ( new Telegram Authorization State ) Ġ{ Ċĉĉ ĉ Telegram Helper . Telegram Authorization State . READY Ġ-> Ġ{ Ċĉĉĉ ĉ update Content () Ċĉĉ ĉ } Ċĉĉ ĉ Telegram Helper . Telegram Authorization State . LOG GING _ OUT , Ċĉĉ ĉ Telegram Helper . Telegram Authorization State . CLOSED , Ċĉĉ ĉ Telegram Helper . Telegram Authorization State . UNKNOWN Ġ-> Ġ{ Ċĉĉĉ ĉ adapter . items Ġ= Ġmutable ListOf () Ċĉĉ ĉ } Ċĉĉ ĉ else Ġ-> ĠUnit Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Telegram Ch ats Read () Ġ{ Ċĉ ĉ update Content () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Telegram Ch ats Changed () Ġ{ Ċĉ ĉ update Content () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Telegram Chat Changed ( chat : ĠT d Api . Chat ) Ġ{ Ċĉ ĉ update Content () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Telegram Chat Created ( chat : ĠT d Api . Chat ) Ġ{ Ċĉ ĉ sharing Mode Ġ= Ġsettings . has Any Chat To Share Location () Ċĉ ĉ update Content () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Telegram User Changed ( user : ĠT d Api . User ) Ġ{ Ċĉ ĉ if Ġ( user . id Ġ== Ġtele gram Helper . getCurrent User ()?. id ) Ġ{ Ċĉĉ ĉ update CurrentUser Photo () Ċĉ ĉ } Ċĉ ĉ update Content () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Telegram Error ( code : ĠInt , Ġmessage : ĠString ) Ġ{ Ċ ĉ } ĊĊ ĉ fun Ġon Primary Btn Click () Ġ{ Ċĉ ĉ if Ġ( selected Ch ats . isNotEmpty () Ġ|| Ġselected Users . isNotEmpty ()) Ġ{ Ċĉĉ ĉ val Ġfm Ġ= Ġfragment Manager Ġ?: Ġreturn Ċĉĉ ĉ Set Time Dialog Fragment . show Instance ( fm , Ġselected Ch ats , Ġselected Users , Ġthis ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġon Secondary Btn Click () Ġ{ Ċĉ ĉ clear Selection () Ċĉ ĉ if Ġ( settings . has Any Chat To Share Location ()) Ġ{ Ċĉĉ ĉ sharing Mode Ġ= Ġtrue Ċĉĉ ĉ update Content () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġask Battery Optim isation () Ġ{ Ċĉ ĉ if Ġ( sharing Mode Ġ&& Ġ! settings . battery Optim isation Ask ed Ġ&& ĠBuild . VERSION . SDK _ INT Ġ>= Ġ 2 6 ) Ġ{ Ċĉĉ ĉ fragment Manager ?. also Ġ{ Ġfm Ġ-> Ċĉĉĉ ĉ Battery Optimization Bottom Sheet . show Instance ( fm ) Ċĉĉĉ ĉ settings . battery Optim isation Ask ed Ġ= Ġtrue Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate CurrentUser Photo () Ġ{ Ċĉ ĉ Telegram Ui Helper . setup Photo ( Ċĉĉ ĉ app , Ċĉĉ ĉ currentUser Icon , Ċĉĉ ĉ telegram Helper . getUser Photo Path ( telegram Helper . getCurrent User ()), Ċĉĉ ĉ R . drawable . img _ user _ placeholder , Ċĉĉ ĉ false Ċĉ ĉ ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġstart Handler () Ġ{ Ċĉ ĉ val Ġupdate Adapter Ġ= ĠHandler () Ċĉ ĉ update Adapter . post Delayed ({ Ċĉĉ ĉ if Ġ( update Enable ) Ġ{ Ċĉĉĉ ĉ update Content () Ċĉĉĉ ĉ start Handler () Ċĉĉ ĉ } Ċĉ ĉ }, ĠAD AP TER _ UPDATE _ INTERVAL _ MS ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġanimate Start Sharing Btn ( show : ĠBoolean ) Ġ{ Ċĉ ĉ if Ġ( start Sharing Btn . visibility Ġ== ĠView . VISIBLE ) Ġ{ Ċĉĉ ĉ val Ġscale Ġ= Ġif Ġ( show ) Ġ 1 f Ġelse Ġ 0 f Ċĉĉ ĉ start Sharing Btn . animate () Ċĉĉĉ ĉ . scale X ( scale ) Ċĉĉĉ ĉ . scale Y ( scale ) Ċĉĉĉ ĉ . set Duration ( 2 0 0 ) Ċĉĉĉ ĉ . set Interpolator ( Linear Interpolator ()) Ċĉĉĉ ĉ . start () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġclear Selection () Ġ{ Ċĉ ĉ selected Ch ats . clear () Ċĉ ĉ selected Users . clear () Ċĉ ĉ adapter . notify DataSet Changed () Ċĉ ĉ action Buttons Listener ?. switch Buttons Visibility ( false ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġadjust Text () Ġ{ Ċĉ ĉ val Ġgravity Ġ= Ġif Ġ( app Bar Collapsed ) ĠGr avity . START Ġelse ĠGr avity . CENTER Ċĉ ĉ val Ġpadding Ġ= Ġif Ġ( app Bar Collapsed ) Ġtext Margin Small Ġelse Ġtext Margin Big Ċĉ ĉ val Ġtitle Padding Ġ= Ġif Ġ( app Bar Collapsed ) Ġtitle Padding Big Ġelse Ġtitle Padding Small Ċĉ ĉ text Container . apply Ġ{ Ċĉĉ ĉ set Padding ( padding , Ġpadding Top , Ġpadding , Ġpadding Bottom ) Ċĉĉ ĉ if Ġ( app Bar Collapsed ) Ġ{ Ċĉĉĉ ĉ Android Utils . add StatusBar Padding 1 9 v ( app , Ġthis ) Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ Android Utils . remove StatusBar Padding 1 9 v ( app , Ġthis ) Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ title . apply Ġ{ Ċĉĉ ĉ this . gravity Ġ= Ġgravity Ċĉĉ ĉ set Padding ( padding Left , Ġtitle Padding , Ġpadding Right , Ġtitle Padding ) Ċĉ ĉ } Ċĉ ĉ description . gravity Ġ= Ġgravity Ċ ĉ } ĊĊ ĉ private Ġfun Ġadjust App bar () Ġ{ Ċĉ ĉ update Title TextColor () Ċĉ ĉ if Ġ( Build . VERSION . SDK _ INT Ġ>= Ġ 2 1 ) Ġ{ Ċĉĉ ĉ if Ġ( app Bar Collapsed ) Ġ{ Ċĉĉĉ ĉ app Bar Layout . outline Provider Ġ= Ġapp Bar Outline Provider Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ app Bar Layout . outline Provider Ġ= Ġnull Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġadjust Search Box () Ġ{ Ċĉ ĉ val Ġcorner Radius From Ġ= Ġif Ġ( app Bar Collapsed ) Ġsearch Box Height Ġ/ Ġ 2 Ġelse Ġ 0 Ċĉ ĉ val Ġcorner Radius To Ġ= Ġif Ġ( app Bar Collapsed ) Ġ 0 Ġelse Ġsearch Box Height Ġ/ Ġ 2 Ċĉ ĉ val Ġmargin From Ġ= Ġif Ġ( app Bar Collapsed ) Ġsearch Box Side s Margin Ġelse Ġ 0 Ċĉ ĉ val Ġmargin To Ġ= Ġif Ġ( app Bar Collapsed ) Ġ 0 Ġelse Ġsearch Box Side s Margin ĊĊĉ ĉ val Ġcorner Animator Ġ= ĠObject Animator . of Float ( Ċĉĉ ĉ search Box Bg , Ċĉĉ ĉ " corner Radius ", Ċĉĉ ĉ corner Radius From . toFloat (), Ċĉĉ ĉ corner Radius To . toFloat () Ċĉ ĉ ) ĊĊĉ ĉ val Ġmargin Animator Ġ= ĠValue Animator . of Int ( margin From , Ġmargin To ) Ċĉ ĉ margin Animator . add Update Listener Ġ{ Ċĉĉ ĉ val Ġvalue Ġ= Ġit . animated Value Ġas ĠInt Ċĉĉ ĉ val Ġparams Ġ= Ġsearch Box . layout Params Ġas ĠLinearLayout . LayoutParams Ċĉĉ ĉ params . set Margins ( value , Ġparams . top Margin , Ġvalue , Ġparams . bottom Margin ) Ċĉĉ ĉ search Box . layout Params Ġ= Ġparams Ċĉ ĉ } ĊĊĉ ĉ Animator Set (). apply Ġ{ Ċĉĉ ĉ duration Ġ= Ġ 2 0 0 Ċĉĉ ĉ play To gether ( corner Animator , Ġmargin Animator ) Ċĉĉ ĉ addListener ( object Ġ: ĠAn imator Listener Adapter () Ġ{ Ċĉĉĉ ĉ override Ġfun Ġon Animation End ( animation : ĠAn imator ?) Ġ{ Ċĉĉĉĉ ĉ update Title TextColor () Ċĉĉĉĉ ĉ if Ġ( app Bar Collapsed Ġ&& ĠBuild . VERSION . SDK _ INT Ġ>= Ġ 2 1 ) Ġ{ Ċĉĉĉĉĉ ĉ app Bar Layout . outline Provider Ġ= Ġapp Bar Outline Provider Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ }) Ċĉĉ ĉ start () Ċĉ ĉ } ĊĊĉ ĉ if Ġ(! app Bar Collapsed Ġ&& ĠBuild . VERSION . SDK _ INT Ġ>= Ġ 2 1 ) Ġ{ Ċĉĉ ĉ app Bar Layout . outline Provider Ġ= Ġnull Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate Title TextColor () Ġ{ Ċĉ ĉ val Ġcolor Ġ= Ġif Ġ( app Bar Collapsed ) ĠR . color . app _ bar _ title _ light Ġelse ĠR . color . ctrl _ active _ light Ċĉ ĉ context ?. also Ġ{ Ċĉĉ ĉ title . setTextColor ( Context Compat . getColor ( it , Ġcolor )) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate Content () Ġ{ Ċĉ ĉ sharing Mode Ġ= Ġsharing Mode Ġ&& Ġsettings . has Any Chat To Share Location () Ċĉ ĉ update Sharing Status () Ċĉ ĉ update Sharing Mode () Ċĉ ĉ update List () Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate Sharing Mode () Ġ{ Ċĉ ĉ val Ġheader Params Ġ= Ġimage Container . layout Params Ġas ĠApp Bar Layout . LayoutParams Ċĉ ĉ image Container . visibility Ġ= Ġif Ġ( sharing Mode ) ĠView . GONE Ġelse ĠView . VISIBLE Ċĉ ĉ text Container . visibility Ġ= Ġif Ġ( sharing Mode ) ĠView . GONE Ġelse ĠView . VISIBLE Ċĉ ĉ title Container . visibility Ġ= Ġif Ġ( sharing Mode ) ĠView . VISIBLE Ġelse ĠView . GONE Ċĉ ĉ start Sharing Btn . visibility Ġ= Ġif Ġ( sharing Mode ) ĠView . VISIBLE Ġelse ĠView . GONE Ċĉ ĉ header Params . scroll Flags Ġ= Ċĉĉĉ ĉ if Ġ( sharing Mode ) Ġ 0 Ġelse ĠApp Bar Layout . LayoutParams . SCROLL _ FLAG _ SCROLL Ċĉ ĉ stop Sharing Switch er . isChecked Ġ= Ġtrue Ċĉ ĉ app Bar Scroll Range Ġ= Ġ- 1 Ċĉ ĉ update Back To O sm And Btn () Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate Back To O sm And Btn () Ġ{ Ċĉ ĉ val Ġp ck g Ġ= Ġapp . settings . app To Connect Package Ċĉ ĉ back To O sm And Btn . apply Ġ{ Ċĉĉ ĉ visibility Ġ= Ġif Ġ( p ck g . isNotEmpty () Ġ&& Ġsharing Mode Ġ&& ĠAndroid Utils . is App Installed ( app , Ġp ck g )) Ġ{ Ċĉĉĉ ĉ setOnClickListener Ġ{ Ċĉĉĉĉ ĉ val Ġstart Intent Ġ= Ġapp . package Manager . get Launch Intent For Package ( p ck g ) Ċĉĉĉĉ ĉ if Ġ( start Intent Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ start Intent . add Category ( Intent . CATEGORY _ LA UNCH ER ) Ċĉĉĉĉĉ ĉ startActivity ( start Intent ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ View . VISIBLE Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ View . GONE Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate Sharing Status () Ġ{ Ċĉ ĉ if Ġ( sharing Mode ) Ġ{ Ċĉĉ ĉ settings . update Sharing Status History () Ċĉĉ ĉ val Ġsharing Status Ġ= Ġsettings . sharing Status Changes . last () Ċĉĉ ĉ sharing Status Title . text Ġ= Ġsharing Status . getTitle ( app ) Ċĉĉ ĉ sharing Status Icon . setImage Drawable ( Ċĉĉĉ ĉ app . ui Utils . get Icon ( Ċĉĉĉĉ ĉ sharing Status . status Type . icon Id , Ċĉĉĉĉ ĉ sharing Status . status Type . icon Color Res Ċĉĉĉ ĉ ) Ċĉĉ ĉ ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate List () Ġ{ Ċĉ ĉ val Ġlast Items Ġ= ĠgetLast Share Items () Ċĉ ĉ val Ġitems : ĠMutable List < Any > Ġ= Ġmutable ListOf () Ċĉ ĉ val Ġch ats : ĠMutable List < Td Api . Chat > Ġ= Ġmutable ListOf () Ċĉ ĉ val Ġcontacts Ġ= Ġtele gram Helper . get Contacts () Ċĉ ĉ val Ġchat List Ġ= Ġif Ġ( sharing Mode ) Ġ{ Ċĉĉ ĉ settings . get Share Location Ch ats () Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ telegram Helper . get Chat List Ids () Ċĉ ĉ } Ċĉ ĉ for Ġ( chat Id Ġin Ġchat List ) Ġ{ Ċĉĉ ĉ val Ġchat Ġ= Ġtele gram Helper . get Chat ( chat Id ) Ċĉĉ ĉ if Ġ( chat Ġ!= Ġnull ) Ġ{ Ċĉĉĉ ĉ if Ġ(! sharing Mode Ġ&& Ġsettings . is Sharing Location To Chat ( chat Id )) Ġ{ Ċĉĉĉĉ ĉ continue Ċĉĉĉ ĉ } Ċĉĉĉ ĉ ch ats . add ( chat ) Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ items . addAll ( ch ats ) Ċĉ ĉ if Ġ(! sharing Mode ) Ġ{ Ċĉĉ ĉ for Ġ( user Ġin Ġcontacts . values ) Ġ{ Ċĉĉĉ ĉ val Ġcontains In Ch ats Ġ= Ġch ats . any Ġ{ Ġtele gram Helper . getUserId From Chat Type ( it . type ) Ġ== Ġuser . id Ġ} Ċĉĉĉ ĉ if Ġ((! sharing Mode Ġ&& Ġsettings . is Sharing Location To User ( user . id )) Ġ|| Ġcontains In Ch ats ) Ġ{ Ċĉĉĉĉ ĉ continue Ċĉĉĉ ĉ } Ċĉĉĉ ĉ items . add ( user ) Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ if Ġ( sharing Mode Ġ&& Ġsettings . has Any Chat To Share Location ()) Ġ{ Ċĉĉ ĉ val Ġfiltered Last Items Ġ= Ġlast Items . filter Ġ{ Ġ! settings . is Sharing Location To Chat ( it . chat . id ) Ġ}. to Mutable List () Ċĉĉ ĉ val Ġsorted Items Ġ= Ġsort Adapter Items ( items Ġas ĠMutable List < Td Api . Object >) Ċĉĉ ĉ sorted Items . add ( Suggest ed Ch ats ( filtered Last Items )) Ċĉĉ ĉ adapter . items Ġ= Ġsorted Items Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ val Ġfiltered Last Items Ġ= Ġlast Items . filter Ġ{ Ġ! settings . is Sharing Location To Chat ( it . chat . id ) Ġ}. to Mutable List () Ċĉĉ ĉ items . add ( 0 , ĠSuggest ed Ch ats ( filtered Last Items )) Ċĉĉ ĉ adapter . items Ġ= Ġitems Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun ĠgetLast Share Items (): ĠMutable List < Last Chat > Ġ{ Ċĉ ĉ val Ġlast Items : ĠMutable List < Last Chat > Ġ= Ġmutable ListOf () Ċĉ ĉ val Ġchat List Ids Ġ= Ġtele gram Helper . get Chat List Ids () Ċĉ ĉ chat List Ids . forEach Ġ{ Ġchat Id Ġ-> Ċĉĉ ĉ val Ġchat Ġ= Ġtele gram Helper . get Chat ( chat Id ) Ċĉĉ ĉ val Ġlast Info Ġ= Ġlast Ch ats Info . find Ġ{ Ġit . chat Id Ġ== Ġchat Id Ġ} Ċĉĉ ĉ if Ġ( chat Ġ!= Ġnull Ġ&& Ġlast Info Ġ!= Ġnull ) Ġ{ Ċĉĉĉ ĉ val Ġindex Ġ= Ġlast Ch ats Info . indexOf ( last Info ) Ċĉĉĉ ĉ last Items . add ( Last Chat ( chat , Ġlast Ch ats Info [ index ]. period )) Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ return Ġlast Items Ċ ĉ } ĊĊ ĉ private Ġfun Ġsave Ch ats To Last Ch ats Info () Ġ{ Ċĉ ĉ val Ġchat List Ids Ġ= Ġsettings . get Share Location Ch ats () Ċĉ ĉ chat List Ids . forEach Ġ{ Ġid Ġ-> Ċĉĉ ĉ val Ġshare Info Ġ= Ġsettings . get Ch ats Share Info ()[ id ] Ċĉĉ ĉ if Ġ( share Info Ġ!= Ġnull ) Ġ{ Ċĉĉĉ ĉ settings . add Time Period To Last Item ( share Info . chat Id , Ġshare Info . live Period ) Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġsort Adapter Items ( list : ĠMutable List < Td Api . Object >): ĠMutable List < Any > Ġ{ Ċĉ ĉ list . sort With ( Comparator < Td Api . Object > Ġ{ Ġo 1 , Ġo 2 Ġ-> Ċĉĉ ĉ val Ġtitle 1 Ġ= Ġwhen Ġ( o 1 ) Ġ{ Ċĉĉĉ ĉ is ĠT d Api . Chat Ġ-> Ġo 1 . title Ċĉĉĉ ĉ is ĠT d Api . User Ġ-> ĠTelegram Ui Helper . getUser Name ( o 1 ) Ċĉĉĉ ĉ else Ġ-> Ġ"" Ċĉĉ ĉ } Ċĉĉ ĉ val Ġtitle 2 Ġ= Ġwhen Ġ( o 2 ) Ġ{ Ċĉĉĉ ĉ is ĠT d Api . Chat Ġ-> Ġo 2 . title Ċĉĉĉ ĉ is ĠT d Api . User Ġ-> ĠTelegram Ui Helper . getUser Name ( o 2 ) Ċĉĉĉ ĉ else Ġ-> Ġ"" Ċĉĉ ĉ } Ċĉĉ ĉ title 1 . compareTo ( title 2 ) Ċĉ ĉ }) Ċĉ ĉ return Ġlist . to Mutable List () Ċ ĉ } ĊĊ ĉ inner Ġclass ĠMy Location ListAdapter Ġ: Ċĉ ĉ android x . recyclerview . widget . RecyclerView . Adapter < My Location ListAdapter . Base ViewHolder >() Ġ{ Ċĉ ĉ var Ġitems Ġ= Ġmutable ListOf < Any >() Ċĉĉ ĉ set ( value ) Ġ{ Ċĉĉĉ ĉ field Ġ= Ġvalue Ċĉĉĉ ĉ notify DataSet Changed () Ċĉĉ ĉ } ĊĊĉ ĉ override Ġfun ĠgetItem ViewType ( position : ĠInt ): ĠInt Ġ{ Ċĉĉ ĉ val Ġitem Ġ= Ġitems [ position ] Ċĉĉ ĉ val Ġid Ġ= Ġwhen Ġ( item ) Ġ{ Ċĉĉĉ ĉ is ĠT d Api . Chat Ġ-> Ġitem . id Ċĉĉĉ ĉ is ĠT d Api . User Ġ-> Ġitem . id . to Long () Ċĉĉĉ ĉ else Ġ-> Ġ- 1 Ċĉĉ ĉ } Ċĉĉ ĉ return Ġif Ġ( item Ġis ĠSuggest ed Ch ats ) Ġ{ Ċĉĉĉ ĉ SU G GEST ED Ċĉĉ ĉ } Ġelse Ġif Ġ( settings . is Sharing Location To Chat ( id ) Ġ&& Ġsharing Mode ) Ġ{ Ċĉĉĉ ĉ SHARE _ LOCATION _ CHAT Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ DEFAULT _ CHAT Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ override Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠBase ViewHolder Ġ{ Ċĉĉ ĉ return Ġwhen Ġ( view Type ) Ġ{ Ċĉĉĉ ĉ SHARE _ LOCATION _ CHAT Ġ-> Ġ{ Ċĉĉĉĉ ĉ val Ġview Ġ= ĠLayoutInflater . from ( parent . context ) Ċĉĉĉĉĉ ĉ . inflate ( R . layout . my _ location _ sharing _ chat , Ġparent , Ġfalse ) Ċĉĉĉĉ ĉ Sharing Chat ViewHolder ( view ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ DEFAULT _ CHAT Ġ-> Ġ{ Ċĉĉĉĉ ĉ val Ġview Ġ= ĠLayoutInflater . from ( parent . context ) Ċĉĉĉĉĉ ĉ . inflate ( R . layout . user _ list _ item , Ġparent , Ġfalse ) Ċĉĉĉĉ ĉ Chat ViewHolder ( view ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ SU G GEST ED Ġ-> Ġ{ Ċĉĉĉĉ ĉ val Ġview Ġ= ĠLayoutInflater . from ( parent . context ) Ċĉĉĉĉĉĉ ĉ . inflate ( R . layout . suggest ed _ list _ item , Ġparent , Ġfalse ) Ċĉĉĉĉ ĉ Suggest ed ViewHolder ( view ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ else Ġ-> Ġthrow ĠRuntimeException (" Unsupported Ġview Ġtype : Ġ$ view Type ") Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ @ Suppress Lint (" SetText I 1 8 n ") Ċĉ ĉ override Ġfun Ġon Bind ViewHolder ( holder : ĠBase ViewHolder , Ġposition : ĠInt ) Ġ{ Ċĉĉ ĉ val Ġitem Ġ= Ġitems [ position ] Ċĉĉ ĉ val Ġis Chat Ġ= Ġitem Ġis ĠT d Api . Chat Ċĉĉ ĉ val ĠitemId Ġ= Ġif Ġ( is Chat ) Ġ{ Ċĉĉĉ ĉ ( item Ġas ĠT d Api . Chat ). id Ċĉĉ ĉ } Ġelse Ġif Ġ( item Ġis ĠT d Api . User ) Ġ{ Ċĉĉĉ ĉ item . id . to Long () Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ - 1 Ċĉĉ ĉ } ĊĊĉĉ ĉ val Ġlast Item Ġ= Ġposition Ġ== Ġitem Count Ġ- Ġ 1 Ċĉĉ ĉ val Ġlive Ġ= Ġ( is Chat Ġ&& Ġsettings . is Sharing Location To Chat ( itemId )) Ċĉĉ ĉ val Ġshare Info Ġ= Ġif Ġ( is Chat ) Ġsettings . get Ch ats Share Info ()[ itemId ] Ġelse Ġnull ĊĊĉĉ ĉ setup Photo ( item , Ġholder . icon , Ġis Chat ) Ċĉĉ ĉ holder . title ?. text Ġ= Ġget Title Text ( item ) ĊĊĉĉ ĉ if Ġ( holder Ġis ĠChat ViewHolder ) Ġ{ Ċĉĉĉ ĉ holder . description ?. visibility Ġ= ĠView . GONE Ċĉĉĉ ĉ if Ġ( live ) Ġ{ Ċĉĉĉĉ ĉ holder . checkBox ?. visibility Ġ= ĠView . GONE Ċĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉ ĉ holder . checkBox ?. apply Ġ{ Ċĉĉĉĉĉ ĉ visibility Ġ= ĠView . VISIBLE Ċĉĉĉĉĉ ĉ setOn Checked ChangeListener ( null ) Ċĉĉĉĉĉ ĉ isChecked Ġ= Ġif Ġ( is Chat ) Ġ{ Ċĉĉĉĉĉĉ ĉ selected Ch ats . contains ( itemId ) Ċĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉ ĉ selected Users . contains ( itemId ) Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ setOn Checked ChangeListener Ġ{ Ġ_, Ġis Checked Ġ-> Ċĉĉĉĉĉĉ ĉ if Ġ( isChecked ) Ġ{ Ċĉĉĉĉĉĉĉ ĉ if Ġ( is Chat ) Ġ{ Ċĉĉĉĉĉĉĉĉ ĉ selected Ch ats . add ( itemId ) Ċĉĉĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉĉĉ ĉ selected Users . add ( itemId ) Ċĉĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉĉ ĉ if Ġ( is Chat ) Ġ{ Ċĉĉĉĉĉĉĉĉ ĉ selected Ch ats . remove ( itemId ) Ċĉĉĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉĉĉ ĉ selected Users . remove ( itemId ) Ċĉĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉĉ ĉ action Buttons Listener ?. switch Buttons Visibility ( selected Ch ats . isNotEmpty () Ġ|| Ġselected Users . isNotEmpty ()) Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ holder . top Shadow Divider ?. visibility Ġ= ĠView . GONE Ċĉĉĉ ĉ holder . bottom Shadow ?. visibility Ġ= Ġif Ġ( last Item ) ĠView . VISIBLE Ġelse ĠView . GONE Ċĉĉĉ ĉ holder . item View . setOnClickListener Ġ{ Ċĉĉĉĉ ĉ if Ġ( live ) Ġ{ Ċĉĉĉĉĉ ĉ settings . share Location To Chat ( itemId , Ġfalse ) Ċĉĉĉĉĉ ĉ share Location Helper . stop Sharing Location () Ċĉĉĉĉĉ ĉ notify Item Changed ( position ) Ċĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉ ĉ holder . checkBox ?. apply Ġ{ Ċĉĉĉĉĉĉ ĉ isChecked Ġ= Ġ! isChecked Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ġelse Ġif Ġ( holder Ġis ĠSh aring Chat ViewHolder ) Ġ{ Ċĉĉĉ ĉ holder . switch er ?. apply Ġ{ Ċĉĉĉĉ ĉ isChecked Ġ= Ġlive Ċĉĉĉĉ ĉ setOn Checked ChangeListener Ġ{ Ġ_, Ġis Checked Ġ-> Ċĉĉĉĉĉ ĉ if Ġ(! isChecked ) Ġ{ Ċĉĉĉĉĉĉ ĉ settings . share Location To Chat ( itemId , Ġfalse ) Ċĉĉĉĉĉĉ ĉ if Ġ( share Info Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉĉĉ ĉ telegram Helper . stop Sending Live Location To Chat ( share Info ) Ċĉĉĉĉĉĉĉ ĉ settings . add Time Period To Last Item ( share Info . chat Id , share Info . live Period ) Ċĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉĉ ĉ removeItem ( item Ġas ĠT d Api . Object ) Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } ĊĊĉĉĉ ĉ val Ġduration Ġ= Ġshare Info ?. user Set Live Period Ċĉĉĉ ĉ if Ġ( duration Ġ!= Ġnull Ġ&& Ġduration Ġ> Ġ 0 ) Ġ{ Ċĉĉĉĉ ĉ holder . description Duration ?. text Ġ= ĠOs mand Formatter . get Formatted Duration ( app , Ġduration ) Ċĉĉĉĉ ĉ holder . description ?. apply Ġ{ Ċĉĉĉĉĉ ĉ visibility Ġ= ĠView . VISIBLE Ċĉĉĉĉĉ ĉ text Ġ= Ġ"${ getText ( R . string . sharing _ time )} :" Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } ĊĊĉĉĉ ĉ val Ġexpires In Ġ= Ġshare Info ?. get Chat Live Message Expire Time () Ġ?: Ġ 0 ĊĊĉĉĉ ĉ holder . text In Area ?. apply Ġ{ Ċĉĉĉĉ ĉ val Ġtime Ġ= Ċĉĉĉĉĉ ĉ share Info ?. additional Active Time Ġ?: ĠADD ITION AL _ ACTIVE _ TIME _ VALUES _ SEC [ 0 ] Ċĉĉĉĉ ĉ visibility Ġ= ĠView . VISIBLE Ċĉĉĉĉ ĉ text Ġ= Ġ"+ Ġ${ Os mand Formatter . get Formatted Duration ( app , Ġtime )}" Ċĉĉĉĉ ĉ setOnClickListener Ġ{ Ċĉĉĉĉĉ ĉ val Ġexpire Time Ġ= Ġshare Info ?. get Chat Live Message Expire Time () Ġ?: Ġ 0 Ċĉĉĉĉĉ ĉ val Ġnew Live Period Ġ= Ġexpire Time Ġ+ Ġ( share Info ?. additional Active Time Ċĉĉĉĉĉĉ ĉ ?: ĠADD ITION AL _ ACTIVE _ TIME _ VALUES _ SEC [ 0 ]) Ċĉĉĉĉĉ ĉ val Ġnext Additional Active Time Ġ= Ġshare Info ?. getNext Additional Active Time () Ċĉĉĉĉĉĉ ĉ ?: ĠADD ITION AL _ ACTIVE _ TIME _ VALUES _ SEC [ 1 ] Ċĉĉĉĉĉ ĉ if Ġ( is Chat ) Ġ{ Ċĉĉĉĉĉĉ ĉ settings . share Location To Chat ( Ċĉĉĉĉĉĉĉ ĉ itemId , Ċĉĉĉĉĉĉĉ ĉ true , Ċĉĉĉĉĉĉĉ ĉ new Live Period , Ċĉĉĉĉĉĉĉ ĉ next Additional Active Time Ċĉĉĉĉĉĉ ĉ ) Ċĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉ ĉ settings . share Location To User ( Ċĉĉĉĉĉĉĉ ĉ itemId . toInt (), Ċĉĉĉĉĉĉĉ ĉ new Live Period , Ċĉĉĉĉĉĉĉ ĉ next Additional Active Time Ċĉĉĉĉĉĉ ĉ ) Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ notify Item Changed ( position ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } ĊĊĉĉĉ ĉ holder . sharing Expires Line ?. apply Ġ{ Ċĉĉĉĉ ĉ visibility Ġ= Ġif Ġ( expires In Ġ> Ġ 0 ) ĠView . VISIBLE Ġelse ĠView . GONE Ċĉĉĉĉ ĉ val Ġdescription Ġ= ĠSp ann able StringBuilder ( getText ( R . string . expire _ at )) Ċĉĉĉĉ ĉ val Ġstart Ġ= Ġdescription . length Ċĉĉĉĉ ĉ description . append (" Ġ${ Os mand Formatter . get Formatted Time ( expires In Ġ* Ġ 1 0 0 0 )} Ġ") Ċĉĉĉĉ ĉ description . set Span ( Style Span ( Type face . BOLD ), Ġstart , Ġdescription . length , Ġ 0 ) Ċĉĉĉĉ ĉ description . set Span ( ForegroundColor Span ( Context Compat . getColor ( app , ĠR . color . primary _ text _ light )), Ġstart , Ġdescription . length , Ġ 0 ) Ċĉĉĉĉ ĉ description . append (( getString ( R . string . in _ time , ĠOs mand Formatter . get Formatted Duration ( app , Ġexpires In , Ġtrue )))) Ċĉĉĉĉ ĉ text Ġ= Ġdescription Ċĉĉĉ ĉ } ĊĊĉĉĉ ĉ holder . gps Points Line ?. apply Ġ{ Ċĉĉĉĉ ĉ visibility Ġ= Ġif Ġ( app . settings . show G ps Points Ġ&& Ġshare Info Ġ!= Ġnull ) ĠView . VISIBLE Ġelse ĠView . GONE Ċĉĉĉĉ ĉ if Ġ( share Info Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ val Ġdescription Ġ= ĠSp ann able StringBuilder ("${ getText ( R . string . gps _ points )} :") Ċĉĉĉĉĉ ĉ val Ġbuffered Points Ġ= Ġif Ġ( app . settings . share Type Value Ġ== ĠSHARE _ TYPE _ MAP ) Ġ{ Ċĉĉĉĉĉĉ ĉ share Info . pending Td Lib Map Ġ+ Ġapp . location Messages . get Buffered Messages Count For Chat ( share Info . chat Id , ĠLocation Messages . TYPE _ MAP ) Ċĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉ ĉ share Info . pending Td Lib Text Ġ+ Ġapp . location Messages . get Buffered Messages Count For Chat ( share Info . chat Id , ĠLocation Messages . TYPE _ TEXT ) Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ val Ġstart Ġ= Ġdescription . length Ċĉĉĉĉĉ ĉ description . append (" Ġ${ share Info . sent Messages } Ġ") Ċĉĉĉĉĉ ĉ description . set Span ( Style Span ( Type face . BOLD ), Ġstart , Ġdescription . length , Ġ 0 ) Ċĉĉĉĉĉ ĉ description . set Span ( ForegroundColor Span ( Context Compat . getColor ( app , ĠR . color . primary _ text _ light )), Ġstart , Ġdescription . length , Ġ 0 ) Ċĉĉĉĉĉ ĉ description . append ( getString ( R . string . gps _ points _ in _ buffer , Ġbuffered Points )) Ċĉĉĉĉĉ ĉ text Ġ= Ġdescription Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ġelse Ġif Ġ( holder Ġis ĠSuggest ed ViewHolder ) Ġ{ Ċĉĉĉ ĉ holder . list . removeAll Views () Ċĉĉĉ ĉ if Ġ(( item Ġas ĠSuggest ed Ch ats ). list . isEmpty ()) Ġ{ Ċĉĉĉĉ ĉ holder . container ?. visibility Ġ= ĠView . GONE Ċĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉ ĉ holder . container ?. visibility Ġ= ĠView . VISIBLE Ċĉĉĉĉ ĉ val Ġiterator Ġ= Ġitem . list . iterator () Ċĉĉĉĉ ĉ iterator . forEach Ġ{ Ċĉĉĉĉĉ ĉ holder . list . addView ( create Last Chat View ( it , Ġiterator . hasNext ())) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ val Ġtv Ġ= ĠTyped Value () Ċĉĉĉ ĉ if Ġ(! sharing Mode ) Ġ{ Ċĉĉĉĉ ĉ holder . divider Top ?. visibility Ġ= ĠView . GONE Ċĉĉĉĉ ĉ holder . divider Bottom ?. visibility Ġ= ĠView . VISIBLE Ċĉĉĉĉ ĉ holder . header ?. visibility Ġ= ĠView . GONE Ċĉĉĉĉ ĉ if Ġ( context ?. theme ?. resolve Attribute ( R . attr . card _ bg _ color , Ġtv , Ġtrue ) Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ holder . container ?. set BackgroundColor ( tv . data ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉ ĉ holder . divider Top ?. visibility Ġ= ĠView . VISIBLE Ċĉĉĉĉ ĉ holder . divider Bottom ?. visibility Ġ= ĠView . GONE Ċĉĉĉĉ ĉ holder . header ?. visibility Ġ= ĠView . VISIBLE Ċĉĉĉĉ ĉ if Ġ( context ?. theme ?. resolve Attribute ( R . attr . shared _ chat _ card _ bg , Ġtv , Ġtrue ) Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ holder . container ?. setBackground Resource ( tv . resourceId ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ private Ġfun Ġget Title Text ( item : ĠAny ): ĠString ? Ġ{ Ċĉĉ ĉ val Ġcurrent UserId Ġ= Ġtele gram Helper . getCurrent UserId () Ċĉĉ ĉ return Ġwhen Ġ( item ) Ġ{ Ċĉĉĉ ĉ is ĠLast Chat Ġ-> Ġ{ Ċĉĉĉĉ ĉ if Ġ( telegram Helper . is Private Chat ( item . chat ) Ġ&& Ġ( item . chat . type Ġas ĠT d Api . Chat Type Private ). userId Ġ== Ġcurrent UserId ) Ġ{ Ċĉĉĉĉĉ ĉ getString ( R . string . saved _ messages ) Ċĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉ ĉ item . chat . title Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ is ĠT d Api . Chat Ġ-> Ġ{ Ċĉĉĉĉ ĉ if Ġ( telegram Helper . is Private Chat ( item ) Ġ&& Ġ( item . type Ġas ĠT d Api . Chat Type Private ). userId Ġ== Ġcurrent UserId ) Ġ{ Ċĉĉĉĉĉ ĉ getString ( R . string . saved _ messages ) Ċĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉ ĉ item . title Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ is ĠT d Api . User Ġ-> Ġ{ Ċĉĉĉĉ ĉ if Ġ( item . id Ġ== Ġcurrent UserId ) ĠgetString ( R . string . saved _ messages ) Ġelse ĠTelegram Ui Helper . getUser Name ( item ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ else Ġ-> Ġnull Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ private Ġfun Ġsetup Photo ( item : ĠAny , Ġicon : ĠImageView ?, Ġis Chat : ĠBoolean ) Ġ{ Ċĉĉ ĉ val Ġphoto Path Ġ= Ġwhen Ġ( item ) Ġ{ Ċĉĉĉ ĉ is ĠLast Chat Ġ-> Ġitem . chat . photo ?. small ?. local ?. path Ċĉĉĉ ĉ is ĠT d Api . Chat Ġ-> Ġitem . photo ?. small ?. local ?. path Ċĉĉĉ ĉ is ĠT d Api . User Ġ-> Ġitem . profile Photo ?. small ?. local ?. path Ċĉĉĉ ĉ else Ġ-> Ġnull Ċĉĉ ĉ } Ċĉĉ ĉ val Ġplaceholder Id Ġ= Ċĉĉĉĉ ĉ if Ġ( is Chat Ġ&& Ġtele gram Helper . is Group ( item Ġas ĠT d Api . Chat )) ĠR . drawable . img _ group _ picture Ġelse ĠR . drawable . img _ user _ picture ĊĊĉĉ ĉ Telegram Ui Helper . setup Photo ( app , Ġicon , Ġphoto Path , Ġplaceholder Id , Ġfalse ) Ċĉ ĉ } ĊĊĉ ĉ private Ġfun Ġcreate Last Chat View ( last Chat : ĠLast Chat , Ġhas Next : ĠBoolean ): ĠView Ġ{ Ċĉĉ ĉ val Ġview Ġ= Ġlayout Inflater . inflate ( R . layout . last _ share _ list _ item , Ġnull ) Ċĉĉ ĉ val Ġtime : ĠTextView Ġ= Ġview . findViewById ( R . id . time ) Ċĉĉ ĉ val Ġcontainer : ĠLinearLayout Ġ= Ġview . findViewById ( R . id . container ) Ċĉĉ ĉ val Ġicon : ĠImageView Ġ= Ġview . findViewById ( R . id . icon ) Ċĉĉ ĉ val Ġtitle : ĠTextView Ġ= Ġview . findViewById ( R . id . title ) Ċĉĉ ĉ val Ġdivider : ĠView Ġ= Ġview . findViewById ( R . id . divider ) ĊĊĉĉ ĉ if Ġ( sharing Mode Ġ&& Ġhas Next ) Ġ{ Ċĉĉĉ ĉ divider . visibility Ġ= ĠView . VISIBLE Ċĉĉ ĉ } ĊĊĉĉ ĉ container . setOnClickListener Ġ{ Ċĉĉĉ ĉ if Ġ(! Android Utils . is Location Permission Available ( view !!. context )) Ġ{ Ċĉĉĉĉ ĉ Android Utils . request Location Permission ( activity !! ) Ċĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉ ĉ settings . share Location To Chat ( last Chat . chat . id , Ġtrue , Ġlast Chat . time ) Ċĉĉĉĉ ĉ app . share Location Helper . start Sharing Location () Ċĉĉĉĉ ĉ ( activity Ġas ĠMainActivity ). refresh Pages () Ċĉĉĉ ĉ } Ċĉĉ ĉ } ĊĊĉĉ ĉ title . text Ġ= Ġget Title Text ( last Chat . chat ) Ċĉĉ ĉ setup Photo ( last Chat . chat , Ġicon , Ġtrue ) Ċĉĉ ĉ icon . color Filter Ġ= ĠColor Matrix Color Filter ( Color Matrix (). apply Ġ{ Ġset Sat uration ( 0 F ) Ġ}) ĊĊĉĉ ĉ val Ġsharing Time Ġ= ĠSp ann able StringBuilder ("${ getString ( R . string . sharing _ time )} : Ġ") Ċĉĉ ĉ val Ġformatted Time Ġ= ĠOs mand Formatter . get Formatted Duration ( app , Ġlast Chat . time , Ġfalse ) Ċĉĉ ĉ val Ġstart Ġ= Ġsharing Time . length Ċĉĉ ĉ sharing Time . append ( formatted Time ) Ċĉĉ ĉ sharing Time . set Span ( Style Span ( Type face . BOLD ), Ġstart , Ġsharing Time . length , Ġ 0 ) Ċĉĉ ĉ sharing Time . set Span ( ForegroundColor Span ( Context Compat . getColor ( app , ĠR . color . ctrl _ active _ light )), Ġstart , Ġsharing Time . length , Ġ 0 ) Ċĉĉ ĉ time . text Ġ= Ġsharing Time Ċĉĉ ĉ return Ġview Ċĉ ĉ } ĊĊĉ ĉ private Ġfun Ġremove Item ( chat : ĠT d Api . Object ) Ġ{ Ċĉĉ ĉ items . remove ( chat ) Ċĉĉ ĉ val Ġfiltered Ġ= Ġitems . filter Is Instance < Td Api . Object >() Ċĉĉ ĉ if Ġ( filtered . isEmpty ()) Ġ{ Ċĉĉĉ ĉ sharing Mode Ġ= Ġfalse Ċĉĉĉ ĉ update Content () Ċĉĉĉ ĉ share Location Helper . stop Sharing Location () Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ adapter . notify DataSet Changed () Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ override Ġfun ĠgetItem Count () Ġ= Ġitems . size ĊĊĉ ĉ abstract Ġinner Ġclass ĠBase ViewHolder ( view : ĠView ) Ġ: Ġandroidx . recyclerview . widget . RecyclerView . ViewHolder ( view ) Ġ{ Ċĉĉ ĉ val Ġicon : ĠImageView ? Ġ= Ġview . findViewById ( R . id . icon ) Ċĉĉ ĉ val Ġtitle : ĠTextView ? Ġ= Ġview . findViewById ( R . id . title ) Ċĉĉ ĉ val Ġdescription : ĠTextView ? Ġ= Ġview . findViewById ( R . id . description ) Ċĉĉ ĉ val Ġtext In Area : ĠTextView ? Ġ= Ġview . findViewById ( R . id . text _ in _ area ) Ċĉ ĉ } ĊĊĉ ĉ inner Ġclass ĠChat ViewHolder ( val Ġview : ĠView ) Ġ: ĠBase ViewHolder ( view ) Ġ{ Ċĉĉ ĉ val ĠcheckBox : ĠCheckBox ? Ġ= Ġview . findViewById ( R . id . check _ box ) Ċĉĉ ĉ val Ġtop Shadow Divider : ĠView ? Ġ= Ġview . findViewById ( R . id . top _ divider ) Ċĉĉ ĉ val Ġbottom Shadow : ĠView ? Ġ= Ġview . findViewById ( R . id . bottom _ shadow ) Ċĉ ĉ } ĊĊĉ ĉ inner Ġclass ĠSh aring Chat ViewHolder ( val Ġview : ĠView ) Ġ: ĠBase ViewHolder ( view ) Ġ{ Ċĉĉ ĉ val Ġdescription Duration : ĠTextView ? Ġ= Ġview . findViewById ( R . id . duration ) Ċĉĉ ĉ val Ġswitch er : ĠSwitch ? Ġ= Ġview . findViewById ( R . id . switch er ) Ċĉĉ ĉ val Ġsharing Expires Line : ĠTextView ? Ġ= Ġview . findViewById ( R . id . expires _ line ) Ċĉĉ ĉ val Ġgps Points Line : ĠTextView ? Ġ= Ġview . findViewById ( R . id . gps _ points _ line ) Ċĉ ĉ } ĊĊĉ ĉ inner Ġclass ĠSuggest ed ViewHolder ( val Ġview : ĠView ) Ġ: ĠBase ViewHolder ( view ) Ġ{ Ċĉĉ ĉ val Ġlist : ĠLinearLayout Ġ= Ġview . findViewById ( R . id . last _ items _ list ) Ċĉĉ ĉ val Ġcontainer : ĠLinearLayout ? Ġ= Ġview . findViewById ( R . id . container ) Ċĉĉ ĉ val Ġdivider Bottom : ĠView ? Ġ= Ġview . findViewById ( R . id . divider _ bottom ) Ċĉĉ ĉ val Ġdivider Top : ĠView ? Ġ= Ġview . findViewById ( R . id . divider _ top ) Ċĉĉ ĉ val Ġheader : ĠTextView ? Ġ= Ġview . findViewById ( R . id . header ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ interface ĠAction Buttons Listener Ġ{ Ċĉ ĉ fun Ġswitch Buttons Visibility ( visible : ĠBoolean ) Ċ ĉ } Ċ } Ċ Ċ class ĠLast Chat Ġinternal Ġconstructor ( val Ġchat : ĠT d Api . Chat , Ġval Ġtime : ĠLong ) Ċ Ċ class ĠSuggest ed Ch ats Ġinternal Ġconstructor ( val Ġlist : ĠMutable List < Last Chat >) Ċ