private static boolean validateVersion ( Context ctx , ChangeLog clog ) { // Get Preferences SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( ctx ) ; int lastSeen = prefs . getInt ( PREF_CHANGELOG_LAST_SEEN , - 1 ) ; // Second sort versions by it's code int latest = Integer . MIN_VALUE ; for ( Version version : clog . versions ) { if ( version . code > latest ) { latest = version . code ; } } // Get applications current version if ( latest > lastSeen ) { if ( ! BuildConfig . DEBUG ) prefs . edit ( ) . putInt ( PREF_CHANGELOG_LAST_SEEN , latest ) . apply ( ) ; return true ; } return false ; }
Validate the last seen stored verion code against the current changelog configuration to see if there is any updates and whether or not we should show the changelog dialog when called .