Android Tutorial: Adding a change log dialog to your app

UPDATE 24-12-2012 – The code in this post is replaced by the open source library “Inscription” for more information:
Inscription library on Github

In this post I’am going to share my code for a change log dialog.

Having a change log in your application gives the user the option to see what new features or bug fixes are done in your app history. It’s a good way to communicate your hard work done to create your app.

The change log dialog that I will be sharing parses a xml file and shows this as a nice styled html text. (See image attached to this post)
The styling is done with CSS code and can be adjusted to fit your app look. I Will explain this later in the post.

Import class

To use the change log in your app follow the following steps.
Download and unzip the following file and import the class in to your project.
ChangeLogDialog source code

String resources

The class needs a few resources, the first resources are string resources.
Just add these to your strings.xml file.
You might want to add translations to your project as well.

<?xml version="1.0" encoding="utf-8"?>
    <string name="title_changelog">Change log</string>
    <string name="changelog_close">Close</string>

Change log XML file

The second resource you will need is a xml file with your change log.
This file should be in the following location of your project: “/res/xml/changelog.xml”
In this xml file you can use the following tags:

changelog This is the root tag.
release You can add a release tag for every version of your app.
The release tag needs to have two atributes:
version – This corresponds to the android:versionName attribute in your manifest file.
versioncode – This corresponds to the android:versionCode attribute in your manifest file.
change This tag is a child tag of the version tag. You can have as many change tags as needed. The change tag contains the actual text that will be displayed as a change in your change log dialog.

Here is a sample file:

<?xml version="1.0" encoding="utf-8"?>
	<release version="1.2" versioncode="3">
		<change>Fixed: A bug fix</change>
		<change>Button appearance changed</change>
		<change>Small layout change in the view item screen</change>
	<release version="1.1" versioncode="2">
		<change>Small layout change in the view item screen</change>
		<change>Minor tweaks</change>

Displaying the dialog

To invoke the change log dialog use the following code:

//Launch change log dialog
ChangeLogDialog _ChangelogDialog = new ChangeLogDialog(this);;  


Now you have your change log up and running.
If you want to change the look of the text within the dialog you can alter the following code in the ChangeLogDialog class. Just adjust the CSS code as needed.

//CSS style for the html
private String GetStyle() {
		"<style type=\"text/css\">"
		+ "h1 { margin-left: 0px; font-size: 12pt; }" 
		+ "li { margin-left: 0px; font-size: 9pt;}" 
		+ "ul { padding-left: 30px;}" 
		+ "</style>";

Leave a Reply

Your email address will not be published. Required fields are marked *