package Ġnet . os mand . telegram . ui Ċ Ċ import Ġandroid . graphics . Color Matrix Ċ import Ġandroid . graphics . Color Matrix Color Filter Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . ImageView Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . fragment . app . Dialog Fragment Ċ import Ġcom . google . android . material . bottom sheet . Bottom Sheet Behavior Ċ import Ġnet . os mand . telegram . R Ċ import Ġnet . os mand . telegram . Telegram Application Ċ import Ġnet . os mand . telegram . helpers . Telegram Ui Helper Ċ import Ġnet . os mand . telegram . ui . views . Bottom Sheet Dialog Ċ Ċ class ĠDisable Sharing Bottom Sheet Ġ: ĠDialog Fragment () Ġ{ ĊĊ ĉ private Ġval Ġapp : ĠTelegram Application Ċĉ ĉ get () Ġ= Ġactivity ?. application Ġas ĠTelegram Application ĊĊ ĉ private Ġval Ġtele gram Helper Ġget () Ġ= Ġapp . telegram Helper ĊĊ ĉ override Ġfun ĠonCreate Dialog ( savedInstanceState : ĠBundle ?) Ġ= ĠBottom Sheet Dialog ( context !! ) ĊĊ ĉ override Ġfun ĠonCreate View ( Ċĉ ĉ in flater : ĠLayoutInflater , Ċĉ ĉ container : ĠViewGroup ?, Ċĉ ĉ savedInstanceState : ĠBundle ? Ċ ĉ ): ĠView ? Ġ{ Ċĉ ĉ val Ġmain View Ġ= Ġinflater . inflate ( R . layout . bottom _ sheet _ disable _ sharing , Ġcontainer , Ġfalse ) ĊĊĉ ĉ main View . findViewById < View >( R . id . scroll _ view _ container ). setOnClickListener Ġ{ Ġdismiss () Ġ} ĊĊĉ ĉ Bottom Sheet Behavior . from ( main View . findViewById < View >( R . id . scroll _ view )) Ċĉĉ ĉ . set Bottom Sheet Callback ( object Ġ: ĠBottom Sheet Behavior . Bottom Sheet Callback () Ġ{ ĊĊĉĉĉ ĉ override Ġfun Ġon StateChanged ( bottom Sheet : ĠView , ĠnewState : ĠInt ) Ġ{ Ċĉĉĉĉ ĉ if Ġ( newState Ġ== ĠBottom Sheet Behavior . STATE _ HIDDEN ) Ġ{ Ċĉĉĉĉĉ ĉ dismiss () Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } ĊĊĉĉĉ ĉ override Ġfun Ġon Slide ( bottom Sheet : ĠView , Ġslide Offset : ĠFloat ) Ġ{} Ċĉĉ ĉ }) ĊĊĉ ĉ main View . findViewById < ImageView >( R . id . user _ icon ). apply Ġ{ Ċĉĉ ĉ color Filter Ġ= ĠColor Matrix Color Filter ( Color Matrix (). apply Ġ{ Ġset Sat uration ( 0 f ) Ġ}) Ċĉĉ ĉ Telegram Ui Helper . setup Photo ( Ċĉĉĉ ĉ app , Ċĉĉĉ ĉ this , Ċĉĉĉ ĉ telegram Helper . getUser Photo Path ( telegram Helper . getCurrent User ()), Ċĉĉĉ ĉ R . drawable . img _ user _ picture , Ċĉĉĉ ĉ false Ċĉĉ ĉ ) Ċĉ ĉ } ĊĊĉ ĉ main View . findViewById < TextView >( R . id . description ). text Ġ= Ċĉĉĉ ĉ getString ( R . string . disable _ all _ sharing _ desc , Ġarguments ?. getInt ( CHAT S _ COUNT _ KEY , Ġ- 1 )) ĊĊĉ ĉ main View . findViewById < TextView >( R . id . secondary _ btn ). apply Ġ{ Ċĉĉ ĉ setText ( R . string . shared _ string _ cancel ) Ċĉĉ ĉ setOnClickListener Ġ{ Ġdismiss () Ġ} Ċĉ ĉ } ĊĊĉ ĉ main View . findViewById < TextView >( R . id . primary _ btn ). apply Ġ{ Ċĉĉ ĉ setText ( R . string . turn _ off _ all ) Ċĉĉ ĉ setOnClickListener Ġ{ Ċĉĉĉ ĉ target Fragment ?. also Ġ{ Ġtarget Ġ-> Ċĉĉĉĉ ĉ target . on Activity Result ( target Request Code , ĠSH AR ING _ DISABLED _ REQUEST _ CODE , Ġnull ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ dismiss () Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ return Ġmain View Ċ ĉ } ĊĊ ĉ comp anion Ġobject Ġ{ ĊĊĉ ĉ const Ġval ĠSH AR ING _ DISABLED _ REQUEST _ CODE Ġ= Ġ 1 ĊĊĉ ĉ private Ġconst Ġval ĠTAG Ġ= Ġ" Disable Sharing Bottom Sheet " Ċĉ ĉ private Ġconst Ġval ĠCH ATS _ COUNT _ KEY Ġ= Ġ" ch ats _ count " ĊĊĉ ĉ fun Ġshow Instance ( fm : Ġandroidx . fragment . app . FragmentManager , Ġtarget : Ġandroidx . fragment . app . Fragment , Ġch ats Count : ĠInt ): ĠBoolean Ġ{ Ċĉĉ ĉ return Ġtry Ġ{ Ċĉĉĉ ĉ Disable Sharing Bottom Sheet (). apply Ġ{ Ċĉĉĉĉ ĉ arguments Ġ= ĠBundle (). apply Ġ{ Ġput Int ( CHAT S _ COUNT _ KEY , Ġch ats Count ) Ġ} Ċĉĉĉĉ ĉ setTarget Fragment ( target , ĠSH AR ING _ DISABLED _ REQUEST _ CODE ) Ċĉĉĉĉ ĉ show ( fm , ĠTAG ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ true Ċĉĉ ĉ } Ġcatch Ġ( e : ĠRuntimeException ) Ġ{ Ċĉĉĉ ĉ false Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } Ċ } Ċ