Darkion Avey
Contact
Apps
Blog
Darkion's Blog © 2011 - 2017
AchievementUnlocked library documentation
darkion
28 July 2015
AchievementUnlocked is an open-source Android library that creates "XBOX Achievement Unlocked"-like alerts. It's super easy to set up.

Download demo app

Demo app can be downloaded from Play Store here

Demo video

Download or view code

Source code for the demo app and the library can be found here on BitBucket , or GitHub

Compatibility

This library is compatible with Android ICS 4.0 and upwards. Backward compatibility is possible with nineoldandroids library, but not implemented.

How to implement

Using AAR

•Download library-initial-release.aar and place it in your project's libs folder.
•Add flatDir {dirs 'libs'} to repositories in build.gradle. It should look like this
repositories {
 mavenCentral()
 flatDir {
 dirs 'libs'
 }
}
•Add this to dependencies section in build.gradle
compile(name:'library-initial-release', ext:'aar')


Manually (for eclipse)

•Download "library" folder.
•Copy java/net/darkion/AchievementUnlockedLib/AchievementUnlocked.java class and place it in your src (or java) folder.
•Copy /res/values/ids.xml and place it in your projects /res/values dir.
•Copy /res/layout/achievement_layout.xml to your /res/layout folder.
•Add SYSTEM_ALERT_WINDOW permission to your AndroidManifest.xml
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

License

MIT license

How to use

You can show a basic achievement by using the following code:
AchievementUnlocked test=
new AchievementUnlocked(YourActivity.this).setTitle("Title")
.setIcon(getDrawable(R.drawable.gpg)).setSubTitle("Subtitle").build().show();
You shouldn't call show() unless you want to actually show the achievement.

Some options

Below are some of the important options that you might be looking for. If you want the full list of options, press control + space on an AchievementUnlocked object, or check the demo app source.

.setAchievementListener

There are four options, each represents a stage of an achievements animations. They come with booleans that represent the end of corresponding stage (such as "boolean created") .
.setAchievementListener(new AchievementUnlocked.achievementListener() {
 @Override
 public void onAchievementBeingCreated(AchievementUnlocked achievement, boolean created) {

 }

 @Override
 public void onAchievementExpanding(AchievementUnlocked achievement, boolean expanded) {
 
 }

 @Override
 public void onAchievementShrinking(AchievementUnlocked achievement, boolean shrunken) {

 }

 @Override
 public void onAchievementBeingDestroyed(AchievementUnlocked achievement, boolean destroyed) {

 }
 });

.alignTop(boolean)

By default, achievement pop-ups are aligned to top, you can use .alignTop(false) to align it to bottom

.setBackgroundDrawable(Drawable)

You can set your own background to an achievement using this option.

.isLarge(boolean)

Specify whether or not you want the achievement to be large. Default is small

.isRounded(boolean)

The default background is rounded, you can override that by using .isRounded(false)
This option is not honored when used with .setBackgroundDrawable(Drawable) option

.getAchievementView()

Returns the achievement container view. You can use this view to attach custom listener, such as Swipe listener.

.getIconView()

Returns the icon container view (not an ImageView). You can use this option to animate the icon.

Disclaimer

This app is for demo purposes only and is not meant to cause any copyrights infringement. This app uses Computer Pixel-7 font, icons [50 raster icons by Vicent Pla, 21 vector (SVG) 8 bit icons by Froschgift]. Uses references to the following games: The Witcher 3 by CD Projekt RED, Deus EX HR by Eidos, Mass Effect by BioWare, and Saints Row series by Volition. XBOX is a copyright owned by Microsoft. Play games is owned by Google. The library (AchievementUnlocked library) and its demo app are under MIT license.