Class ChangeLog


  • public final class ChangeLog
    extends Object
    Generate a full or partial (What's New) Change Log.
    • Method Detail

      • newInstance

        public static ChangeLog newInstance​(Context context)
        Create a ChangeLog instance using the default SharedPreferences file.
        Parameters:
        context - Context that is used to access resources.
      • newInstance

        public static ChangeLog newInstance​(Context context,
                                            SharedPreferences preferences)
        Create a ChangeLog instance using the supplied SharedPreferences instance.
        Parameters:
        context - Context that is used to access resources.
        preferences - SharedPreferences instance that is used to persist the last version code.
      • newInstance

        public static ChangeLog newInstance​(Context context,
                                            SharedPreferences preferences,
                                            ChangeLogProvider changeLogProvider)
        Create a ChangeLog instance using the supplied SharedPreferences and ChangeLogProvider instances.
        Parameters:
        context - Context that is used to access resources.
        preferences - SharedPreferences instance that is used to persist the last version code.
        changeLogProvider - ChangeLogProvider instance that is used to retrieve the Change Log.
      • getLastVersionCode

        public int getLastVersionCode()
        Get version code of last installation.
        Returns:
        The version code of the last installation of this app (as described in the former manifest). This will be the same as returned by getCurrentVersionCode() the second time this version of the app is launched (more precisely: the second time ChangeLog is instantiated).
        See Also:
        android:versionCode
      • getCurrentVersionCode

        public int getCurrentVersionCode()
        Get version code of current installation.
        Returns:
        The version code of this app as described in the manifest.
        See Also:
        android:versionCode
      • getCurrentVersionName

        public String getCurrentVersionName()
        Get version name of current installation.
        Returns:
        The version name of this app as described in the manifest.
        See Also:
        android:versionName
      • isFirstRun

        public boolean isFirstRun()
        Check if this is the first execution of this app version.
        Returns:
        true if this version of your app is started the first time.
      • isFirstRunEver

        public boolean isFirstRunEver()
        Check if this is a new installation.
        Returns:
        true if your app including ChangeLog is started the first time ever. Also true if your app was uninstalled and installed again.
      • writeCurrentVersion

        public void writeCurrentVersion()
        Write current version code to the preferences.

        Future calls to isFirstRun() and isFirstRunEver() will return false for the current app version.

      • getChangeLog

        public List<ReleaseItem> getChangeLog()
        Returns the full Change Log.
        Returns:
        A sorted List containing ReleaseItems representing the full Change Log.
      • getRecentChanges

        public List<ReleaseItem> getRecentChanges()
        Returns the list of changes for versions newer than the last version ("What's New").
        Returns:
        A sorted List containing ReleaseItems representing the recent changes.