/* Ċ Ġ* ĠCreated Ġby ĠSer g ii Ġ@ F rost Â° Ġ 2 9 / 1 / 2 0 1 9 Ċ Ġ* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 9 . Ċ Ġ* Ċ Ġ* ĠPermission Ġis Ġhereby Ġgranted , Ġfree Ġof Ġcharge , Ġto Ġany Ġperson Ġobtaining Ġa Ġcopy Ċ Ġ* Ġof Ġthis Ġsoftware Ġand Ġassociated Ġdocumentation Ġfiles Ġ( the Ġ" Software "), Ġto Ġdeal Ċ Ġ* Ġin Ġthe ĠSoftware Ġwithout Ġrestriction , Ġincluding Ġwithout Ġlimitation Ġthe Ġrights Ċ Ġ* Ġto Ġuse , Ġcopy , Ġmodify , Ġmerge , Ġpublish , Ġdistribute , Ġsublicense , Ġand / or Ġsell Ċ Ġ* Ġcopies Ġof Ġthe ĠSoftware , Ġand Ġto Ġpermit Ġpersons Ġto Ġwhom Ġthe ĠSoftware Ġis Ċ Ġ* Ġfurnished Ġto Ġdo Ġso , Ġsubject Ġto Ġthe Ġfollowing Ġconditions : Ċ Ġ* Ċ Ġ* ĠThe Ġabove Ġcopyright Ġnotice Ġand Ġthis Ġpermission Ġnotice Ġshall Ġbe Ġincluded Ġin Ġall Ċ Ġ* Ġcopies Ġor Ġsubstantial Ġportions Ġof Ġthe ĠSoftware . Ċ Ġ* Ċ Ġ* ĠTHE ĠSOFTWARE ĠIS ĠPROVIDED Ġ" AS ĠIS ", ĠWITHOUT ĠWARRANTY ĠOF ĠANY ĠKIND , ĠEXPRESS ĠOR Ċ Ġ* ĠIMPLIED , ĠINCLUDING ĠBUT ĠNOT ĠLIMITED ĠTO ĠTHE ĠWARRANTIES ĠOF ĠMERCHANTABILITY , Ċ Ġ* ĠFITNESS ĠFOR ĠA ĠPARTICULAR ĠPURPOSE ĠAND ĠNONINFRINGEMENT . ĠIN ĠNO ĠEVENT ĠSHALL ĠTHE Ċ Ġ* ĠAUTHORS ĠOR ĠCOPYRIGHT ĠHOLDERS ĠBE ĠLIABLE ĠFOR ĠANY ĠCLAIM , ĠDAMAGES ĠOR ĠOTHER Ċ Ġ* ĠLIABILITY , ĠWHETHER ĠIN ĠAN ĠACTION ĠOF ĠCONTRACT , ĠTORT ĠOR ĠOTHERWISE , ĠARISING ĠFROM , Ċ Ġ* ĠOUT ĠOF ĠOR ĠIN ĠCONNECTION ĠWITH ĠTHE ĠSOFTWARE ĠOR ĠTHE ĠUSE ĠOR ĠOTHER ĠDEALINGS ĠIN ĠTHE Ċ Ġ* ĠSOFTWARE . Ċ Ġ*/ Ċ Ċ package Ġse . f rost . contact sg ener ator . features Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . view . MenuItem Ċ import Ġse . f rost . contact sg ener ator . R Ċ import Ġse . f rost . contact sg ener ator . extensions . Fragment Transition Ċ import Ġse . f rost . contact sg ener ator . extensions . can Navigate Back Ċ import Ġse . f rost . contact sg ener ator . extensions . get Visible Fragment Ċ import Ġse . f rost . contact sg ener ator . extensions . init Fragment Ċ import Ġse . f rost . contact sg ener ator . features . contacts . Country Contacts Fragment Ċ import Ġse . f rost . contact sg ener ator . features . countries . Countries Fragment Ċ import Ġse . f rost . contact sg ener ator . features . countries . Country Contacts Model Ċ import Ġse . f rost . contact sg ener ator . helpers . Permissions Helper Ċ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity (), ĠContact s Permissions Fragment . On Fragment Inter ation Listener , ĠCount ries Fragment . On Fragment Interaction Listener Ġ{ ĊĊ ĉ override Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . onCreate ( savedInstanceState ) Ċĉ ĉ set ContentView ( R . layout . activity _ main ) Ċĉ ĉ init Fragments () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Contacts Permissions Granted () Ġ{ Ċĉ ĉ show Contacts UI () Ċ ĉ } ĊĊ ĉ override Ġfun Ġopen Country Contacts ( model : ĠCountry Contacts Model ) Ġ{ Ċĉ ĉ show Country Contacts ( model ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġadd Contacts () Ġ{ Ċĉ ĉ show Add Contacts () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Options ItemSelected ( item : ĠMenuItem ?): ĠBoolean Ġ{ Ċĉ ĉ when Ġ( item ?. itemId ) Ġ{ Ċĉĉ ĉ android . R . id . home Ġ-> Ġ{ Ċĉĉĉ ĉ on Back Pressed () Ċĉĉĉ ĉ return Ġtrue Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ return Ġsuper . on Options ItemSelected ( item ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġinit Fragments () Ġ{ Ċĉ ĉ support FragmentManager . add On Back Stack Changed Listener Ġ{ Ċĉĉ ĉ get Visible Fragment ( R . id . content _ frame )?. user Visible Hint Ġ= Ġtrue Ċĉĉ ĉ support ActionBar ?. set Display Home As Up Enabled ( can Navigate Back ()) Ċĉĉ ĉ invalidate Options Menu () Ċĉ ĉ } ĊĊĉ ĉ if Ġ( Permissions Helper . instance . has Contacts Permissions ( application Context )) Ġ{ Ċĉĉ ĉ show Contacts UI () Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ show Permissions UI () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġshow Permissions UI () Ġ{ Ċĉ ĉ init Fragment ( Contacts Permissions Fragment . newInstance (), ĠContact s Permissions Fragment . TAG , ĠFragment Transition . FRAGMENT _ REPLACE , ĠR . id . content _ frame ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġshow Contacts UI () Ġ{ Ċĉ ĉ init Fragment ( Countries Fragment . newInstance (), ĠCount ries Fragment . TAG , ĠFragment Transition . FRAGMENT _ REPLACE , ĠR . id . content _ frame ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġshow Country Contacts ( model : ĠCountry Contacts Model ) Ġ{ Ċĉ ĉ init Fragment ( Country Contacts Fragment . newInstance ( model ), ĠCountry Contacts Fragment . TAG , ĠFragment Transition . FRAGMENT _ ADD _ TO _ POP _ STACK , ĠR . id . content _ frame ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġshow Add Contacts () Ġ{ Ċĉ ĉ init Fragment ( Add Contacts Fragment . newInstance (), ĠAdd Contacts Fragment . TAG , ĠFragment Transition . FRAGMENT _ ADD _ TO _ POP _ STACK , ĠR . id . content _ frame ) Ċ ĉ } Ċ Ċ } Ċ