package Ġcom . snap . stuff ing . lib Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . util . Log Ċ import Ġcom . snap . stuff ing . api . Dynamic App Manager Ċ Ċ private Ġconst Ġval ĠTAG Ġ= Ġ" Single Dynamic App Manager " Ċ /** Ċ Ġ* ĠA Ġ[ Dynamic App Manager ] Ġimplementation Ġfor Ġapplication Ġthat Ġare Ġnot Ġactually Ġdynamic , Ġand Ġcontain Ġonly Ġa Ġsingle Ċ Ġ* Ġapplication . Ċ Ġ*/ Ċ internal Ġclass ĠSingle Dynamic App Manager Ġconstructor ( app Context : ĠContext , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġdefault Activity ClassName : ĠString , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġdefault App Family : ĠString Ċ ): ĠBase Dynamic App Manager ( app Context , ĠTAG ) Ġ{ ĊĊĠĠĠ Ġoverride Ġval Ġactive : ĠBoolean Ġ= Ġfalse ĊĊĠĠĠ Ġoverride Ġval Ġapplication Family Ġ= Ġdefault App Family ĊĊĠĠĠ Ġoverride Ġfun ĠgetDefault Activity ClassName (): ĠString ? Ġ= Ġdefault Activity ClassName ĊĊĠĠĠ Ġoverride Ġfun Ġinitialize () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcurrent App Family Ġ= Ġpreferences . getString ( Dynamic App Manager Prefs . app Family Key , Ġ"") ĊĠĠĠĠĠĠĠ Ġfailed Toggle Attempt Count Ġ= Ġpreferences . getInt ( Dynamic App Manager Prefs . failed Toggle Attempt Count Key , Ġ 0 ) ĊĊĠĠĠĠĠĠĠ ĠLog . d ( TAG , Ġ" ST UFF ING Ġ-- ĠInitial izing Ġwith Ġstate : Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" current App Family =$ current App Family , Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" expected App Family =$ application Family , Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" failed Toggle Attempt Count =$ failed Toggle Attempt Count ") ĊĊĠĠĠĠĠĠĠ Ġif Ġ( current App Family Ġ!= Ġapplication Family Ġ&& Ġfailed Toggle Attempt Count Ġ< ĠMAX _ FAILED _ AT TEMP T _ COUNT ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpreferences . edit () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. put Int ( Dynamic App Manager Prefs . failed Toggle Attempt Count Key , Ġfailed Toggle Attempt Count Ġ+ Ġ 1 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. commit () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Component Modifier . reset All Components ( TAG ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġpreferences . edit () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. putString ( Dynamic App Manager Prefs . app Family Key , Ġapplication Family ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. putString ( Dynamic App Manager Prefs . expected App Family Key , Ġapplication Family ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. put Int ( Dynamic App Manager Prefs . previous Version Key , Ġapp Version Code ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. put Int ( Dynamic App Manager Prefs . failed Toggle Attempt Count Key , Ġ 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. putString ( Dynamic App Manager Prefs . previous App Family Key , Ġcurrent App Family ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. commit () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Event ( eventName : ĠString ) Ġ{ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġreturn To Default Family () Ġ{ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġswitch To App Family ( app Family : ĠString , Ġuse Switch Activity : ĠBoolean , Ġlaunch Intent : ĠIntent ?) Ġ{ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġhas Pending App Family Change Signal () Ġ= Ġfalse ĊĊĠĠĠ Ġoverride Ġfun Ġconsume Pending App Family Change Signal () Ġ{ Ġ} Ċ } Ċ