package Ġnet . os mand . telegram Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . text . Sp ann able StringBuilder Ċ import Ġandroid . text . style . ForegroundColor Span Ċ import Ġandroidx . annotation . Color Res Ċ import Ġandroidx . annotation . Drawable Res Ċ import Ġandroidx . annotation . String Res Ċ import Ġnet . os mand . Platform Util Ċ import Ġnet . os mand . telegram . helpers . Os mand A idl Helper Ċ import Ġnet . os mand . telegram . helpers . Share Location Helper . Companion . MAX _ MESSAGES _ IN _ TD LIB _ PER _ CHAT Ċ import Ġnet . os mand . telegram . helpers . Show Location Helper Ċ import Ġnet . os mand . telegram . helpers . Telegram Helper Ċ import Ġnet . os mand . telegram . utils .* Ċ import Ġnet . os mand . telegram . utils . Os mand Formatter . Metrics Constants Ċ import Ġnet . os mand . telegram . utils . Os mand Formatter . Speed Constants Ċ import Ġorg . dr ink less . td . lib core . telegram . Td Api Ċ import Ġorg . json . JSONArray Ċ import Ġorg . json . JSONException Ċ import Ġorg . json . JSONObject Ċ import Ġjava . util .* Ċ import Ġjava . util . concurrent . Concurrent HashMap Ċ import Ġjava . util . concurrent . Concurrent Linked Queue Ċ import Ġkotlin . collections . ArrayList Ċ import Ġkotlin . math . max Ċ Ċ val ĠADD ITION AL _ ACTIVE _ TIME _ VALUES _ SEC Ġ= ĠlistOf ( 1 5 Ġ* Ġ 6 0 L , Ġ 3 0 Ġ* Ġ 6 0 L , Ġ 6 0 Ġ* Ġ 6 0 L , Ġ 1 8 0 Ġ* Ġ 6 0 L ) Ċ Ċ const Ġval ĠSHARE _ DEVICES _ KEY Ġ= Ġ" devices " Ċ Ċ const Ġval ĠLI VE _ TRACK S _ KEY Ġ= Ġ" live _ tracks " Ċ Ċ private Ġval ĠS END _ MY _ LOC _ VALUES _ SEC Ġ= Ċ ĉ listOf ( 1 L , Ġ 2 L , Ġ 3 L , Ġ 5 L , Ġ 1 0 L , Ġ 1 5 L , Ġ 3 0 L , Ġ 6 0 L , Ġ 9 0 L , Ġ 2 Ġ* Ġ 6 0 L , Ġ 3 Ġ* Ġ 6 0 L , Ġ 5 Ġ* Ġ 6 0 L ) Ċ private Ġval ĠST ALE _ LOC _ VALUES _ SEC Ġ= Ċ ĉ listOf ( 1 Ġ* Ġ 6 0 L , Ġ 2 Ġ* Ġ 6 0 L , Ġ 5 Ġ* Ġ 6 0 L , Ġ 1 0 Ġ* Ġ 6 0 L , Ġ 1 5 Ġ* Ġ 6 0 L , Ġ 3 0 Ġ* Ġ 6 0 L , Ġ 6 0 Ġ* Ġ 6 0 L ) Ċ private Ġval ĠLOC _ HISTORY _ VALUES _ SEC Ġ= ĠlistOf ( Ċĉ 5 Ġ* Ġ 6 0 L , Ċĉ 1 5 Ġ* Ġ 6 0 L , Ċĉ 3 0 Ġ* Ġ 6 0 L , Ċĉ 1 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ċĉ 2 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ċĉ 3 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ċĉ 5 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ċĉ 8 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ċĉ 1 2 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ċĉ 2 4 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L Ċ ) Ċ private Ġval ĠMIN _ LOCATION _ DISTANCE Ġ= ĠlistOf ( 0 f , Ġ 2 . 0 f , Ġ 5 . 0 f , Ġ 1 0 . 0 f , Ġ 2 0 . 0 f , Ġ 3 0 . 0 f , Ġ 5 0 . 0 f ) Ċ private Ġval ĠMIN _ LOCATION _ AC CUR ACY Ġ= ĠlistOf ( 0 f , Ġ 1 . 0 f , Ġ 2 . 0 f , Ġ 5 . 0 f , Ġ 1 0 . 0 f , Ġ 1 5 . 0 f , Ġ 2 0 . 0 f , Ġ 5 0 . 0 f , Ġ 1 0 0 . 0 f ) Ċ private Ġval ĠMIN _ LOCATION _ SPEED Ġ= ĠlistOf ( 0 f , Ġ 0 . 0 0 0 0 0 1 f , Ġ 1 . 0 f , Ġ 2 . 0 f , Ġ 3 . 0 f , Ġ 4 . 0 f , Ġ 5 . 0 f , Ġ 6 . 0 f , Ġ 7 . 0 f ) Ċ Ċ const Ġval ĠSHARE _ TYPE _ MAP Ġ= Ġ" Map " Ċ const Ġval ĠSHARE _ TYPE _ TEXT Ġ= Ġ Ġ" Text " Ċ const Ġval ĠSHARE _ TYPE _ MAP _ AND _ TEXT Ġ= Ġ" Map _ and _ text " Ċ private Ġval ĠSHARE _ TYPE _ VALUES Ġ= ĠlistOf ( SHARE _ TYPE _ MAP , ĠSHARE _ TYPE _ TEXT , ĠSHARE _ TYPE _ MAP _ AND _ TEXT ) Ċ Ċ private Ġconst Ġval ĠS END _ MY _ LOC _ DEFAULT _ INDEX Ġ= Ġ 6 Ċ private Ġconst Ġval ĠST ALE _ LOC _ DEFAULT _ INDEX Ġ= Ġ 0 Ċ private Ġconst Ġval ĠLOC _ HISTORY _ DEFAULT _ INDEX Ġ= Ġ 7 Ċ private Ġconst Ġval ĠSHARE _ TYPE _ DEFAULT _ INDEX Ġ= Ġ 2 Ċ private Ġconst Ġval ĠMIN _ LOCATION _ DISTANCE _ INDEX Ġ= Ġ 0 Ċ private Ġconst Ġval ĠMIN _ LOCATION _ AC CUR ACY _ INDEX Ġ= Ġ 0 Ċ private Ġconst Ġval ĠMIN _ LOCATION _ SPEED _ INDEX Ġ= Ġ 0 Ċ Ċ private Ġval ĠBUFFER _ TIME Ġ= ĠlistOf ( 6 0 Ġ* Ġ 6 0 L , Ġ 2 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ġ 4 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ġ 8 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ċĉĉ 1 2 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L , Ġ 2 4 Ġ* Ġ 6 0 Ġ* Ġ 6 0 L ) Ċ private Ġconst Ġval ĠBUFFER _ TIME _ INDEX Ġ= Ġ 0 Ċ private Ġconst Ġval ĠBUFFER _ TIME _ KEY Ġ= Ġ" buffer _ time " Ċ private Ġconst Ġval ĠFREE _ TIME LINE _ INFO _ SHO WN _ TIME _ KEY Ġ= Ġ" free _ timeline _ info _ shown _ time " Ċ Ċ private Ġconst Ġval ĠSET T INGS _ NAME Ġ= Ġ" os mand _ telegram _ settings " Ċ Ċ private Ġconst Ġval ĠSHARE _ LOCATION _ CHAT S _ KEY Ġ= Ġ" share _ location _ ch ats " Ċ private Ġconst Ġval ĠHID DEN _ ON _ MAP _ CHAT S _ KEY Ġ= Ġ" hidden _ on _ map _ ch ats " Ċ Ċ private Ġconst Ġval ĠSH AR ING _ MODE _ KEY Ġ= Ġ" current _ sharing _ mode " Ċ Ċ private Ġconst Ġval ĠMET R ICS _ CONSTANT S _ KEY Ġ= Ġ" metrics _ constants " Ċ private Ġconst Ġval ĠSPE ED _ CONSTANT S _ KEY Ġ= Ġ" speed _ constants " Ċ private Ġconst Ġval ĠUTC _ OFFSET _ CONSTANT S _ KEY Ġ= Ġ" utc _ offset _ constants " Ċ Ċ private Ġconst Ġval ĠS END _ MY _ LOC _ INTERVAL _ KEY Ġ= Ġ" send _ my _ loc _ interval " Ċ private Ġconst Ġval ĠST ALE _ LOC _ TIME _ KEY Ġ= Ġ" st ale _ loc _ time " Ċ private Ġconst Ġval ĠLOC _ HISTORY _ TIME _ KEY Ġ= Ġ" loc _ history _ time " Ċ private Ġconst Ġval ĠSHARE _ TYPE _ KEY Ġ= Ġ" share _ type " Ċ Ċ private Ġconst Ġval ĠMIN _ LOCATION _ DISTANCE _ KEY Ġ= Ġ" min _ location _ distance " Ċ private Ġconst Ġval ĠMIN _ LOCATION _ AC CUR ACY _ KEY Ġ= Ġ" min _ location _ accuracy " Ċ private Ġconst Ġval ĠMIN _ LOCATION _ SPEED _ KEY Ġ= Ġ" min _ location _ speed " Ċ Ċ private Ġconst Ġval ĠAPP _ TO _ CONNECT _ PACKAGE _ KEY Ġ= Ġ" app _ to _ connect _ package " Ċ Ċ private Ġconst Ġval ĠDEFAULT _ VISIBLE _ TIME _ SECONDS Ġ= Ġ 6 0 Ġ* Ġ 6 0 L Ġ// Ġ 1 Ġhour Ċ Ċ private Ġconst Ġval ĠT IT LES _ REPL AC ED _ WITH _ IDS Ġ= Ġ" changed _ to _ chat _ id " Ċ Ċ private Ġconst Ġval ĠLI VE _ NOW _ SORT _ TYPE _ KEY Ġ= Ġ" live _ now _ sort _ type " Ċ Ċ private Ġconst Ġval ĠSHARE _ CHAT S _ INFO _ KEY Ġ= Ġ" share _ ch ats _ info " Ċ Ċ private Ġconst Ġval ĠB ATTER Y _ OP TI MIS ATION _ ASK ED Ġ= Ġ" battery _ optim isation _ ask ed " Ċ Ċ private Ġconst Ġval ĠMON ITOR ING _ ENABLED Ġ= Ġ" monitoring _ enabled " Ċ Ċ private Ġconst Ġval ĠSHOW _ GPS _ POINTS Ġ= Ġ" show _ gps _ points " Ċ Ċ private Ġconst Ġval ĠPRO XY _ ENABLED Ġ= Ġ" proxy _ enabled " Ċ private Ġconst Ġval ĠPRO XY _ PREFER ENCES _ KEY Ġ= Ġ" proxy _ preferences " Ċ Ċ private Ġconst Ġval ĠSH AR ING _ INITIAL IZATION _ TIME Ġ= Ġ 6 0 Ġ* Ġ 2 L Ġ// Ġ 2 Ġminutes Ċ private Ġconst Ġval ĠWAIT ING _ TD LIB _ TIME Ġ= Ġ 7 Ġ// Ġ 7 Ġseconds Ċ Ċ private Ġconst Ġval ĠGPS _ UPDATE _ EXPI RED _ TIME Ġ= Ġ 6 0 Ġ* Ġ 3 L Ġ// Ġ 3 Ġminutes Ċ Ċ private Ġconst Ġval ĠLAST _ CHAT S _ INFO _ KEY Ġ= Ġ" last _ ch ats _ info " Ċ Ċ class ĠTelegram Settings ( private Ġval Ġapp : ĠTelegram Application ) Ġ{ ĊĊ ĉ private Ġval Ġlog Ġ= ĠPlatform Util . getLog ( Telegram Settings :: class . java ) ĊĊ ĉ private Ġvar Ġshare Ch ats Info Ġ= ĠConcurrent HashMap < Long , ĠShare Chat Info >() Ċ ĉ private Ġvar Ġhidden On Map Ch ats : ĠSet < Long > Ġ= Ġempty Set () Ċ ĉ private Ġvar Ġshare Devices : ĠSet < Device Bot > Ġ= Ġempty Set () Ċ ĉ private Ġvar Ġlive Tracks Info Ġ= Ġempty List < Live Track Info >() Ċ ĉ var Ġlast Ch ats Info Ġ= ĠLinkedList < Last Chat Info >() ĊĊ ĉ var Ġsharing Status Changes Ġ= ĠConcurrent Linked Queue < Sharing Status >() ĊĊ ĉ var Ġcurrent Sharing Mode Ġ= Ġ"" Ċĉ ĉ private Ġset ĊĊ ĉ var Ġcurrent Proxy Pref : ĠProxy Pref Ġ= ĠProxy SOCK S 5 Pref (- 1 , Ġ"", Ġ- 1 , Ġ"", Ġ"") Ċĉ ĉ private Ġset ĊĊ ĉ var Ġmetrics Constants Ġ= ĠMetrics Constants . KI LO METER S _ AND _ METER S Ċ ĉ var Ġspeed Constants Ġ= ĠSpeed Constants . KI LO METER S _ PER _ HOUR Ċ ĉ var Ġut c Offset Ġ= ĠData Constants . UTC _ FORMAT ĊĊ ĉ var Ġsend My Loc Interval Ġ= ĠS END _ MY _ LOC _ VALUES _ SEC [ SEND _ MY _ LOC _ DEFAULT _ INDEX ] Ċ ĉ var Ġstale Loc Time Ġ= ĠST ALE _ LOC _ VALUES _ SEC [ ST ALE _ LOC _ DEFAULT _ INDEX ] Ċ ĉ var Ġloc History Time Ġ= ĠLOC _ HISTORY _ VALUES _ SEC [ LOC _ HISTORY _ DEFAULT _ INDEX ] Ċ ĉ var Ġshare Type Value Ġ= ĠSHARE _ TYPE _ VALUES [ SHARE _ TYPE _ DEFAULT _ INDEX ] ĊĊ ĉ var Ġmin Location Distance Ġ= ĠMIN _ LOCATION _ DISTANCE [ MIN _ LOCATION _ DISTANCE _ INDEX ] Ċ ĉ var Ġmin Location Accuracy Ġ= ĠMIN _ LOCATION _ AC CUR ACY [ MIN _ LOCATION _ AC CUR ACY _ INDEX ] Ċ ĉ var Ġmin Location Speed Ġ= ĠMIN _ LOCATION _ SPEED [ MIN _ LOCATION _ SPEED _ INDEX ] ĊĊ ĉ var Ġapp To Connect Package Ġ= Ġ"" Ċĉ ĉ private Ġset ĊĊ ĉ var Ġlive Now Sort Type Ġ= ĠLive Now Sort Type . SORT _ BY _ DISTANCE ĊĊ ĉ val Ġgps And Loc Prefs Ġ= ĠlistOf ( Send My Loc Pref (), ĠSt ale Loc Pref (), ĠLoc History Pref (), ĠShare Type Pref (), Ċĉĉ ĉ Buffer Time Pref ()) Ċ ĉ val Ġg px Logging Prefs Ġ= ĠlistOf ( Min Location Distance (), ĠMin Location Accuracy (), ĠMin Location Speed ()) Ċ ĉ val Ġunits And Formats Prefs Ġ= ĠlistOf ( Units Of Speed (), ĠUnits Of Length (), ĠU tc Offset ()) ĊĊ ĉ var Ġbattery Optim isation Ask ed Ġ= Ġfalse ĊĊ ĉ var Ġmonitoring Enabled Ġ= Ġfalse ĊĊ ĉ var Ġshow G ps Points Ġ= Ġfalse ĊĊ ĉ var Ġproxy Enabled Ġ= Ġfalse ĊĊ ĉ var Ġbuffer Time Ġ= ĠBUFFER _ TIME [ BUFFER _ TIME _ INDEX ] ĊĊ ĉ var Ġfree Timeline Info Shown Time Ġ= Ġ 0 L ĊĊ ĉ init Ġ{ Ċĉ ĉ update Prefs () Ċĉ ĉ read () Ċĉ ĉ apply Proxy Pref () Ċ ĉ } ĊĊ ĉ fun Ġhas Any Chat To Share Location () Ġ= Ġshare Ch ats Info . isNotEmpty () ĊĊ ĉ fun Ġis Sharing Location To Chat ( chat Id : ĠLong ) Ġ= Ġshare Ch ats Info . containsKey ( chat Id ) ĊĊ ĉ fun Ġis Sharing Location To User ( userId : ĠInt ) Ġ= Ġshare Ch ats Info . values . any Ġ{ Ġit . userId Ġ== ĠuserId Ġ} ĊĊ ĉ fun Ġhas Any Chat To Show On Map () Ġ= Ġ! hidden On Map Ch ats . contains All ( get Live Now Ch ats ()) ĊĊ ĉ fun Ġhas Any Live Track sTo Show On Map (): ĠBoolean Ġ{ Ċĉ ĉ val Ġtime Ġ= ĠSystem . currentTimeMillis () Ġ- Ġloc History Time Ġ* Ġ 1 0 0 0 Ċĉ ĉ val Ġlocations Ġ= Ġapp . location Messages . getLast Location Messages Since Time ( time ) Ċĉ ĉ locations . forEach Ġ{ Ġloc Ġ-> Ċĉĉ ĉ if Ġ( live Tracks Info . any Ġ{ Ġit . userId Ġ== Ġloc . userId Ġ&& Ġit . chat Id Ġ== Ġloc . chat Id Ġ&& Ġit . device Name Ġ== Ġloc . device Name Ġ}) Ġ{ Ċĉĉĉ ĉ return Ġtrue Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ return Ġfalse Ċ ĉ } ĊĊ ĉ fun Ġget Live Tracks Info () Ġ= Ġlive Tracks Info ĊĊ ĉ fun Ġget Live Track Info ( userId : ĠInt , Ġchat Id : ĠLong , Ġdevice Name : ĠString ) Ġ= Ċĉ ĉ live Tracks Info . first OrNull Ġ{ Ġit . userId Ġ== ĠuserId Ġ&& Ġit . chat Id Ġ== Ġchat Id Ġ&& Ġit . device Name Ġ== Ġdevice Name Ġ} ĊĊ ĉ fun Ġis Showing Chat On Map ( chat Id : ĠLong ) Ġ= Ġ! hidden On Map Ch ats . contains ( chat Id ) ĊĊ ĉ fun Ġis Live Track Enabled ( userId : ĠInt , Ġchat Id : ĠLong , Ġdevice Name : ĠString ) Ġ= Ċĉ ĉ live Tracks Info . any Ġ{ Ġ( it . chat Id Ġ== Ġchat Id Ġ&& Ġit . userId Ġ== ĠuserId Ġ&& Ġit . device Name Ġ== Ġdevice Name ) Ġ} ĊĊ ĉ fun Ġupdate Live Track ( userId : ĠInt , Ġchat Id : ĠLong , Ġdevice Name : ĠString , Ġenable : ĠBoolean ) Ġ{ Ċĉ ĉ val Ġtracks Info Ġ= Ġlive Tracks Info . to Mutable List () Ċĉ ĉ if Ġ( enable ) Ġ{ Ċĉĉ ĉ val Ġcolor Index Ġ= Ġif Ġ( tracks Info . size Ġ> Ġ 0 ) Ġ( tracks Info . last (). color Index Ġ+ Ġ 1 ) Ġ% ĠShow Location Helper . GP X _ COLORS . size Ġelse Ġ 0 Ċĉĉ ĉ tracks Info . add ( Live Track Info ( userId , Ġchat Id , Ġdevice Name , Ġcolor Index )) Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ tracks Info . removeAll Ġ{ Ġit . userId Ġ== ĠuserId Ġ&& Ġit . chat Id Ġ== Ġchat Id Ġ&& Ġit . device Name Ġ== Ġdevice Name Ġ} Ċĉ ĉ } Ċĉ ĉ live Tracks Info Ġ= Ġtracks Info . toList () Ċ ĉ } ĊĊ ĉ fun Ġremove Non existing Ch ats ( present Chat Ids : ĠList < Long >) Ġ{ Ċĉ ĉ val Ġhidden Ch ats Ġ= Ġhidden On Map Ch ats . to Mutable List () Ċĉ ĉ hidden Ch ats . intersect ( present Chat Ids ) Ċĉ ĉ hidden On Map Ch ats Ġ= Ġhidden Ch ats . to HashSet () ĊĊĉ ĉ share Ch ats Info Ġ= ĠConcurrent HashMap ( share Ch ats Info . filter Ġ{ Ġ( key , Ġ_) Ġ-> Ġpresent Chat Ids . contains ( key ) Ġ}) Ċ ĉ } ĊĊ ĉ fun Ġshare Location To Chat ( Ċĉ ĉ chat Id : ĠLong , Ċĉ ĉ share : ĠBoolean , Ċĉ ĉ live Period : ĠLong Ġ= ĠDEFAULT _ VISIBLE _ TIME _ SECONDS , Ċĉ ĉ add Active Time : ĠLong Ġ= ĠADD ITION AL _ ACTIVE _ TIME _ VALUES _ SEC [ 0 ] Ċ ĉ ) Ġ{ Ċĉ ĉ if Ġ( share ) Ġ{ Ċĉĉ ĉ var Ġshare Chat Info Ġ= Ġshare Ch ats Info [ chat Id ] Ċĉĉ ĉ if Ġ( share Chat Info Ġ== Ġnull ) Ġ{ Ċĉĉĉ ĉ share Chat Info Ġ= ĠShare Chat Info () Ċĉĉ ĉ } Ċĉĉ ĉ val Ġchat Ġ= Ġapp . telegram Helper . get Chat ( chat Id ) Ċĉĉ ĉ if Ġ( chat Ġ!= Ġnull Ġ&& Ġ( chat . type Ġis ĠT d Api . Chat Type Private Ġ|| Ġchat . type Ġis ĠT d Api . Chat Type Secret )) Ġ{ Ċĉĉĉ ĉ share Chat Info . userId Ġ= Ġapp . telegram Helper . getUserId From Chat Type ( chat . type ) Ċĉĉ ĉ } Ċĉĉ ĉ share Chat Info . chat Id Ġ= Ġchat Id Ċĉĉ ĉ update Chat Share Info ( share Chat Info , Ġlive Period , Ġadd Active Time ) Ċĉĉ ĉ share Ch ats Info [ chat Id ] Ġ= Ġshare Chat Info Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ share Ch ats Info . remove ( chat Id ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġshare Location To User ( Ċĉ ĉ userId : ĠInt , Ċĉ ĉ live Period : ĠLong Ġ= ĠDEFAULT _ VISIBLE _ TIME _ SECONDS , Ċĉ ĉ add Active Time : ĠLong Ġ= ĠADD ITION AL _ ACTIVE _ TIME _ VALUES _ SEC [ 0 ] Ċ ĉ ) Ġ{ Ċĉ ĉ val Ġshare Chat Info Ġ= ĠShare Chat Info () Ċĉ ĉ share Chat Info . userId Ġ= ĠuserId Ċĉ ĉ update Chat Share Info ( share Chat Info , Ġlive Period , Ġadd Active Time ) Ċĉ ĉ app . telegram Helper . create Private Chat With User ( userId , Ġshare Chat Info , Ġshare Ch ats Info ) Ċ ĉ } ĊĊ ĉ fun Ġupdate Share Devices ( list : ĠList < Device Bot >) Ġ{ Ċĉ ĉ share Devices Ġ= Ġlist . to HashSet () Ċ ĉ } ĊĊ ĉ fun Ġadd Share Device ( device : ĠDevice Bot ) Ġ{ Ċĉ ĉ val Ġdevices Ġ= Ġshare Devices . to Mutable List () Ċĉ ĉ devices . add ( device ) Ċĉ ĉ share Devices Ġ= Ġdevices . to HashSet () Ċ ĉ } ĊĊ ĉ fun Ġupdate Current Sharing Mode ( sharing Mode : ĠString ) Ġ{ Ċĉ ĉ if Ġ( current Sharing Mode Ġ!= Ġsharing Mode ) Ġ{ Ċĉĉ ĉ share Ch ats Info . forEach Ġ{ Ġ(_, Ġshare Info ) Ġ-> Ċĉĉĉ ĉ share Info . should Send Via Bot Text Message Ġ= Ġtrue Ċĉĉĉ ĉ share Info . should Send Via Bot Map Message Ġ= Ġtrue Ċĉĉ ĉ } Ċĉĉ ĉ prepare For Sharing New Messages () Ċĉ ĉ } Ċĉ ĉ current Sharing Mode Ġ= Ġsharing Mode Ċ ĉ } ĊĊ ĉ fun Ġupdate Current Proxy Pref ( proxy Pref : ĠProxy Pref , Ġproxy Enabled : ĠBoolean ) Ġ{ Ċĉ ĉ this . proxy Enabled Ġ= Ġproxy Enabled Ċĉ ĉ current Proxy Pref Ġ= Ġproxy Pref Ċĉ ĉ apply Proxy Pref () Ċ ĉ } ĊĊ ĉ fun Ġupdate Proxy Setting ( enable : ĠBoolean ) Ġ{ Ċĉ ĉ this . proxy Enabled Ġ= Ġenable Ċĉ ĉ if Ġ( enable ) Ġ{ Ċĉĉ ĉ app . telegram Helper . enable Proxy ( current Proxy Pref . id ) Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ app . telegram Helper . disable Proxy () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġapply Proxy Pref () Ġ{ Ċĉ ĉ val Ġproxy Id Ġ= Ġcurrent Proxy Pref . id Ċĉ ĉ if Ġ( proxy Id Ġ!= Ġ- 1 ) Ġ{ Ċĉĉ ĉ app . telegram Helper . edit Proxy Pref ( current Proxy Pref , Ġproxy Enabled ) Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ app . telegram Helper . add Proxy Pref ( current Proxy Pref , Ġproxy Enabled ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġprepare For Sharing New Messages () Ġ{ Ċĉ ĉ share Ch ats Info . forEach Ġ{ Ġ(_, Ġshare Info ) Ġ-> Ċĉĉ ĉ share Info . reset Messages Info () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġprepare For Sharing New Messages ( ch ats Ids : ĠList < Long >) Ġ{ Ċĉ ĉ ch ats Ids . forEach Ġ{ Ċĉĉ ĉ share Ch ats Info [ it ]?. also Ġ{ Ġshare Info Ġ-> Ċĉĉĉ ĉ share Info . reset Messages Info () Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġget Chat Live Period ( chat Id : ĠLong ) Ġ= Ġshare Ch ats Info [ chat Id ]?. live Period ĊĊ ĉ fun Ġget Ch ats Share Info () Ġ= Ġshare Ch ats Info ĊĊ ĉ fun Ġget Share Devices () Ġ= Ġshare Devices ĊĊ ĉ fun Ġcontains Share Device WithName ( name : ĠString ): ĠBoolean Ġ{ Ċĉ ĉ share Devices . forEach Ġ{ Ċĉĉ ĉ if Ġ( it . device Name Ġ== Ġname ) Ġ{ Ċĉĉĉ ĉ return Ġtrue Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ return Ġfalse Ċ ĉ } ĊĊ ĉ fun ĠgetCurrent Sharing Device () Ġ= Ġshare Devices . single OrNull Ġ{ Ġit . external Id Ġ== Ġcurrent Sharing Mode Ġ} ĊĊ ĉ fun ĠgetLast Successful Send Time (): ĠLong Ġ{ Ċĉ ĉ val Ġlast Success Text Send Ġ= Ġshare Ch ats Info . values . max By OrNull Ġ{ Ġit . last Text Successful Send Time Ġ} ?. last Text Successful Send Time Ġ?: Ġ- 1 Ċĉ ĉ val Ġlast Success Map Send Ġ= Ġshare Ch ats Info . values . max By OrNull Ġ{ Ġit . last Map Successful Send Time Ġ} ?. last Map Successful Send Time Ġ?: Ġ- 1 Ċĉ ĉ return ĠMath . max ( last Success Text Send , Ġlast Success Map Send ) Ċ ĉ } ĊĊ ĉ fun Ġstop Sharing Location To Ch ats () Ġ{ Ċĉ ĉ share Ch ats Info . clear () Ċ ĉ } ĊĊ ĉ fun Ġshow Chat On Map ( chat Id : ĠLong , Ġshow : ĠBoolean ) Ġ{ Ċĉ ĉ val Ġhidden Ch ats Ġ= Ġhidden On Map Ch ats . to Mutable List () Ċĉ ĉ if Ġ( show ) Ġ{ Ċĉĉ ĉ hidden Ch ats . remove ( chat Id ) Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ hidden Ch ats . add ( chat Id ) Ċĉ ĉ } Ċĉ ĉ hidden On Map Ch ats Ġ= Ġhidden Ch ats . to HashSet () Ċ ĉ } ĊĊ ĉ fun Ġget Share Location Ch ats () Ġ= Ġshare Ch ats Info . keys ĊĊ ĉ fun Ġget Show On Map Ch ats () Ġ= Ġget Live Now Ch ats (). minus ( hidden On Map Ch ats ) ĊĊ ĉ fun Ġget Show On Map Ch ats Count () Ġ= Ġget Show On Map Ch ats (). size ĊĊ ĉ fun Ġclear () Ġ{ Ċĉ ĉ stop Sharing Location To Ch ats () Ċĉ ĉ app . get SharedPreferences ( SETTINGS _ NAME , ĠContext . MODE _ PRIVATE ). edit (). clear (). apply () Ċ ĉ } ĊĊ ĉ fun Ġupdate App To Connect ( app To Connect Package : ĠString ) Ġ{ Ċĉ ĉ app . show Location Helper . stop Showing Location () Ċĉ ĉ this . app To Connect Package Ġ= Ġapp To Connect Package Ċĉ ĉ app . os mand A idl Helper . reconnect Os mand () Ċ ĉ } ĊĊ ĉ fun Ġupdate Share Info ( message : ĠT d Api . Message ) Ġ{ Ċĉ ĉ val Ġshare Info Ġ= Ġshare Ch ats Info [ message . chat Id ] Ċĉ ĉ val Ġcontent Ġ= Ġmessage . content Ċĉ ĉ val Ġis O sm And Bot Ġ= Ġapp . telegram Helper . is O sm And Bot ( Os mand Location Utils . get Sender MessageId ( message )) Ġ|| Ġapp . telegram Helper . is O sm And Bot ( message . via Bot UserId ) Ċĉ ĉ if Ġ( share Info Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ when Ġ( content ) Ġ{ Ċĉĉĉ ĉ is ĠT d Api . Message Location Ġ-> Ġ{ Ċĉĉĉĉ ĉ val Ġstate Ġ= Ġmessage . sending State Ċĉĉĉĉ ĉ if Ġ( state Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ if Ġ( state . constructor Ġ== ĠT d Api . Message Sending State Pending . CON STRUCTOR ) Ġ{ Ċĉĉĉĉĉĉ ĉ share Info . pending Map Message Ġ= Ġtrue Ċĉĉĉĉĉĉ ĉ log . debug (" update Share Info ĠMAP Ġ${ message . id } ĠMessage Sending State Pending ") Ċĉĉĉĉĉĉ ĉ share Info . old Map MessageId Ġ= Ġmessage . id Ċĉĉĉĉĉĉ ĉ if Ġ( is O sm And Bot ) Ġ{ Ċĉĉĉĉĉĉĉ ĉ share Info . should Send Via Bot Map Message Ġ= Ġfalse Ċĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ } Ġelse Ġif Ġ( state . constructor Ġ== ĠT d Api . Message Sending State Failed . CON STRUCTOR ) Ġ{ Ċĉĉĉĉĉĉ ĉ share Info . has Sharing Error Ġ= Ġtrue Ċĉĉĉĉĉĉ ĉ share Info . pending Map Message Ġ= Ġfalse Ċĉĉĉĉĉĉ ĉ if Ġ(! is O sm And Bot ) Ġ{ Ċĉĉĉĉĉĉĉ ĉ share Info . pending Td Lib Map -- Ċĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉĉ ĉ log . debug (" update Share Info ĠMAP Ġ${ message . id } ĠMessage Sending State Failed ") Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉ ĉ share Info . current Map MessageId Ġ= Ġmessage . id Ċĉĉĉĉĉ ĉ share Info . pending Map Message Ġ= Ġfalse Ċĉĉĉĉĉ ĉ share Info . last Map Successful Send Time Ġ= ĠSystem . currentTimeMillis () Ġ/ Ġ 1 0 0 0 Ċĉĉĉĉĉ ĉ if Ġ(! is O sm And Bot ) Ġ{ Ċĉĉĉĉĉĉ ĉ share Info . pending Td Lib Map -- Ċĉĉĉĉĉĉ ĉ if Ġ( share Type Value Ġ== ĠSHARE _ TYPE _ MAP ) Ġ{ Ċĉĉĉĉĉĉĉ ĉ share Info . sent Messages ++ Ċĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉ ĉ share Info . should Send Via Bot Map Message Ġ= Ġfalse Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ log . debug (" update Share Info ĠMAP Ġ${ message . id } ĠSUCCESS Ġpending Td Lib Map : Ġ${ share Info . pending Td Lib Map }") Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ is ĠT d Api . Message Text Ġ-> Ġ{ Ċĉĉĉĉ ĉ val Ġstate Ġ= Ġmessage . sending State Ċĉĉĉĉ ĉ if Ġ( state Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ if Ġ( state . constructor Ġ== ĠT d Api . Message Sending State Pending . CON STRUCTOR ) Ġ{ Ċĉĉĉĉĉĉ ĉ log . debug (" update Share Info ĠTEXT Ġ${ message . id } ĠMessage Sending State Pending ") Ċĉĉĉĉĉĉ ĉ share Info . pending Text Message Ġ= Ġtrue Ċĉĉĉĉĉĉ ĉ share Info . old Text MessageId Ġ= Ġmessage . id Ċĉĉĉĉĉĉ ĉ if Ġ( is O sm And Bot ) Ġ{ Ċĉĉĉĉĉĉĉ ĉ share Info . should Send Via Bot Text Message Ġ= Ġfalse Ċĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ } Ġelse Ġif Ġ( state . constructor Ġ== ĠT d Api . Message Sending State Failed . CON STRUCTOR ) Ġ{ Ċĉĉĉĉĉĉ ĉ log . debug (" update Share Info ĠTEXT Ġ${ message . id } ĠMessage Sending State Failed ") Ċĉĉĉĉĉĉ ĉ share Info . has Sharing Error Ġ= Ġtrue Ċĉĉĉĉĉĉ ĉ share Info . pending Text Message Ġ= Ġfalse Ċĉĉĉĉĉĉ ĉ if Ġ(! is O sm And Bot ) Ġ{ Ċĉĉĉĉĉĉĉ ĉ share Info . pending Td Lib Text -- Ċĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉ ĉ share Info . current Text MessageId Ġ= Ġmessage . id Ċĉĉĉĉĉ ĉ share Info . update Text MessageId ++ Ċĉĉĉĉĉ ĉ share Info . pending Text Message Ġ= Ġfalse Ċĉĉĉĉĉ ĉ share Info . last Text Successful Send Time Ġ= ĠSystem . currentTimeMillis () Ġ/ Ġ 1 0 0 0 Ċĉĉĉĉĉ ĉ if Ġ(! is O sm And Bot ) Ġ{ Ċĉĉĉĉĉĉ ĉ share Info . pending Td Lib Text -- Ċĉĉĉĉĉĉ ĉ share Info . sent Messages ++ Ċĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉ ĉ share Info . should Send Via Bot Text Message Ġ= Ġfalse Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ log . debug (" update Share Info ĠTEXT Ġ${ message . id } ĠSUCCESS Ġpending Td Lib Map : Ġ${ share Info . pending Td Lib Text }") Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġupdate Sharing Status History () Ġ{ Ċĉ ĉ val Ġnew Sharing Status Ġ= Ġget New Sharing Status History Item () ĊĊĉ ĉ if Ġ( sharing Status Changes . isNotEmpty ()) Ġ{ Ċĉĉ ĉ val Ġlast Sharing Status Ġ= Ġsharing Status Changes . last () Ċĉĉ ĉ if Ġ( last Sharing Status . status Type Ġ!= Ġnew Sharing Status . status Type ) Ġ{ Ċĉĉĉ ĉ sharing Status Changes . add ( new Sharing Status ) Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ last Sharing Status . apply Ġ{ Ċĉĉĉĉ ĉ status Change Time Ġ= Ġnew Sharing Status . status Change Time Ċĉĉĉĉ ĉ location Time Ġ= Ġnew Sharing Status . location Time Ċĉĉĉĉ ĉ ch ats Ids Ġ= Ġnew Sharing Status . ch ats Ids Ċĉĉĉĉ ĉ title Ġ= Ġnew Sharing Status . title ĊĊĉĉĉĉ ĉ if Ġ( status Type Ġ== ĠSh aring StatusType . INITIAL IZ ING Ċĉĉĉĉĉ ĉ && Ġnew Sharing Status . status Type Ġ== ĠSh aring StatusType . INITIAL IZ ING ) Ġ{ Ċĉĉĉĉĉ ĉ if Ġ(! description . contains ( new Sharing Status . description )) Ġ{ Ċĉĉĉĉĉĉ ĉ description Ġ= Ġ"$ description , Ġ${ new Sharing Status . description }" Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉ ĉ description Ġ= Ġnew Sharing Status . description Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ sharing Status Changes . add ( new Sharing Status ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate Chat Share Info ( Ċĉ ĉ share Chat Info : ĠShare Chat Info , Ċĉ ĉ live Period : ĠLong Ġ= ĠDEFAULT _ VISIBLE _ TIME _ SECONDS , Ċĉ ĉ add Active Time : ĠLong Ġ= ĠADD ITION AL _ ACTIVE _ TIME _ VALUES _ SEC [ 0 ] Ċ ĉ ) Ġ{ Ċĉ ĉ val Ġlp : ĠLong Ġ= Ġwhen Ġ{ Ċĉĉ ĉ live Period Ġ< ĠTelegram Helper . MIN _ LOCATION _ MESSAGE _ LI VE _ PERIOD _ SEC Ġ-> ĠTelegram Helper . MIN _ LOCATION _ MESSAGE _ LI VE _ PERIOD _ SEC . to Long () Ċĉĉ ĉ else Ġ-> Ġlive Period Ċĉ ĉ } Ċĉ ĉ val ĠcurrentTime Ġ= ĠSystem . currentTimeMillis () Ġ/ Ġ 1 0 0 0 Ċĉ ĉ val Ġuser Ġ= Ġapp . telegram Helper . getCurrent User () Ċĉ ĉ if Ġ( user Ġ!= Ġnull Ġ&& Ġcurrent Sharing Mode Ġ!= Ġuser . id . toString () Ġ&& Ġshare Chat Info . start Ġ== Ġ- 1 L ) Ġ{ Ċĉĉ ĉ share Chat Info . should Send Via Bot Text Message Ġ= Ġtrue Ċĉĉ ĉ share Chat Info . should Send Via Bot Map Message Ġ= Ġtrue Ċĉ ĉ } ĊĊĉ ĉ share Chat Info . start Ġ= ĠcurrentTime Ċĉ ĉ if Ġ( share Chat Info . live Period Ġ== Ġ- 1 L ) Ġ{ Ċĉĉ ĉ share Chat Info . live Period Ġ= Ġlp Ċĉ ĉ } Ċĉ ĉ share Chat Info . user Set Live Period Ġ= Ġlp Ċĉ ĉ share Chat Info . user Set Live Period Start Ġ= ĠcurrentTime Ċĉ ĉ share Chat Info . current Message Limit Ġ= ĠcurrentTime Ġ+ ĠMath . min ( lp , ĠTelegram Helper . MAX _ LOCATION _ MESSAGE _ LI VE _ PERIOD _ SEC . to Long ()) Ċĉ ĉ share Chat Info . additional Active Time Ġ= Ġadd Active Time Ċ ĉ } ĊĊ ĉ private Ġfun Ġget New Sharing Status History Item (): ĠSh aring Status Ġ{ Ċĉ ĉ return ĠSh aring Status (). apply Ġ{ Ċĉĉ ĉ val ĠcurrentTime Millis Ġ= ĠSystem . currentTimeMillis () Ċĉĉ ĉ val ĠcurrentTime Ġ= ĠcurrentTime Millis Ġ/ Ġ 1 0 0 0 Ċĉĉ ĉ status Change Time Ġ= ĠcurrentTime Millis Ċĉĉ ĉ /* Ċĉĉ ĉ val Ġlm Ġ= Ġapp . getSystem Service ( Context . LOCATION _ SERVICE ) Ġas ĠLocation Manager Ċĉĉ ĉ val Ġgps Enabled Ġ= Ġtry Ġ{ Ċĉĉĉ ĉ if Ġ( lm . is Provider Enabled ( Location Manager . GPS _ PROVIDER )) Ġ{ Ċĉĉĉĉ ĉ val Ġloc Ġ= Ġlm . getLast Known Location ( Location Manager . GPS _ PROVIDER ) Ċĉĉĉĉ ĉ val Ġgps Active Ġ= Ġloc Ġ!= Ġnull Ġ&& Ġ(( currentTimeMillis Ġ- Ġloc . time ) Ġ/ Ġ 1 0 0 0 ) Ġ< ĠGPS _ UPDATE _ EXPI RED _ TIME Ċĉĉĉĉ ĉ val Ġlast Sent Location Expired Ġ= Ġ(( currentTimeMillis Ġ- Ġapp . share Location Helper . last Location UpdateTime ) Ġ/ Ġ 1 0 0 0 ) Ġ> ĠGPS _ UPDATE _ EXPI RED _ TIME Ċĉĉĉĉ ĉ ( gps Active Ġ|| Ġ! last Sent Location Expired ) Ċĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉ ĉ false Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ġcatch Ġ( ex : ĠException ) Ġ{ Ċĉĉĉ ĉ false Ċĉĉ ĉ } Ċĉĉ ĉ */ Ċĉĉ ĉ val Ġgps Enabled Ġ= Ġtry Ġ{ Ċĉĉĉĉ ĉ val Ġloc Ġ= Ġapp . location Provider . last Known Location Ċĉĉĉĉ ĉ val Ġgps Active Ġ= Ġloc Ġ!= Ġnull Ġ&& Ġ(( currentTimeMillis Ġ- Ġloc . time ) Ġ/ Ġ 1 0 0 0 ) Ġ< ĠGPS _ UPDATE _ EXPI RED _ TIME Ċĉĉĉĉ ĉ val Ġlast Sent Location Expired Ġ= Ġ(( currentTimeMillis Ġ- Ġapp . share Location Helper . last Location UpdateTime ) Ġ/ Ġ 1 0 0 0 ) Ġ> ĠGPS _ UPDATE _ EXPI RED _ TIME Ċĉĉĉĉ ĉ ( gps Active Ġ|| Ġ! last Sent Location Expired ) Ċĉĉ ĉ } Ġcatch Ġ( ex : ĠException ) Ġ{ Ċĉĉĉ ĉ false Ċĉĉ ĉ } ĊĊĉĉ ĉ var Ġinitializing Ġ= Ġfalse Ċĉĉ ĉ var Ġsend Ch ats Errors Ġ= Ġfalse ĊĊĉĉ ĉ val Ġch ats Count Ġ= Ġshare Ch ats Info . size Ċĉĉ ĉ share Ch ats Info . forEach Ġ{ Ġ(_, Ġshare Info ) Ġ-> Ċĉĉĉ ĉ val Ġinit Time Ġ= Ġ( currentTime Ġ- Ġshare Info . start ) Ġ< ĠSH AR ING _ INITIAL IZATION _ TIME Ċĉĉĉ ĉ var Ġinit Sending Ġ= Ġfalse Ċĉĉĉ ĉ init Sending Ġ= Ġinit Sending Ġ|| Ġ( share Info . last Text Successful Send Time Ġ== Ġ- 1 L Ġ&& Ġshare Type Value Ġ!= ĠSHARE _ TYPE _ MAP ) Ċĉĉĉ ĉ init Sending Ġ= Ġinit Sending Ġ|| Ġ( share Info . last Map Successful Send Time Ġ== Ġ- 1 L Ġ&& Ġshare Type Value Ġ!= ĠSHARE _ TYPE _ TEXT ) Ċĉĉĉ ĉ if Ġ( init Time Ġ&& Ġinit Sending ) Ġ{ Ċĉĉĉĉ ĉ initial izing Ġ= Ġtrue Ċĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉ ĉ var Ġwaiting Time Error Ġ= Ġfalse Ċĉĉĉĉ ĉ val Ġmax Waiting Time Ġ= ĠWAIT ING _ TD LIB _ TIME Ġ* ĠMAX _ MESSAGES _ IN _ TD LIB _ PER _ CHAT Ġ* Ġmax ( 1 , Ġch ats Count ) Ċĉĉĉĉ ĉ val Ġtext Sharing Waiting Time Ġ= ĠcurrentTime Ġ- Ġshare Info . last Send Text Message Time Ċĉĉĉĉ ĉ val Ġmap Sharing Waiting Time Ġ= ĠcurrentTime Ġ- Ġshare Info . last Send Map Message Time Ċĉĉĉĉ ĉ val Ġtext Sharing Error Ġ= Ġ! share Info . last Text Message Handled Ġ&& Ġtext Sharing Waiting Time Ġ> Ġmax Waiting Time Ċĉĉĉĉ ĉ val Ġmap Sharing Error Ġ= Ġ! share Info . last Map Message Handled Ġ&& Ġmap Sharing Waiting Time Ġ> Ġmax Waiting Time Ċĉĉĉĉ ĉ if Ġ(( share Type Value Ġ== ĠSHARE _ TYPE _ MAP _ AND _ TEXT Ġ&& Ġ( text Sharing Error Ġ|| Ġmap Sharing Error )) Ċĉĉĉĉĉĉ ĉ || Ġtext Sharing Error Ġ&& Ġ( share Type Value Ġ== ĠSHARE _ TYPE _ TEXT ) Ċĉĉĉĉĉĉ ĉ || Ġmap Sharing Error Ġ&& Ġ( share Type Value Ġ== ĠSHARE _ TYPE _ MAP )) Ġ{ Ċĉĉĉĉĉ ĉ waiting Time Error Ġ= Ġtrue Ċĉĉĉĉĉ ĉ log . debug (" Send Ġch ats Ġerror Ġfor Ġshare Ġtype Ġ\"$ share Type Value \"" Ġ+ Ċĉĉĉĉĉĉĉ ĉ "\ n Max Ġwaiting Ġtime : Ġ${ max Waiting Time } s " Ġ+ Ċĉĉĉĉĉĉĉ ĉ "\ n Last Ġtext Ġmessage Ġhandled : Ġ${ share Info . last Text Message Handled }" Ġ+ Ċĉĉĉĉĉĉĉ ĉ "\ n Text Ġsharing Ġwaiting Ġtime : Ġ${ text Sharing Waiting Time } s " Ġ+ Ċĉĉĉĉĉĉĉ ĉ "\ n Last Ġmap Ġmessage Ġhandled : Ġ${ share Info . last Map Message Handled }" Ġ+ Ċĉĉĉĉĉĉĉ ĉ "\ n Map Ġsharing Ġwaiting Ġtime : Ġ${ map Sharing Waiting Time } s ") Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ if Ġ( share Info . has Sharing Error Ġ|| Ġwaiting Time Error ) Ġ{ Ċĉĉĉĉĉ ĉ send Ch ats Errors Ġ= Ġtrue Ċĉĉĉĉĉ ĉ location Time Ġ= Ġmax ( share Info . last Text Successful Send Time , Ġshare Info . last Map Successful Send Time ) Ċĉĉĉĉĉ ĉ ch ats Ids . add ( share Info . chat Id ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } ĊĊĉĉ ĉ if Ġ( send Ch ats Errors ) Ġ{ Ċĉĉĉ ĉ title Ġ= Ġapp . getString ( R . string . not _ possible _ to _ send _ to _ telegram _ ch ats ) Ċĉĉĉ ĉ description Ġ= Ġapp . getString ( R . string . last _ updated _ location ) Ċĉĉĉ ĉ status Type Ġ= ĠSh aring StatusType . NOT _ PO SS IBLE _ TO _ SENT _ TO _ CHAT S Ċĉĉ ĉ } Ġelse Ġif Ġ(! initial izing ) Ġ{ Ċĉĉĉ ĉ when Ġ{ Ċĉĉĉĉ ĉ ! gps Enabled Ġ-> Ġ{ Ċĉĉĉĉĉ ĉ location Time Ġ= Ġapp . share Location Helper . last Location UpdateTime Ġ/ Ġ 1 0 0 0 Ċĉĉĉĉĉ ĉ if Ġ( location Time Ġ<= Ġ 0 ) Ġ{ Ċĉĉĉĉĉĉ ĉ location Time Ġ= ĠgetLast Successful Send Time () Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ title Ġ= Ġapp . getString ( R . string . no _ gps _ connection ) Ċĉĉĉĉĉ ĉ description Ġ= Ġapp . getString ( R . string . last _ updated _ location ) Ċĉĉĉĉĉ ĉ status Type Ġ= ĠSh aring StatusType . NO _ GPS Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ ! app . is Internet Connection Available Ġ-> Ġ{ Ċĉĉĉĉĉ ĉ location Time Ġ= ĠgetLast Successful Send Time () Ċĉĉĉĉĉ ĉ title Ġ= Ġapp . getString ( R . string . no _ internet _ connection ) Ċĉĉĉĉĉ ĉ description Ġ= Ġapp . getString ( R . string . last _ updated _ location ) Ċĉĉĉĉĉ ĉ status Type Ġ= ĠSh aring StatusType . NO _ INTER NET Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ else Ġ-> Ġ{ Ċĉĉĉĉĉ ĉ location Time Ġ= ĠgetLast Successful Send Time () Ċĉĉĉĉĉ ĉ status Type Ġ= ĠSh aring StatusType . SEND ING Ċĉĉĉĉĉ ĉ if Ġ( location Time Ġ== Ġ- 1 L ) Ġ{ Ċĉĉĉĉĉĉ ĉ title Ġ= Ġapp . getString ( R . string . sending _ location _ messages ) Ċĉĉĉĉĉĉ ĉ description Ġ= Ġapp . getString ( R . string . waiting _ for _ response _ from _ telegram ) Ċĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉ ĉ title Ġ= Ġapp . getString ( R . string . successfully _ sent _ and _ updated ) Ċĉĉĉĉĉĉ ĉ description Ġ= Ġapp . getString ( R . string . last _ updated _ location ) Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ if Ġ( gps Enabled Ġ&& Ġapp . is Internet Connection Available ) Ġ{ Ċĉĉĉĉ ĉ title Ġ= Ġapp . getString ( R . string . sending _ location _ messages ) Ċĉĉĉĉ ĉ description Ġ= Ġapp . getString ( R . string . waiting _ for _ response _ from _ telegram ) Ċĉĉĉĉ ĉ status Type Ġ= ĠSh aring StatusType . SEND ING Ċĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉ ĉ title Ġ= Ġapp . getString ( R . string . initial izing ) Ċĉĉĉĉ ĉ status Type Ġ= ĠSh aring StatusType . INITIAL IZ ING Ċĉĉĉĉ ĉ if Ġ(! gps Enabled ) Ġ{ Ċĉĉĉĉĉ ĉ description Ġ= Ġapp . getString ( R . string . search ing _ for _ gps ) Ċĉĉĉĉ ĉ } Ġelse Ġif Ġ(! app . is Internet Connection Available ) Ġ{ Ċĉĉĉĉĉ ĉ description Ġ= Ġapp . getString ( R . string . connecting _ to _ the _ internet ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun ĠonDelete Live Messages ( chat Id : ĠLong , Ġmessages : ĠList < Long >) Ġ{ Ċĉ ĉ val Ġcurrent Map MessageId Ġ= Ġshare Ch ats Info [ chat Id ]?. current Map MessageId Ċĉ ĉ if Ġ( messages . contains ( current Map MessageId )) Ġ{ Ċĉĉ ĉ share Ch ats Info [ chat Id ]?. current Map MessageId Ġ= Ġ- 1 Ċĉĉ ĉ share Ch ats Info [ chat Id ]?. should Send Via Bot Map Message Ġ= Ġtrue Ċĉĉ ĉ share Ch ats Info [ chat Id ]?. should Send Via Bot Text Message Ġ= Ġtrue Ċĉ ĉ } Ċĉ ĉ val Ġcurrent Text MessageId Ġ= Ġshare Ch ats Info [ chat Id ]?. current Text MessageId Ċĉ ĉ if Ġ( messages . contains ( current Text MessageId )) Ġ{ Ċĉĉ ĉ share Ch ats Info [ chat Id ]?. current Text MessageId Ġ= Ġ- 1 Ċĉĉ ĉ share Ch ats Info [ chat Id ]?. update Text MessageId Ġ= Ġ 1 Ċĉĉ ĉ share Ch ats Info [ chat Id ]?. should Send Via Bot Map Message Ġ= Ġtrue Ċĉĉ ĉ share Ch ats Info [ chat Id ]?. should Send Via Bot Text Message Ġ= Ġtrue Ċĉ ĉ } Ċ ĉ } ĊĉĊ ĉ fun Ġsave () Ġ{ Ċĉ ĉ val Ġprefs Ġ= Ġapp . get SharedPreferences ( SETTINGS _ NAME , ĠContext . MODE _ PRIVATE ) Ċĉ ĉ val Ġedit Ġ= Ġprefs . edit () ĊĊĉ ĉ val Ġhidden Ch ats Set Ġ= Ġmutable Set Of < String >() Ċĉ ĉ val Ġhidden Ch ats Ġ= ĠArrayList ( hidden On Map Ch ats ) Ċĉ ĉ for Ġ( chat Id Ġin Ġhidden Ch ats ) Ġ{ Ċĉĉ ĉ hidden Ch ats Set . add ( chat Id . toString ()) Ċĉ ĉ } Ċĉ ĉ edit . putString Set ( HIDDEN _ ON _ MAP _ CHAT S _ KEY , Ġhidden Ch ats Set ) ĊĊĉ ĉ edit . putString ( SH AR ING _ MODE _ KEY , Ġcurrent Sharing Mode ) ĊĊĉ ĉ edit . putString ( METR ICS _ CONSTANT S _ KEY , Ġmetrics Constants . name ) Ċĉ ĉ edit . putString ( SPEED _ CONSTANT S _ KEY , Ġspeed Constants . name ) Ċĉ ĉ edit . putString ( UTC _ OFFSET _ CONSTANT S _ KEY , Ġut c Offset ) ĊĊĉ ĉ edit . put Long ( SEND _ MY _ LOC _ INTERVAL _ KEY , Ġsend My Loc Interval ) Ċĉ ĉ edit . put Long ( ST ALE _ LOC _ TIME _ KEY , Ġstale Loc Time ) Ċĉ ĉ edit . put Long ( LOC _ HISTORY _ TIME _ KEY , Ġloc History Time ) ĊĊĉ ĉ edit . put Float ( MIN _ LOCATION _ DISTANCE _ KEY , Ġmin Location Distance ) Ċĉ ĉ edit . put Float ( MIN _ LOCATION _ AC CUR ACY _ KEY , Ġmin Location Accuracy ) Ċĉ ĉ edit . put Float ( MIN _ LOCATION _ SPEED _ KEY , Ġmin Location Speed ) ĊĊĉ ĉ edit . putString ( SHARE _ TYPE _ KEY , Ġshare Type Value ) ĊĊĉ ĉ edit . putString ( APP _ TO _ CONNECT _ PACKAGE _ KEY , Ġapp To Connect Package ) ĊĊĉ ĉ edit . putString ( LI VE _ NOW _ SORT _ TYPE _ KEY , Ġlive Now Sort Type . name ) ĊĊĉ ĉ edit . put Boolean ( B ATTER Y _ OP TI MIS ATION _ ASK ED , Ġbattery Optim isation Ask ed ) ĊĊĉ ĉ edit . put Boolean ( MONITOR ING _ ENABLED , Ġmonitoring Enabled ) ĊĊĉ ĉ edit . put Boolean ( SHOW _ GPS _ POINTS , Ġshow G ps Points ) ĊĊĉ ĉ edit . put Boolean ( PROXY _ ENABLED , Ġproxy Enabled ) ĊĊĉ ĉ edit . put Long ( BUFFER _ TIME _ KEY , Ġbuffer Time ) ĊĊĉ ĉ edit . put Long ( FREE _ TIME LINE _ INFO _ SHO WN _ TIME _ KEY , Ġfree Timeline Info Shown Time ) ĊĊĉ ĉ val Ġj Array Ġ= Ġconvert Share Ch ats Info ToJson () Ċĉ ĉ if Ġ( j Array Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ edit . putString ( SHARE _ CHAT S _ INFO _ KEY , Ġj Array . toString ()) Ċĉ ĉ } ĊĊĉ ĉ val ĠjsonObject Ġ= Ġconvert Share Devices ToJson () Ċĉ ĉ if Ġ( jsonObject Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ edit . putString ( SHARE _ DEVICES _ KEY , ĠjsonObject . toString ()) Ċĉ ĉ } ĊĊĉ ĉ val ĠjsonObject Proxy Ġ= Ġconvert Proxy Pref ToJson () Ċĉ ĉ if Ġ( jsonObject Proxy Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ edit . putString ( PROXY _ PREFER ENCES _ KEY , ĠjsonObject Proxy . toString ()) Ċĉ ĉ } ĊĊĉ ĉ val Ġjson Array Live Tracks Ġ= Ġconvert Live Tracks Info ToJson () Ċĉ ĉ if Ġ( json Array Live Tracks Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ edit . putString ( LI VE _ TRACK S _ KEY , Ġjson Array Live Tracks . toString ()) Ċĉ ĉ } ĊĊĉ ĉ val Ġj Array Last Info Ġ= Ġconvert Last Ch ats Info ToJson () Ċĉ ĉ if Ġ( j Array Last Info Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ edit . putString ( LAST _ CHAT S _ INFO _ KEY , Ġj Array Last Info . toString ()) Ċĉ ĉ } ĊĊĉ ĉ edit . apply () Ċ ĉ } ĊĊ ĉ fun Ġread () Ġ{ Ċĉ ĉ val Ġprefs Ġ= Ġapp . get SharedPreferences ( SETTINGS _ NAME , ĠContext . MODE _ PRIVATE ) ĊĊĉ ĉ val Ġhidden Ch ats Ġ= Ġmutable Set Of < Long >() Ċĉ ĉ val Ġhidden Ch ats Set Ġ= Ġprefs . getString Set ( HIDDEN _ ON _ MAP _ CHAT S _ KEY , Ġmutable Set Of ()) Ċĉ ĉ hidden Ch ats Set ?. let Ġ{ Ċĉĉ ĉ for Ġ( chat Id Ġin Ġit ) Ġ{ Ċĉĉĉ ĉ hidden Ch ats . add ( chat Id . to Long ()) Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ hidden On Map Ch ats Ġ= Ġhidden Ch ats ĊĊĉ ĉ metrics Constants Ġ= ĠMetrics Constants . valueOf ( Ċĉĉ ĉ prefs . getString ( METR ICS _ CONSTANT S _ KEY , ĠMetrics Constants . KI LO METER S _ AND _ METER S . name ) !! Ċĉ ĉ ) Ċĉ ĉ speed Constants Ġ= ĠSpeed Constants . valueOf ( Ċĉĉ ĉ prefs . getString ( SPEED _ CONSTANT S _ KEY , ĠSpeed Constants . KI LO METER S _ PER _ HOUR . name ) !! Ċĉ ĉ ) Ċĉ ĉ utc Offset Ġ= Ġprefs . getString ( UTC _ OFFSET _ CONSTANT S _ KEY , ĠData Constants . UTC _ FORMAT ) !! ĊĊĉ ĉ try Ġ{ Ċĉĉ ĉ parse Share Ch ats Info ( JSONArray ( prefs . getString ( SHARE _ CHAT S _ INFO _ KEY , Ġ" "))) Ċĉ ĉ } Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ Ċĉĉ ĉ e . printStackTrace () Ċĉ ĉ } ĊĊĉ ĉ try Ġ{ Ċĉĉ ĉ parse Last Ch ats Info ( JSONArray ( prefs . getString ( LAST _ CHAT S _ INFO _ KEY , Ġ" "))) Ċĉ ĉ } Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ Ċĉĉ ĉ log . error ( e ) Ċĉ ĉ } ĊĊĉ ĉ parse Share Devices ( prefs . getString ( SHARE _ DEVICES _ KEY , Ġ"") !! ) ĊĊĉ ĉ val Ġsend My Loc Def Ġ= ĠS END _ MY _ LOC _ VALUES _ SEC [ SEND _ MY _ LOC _ DEFAULT _ INDEX ] Ċĉ ĉ send My Loc Interval Ġ= Ġprefs . getLong ( SEND _ MY _ LOC _ INTERVAL _ KEY , Ġsend My Loc Def ) Ċĉ ĉ val Ġstale Loc Def Ġ= ĠST ALE _ LOC _ VALUES _ SEC [ ST ALE _ LOC _ DEFAULT _ INDEX ] Ċĉ ĉ st ale Loc Time Ġ= Ġprefs . getLong ( ST ALE _ LOC _ TIME _ KEY , Ġstale Loc Def ) Ċĉ ĉ val Ġloc History Def Ġ= ĠLOC _ HISTORY _ VALUES _ SEC [ LOC _ HISTORY _ DEFAULT _ INDEX ] Ċĉ ĉ loc History Time Ġ= Ġprefs . getLong ( LOC _ HISTORY _ TIME _ KEY , Ġloc History Def ) Ċĉ ĉ val Ġshare TypeDef Ġ= ĠSHARE _ TYPE _ VALUES [ SHARE _ TYPE _ DEFAULT _ INDEX ] Ċĉ ĉ share Type Value Ġ= Ġprefs . getString ( SHARE _ TYPE _ KEY , Ġshare TypeDef ) !! ĊĊĉ ĉ val Ġmin Location Distance Def Ġ= ĠMIN _ LOCATION _ DISTANCE [ MIN _ LOCATION _ DISTANCE _ INDEX ] Ċĉ ĉ min Location Distance Ġ= Ġprefs . get Float ( MIN _ LOCATION _ DISTANCE _ KEY , Ġmin Location Distance Def ) Ċĉ ĉ val Ġmin Location Precision Def Ġ= ĠMIN _ LOCATION _ AC CUR ACY [ MIN _ LOCATION _ AC CUR ACY _ INDEX ] Ċĉ ĉ min Location Accuracy Ġ= Ġprefs . get Float ( MIN _ LOCATION _ AC CUR ACY _ KEY , Ġmin Location Precision Def ) Ċĉ ĉ val Ġmin Location Speed Def Ġ= ĠMIN _ LOCATION _ SPEED [ MIN _ LOCATION _ SPEED _ INDEX ] Ċĉ ĉ min Location Speed Ġ= Ġprefs . get Float ( MIN _ LOCATION _ SPEED _ KEY , Ġmin Location Speed Def ) ĊĊĉ ĉ val Ġcurrent UserId Ġ= Ġapp . telegram Helper . getCurrent UserId () Ċĉ ĉ current Sharing Mode Ġ= Ġprefs . getString ( SH AR ING _ MODE _ KEY , Ġif Ġ( current UserId Ġ!= Ġ- 1 ) Ġcurrent UserId . toString () Ġelse Ġ"") !! ĊĊĉ ĉ val Ġdef Package Ġ= Ġif Ġ( App Connect . get Installed Apps ( app ). size Ġ== Ġ 1 ) ĠApp Connect . get Installed Apps ( app ). first (). app Package Ġelse Ġ"" Ċĉ ĉ app To Connect Package Ġ= Ġprefs . getString ( APP _ TO _ CONNECT _ PACKAGE _ KEY , Ġdef Package ) !! ĊĊĉ ĉ live Now Sort Type Ġ= ĠLive Now Sort Type . valueOf ( Ċĉĉ ĉ prefs . getString ( LI VE _ NOW _ SORT _ TYPE _ KEY , ĠLive Now Sort Type . SORT _ BY _ DISTANCE . name ) !! Ċĉ ĉ ) ĊĊĉ ĉ battery Optim isation Ask ed Ġ= Ġprefs . getBoolean ( B ATTER Y _ OP TI MIS ATION _ ASK ED , false ) ĊĊĉ ĉ monitoring Enabled Ġ= Ġprefs . getBoolean ( MONITOR ING _ ENABLED , false ) ĊĊĉ ĉ show G ps Points Ġ= Ġprefs . getBoolean ( SHOW _ GPS _ POINTS , Ġfalse ) ĊĊĉ ĉ proxy Enabled Ġ= Ġprefs . getBoolean ( PROXY _ ENABLED , Ġfalse ) ĊĊĉ ĉ buffer Time Ġ= Ġprefs . getLong ( BUFFER _ TIME _ KEY , ĠBUFFER _ TIME [ BUFFER _ TIME _ INDEX ]) ĊĊĉ ĉ free Timeline Info Shown Time Ġ= Ġprefs . getLong ( FREE _ TIME LINE _ INFO _ SHO WN _ TIME _ KEY , Ġ 0 L ) ĊĊĉ ĉ try Ġ{ Ċĉĉ ĉ parse Proxy Preferences ( JSONObject ( prefs . getString ( PROXY _ PREFER ENCES _ KEY , Ġ" "))) Ċĉ ĉ } Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ Ċĉĉ ĉ log . error ( e ) Ċĉ ĉ } ĊĊĉ ĉ try Ġ{ Ċĉĉ ĉ parse Live Tracks ( JSONArray ( prefs . getString ( LI VE _ TRACK S _ KEY , Ġ" "))) Ċĉ ĉ } Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ Ċĉĉ ĉ log . error ( e ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġconvert Share Devices ToJson (): JSONObject ? { Ċĉ ĉ return Ġtry Ġ{ Ċĉĉ ĉ val ĠjsonObject Ġ= ĠJSONObject () Ċĉĉ ĉ val Ġj Array Ġ= ĠJSONArray () Ċĉĉ ĉ share Devices . forEach Ġ{ Ġdevice Ġ-> Ċĉĉĉ ĉ val Ġobj Ġ= ĠJSONObject () Ċĉĉĉ ĉ obj . put ( Device Bot . DEVICE _ ID , Ġdevice . id ) Ċĉĉĉ ĉ obj . put ( Device Bot . USER _ ID , Ġdevice . userId ) Ċĉĉĉ ĉ obj . put ( Device Bot . CHAT _ ID , Ġdevice . chat Id ) Ċĉĉĉ ĉ obj . put ( Device Bot . DEVICE _ NAME , Ġdevice . device Name ) Ċĉĉĉ ĉ obj . put ( Device Bot . EXTERNAL _ ID , Ġdevice . external Id ) Ċĉĉĉ ĉ obj . put ( Device Bot . DATA , ĠJSONObject ( device . data )) Ċĉĉĉ ĉ j Array . put ( obj ) Ċĉĉ ĉ } Ċĉĉ ĉ jsonObject . put ( SHARE _ DEVICES _ KEY , Ġj Array ) Ċĉ ĉ } Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ Ċĉĉ ĉ e . printStackTrace () Ċĉĉ ĉ null Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġconvert Live Tracks Info ToJson (): ĠJSONArray ? Ġ{ Ċĉ ĉ return Ġtry Ġ{ Ċĉĉ ĉ JSONArray (). apply Ġ{ Ċĉĉĉ ĉ live Tracks Info . forEach Ġ{ Ġlive Track Info Ġ-> Ċĉĉĉĉ ĉ val Ġobj Ġ= ĠJSONObject () Ċĉĉĉĉ ĉ obj . put ( Live Track Info . USER _ ID , Ġlive Track Info . userId ) Ċĉĉĉĉ ĉ obj . put ( Live Track Info . CHAT _ ID , Ġlive Track Info . chat Id ) Ċĉĉĉĉ ĉ obj . put ( Live Track Info . DEVICE _ NAME , Ġlive Track Info . device Name ) Ċĉĉĉĉ ĉ obj . put ( Live Track Info . COLOR _ INDEX , Ġlive Track Info . color Index ) Ċĉĉĉĉ ĉ put ( obj ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ Ċĉĉ ĉ log . error ( e ) Ċĉĉ ĉ null Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġconvert Proxy Pref ToJson (): ĠJSONObject ? Ġ{ Ċĉ ĉ return Ġtry Ġ{ Ċĉĉ ĉ val Ġproxy Pref Ġ= Ġcurrent Proxy Pref Ċĉĉ ĉ JSONObject (). apply Ġ{ Ċĉĉĉ ĉ put ( Proxy Pref . PROXY _ ID , Ġproxy Pref . id ) Ċĉĉĉ ĉ put ( Proxy Pref . TYPE _ ID , Ġproxy Pref . type ) Ċĉĉĉ ĉ put ( Proxy Pref . SERVER _ ID , Ġproxy Pref . server ) Ċĉĉĉ ĉ put ( Proxy Pref . PORT _ ID , Ġproxy Pref . port ) Ċĉĉĉ ĉ if Ġ( proxy Pref Ġis ĠProxy MT Proto Pref ) Ġ{ Ċĉĉĉĉ ĉ put ( Proxy MT Proto Pref . KEY _ ID , Ġproxy Pref . key ) Ċĉĉĉ ĉ } Ġelse Ġif Ġ( proxy Pref Ġis ĠProxy SOCK S 5 Pref ) Ġ{ Ċĉĉĉĉ ĉ put ( Proxy SOCK S 5 Pref . LOGIN _ ID , Ġproxy Pref . login ) Ċĉĉĉĉ ĉ put ( Proxy SOCK S 5 Pref . PASSWORD _ ID , Ġproxy Pref . password ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ Ċĉĉ ĉ e . printStackTrace () Ċĉĉ ĉ null Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġconvert Share Ch ats Info ToJson (): ĠJSONArray ? Ġ{ Ċĉ ĉ return Ġtry Ġ{ Ċĉĉ ĉ val Ġj Array Ġ= ĠJSONArray () Ċĉĉ ĉ share Ch ats Info . forEach Ġ{ Ġ( chat Id , Ġchat Info ) Ġ-> Ċĉĉĉ ĉ val Ġobj Ġ= ĠJSONObject () Ċĉĉĉ ĉ obj . put ( Share Chat Info . CHAT _ ID _ KEY , Ġchat Id ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . USER _ ID _ KEY , Ġchat Info . userId ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . START _ KEY , Ġchat Info . start ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . LI VE _ PERIOD _ KEY , Ġchat Info . live Period ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . LIMIT _ KEY , Ġchat Info . current Message Limit ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . UPDATE _ TEXT _ MESSAGE _ ID _ KEY , Ġchat Info . update Text MessageId ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . CURRENT _ MAP _ MESSAGE _ ID _ KEY , Ġchat Info . current Map MessageId ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . CURRENT _ TEXT _ MESSAGE _ ID _ KEY , Ġchat Info . current Text MessageId ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . USER _ SET _ LI VE _ PERIOD _ KEY , Ġchat Info . user Set Live Period ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . USER _ SET _ LI VE _ PERIOD _ START _ KEY , Ġchat Info . user Set Live Period Start ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . LAST _ TEXT _ SUCCESS FUL _ SEND _ TIME _ KEY , Ġchat Info . last Text Successful Send Time ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . LAST _ MAP _ SUCCESS FUL _ SEND _ TIME _ KEY , Ġchat Info . last Map Successful Send Time ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . LAST _ SEND _ MAP _ TIME _ KEY , Ġchat Info . last Send Map Message Time ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . LAST _ SEND _ TEXT _ TIME _ KEY , Ġchat Info . last Send Text Message Time ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . PENDING _ TEXT _ MESSAGE _ KEY , Ġchat Info . pending Text Message ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . PENDING _ MAP _ MESSAGE _ KEY , Ġchat Info . pending Map Message ) Ċĉĉĉ ĉ obj . put ( Share Chat Info . SENT _ MESSAGES _ KEY , Ġchat Info . sent Messages ) Ċĉĉĉ ĉ j Array . put ( obj ) Ċĉĉ ĉ } Ċĉĉ ĉ j Array Ċĉ ĉ } Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ Ċĉĉ ĉ log . error ( e ) Ċĉĉ ĉ null Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġconvert Last Ch ats Info ToJson (): ĠJSONArray ? Ġ{ Ċĉ ĉ return Ġtry Ġ{ Ċĉĉ ĉ val Ġj Array Ġ= ĠJSONArray () Ċĉĉ ĉ last Ch ats Info . forEach Ġ{ Ġlast Info Ġ-> Ċĉĉĉ ĉ val Ġobj Ġ= ĠJSONObject () Ċĉĉĉ ĉ obj . put ( Last Chat Info . CHAT _ ID _ KEY , Ġlast Info . chat Id ) Ċĉĉĉ ĉ obj . put ( Last Chat Info . PERIOD _ KEY , Ġlast Info . period ) Ċĉĉĉ ĉ j Array . put ( obj ) Ċĉĉ ĉ } Ċĉĉ ĉ j Array Ċĉ ĉ } Ġcatch Ġ( e : ĠJSON Exception ) Ġ{ Ċĉĉ ĉ log . error ( e ) Ċĉĉ ĉ null Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġparse Share Ch ats Info ( json : ĠJSONArray ) Ġ{ Ċĉ ĉ for Ġ( i Ġin Ġ 0 Ġuntil Ġjson . length ()) Ġ{ Ċĉĉ ĉ val Ġobj Ġ= Ġjson . getJSONObject ( i ) Ċĉĉ ĉ val Ġshare Info Ġ= ĠShare Chat Info (). apply Ġ{ Ċĉĉĉ ĉ chat Id Ġ= Ġobj . opt Long ( Share Chat Info . CHAT _ ID _ KEY ) Ċĉĉĉ ĉ userId Ġ= Ġobj . opt Int ( Share Chat Info . USER _ ID _ KEY ) Ċĉĉĉ ĉ start Ġ= Ġobj . opt Long ( Share Chat Info . START _ KEY ) Ċĉĉĉ ĉ live Period Ġ= Ġobj . opt Long ( Share Chat Info . LI VE _ PERIOD _ KEY ) Ċĉĉĉ ĉ current Message Limit Ġ= Ġobj . opt Long ( Share Chat Info . LIMIT _ KEY ) Ċĉĉĉ ĉ update Text MessageId Ġ= Ġobj . opt Int ( Share Chat Info . UPDATE _ TEXT _ MESSAGE _ ID _ KEY ) Ċĉĉĉ ĉ current Map MessageId Ġ= Ġobj . opt Long ( Share Chat Info . CURRENT _ MAP _ MESSAGE _ ID _ KEY ) Ċĉĉĉ ĉ current Text MessageId Ġ= Ġobj . opt Long ( Share Chat Info . CURRENT _ TEXT _ MESSAGE _ ID _ KEY ) Ċĉĉĉ ĉ user Set Live Period Ġ= Ġobj . opt Long ( Share Chat Info . USER _ SET _ LI VE _ PERIOD _ KEY ) Ċĉĉĉ ĉ user Set Live Period Start Ġ= Ġobj . opt Long ( Share Chat Info . USER _ SET _ LI VE _ PERIOD _ START _ KEY ) Ċĉĉĉ ĉ last Text Successful Send Time Ġ= Ġobj . opt Long ( Share Chat Info . LAST _ TEXT _ SUCCESS FUL _ SEND _ TIME _ KEY ) Ċĉĉĉ ĉ last Map Successful Send Time Ġ= Ġobj . opt Long ( Share Chat Info . LAST _ MAP _ SUCCESS FUL _ SEND _ TIME _ KEY ) Ċĉĉĉ ĉ last Send Map Message Time Ġ= Ġobj . opt Int ( Share Chat Info . LAST _ SEND _ MAP _ TIME _ KEY ) Ċĉĉĉ ĉ last Send Text Message Time Ġ= Ġobj . opt Int ( Share Chat Info . LAST _ SEND _ TEXT _ TIME _ KEY ) Ċĉĉĉ ĉ pending Text Message Ġ= Ġobj . opt Boolean ( Share Chat Info . PENDING _ TEXT _ MESSAGE _ KEY ) Ċĉĉĉ ĉ pending Map Message Ġ= Ġobj . opt Boolean ( Share Chat Info . PENDING _ MAP _ MESSAGE _ KEY ) Ċĉĉĉ ĉ sent Messages Ġ= Ġobj . opt Int ( Share Chat Info . SENT _ MESSAGES _ KEY ) Ċĉĉ ĉ } Ċĉĉ ĉ share Ch ats Info [ share Info . chat Id ] Ġ= Ġshare Info Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġparse Proxy Preferences ( jsonObject : ĠJSONObject ) Ġ{ Ċĉ ĉ val Ġproxy Id Ġ= ĠjsonObject . opt Int ( Proxy Pref . PROXY _ ID ) Ċĉ ĉ val Ġtype String Ġ= ĠjsonObject . opt String ( Proxy Pref . TYPE _ ID ) Ċĉ ĉ val Ġserver Ġ= ĠjsonObject . opt String ( Proxy Pref . SERVER _ ID ) Ċĉ ĉ val Ġport Ġ= ĠjsonObject . opt Int ( Proxy Pref . PORT _ ID ) Ċĉ ĉ val Ġproxy Pref Ġ= Ġwhen Ġ{ Ċĉĉ ĉ Proxy Type . valueOf ( type String ) Ġ== ĠProxy Type . M TP RO TO Ġ-> Ġ{ Ċĉĉĉ ĉ val Ġkey Ġ= ĠjsonObject . opt String ( Proxy MT Proto Pref . KEY _ ID ) Ċĉĉĉ ĉ Proxy MT Proto Pref ( proxy Id , Ġserver , Ġport , Ġkey ) Ċĉĉ ĉ } Ċĉĉ ĉ Proxy Type . valueOf ( type String ) Ġ== ĠProxy Type . SOCK S 5 Ġ-> Ġ{ Ċĉĉĉ ĉ val Ġlogin Ġ= ĠjsonObject . opt String ( Proxy SOCK S 5 Pref . LOGIN _ ID ) Ċĉĉĉ ĉ val Ġpassword Ġ= ĠjsonObject . opt String ( Proxy SOCK S 5 Pref . PASSWORD _ ID ) Ċĉĉĉ ĉ Proxy SOCK S 5 Pref ( proxy Id , Ġserver , Ġport , Ġlogin , Ġpassword ) Ċĉĉ ĉ } Ċĉĉ ĉ else Ġ-> Ġnull Ċĉ ĉ } Ċĉ ĉ if Ġ( proxy Pref Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ current Proxy Pref Ġ= Ġproxy Pref Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġparse Live Tracks ( json : ĠJSONArray ) Ġ{ Ċĉ ĉ val Ġlist Ġ= Ġmutable ListOf < Live Track Info >() Ċĉ ĉ for Ġ( i Ġin Ġ 0 Ġuntil Ġjson . length ()) Ġ{ Ċĉĉ ĉ val Ġobj Ġ= Ġjson . getJSONObject ( i ) Ċĉĉ ĉ val ĠuserId Ġ= Ġobj . opt Int ( Live Track Info . USER _ ID ) Ċĉĉ ĉ val Ġchat Id Ġ= Ġobj . opt Long ( Live Track Info . CHAT _ ID ) Ċĉĉ ĉ val Ġdevice Name Ġ= Ġobj . opt String ( Live Track Info . DEVICE _ NAME ) Ċĉĉ ĉ val Ġcolor Index Ġ= Ġobj . opt Int ( Live Track Info . COLOR _ INDEX ) ĊĊĉĉ ĉ list . add ( Live Track Info ( userId , Ġchat Id , Ġdevice Name , Ġcolor Index )) Ċĉ ĉ } Ċĉ ĉ live Tracks Info Ġ= Ġlist . toList () Ċ ĉ } ĊĊ ĉ private Ġfun Ġparse Share Devices ( json : ĠString ) Ġ{ Ċĉ ĉ share Devices Ġ= ĠOs mand Api Utils . parse Json Contents ( json ). to HashSet () Ċ ĉ } ĊĊ ĉ private Ġfun Ġparse Last Ch ats Info ( json : ĠJSONArray ) Ġ{ Ċĉ ĉ for Ġ( i Ġin Ġ 0 Ġuntil Ġjson . length ()) Ġ{ Ċĉĉ ĉ val Ġobj Ġ= Ġjson . getJSONObject ( i ) Ċĉĉ ĉ val Ġlast Info Ġ= ĠLast Chat Info (). apply Ġ{ Ċĉĉĉ ĉ chat Id Ġ= Ġobj . opt Long ( Last Chat Info . CHAT _ ID _ KEY ) Ċĉĉĉ ĉ period Ġ= Ġobj . opt Long ( Last Chat Info . PERIOD _ KEY ) Ċĉĉ ĉ } Ċĉĉ ĉ last Ch ats Info . add Last ( last Info ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġadd Time Period To Last Item ( id : ĠLong , Ġtime : ĠLong ) Ġ{ Ċĉ ĉ val Ġlast Info Ġ= Ġlast Ch ats Info . find Ġ{ Ġit . chat Id Ġ== Ġid Ġ} Ċĉ ĉ if Ġ( last Info Ġ== Ġnull ) Ġ{ Ċĉĉ ĉ addItem To Suggest ed ( id , Ġtime ) Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ val Ġindex Ġ= Ġlast Ch ats Info . indexOf ( last Info ) Ċĉĉ ĉ last Ch ats Info [ index ]. period Ġ= Ġtime Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġadd Item To Suggest ed ( id : ĠLong , Ġtime : ĠLong ) Ġ{ Ċĉ ĉ val Ġnew Last Info Ġ= ĠLast Chat Info (). apply Ġ{ Ċĉĉ ĉ chat Id Ġ= Ġid Ċĉĉ ĉ period Ġ= Ġtime Ċĉ ĉ } Ċĉ ĉ if Ġ( last Ch ats Info . size Ġ< Ġ 5 ) Ġ{ Ċĉĉ ĉ last Ch ats Info . add First ( new Last Info ) Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ last Ch ats Info . remove Last () Ċĉĉ ĉ last Ch ats Info . add First ( new Last Info ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġget Live Now Ch ats () Ġ= Ġapp . telegram Helper . get Messages By Chat Ids ( loc History Time ). keys ĊĊ ĉ private Ġfun Ġupdate Prefs () Ġ{ Ċĉ ĉ val Ġprefs Ġ= Ġapp . get SharedPreferences ( SETTINGS _ NAME , ĠContext . MODE _ PRIVATE ) Ċĉ ĉ val Ġids InUse Ġ= Ġprefs . getBoolean ( TIT LES _ REPL AC ED _ WITH _ IDS , Ġfalse ) Ċĉ ĉ if Ġ(! ids InUse ) Ġ{ Ċĉĉ ĉ val Ġedit Ġ= Ġprefs . edit () ĊĊĉĉ ĉ edit . putString Set ( SHARE _ LOCATION _ CHAT S _ KEY , Ġempty Set ()) Ċĉĉ ĉ edit . put Boolean ( TIT LES _ REPL AC ED _ WITH _ IDS , Ġtrue ) ĊĊĉĉ ĉ edit . apply () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ inner Ġclass ĠSend My Loc Pref Ġ: ĠList Preference ( Ċĉ ĉ R . drawable . ic _ action _ share _ location , Ċĉ ĉ R . string . send _ my _ location , Ċĉ ĉ R . string . send _ my _ location _ desc Ċ ĉ ) Ġ{ ĊĊĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= Ċĉĉ ĉ Os mand Formatter . get Formatted Duration ( app , Ġsend My Loc Interval ) ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ send My Loc Interval Ġ= ĠS END _ MY _ LOC _ VALUES _ SEC [ index ] Ċĉĉ ĉ app . update Send Location Interval () Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items () Ġ= Ċĉĉ ĉ SEND _ MY _ LOC _ VALUES _ SEC . map Ġ{ ĠOs mand Formatter . get Formatted Duration ( app , Ġit ) Ġ} Ċ ĉ } ĊĊ ĉ inner Ġclass ĠSt ale Loc Pref Ġ: ĠList Preference ( Ċĉ ĉ R . drawable . ic _ action _ time _ span , Ċĉ ĉ R . string . st ale _ location , Ċĉ ĉ R . string . st ale _ location _ desc Ċ ĉ ) Ġ{ ĊĊĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= Ċĉĉ ĉ Os mand Formatter . get Formatted Duration ( app , Ġstale Loc Time ) ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ st ale Loc Time Ġ= ĠST ALE _ LOC _ VALUES _ SEC [ index ] Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items () Ġ= Ċĉĉ ĉ ST ALE _ LOC _ VALUES _ SEC . map Ġ{ ĠOs mand Formatter . get Formatted Duration ( app , Ġit ) Ġ} Ċ ĉ } ĊĊ ĉ inner Ġclass ĠLoc History Pref Ġ: ĠList Preference ( Ċĉ ĉ R . drawable . ic _ action _ location _ history , Ċĉ ĉ R . string . location _ history , Ċĉ ĉ R . string . location _ history _ desc Ċ ĉ ) Ġ{ ĊĊĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= Ċĉĉ ĉ Os mand Formatter . get Formatted Duration ( app , Ġloc History Time ) ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ val Ġvalue Ġ= ĠLOC _ HISTORY _ VALUES _ SEC [ index ] Ċĉĉ ĉ loc History Time Ġ= Ġvalue Ċĉĉ ĉ app . telegram Helper . message Active Time Sec Ġ= Ġvalue Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items () Ġ= Ċĉĉ ĉ LOC _ HISTORY _ VALUES _ SEC . map Ġ{ ĠOs mand Formatter . get Formatted Duration ( app , Ġit ) Ġ} Ċ ĉ } ĊĊ ĉ inner Ġclass ĠShare Type Pref Ġ: ĠList Preference ( Ċĉ ĉ R . drawable . ic _ action _ location _ history , Ċĉ ĉ R . string . send _ location _ as , Ċĉ ĉ R . string . send _ location _ as _ descr Ċ ĉ ) Ġ{ ĊĊĉ ĉ override Ġfun ĠgetCurrent Value (): ĠString Ġ{ Ċĉĉ ĉ return ĠgetText Value ( share Type Value ) Ċĉ ĉ } ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ val Ġnew Sharing Type Ġ= ĠSHARE _ TYPE _ VALUES [ index ] Ċĉĉ ĉ if Ġ( share Type Value Ġ!= Ġnew Sharing Type Ġ&& Ġapp . telegram Helper . getCurrent User ()?. id . toString () Ġ!= Ġcurrent Sharing Mode ) Ġ{ Ċĉĉĉ ĉ share Ch ats Info . forEach Ġ{ Ġ(_, Ġshare Info ) Ġ-> Ċĉĉĉĉ ĉ share Info . should Send Via Bot Text Message Ġ= Ġtrue Ċĉĉĉĉ ĉ share Info . should Send Via Bot Map Message Ġ= Ġtrue Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ share Type Value Ġ= Ġnew Sharing Type Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items (): ĠList < String > Ġ{ Ċĉĉ ĉ return ĠSHARE _ TYPE _ VALUES . map Ġ{ ĠgetText Value ( it ) Ġ} Ċĉ ĉ } ĊĊĉ ĉ private Ġfun ĠgetText Value ( share Type : ĠString ): ĠString Ġ{ Ċĉĉ ĉ return Ġwhen Ġ( share Type ) Ġ{ Ċĉĉĉ ĉ SHARE _ TYPE _ MAP Ġ-> Ġapp . getString ( R . string . shared _ string _ map ) Ċĉĉĉ ĉ SHARE _ TYPE _ TEXT Ġ-> Ġapp . getString ( R . string . shared _ string _ text ) Ċĉĉĉ ĉ SHARE _ TYPE _ MAP _ AND _ TEXT Ġ-> Ġapp . getString ( R . string . map _ and _ text ) Ċĉĉĉ ĉ else Ġ-> Ġ"" Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ inner Ġclass ĠMin Location Distance Ġ: Ċĉ ĉ List Preference ( 0 , ĠR . string . min _ logging _ distance , ĠR . string . min _ logging _ distance _ descr ) Ġ{ ĊĊĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= Ġget Formatted Value ( min Location Distance ) ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ min Location Distance Ġ= ĠMIN _ LOCATION _ DISTANCE [ index ] Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items () Ġ= ĠMIN _ LOCATION _ DISTANCE . map Ġ{ Ġget Formatted Value ( it ) Ġ} ĊĊĉ ĉ private Ġfun Ġget Formatted Value ( value : ĠFloat ): ĠString Ġ{ Ċĉĉ ĉ return Ġif Ġ( value Ġ== Ġ 0 f ) Ġapp . getString ( R . string . shared _ string _ select ) Ċĉĉ ĉ else ĠOs mand Formatter . get Formatted Distance ( value , Ġapp ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ inner Ġclass ĠMin Location Accuracy Ġ: Ċĉ ĉ List Preference ( 0 , ĠR . string . min _ logging _ accuracy , ĠR . string . min _ logging _ accuracy _ descr ) Ġ{ ĊĊĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= Ġget Formatted Value ( min Location Accuracy ) ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ min Location Accuracy Ġ= ĠMIN _ LOCATION _ AC CUR ACY [ index ] Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items () Ġ= ĠMIN _ LOCATION _ AC CUR ACY . map Ġ{ Ġget Formatted Value ( it ) Ġ} ĊĊĉ ĉ private Ġfun Ġget Formatted Value ( value : ĠFloat ): ĠString Ġ{ Ċĉĉ ĉ return Ġif Ġ( value Ġ== Ġ 0 f ) Ġapp . getString ( R . string . shared _ string _ select ) Ċĉĉ ĉ else ĠOs mand Formatter . get Formatted Distance ( value , Ġapp ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ inner Ġclass ĠMin Location Speed Ġ: Ċĉ ĉ List Preference ( 0 , ĠR . string . min _ logging _ speed , ĠR . string . min _ logging _ speed _ descr ) Ġ{ ĊĊĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= Ġget Formatted Value ( min Location Speed ) ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ min Location Speed Ġ= ĠMIN _ LOCATION _ SPEED [ index ] Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items () Ġ= ĠMIN _ LOCATION _ SPEED . map Ġ{ Ġget Formatted Value ( it ) Ġ} ĊĊĉ ĉ private Ġfun Ġget Formatted Value ( value : ĠFloat ): ĠString Ġ{ Ċĉĉ ĉ return Ġwhen Ġ( value ) Ġ{ Ċĉĉĉ ĉ MIN _ LOCATION _ SPEED [ 0 ] Ġ-> Ġapp . getString ( R . string . shared _ string _ select ) Ċĉĉĉ ĉ MIN _ LOCATION _ SPEED [ 1 ] Ġ-> Ġ"> Ġ 0 " Ċĉĉĉ ĉ else Ġ-> ĠOs mand Formatter . get Formatted Speed ( value , Ġapp ) Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ inner Ġclass ĠUnits Of Speed Ġ: ĠList Preference ( Ċĉ ĉ R . drawable . ic _ action _ speed , Ċĉ ĉ R . string . unit _ of _ speed _ system , Ċĉ ĉ R . string . unit _ of _ speed _ system _ descr Ċ ĉ ) Ġ{ ĊĊĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= Ġspeed Constants . to Short String ( app ) ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ speed Constants Ġ= ĠSpeed Constants . values ()[ index ] Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items () Ġ= ĠSpeed Constants . values (). map Ġ{ Ġit . to Short String ( app ) Ġ} Ċ ĉ } ĊĊ ĉ inner Ġclass ĠUnits Of Length Ġ: ĠList Preference ( Ċĉ ĉ R . drawable . ic _ action _ r uler _ unit , ĠR . string . unit _ of _ length , Ċĉ ĉ R . string . unit _ of _ length _ descr Ċ ĉ ) Ġ{ ĊĊĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= Ġmetrics Constants . to Human String ( app ) ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ metrics Constants Ġ= ĠMetrics Constants . values ()[ index ] Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items () Ġ= ĠMetrics Constants . values (). map Ġ{ Ġit . to Human String ( app ) Ġ} Ċ ĉ } ĊĊ ĉ inner Ġclass ĠU tc Offset Ġ: ĠList Preference ( Ċĉ ĉ R . drawable . ic _ world _ glo be _ dark , ĠR . string . time _ zone , Ċĉ ĉ R . string . time _ zone _ descr Ċ ĉ ) Ġ{ Ċĉ ĉ private Ġval Ġformatted Utc Offsets Ġ= ĠData Constants . utc Offsets . keys . toList () ĊĊĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= Ġut c Offset ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ utc Offset Ġ= Ġformatted Utc Offsets [ index ] Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items () Ġ= Ġformatted Utc Offsets Ċ ĉ } ĊĊ ĉ inner Ġclass ĠBuffer Time Pref Ġ: ĠList Preference ( R . drawable . ic _ action _ time _ span , ĠR . string . buffer _ time , Ċĉĉ ĉ R . string . buffer _ time _ descr ) Ġ{ Ċĉ ĉ override Ġfun ĠgetCurrent Value () Ġ= ĠOs mand Formatter . get Formatted Duration ( app , Ġbuffer Time ) ĊĊĉ ĉ override Ġfun ĠsetCurrent Value ( index : ĠInt ) Ġ{ Ċĉĉ ĉ buffer Time Ġ= ĠBUFFER _ TIME [ index ] Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġget Menu Items (): ĠList < String > Ġ{ Ċĉĉ ĉ return ĠBUFFER _ TIME . map Ġ{ ĠOs mand Formatter . get Formatted Duration ( app , Ġit ) Ġ} Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ abstract Ġinner Ġclass ĠList Preference ( Ċĉ ĉ @ Drawable Res Ġval Ġicon Id : ĠInt , Ċĉ ĉ @ String Res Ġval Ġtitle Id : ĠInt , Ċĉ ĉ @ String Res Ġval Ġdescription Id : ĠInt Ċ ĉ ) Ġ{ ĊĊĉ ĉ abstract Ġfun ĠgetCurrent Value (): ĠString ĊĊĉ ĉ abstract Ġfun ĠsetCurrent Value ( index : ĠInt ) ĊĊĉ ĉ abstract Ġfun Ġget Menu Items (): ĠList < String > Ċ ĉ } ĊĊ ĉ enum Ġclass ĠApp Connect ( Ċĉ ĉ @ Drawable Res Ġval Ġicon Id : ĠInt , Ċĉ ĉ @ Drawable Res Ġval Ġwhite Icon Id : ĠInt , Ċĉ ĉ val Ġtitle : ĠString , Ċĉ ĉ val Ġapp Package : ĠString , Ċĉ ĉ val Ġshow Only Installed : ĠBoolean Ċ ĉ ) Ġ{ Ċĉ ĉ OS M AND _ PLUS ( Ċĉĉ ĉ R . drawable . ic _ logo _ os mand _ plus , Ċĉĉ ĉ R . drawable . ic _ action _ os mand _ plus , Ċĉĉ ĉ " O sm And +", Ċĉĉ ĉ Os mand A idl Helper . OS M AND _ PLUS _ PACKAGE _ NAME , Ċĉĉ ĉ false Ċĉ ĉ ), Ċĉ ĉ OS M AND _ FREE ( Ċĉĉ ĉ R . drawable . ic _ logo _ os mand _ free , Ċĉĉ ĉ R . drawable . ic _ action _ os mand _ free , Ċĉĉ ĉ " O sm And ", Ċĉĉ ĉ Os mand A idl Helper . OS M AND _ FREE _ PACKAGE _ NAME , Ċĉĉ ĉ false Ċĉ ĉ ), Ċĉ ĉ OS M AND _ N IGHT LY ( Ċĉĉ ĉ R . drawable . ic _ logo _ os mand _ nightly , Ċĉĉ ĉ R . drawable . ic _ action _ os mand _ free , Ċĉĉ ĉ " O sm And ĠNight ly ", Ċĉĉ ĉ Os mand A idl Helper . OS M AND _ N IGHT LY _ PACKAGE _ NAME , Ċĉĉ ĉ true Ċĉ ĉ ); ĊĊĉ ĉ comp anion Ġobject Ġ{ ĊĊĉĉ ĉ @ Drawable Res Ċĉĉ ĉ fun Ġget White Icon Id ( app Package : ĠString ): ĠInt Ġ{ Ċĉĉĉ ĉ for Ġ( item Ġin Ġvalues ()) Ġ{ Ċĉĉĉĉ ĉ if Ġ( item . app Package Ġ== Ġapp Package ) Ġ{ Ċĉĉĉĉĉ ĉ return Ġitem . white Icon Id Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ return Ġ 0 Ċĉĉ ĉ } ĊĊĉĉ ĉ @ Drawable Res Ċĉĉ ĉ fun Ġget Icon Id ( app Package : ĠString ): ĠInt Ġ{ Ċĉĉĉ ĉ for Ġ( item Ġin Ġvalues ()) Ġ{ Ċĉĉĉĉ ĉ if Ġ( item . app Package Ġ== Ġapp Package ) Ġ{ Ċĉĉĉĉĉ ĉ return Ġitem . icon Id Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ return Ġ 0 Ċĉĉ ĉ } ĊĊĉĉ ĉ fun Ġget Installed Apps ( context : ĠContext ) Ġ= Ċĉĉĉ ĉ values (). filter Ġ{ ĠAndroid Utils . is App Installed ( context , Ġit . app Package ) Ġ} Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ enum Ġclass ĠLive Now Sort Type ( Ċĉ ĉ @ Drawable Res Ġval Ġicon Id : ĠInt , Ċĉ ĉ @ String Res Ġval Ġtitle Id : ĠInt , Ċĉ ĉ @ String Res Ġval Ġshort Title Id : ĠInt Ċ ĉ ) Ġ{ Ċĉ ĉ SORT _ BY _ GROUP ( Ċĉĉ ĉ R . drawable . ic _ action _ sort _ by _ group , Ċĉĉ ĉ R . string . shared _ string _ group , Ċĉĉ ĉ R . string . by _ group Ċĉ ĉ ), Ċĉ ĉ SORT _ BY _ NAME ( Ċĉĉ ĉ R . drawable . ic _ action _ sort _ by _ name , Ċĉĉ ĉ R . string . shared _ string _ name , Ċĉĉ ĉ R . string . by _ name Ċĉ ĉ ), Ċĉ ĉ SORT _ BY _ DISTANCE ( Ċĉĉ ĉ R . drawable . ic _ action _ sort _ by _ distance , Ċĉĉ ĉ R . string . shared _ string _ distance , Ċĉĉ ĉ R . string . by _ distance Ċĉ ĉ ); ĊĊĉ ĉ fun Ġis Sort By Group () Ġ= Ġthis Ġ== ĠSORT _ BY _ GROUP Ċ ĉ } ĊĊ ĉ enum Ġclass ĠSh aring StatusType ( Ċĉ ĉ @ Drawable Res Ġval Ġicon Id : ĠInt , Ċĉ ĉ @ Color Res Ġval Ġicon Color Res : ĠInt , Ċĉ ĉ val Ġcan Res end Location : ĠBoolean Ċ ĉ ) Ġ{ Ċĉ ĉ NO _ INTER NET ( Ċĉĉ ĉ R . drawable . ic _ action _ wifi _ off , Ċĉĉ ĉ R . color . sharing _ status _ icon _ error , Ċĉĉ ĉ true Ċĉ ĉ ), Ċĉ ĉ SEND ING ( Ċĉĉ ĉ R . drawable . ic _ action _ share _ location , Ċĉĉ ĉ R . color . sharing _ status _ icon _ success , Ċĉĉ ĉ false Ċĉ ĉ ), Ċĉ ĉ NOT _ PO SS IBLE _ TO _ SENT _ TO _ CHAT S ( Ċĉĉ ĉ R . drawable . ic _ action _ message _ send _ error , Ċĉĉ ĉ R . color . sharing _ status _ icon _ error , Ċĉĉ ĉ true Ċĉ ĉ ), Ċĉ ĉ NO _ GPS ( Ċĉĉ ĉ R . drawable . ic _ action _ location _ off , Ċĉĉ ĉ R . color . sharing _ status _ icon _ error , Ċĉĉ ĉ false Ċĉ ĉ ), Ċĉ ĉ INITIAL IZ ING ( Ċĉĉ ĉ R . drawable . ic _ action _ connect , Ċĉĉ ĉ R . color . sharing _ status _ icon _ error , Ċĉĉ ĉ false Ċĉ ĉ ); Ċ ĉ } ĊĊ ĉ class ĠDevice Bot Ġ{ Ċĉ ĉ var Ġid : ĠLong Ġ= Ġ- 1 Ċĉ ĉ var ĠuserId : ĠLong Ġ= Ġ- 1 Ċĉ ĉ var Ġchat Id : ĠLong Ġ= Ġ- 1 Ċĉ ĉ var Ġdevice Name : ĠString Ġ= Ġ"" Ċĉ ĉ var Ġexternal Id : ĠString Ġ= Ġ"" Ċĉ ĉ var Ġdata : ĠString Ġ= Ġ"" ĊĊĉ ĉ comp anion Ġobject Ġ{ ĊĊĉĉ ĉ internal Ġconst Ġval ĠDEVICE _ ID Ġ= Ġ" id " Ċĉĉ ĉ internal Ġconst Ġval ĠUSER _ ID Ġ= Ġ" userId " Ċĉĉ ĉ internal Ġconst Ġval ĠCH AT _ ID Ġ= Ġ" chat Id " Ċĉĉ ĉ internal Ġconst Ġval ĠDEVICE _ NAME Ġ= Ġ" device Name " Ċĉĉ ĉ internal Ġconst Ġval ĠEXTER NAL _ ID Ġ= Ġ" external Id " Ċĉĉ ĉ internal Ġconst Ġval ĠDATA Ġ= Ġ" data " Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ data Ġclass ĠLive Track Info ( val ĠuserId : ĠInt , Ġval Ġchat Id : ĠLong , Ġval Ġdevice Name : ĠString , Ġval Ġcolor Index : ĠInt ) Ġ{ Ċĉ ĉ comp anion Ġobject Ġ{ ĊĊĉĉ ĉ internal Ġconst Ġval ĠUSER _ ID Ġ= Ġ" userId " Ċĉĉ ĉ internal Ġconst Ġval ĠCH AT _ ID Ġ= Ġ" chat Id " Ċĉĉ ĉ internal Ġconst Ġval ĠDEVICE _ NAME Ġ= Ġ" device Name " Ċĉĉ ĉ internal Ġconst Ġval ĠCOLOR _ INDEX Ġ= Ġ" color Index " Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ enum Ġclass ĠProxy Type Ġ{ Ċĉ ĉ M TP RO TO , ĠSOCK S 5 Ċ ĉ } ĊĊ ĉ abstract Ġclass ĠProxy Pref ( Ċĉ ĉ var Ġid : ĠInt , Ċĉ ĉ var Ġtype : ĠProxy Type , Ċĉ ĉ open Ġvar Ġserver : ĠString , Ċĉ ĉ open Ġvar Ġport : ĠInt Ċ ĉ ) Ġ{ Ċĉ ĉ comp anion Ġobject Ġ{ Ċĉĉ ĉ internal Ġconst Ġval ĠPRO XY _ ID Ġ= Ġ" proxy Id " Ċĉĉ ĉ internal Ġconst Ġval ĠTYPE _ ID Ġ= Ġ" type " Ċĉĉ ĉ internal Ġconst Ġval ĠSERVER _ ID Ġ= Ġ" server Id " Ċĉĉ ĉ internal Ġconst Ġval ĠPORT _ ID Ġ= Ġ" port Id " Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ class ĠProxy MT Proto Pref ( id : ĠInt , Ġserver : ĠString , Ġport : ĠInt , Ġvar Ġkey : ĠString ) Ġ: Ċĉ ĉ Proxy Pref ( id , ĠProxy Type . M TP RO TO , Ġserver , Ġport ) Ġ{ Ċĉ ĉ comp anion Ġobject Ġ{ Ċĉĉ ĉ internal Ġconst Ġval ĠKEY _ ID Ġ= Ġ" key " Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ class ĠProxy SOCK S 5 Pref ( Ċĉ ĉ id : ĠInt , Ċĉ ĉ server : ĠString , Ċĉ ĉ port : ĠInt , Ċĉ ĉ var Ġlogin : ĠString , Ċĉ ĉ var Ġpassword : ĠString Ċ ĉ ) Ġ: Ċĉ ĉ Proxy Pref ( id , ĠProxy Type . SOCK S 5 , Ġserver , Ġport ) Ġ{ Ċĉ ĉ comp anion Ġobject Ġ{ Ċĉĉ ĉ internal Ġconst Ġval ĠLOGIN _ ID Ġ= Ġ" login " Ċĉĉ ĉ internal Ġconst Ġval ĠPASSWORD _ ID Ġ= Ġ" password " Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ class ĠSh aring Status Ġ{ ĊĊĉ ĉ var Ġtitle : ĠString Ġ= Ġ"" Ċĉ ĉ var Ġdescription : ĠString Ġ= Ġ"" Ċĉ ĉ var Ġlocation Time : ĠLong Ġ= Ġ- 1 Ċĉ ĉ var Ġstatus Change Time : ĠLong Ġ= Ġ- 1 Ċĉ ĉ var Ġch ats Ids : ĠMutable List < Long > Ġ= Ġmutable ListOf () ĊĊĉ ĉ late init Ġvar Ġstatus Type : ĠSh aring StatusType ĊĊĉ ĉ fun Ġget Title ( app : ĠTelegram Application ): ĠCharSequence Ġ{ Ċĉĉ ĉ return Ġif Ġ( status Type Ġ!= ĠSh aring StatusType . NOT _ PO SS IBLE _ TO _ SENT _ TO _ CHAT S Ġ|| Ġch ats Ids . isEmpty ()) Ġ{ Ċĉĉĉ ĉ title Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ val Ġsp ann able String Ġ= ĠSp ann able StringBuilder ( title ) Ċĉĉĉ ĉ val Ġiterator Ġ= Ġch ats Ids . iterator () Ċĉĉĉ ĉ while Ġ( iterator . hasNext ()) Ġ{ Ċĉĉĉĉ ĉ val Ġchat Id Ġ= Ġiterator . next () Ċĉĉĉĉ ĉ val Ġchat Title Ġ= Ġapp . telegram Helper . get Chat ( chat Id )?. title Ċĉĉĉĉ ĉ if Ġ( chat Title Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ val Ġstart Ġ= Ġsp ann able String . length Ċĉĉĉĉĉ ĉ val Ġnew Sp ann able Ġ= Ġif Ġ( iterator . hasNext ()) Ġ" Ġ@$ chat Title ," Ġelse Ġ" Ġ@$ chat Title ." Ċĉĉĉĉĉ ĉ span nable String . append ( new Sp ann able ) Ċĉĉĉĉĉ ĉ span nable String . set Span ( ForegroundColor Span ( app . ui Utils . getActive Color ()), Ġstart , Ġsp ann able String . length Ġ- Ġ 1 , Ġ 0 ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ span nable String Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ class ĠShare Chat Info Ġ{ ĊĊĉ ĉ var Ġchat Id Ġ= Ġ- 1 L Ċĉ ĉ var ĠuserId Ġ= Ġ- 1 Ċĉ ĉ var Ġstart Ġ= Ġ- 1 L Ċĉ ĉ var Ġlive Period Ġ= Ġ- 1 L Ċĉ ĉ var Ġupdate Text MessageId Ġ= Ġ 1 Ċĉ ĉ var Ġcurrent Message Limit Ġ= Ġ- 1 L Ċĉ ĉ var Ġcurrent Map MessageId Ġ= Ġ- 1 L Ċĉ ĉ var Ġold Map MessageId Ġ= Ġ- 1 L Ċĉ ĉ var Ġcurrent Text MessageId Ġ= Ġ- 1 L Ċĉ ĉ var Ġold Text MessageId Ġ= Ġ- 1 L Ċĉ ĉ var Ġuser Set Live Period Ġ= Ġ- 1 L Ċĉ ĉ var Ġuser Set Live Period Start Ġ= Ġ- 1 L Ċĉ ĉ var Ġlast Text Successful Send Time Ġ= Ġ- 1 L Ċĉ ĉ var Ġlast Map Successful Send Time Ġ= Ġ- 1 L Ċĉ ĉ var Ġlast Send Text Message Time Ġ= Ġ- 1 Ċĉĉ ĉ set ( value ) Ġ{ Ċĉĉĉ ĉ field Ġ= Ġvalue Ċĉĉĉ ĉ last Text Message Handled Ġ= Ġfalse Ċĉĉ ĉ } Ċĉ ĉ var Ġlast Send Map Message Time Ġ= Ġ- 1 Ċĉĉ ĉ set ( value ) Ġ{ Ċĉĉĉ ĉ field Ġ= Ġvalue Ċĉĉĉ ĉ last Map Message Handled Ġ= Ġfalse Ċĉĉ ĉ } Ċĉ ĉ var Ġsent Messages Ġ= Ġ 0 Ċĉ ĉ var Ġpending Td Lib Text Ġ= Ġ 0 Ċĉĉ ĉ set ( value ) Ġ{ Ċĉĉĉ ĉ field Ġ= Ġmax ( 0 , Ġvalue ) Ċĉĉ ĉ } Ċĉ ĉ var Ġpending Td Lib Map Ġ= Ġ 0 Ċĉĉ ĉ set ( value ) Ġ{ Ċĉĉĉ ĉ field Ġ= Ġmax ( 0 , Ġvalue ) Ċĉĉ ĉ } Ċĉ ĉ var Ġpending Text Message Ġ= Ġfalse Ċĉ ĉ var Ġpending Map Message Ġ= Ġfalse Ċĉ ĉ var Ġshould Send Via Bot Text Message Ġ= Ġfalse Ċĉ ĉ var Ġshould Send Via Bot Map Message Ġ= Ġfalse Ċĉ ĉ var Ġhas Sharing Error Ġ= Ġfalse Ċĉ ĉ var Ġadditional Active Time Ġ= ĠADD ITION AL _ ACTIVE _ TIME _ VALUES _ SEC [ 0 ] Ċĉ ĉ var Ġlast Map Message Handled Ġ= Ġfalse Ċĉ ĉ var Ġlast Text Message Handled Ġ= Ġfalse Ċĉ ĉ var Ġlast Buffer Check Time Ġ= Ġ- 1 L ĊĊĉ ĉ fun ĠgetNext Additional Active Time (): ĠLong Ġ{ Ċĉĉ ĉ var Ġindex Ġ= ĠADD ITION AL _ ACTIVE _ TIME _ VALUES _ SEC . indexOf ( additional Active Time ) Ċĉĉ ĉ return Ġif Ġ( AD DITION AL _ ACTIVE _ TIME _ VALUES _ SEC . last Index Ġ> Ġindex ) Ġ{ Ċĉĉĉ ĉ AD DITION AL _ ACTIVE _ TIME _ VALUES _ SEC [++ index ] Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ AD DITION AL _ ACTIVE _ TIME _ VALUES _ SEC [ index ] Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ fun Ġget Chat Live Message Expire Time (): ĠLong Ġ{ Ċĉĉ ĉ return Ġuser Set Live Period Ġ- Ġ(( System . currentTimeMillis () Ġ/ Ġ 1 0 0 0 ) Ġ- Ġstart ) Ċĉ ĉ } ĊĊĉ ĉ fun Ġis Pending Messages Limit Reached () Ġ= Ċĉĉĉ ĉ pending Td Lib Text Ġ>= ĠMAX _ MESSAGES _ IN _ TD LIB _ PER _ CHAT Ġ|| Ġpending Td Lib Map Ġ>= ĠMAX _ MESSAGES _ IN _ TD LIB _ PER _ CHAT ĊĊĉ ĉ fun Ġis Pending Text Messages Limit Reached () Ġ= Ġpending Td Lib Text Ġ>= ĠMAX _ MESSAGES _ IN _ TD LIB _ PER _ CHAT ĊĊĉ ĉ fun Ġis Pending Map Messages Limit Reached () Ġ= Ġpending Td Lib Map Ġ>= ĠMAX _ MESSAGES _ IN _ TD LIB _ PER _ CHAT ĊĊĉ ĉ fun Ġreset Messages Info () Ġ{ Ċĉĉ ĉ reset Text MessageInfo () Ċĉĉ ĉ reset Map MessageInfo () Ċĉ ĉ } ĊĊĉ ĉ fun Ġreset Text MessageInfo () Ġ{ Ċĉĉ ĉ pending Td Lib Text Ġ= Ġ 0 Ċĉĉ ĉ current Text MessageId Ġ= Ġ- 1 L Ċĉĉ ĉ pending Text Message Ġ= Ġfalse Ċĉ ĉ } ĊĊĉ ĉ fun Ġreset Map MessageInfo () Ġ{ Ċĉĉ ĉ pending Td Lib Map Ġ= Ġ 0 Ċĉĉ ĉ current Map MessageId Ġ= Ġ- 1 L Ċĉĉ ĉ pending Map Message Ġ= Ġfalse Ċĉ ĉ } ĊĊĉ ĉ fun Ġis Text MessageId Present () Ġ= Ġcurrent Text MessageId Ġ!= Ġ- 1 L ĊĊĉ ĉ fun Ġis Map MessageId Present () Ġ= Ġcurrent Map MessageId Ġ!= Ġ- 1 L ĊĊĉ ĉ comp anion Ġobject Ġ{ ĊĊĉĉ ĉ internal Ġconst Ġval ĠCH AT _ ID _ KEY Ġ= Ġ" chat Id " Ċĉĉ ĉ internal Ġconst Ġval ĠUSER _ ID _ KEY Ġ= Ġ" userId " Ċĉĉ ĉ internal Ġconst Ġval ĠSTART _ KEY Ġ= Ġ" start " Ċĉĉ ĉ internal Ġconst Ġval ĠLI VE _ PERIOD _ KEY Ġ= Ġ" live Period " Ċĉĉ ĉ internal Ġconst Ġval ĠLIMIT _ KEY Ġ= Ġ" limit " Ċĉĉ ĉ internal Ġconst Ġval ĠUPDATE _ TEXT _ MESSAGE _ ID _ KEY Ġ= Ġ" update Text MessageId " Ċĉĉ ĉ internal Ġconst Ġval ĠCURRENT _ MAP _ MESSAGE _ ID _ KEY Ġ= Ġ" current Map MessageId " Ċĉĉ ĉ internal Ġconst Ġval ĠCURRENT _ TEXT _ MESSAGE _ ID _ KEY Ġ= Ġ" current Text MessageId " Ċĉĉ ĉ internal Ġconst Ġval ĠUSER _ SET _ LI VE _ PERIOD _ KEY Ġ= Ġ" user Set Live Period " Ċĉĉ ĉ internal Ġconst Ġval ĠUSER _ SET _ LI VE _ PERIOD _ START _ KEY Ġ= Ġ" user Set Live Period Start " Ċĉĉ ĉ internal Ġconst Ġval ĠLAST _ MAP _ SUCCESS FUL _ SEND _ TIME _ KEY Ġ= Ġ" last Map Successful Send Time " Ċĉĉ ĉ internal Ġconst Ġval ĠLAST _ TEXT _ SUCCESS FUL _ SEND _ TIME _ KEY Ġ= Ġ" last Text Successful Send Time " Ċĉĉ ĉ internal Ġconst Ġval ĠLAST _ SEND _ MAP _ TIME _ KEY Ġ= Ġ" last Send Map Message Time " Ċĉĉ ĉ internal Ġconst Ġval ĠLAST _ SEND _ TEXT _ TIME _ KEY Ġ= Ġ" last Send Text Message Time " Ċĉĉ ĉ internal Ġconst Ġval ĠP ENDING _ TEXT _ MESSAGE _ KEY Ġ= Ġ" pending Text Message " Ċĉĉ ĉ internal Ġconst Ġval ĠP ENDING _ MAP _ MESSAGE _ KEY Ġ= Ġ" pending Map Message " Ċĉĉ ĉ internal Ġconst Ġval ĠS ENT _ MESSAGES _ KEY Ġ= Ġ" sent Messages " Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ class ĠLast Chat Info Ġ{ ĊĊĉ ĉ var Ġchat Id Ġ= Ġ- 1 L Ċĉ ĉ var Ġperiod Ġ= Ġ- 1 L ĊĊĉ ĉ comp anion Ġobject Ġ{ Ċĉĉ ĉ internal Ġconst Ġval ĠCH AT _ ID _ KEY Ġ= Ġ" chat Id " Ċĉĉ ĉ internal Ġconst Ġval ĠPER IOD _ KEY Ġ= Ġ" period " Ċĉ ĉ } Ċ ĉ } Ċ } Ċ