package Ġorg . opp ia . android . app . options Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġorg . opp ia . android . app . fragment . Injectable Fragment Ċ import Ġjavax . inject . Inject Ċ Ċ private Ġconst Ġval ĠKEY _ APP _ LANGUAGE _ PREFER ENCE _ TITLE Ġ= Ġ" APP _ LANGUAGE _ PREFER ENCE " Ċ private Ġconst Ġval ĠKEY _ APP _ LANGUAGE _ PREFER ENCE _ SUM MARY _ VALUE Ġ= ĊĠ Ġ" APP _ LANGUAGE _ PREFER ENCE _ SUM MARY _ VALUE " Ċ private Ġconst Ġval ĠKEY _ SELECTED _ LANGUAGE Ġ= Ġ" SELECTED _ LANGUAGE " Ċ Ċ /** ĠThe Ġfragment Ġto Ġchange Ġthe Ġlanguage Ġof Ġthe Ġapp . Ġ*/ Ċ class ĠApp Language Fragment Ġ: ĠInjectable Fragment () Ġ{ ĊĊĠ Ġ@ Inject ĊĠ Ġlateinit Ġvar Ġapp Language Fragment Presenter : ĠApp Language Fragment Presenter ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġfun Ġnew Instance ( prefs Key : ĠString , Ġprefs Summary Value : ĠString ): ĠApp Language Fragment Ġ{ ĊĠĠĠĠĠ Ġval Ġfragment Ġ= ĠApp Language Fragment () ĊĠĠĠĠĠ Ġval Ġargs Ġ= ĠBundle () ĊĠĠĠĠĠ Ġargs . putString ( KEY _ APP _ LANGUAGE _ PREFER ENCE _ TITLE , Ġprefs Key ) ĊĠĠĠĠĠ Ġargs . putString ( KEY _ APP _ LANGUAGE _ PREFER ENCE _ SUM MARY _ VALUE , Ġprefs Summary Value ) ĊĠĠĠĠĠ Ġfragment . arguments Ġ= Ġargs ĊĠĠĠĠĠ Ġreturn Ġfragment ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Attach ( context : ĠContext ) Ġ{ ĊĠĠĠ Ġsuper . on Attach ( context ) ĊĠĠĠ Ġfragment Component . inject ( this ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠ Ġinflater : ĠLayoutInflater , ĊĠĠĠ Ġcontainer : ĠViewGroup ?, ĊĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠ Ġ): ĠView ? Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= ĊĠĠĠĠĠ ĠcheckNotNull ( arguments ) Ġ{ Ġ" Expected Ġarguments Ġto Ġbe Ġpassed Ġto ĠApp Language Fragment " Ġ} ĊĠĠĠ Ġval Ġprefs Key Ġ= Ġargs . getString ( KEY _ APP _ LANGUAGE _ PREFER ENCE _ TITLE ) ĊĠĠĠ Ġval Ġprefs Summary Value Ġ= Ġif Ġ( savedInstanceState Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġargs . getString ( KEY _ APP _ LANGUAGE _ PREFER ENCE _ SUM MARY _ VALUE ) ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠ ĠsavedInstanceState . get ( KEY _ SELECTED _ LANGUAGE ) Ġas ĠString ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġapp Language Fragment Presenter . handle On Create View ( ĊĠĠĠĠĠ Ġinflater , ĊĠĠĠĠĠ Ġcontainer , ĊĠĠĠĠĠ Ġprefs Key !! , ĊĠĠĠĠĠ Ġprefs Summary Value !! ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Save InstanceState ( out State : ĠBundle ) Ġ{ ĊĠĠĠ Ġsuper . on Save InstanceState ( out State ) ĊĠĠĠ Ġout State . putString ( KEY _ SELECTED _ LANGUAGE , Ġapp Language Fragment Presenter . get Language Selected ()) ĊĠ Ġ} Ċ } Ċ