Package de.cketti.changelog
Class ChangeLog
- java.lang.Object
-
- de.cketti.changelog.ChangeLog
-
public final class ChangeLog extends Object
Generate a full or partial (What's New) Change Log.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ReleaseItem>getChangeLog()Returns the full Change Log.intgetCurrentVersionCode()Get version code of current installation.StringgetCurrentVersionName()Get version name of current installation.intgetLastVersionCode()Get version code of last installation.List<ReleaseItem>getRecentChanges()Returns the list of changes for versions newer than the last version ("What's New").booleanisFirstRun()Check if this is the first execution of this app version.booleanisFirstRunEver()Check if this is a new installation.static ChangeLognewInstance(Context context)Create aChangeLoginstance using the defaultSharedPreferencesfile.static ChangeLognewInstance(Context context, SharedPreferences preferences)Create aChangeLoginstance using the suppliedSharedPreferencesinstance.static ChangeLognewInstance(Context context, SharedPreferences preferences, ChangeLogProvider changeLogProvider)Create aChangeLoginstance using the suppliedSharedPreferencesandChangeLogProviderinstances.voidwriteCurrentVersion()Write current version code to the preferences.
-
-
-
Method Detail
-
newInstance
public static ChangeLog newInstance(Context context)
Create aChangeLoginstance using the defaultSharedPreferencesfile.- Parameters:
context- Context that is used to access resources.
-
newInstance
public static ChangeLog newInstance(Context context, SharedPreferences preferences)
Create aChangeLoginstance using the suppliedSharedPreferencesinstance.- Parameters:
context- Context that is used to access resources.preferences-SharedPreferencesinstance that is used to persist the last version code.
-
newInstance
public static ChangeLog newInstance(Context context, SharedPreferences preferences, ChangeLogProvider changeLogProvider)
Create aChangeLoginstance using the suppliedSharedPreferencesandChangeLogProviderinstances.- Parameters:
context- Context that is used to access resources.preferences-SharedPreferencesinstance that is used to persist the last version code.changeLogProvider-ChangeLogProviderinstance 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 timeChangeLogis 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:
trueif this version of your app is started the first time.
-
isFirstRunEver
public boolean isFirstRunEver()
Check if this is a new installation.- Returns:
trueif your app includingChangeLogis started the first time ever. Alsotrueif your app was uninstalled and installed again.
-
writeCurrentVersion
public void writeCurrentVersion()
Write current version code to the preferences.Future calls to
isFirstRun()andisFirstRunEver()will returnfalsefor the current app version.
-
getChangeLog
public List<ReleaseItem> getChangeLog()
Returns the full Change Log.- Returns:
- A sorted
ListcontainingReleaseItems 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
ListcontainingReleaseItems representing the recent changes.
-
-