public class ChangeLog extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
ChangeLog.ChangeLogTag
Contains constants for the root element of
changelog.xml. |
protected static interface |
ChangeLog.ChangeTag
Contains constants for the change element of
changelog.xml. |
static class |
ChangeLog.ReleaseItem
Container used to store information about a release/version.
|
protected static interface |
ChangeLog.ReleaseTag
Contains constants for the release element of
changelog.xml. |
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CSS
Default CSS styles used to format the change log.
|
protected static String |
LOG_TAG
Tag that is used when sending error/debug messages to the log.
|
protected Context |
mContext
Context that is used to access the resources and to create the ChangeLog dialogs.
|
protected String |
mCss
Contains the CSS rules used to format the change log.
|
protected static int |
NO_VERSION
Constant that used when no version code is available.
|
protected static String |
VERSION_KEY
This is the key used when storing the version code in SharedPreferences.
|
| Constructor and Description |
|---|
ChangeLog(Context context)
Create a
ChangeLog instance using the default SharedPreferences file. |
ChangeLog(Context context,
SharedPreferences preferences,
String css)
Create a
ChangeLog instance using the supplied SharedPreferences instance. |
ChangeLog(Context context,
String css)
Create a
ChangeLog instance using the default SharedPreferences file. |
| Modifier and Type | Method and Description |
|---|---|
List<ChangeLog.ReleaseItem> |
getChangeLog(boolean full)
Returns the merged change log.
|
protected Comparator<ChangeLog.ReleaseItem> |
getChangeLogComparator()
Returns a
Comparator that specifies the sort order of the ChangeLog.ReleaseItems. |
int |
getCurrentVersionCode()
Get version code of current installation.
|
String |
getCurrentVersionName()
Get version name of current installation.
|
protected AlertDialog |
getDialog(boolean full)
Create a dialog containing (parts of the) change log.
|
String |
getFullLog()
Get full change log as HTML string.
|
AlertDialog |
getFullLogDialog()
Get a dialog with the full change log.
|
int |
getLastVersionCode()
Get version code of last installation.
|
protected SparseArray<ChangeLog.ReleaseItem> |
getLocalizedChangeLog(boolean full)
Read localized change log from
xml[-lang]/changelog.xml |
String |
getLog()
Get changes since last version as HTML string.
|
protected String |
getLog(boolean full)
Get (partial) change log as HTML string.
|
AlertDialog |
getLogDialog()
Get the "What's New" dialog.
|
protected SparseArray<ChangeLog.ReleaseItem> |
getMasterChangeLog(boolean full)
Read master change log from
xml/changelog_master.xml |
boolean |
isFirstRun()
Check if this is the first execution of this app version.
|
boolean |
isFirstRunEver()
Check if this is a new installation.
|
protected SparseArray<ChangeLog.ReleaseItem> |
readChangeLog(XmlPullParser xml,
boolean full)
Read the change log from an XML file.
|
protected SparseArray<ChangeLog.ReleaseItem> |
readChangeLogFromResource(int resId,
boolean full)
Read change log from XML resource file.
|
void |
skipLogDialog()
Skip the "What's new" dialog for this app version.
|
protected void |
updateVersionInPreferences()
Write current version code to the preferences.
|
protected static final String LOG_TAG
protected static final String VERSION_KEY
protected static final int NO_VERSION
public static final String DEFAULT_CSS
protected final Context mContext
protected final String mCss
public ChangeLog(Context context)
ChangeLog instance using the default SharedPreferences file.context - Context that is used to access the resources and to create the ChangeLog dialogs.public ChangeLog(Context context, String css)
ChangeLog instance using the default SharedPreferences file.context - Context that is used to access the resources and to create the ChangeLog dialogs.css - CSS styles that will be used to format the change log.public ChangeLog(Context context, SharedPreferences preferences, String css)
ChangeLog instance using the supplied SharedPreferences instance.context - Context that is used to access the resources and to create the ChangeLog dialogs.preferences - SharedPreferences instance that is used to persist the last version code.css - CSS styles used to format the change log (excluding <style> and
</style>).public int getLastVersionCode()
getCurrentVersionCode() the
second time this version of the app is launched (more precisely: the second time
ChangeLog is instantiated).public int getCurrentVersionCode()
public String getCurrentVersionName()
public boolean isFirstRun()
true if this version of your app is started the first time.public boolean isFirstRunEver()
true if your app including ChangeLog is started the first time ever.
Also true if your app was uninstalled and installed again.public void skipLogDialog()
Future calls to isFirstRun() and isFirstRunEver() will return false
for the current app version.
public AlertDialog getLogDialog()
ChangeLog then the full log dialog is show.public AlertDialog getFullLogDialog()
protected AlertDialog getDialog(boolean full)
full - If this is true the full change log is displayed. Otherwise only changes for
versions newer than the last version are displayed.protected void updateVersionInPreferences()
public String getLog()
public String getFullLog()
protected String getLog(boolean full)
full - If this is true the full change log is returned. Otherwise only changes for
versions newer than the last version are returned.public List<ChangeLog.ReleaseItem> getChangeLog(boolean full)
full - If this is true the full change log is returned. Otherwise only changes for
versions newer than the last version are returned.List containing ChangeLog.ReleaseItems representing the (partial)
change log.getChangeLogComparator()protected SparseArray<ChangeLog.ReleaseItem> getMasterChangeLog(boolean full)
xml/changelog_master.xmlprotected SparseArray<ChangeLog.ReleaseItem> getLocalizedChangeLog(boolean full)
xml[-lang]/changelog.xmlprotected final SparseArray<ChangeLog.ReleaseItem> readChangeLogFromResource(int resId, boolean full)
resId - Resource ID of the XML file to read the change log from.full - If this is true the full change log is returned. Otherwise only changes for
versions newer than the last version are returned.SparseArray containing ChangeLog.ReleaseItems representing the (partial)
change log.protected SparseArray<ChangeLog.ReleaseItem> readChangeLog(XmlPullParser xml, boolean full)
xml - The XmlPullParser instance used to read the change log.full - If true the full change log is read. Otherwise only the changes since the
last (saved) version are read.SparseArray mapping the version codes to release information.protected Comparator<ChangeLog.ReleaseItem> getChangeLogComparator()
Comparator that specifies the sort order of the ChangeLog.ReleaseItems.
The default implementation returns the items in reverse order (latest version first).