Skip to content

Commit

Permalink
Merge branch 'release/v3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jul 2, 2015
2 parents 42d4542 + 7d697f3 commit 21b7c68
Show file tree
Hide file tree
Showing 30 changed files with 527 additions and 811 deletions.
32 changes: 11 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

ActionItemBadge is a library which offers a simple and easy to use method to add a badge to your action item!


##Screenshots
![Image](https://raw.githubusercontent.com/mikepenz/Android-ActionItemBadge/master/DEV/screenshot/screenshot1_small.png).
![Image](https://raw.githubusercontent.com/mikepenz/Android-ActionItemBadge/master/DEV/screenshot/screenshot2_small.png)
Expand All @@ -15,7 +14,7 @@ The ActionItemBadge Library is pushed to [Maven Central], so you just need to ad

```javascript
dependencies {
compile('com.mikepenz:actionitembadge:2.5.5@aar') {
compile('com.mikepenz:actionitembadge:3.0.0@aar') {
transitive = true
}
}
Expand All @@ -28,19 +27,9 @@ dependencies {
}
```

You use ActionbarSherlock? No problem there's now a SNAPSHOT release for ActionbarSherlock. Just do the following:

Add the SNAPSHOT repo to your repositories:
```javascript
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
```

And the compile dependency
```javascript
dependencies {
compile 'com.tundem.actionitembadge:library-abs:1.2.0@aar'
}
```
##UPGRADE NOTES
####< 3.0.0
- If you come from a version prior 3.0.0 you will have to rename some classes, and the default styles also found a new place. Just check out the updated sample app for all the changes.

##Usage
###menu.xml
Expand All @@ -65,28 +54,29 @@ Override the onCreateOptionsMenu method
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);

//you can add some logic (hide it if the count == 0)
//you can add some logic (hide it if the count == 0)
if (badgeCount > 0) {
ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, ActionItemBadge.BadgeStyle.DARKGREY, badgeCount);
ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, ActionItemBadge.BadgeStyles.DARK_GREY, badgeCount);
} else {
ActionItemBadge.hide(menu.findItem(R.id.item_samplebadge));
}

//If you want to add your ActionItem programmatically you can do this too. You do the following:
new ActionItemBadge.Add().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1).showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).build(ActionItemBadge.BadgeStyle.BLUE_LARGE, 1);
//If you want to add your ActionItem programmatically you can do this too. You do the following:
new ActionItemBadgeAdder().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1).showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).add(bigStyle, 1);
return true;
}
```

If you want to update the item itself you can do the required stuff in the onOptionsItemSelected method and
call invalidateOptionsMenu() afterwards.
```java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.item_samplebadge) {
Toast.makeText(this, R.string.sample_3, Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.sample_3, Toast.LENGTH_SHORT).show();.LENGTH_SHORT).show();
badgeCount--;
invalidateOptionsMenu();
ActionItemBadge.update(item, badgeCount);
return true;
} else if (id == SAMPLE2_ID) {
Toast.makeText(this, R.string.sample_4, Toast.LENGTH_SHORT).show();
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.mikepenz.actionitembadge.sample"
minSdkVersion 14
targetSdkVersion 22
versionCode 255
versionName "2.5.5"
versionCode 300
versionName "3.0.0"
}
buildTypes {
release {
Expand All @@ -22,10 +22,10 @@ android {

dependencies {
compile project(':library')
compile('com.mikepenz:materialdrawer:3.0.7@aar') {
compile('com.mikepenz:materialdrawer:3.0.9@aar') {
transitive = true
}
compile('com.mikepenz:aboutlibraries:5.0.5@aar') {
compile('com.mikepenz:aboutlibraries:5.0.6@aar') {
transitive = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.mikepenz.aboutlibraries.ui.LibsFragment;
import com.mikepenz.actionitembadge.R;
import com.mikepenz.actionitembadge.library.ActionItemBadge;
import com.mikepenz.actionitembadge.library.ActionItemBadgeAdder;
import com.mikepenz.iconics.typeface.FontAwesome;


Expand Down Expand Up @@ -45,12 +46,12 @@ public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);

if (badgeCount > 0) {
ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, ActionItemBadge.BadgeStyle.DARKGREY, badgeCount);
ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, ActionItemBadge.BadgeStyles.GREY, badgeCount);
} else {
ActionItemBadge.hide(menu.findItem(R.id.item_samplebadge));
}

new ActionItemBadge.Add().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1).showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).build(ActionItemBadge.BadgeStyle.BLUE_LARGE, 1);
new ActionItemBadgeAdder().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1).showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).add(ActionItemBadge.BadgeStyles.GREY_LARGE, 1);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mikepenz.actionitembadge.sample;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -15,6 +16,8 @@
import com.mikepenz.aboutlibraries.ui.LibsFragment;
import com.mikepenz.actionitembadge.R;
import com.mikepenz.actionitembadge.library.ActionItemBadge;
import com.mikepenz.actionitembadge.library.ActionItemBadgeAdder;
import com.mikepenz.actionitembadge.library.utils.BadgeStyle;
import com.mikepenz.iconics.typeface.FontAwesome;
import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder;
Expand All @@ -27,8 +30,8 @@ public class ToolbarActivity extends AppCompatActivity {

private Drawer drawer;

private ActionItemBadge.BadgeStyle style = ActionItemBadge.BadgeStyle.DARKGREY;
private ActionItemBadge.BadgeStyle bigStyle = ActionItemBadge.BadgeStyle.DARKGREY_LARGE;
private BadgeStyle style = ActionItemBadge.BadgeStyles.DARK_GREY.getStyle();
private BadgeStyle bigStyle = ActionItemBadge.BadgeStyles.DARK_GREY_LARGE.getStyle();
private int badgeCount = 10;

private static final int SAMPLE2_ID = 34536;
Expand All @@ -55,8 +58,11 @@ protected void onCreate(Bundle savedInstanceState) {
new PrimaryDrawerItem().withName("Green").withIdentifier(5),
new PrimaryDrawerItem().withName("Purple").withIdentifier(6),
new PrimaryDrawerItem().withName("Yellow").withIdentifier(7),
new PrimaryDrawerItem().withName("Custom").withIdentifier(8),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName("RESET COUNT").withIdentifier(10)
new PrimaryDrawerItem().withName("SWITCH").withIdentifier(9).withCheckable(false),
new PrimaryDrawerItem().withName("RESET COUNT").withIdentifier(10).withCheckable(false),
new PrimaryDrawerItem().withName("HIDE BADGE").withIdentifier(11).withCheckable(false)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
Expand All @@ -66,28 +72,38 @@ public boolean onItemClick(AdapterView<?> adapterView, View view, int i, long l,
startActivity(intent);
return false;
} else if (iDrawerItem.getIdentifier() == 1) {
style = ActionItemBadge.BadgeStyle.DARKGREY;
bigStyle = ActionItemBadge.BadgeStyle.DARKGREY_LARGE;
style = ActionItemBadge.BadgeStyles.DARK_GREY.getStyle();
bigStyle = ActionItemBadge.BadgeStyles.DARK_GREY_LARGE.getStyle();
} else if (iDrawerItem.getIdentifier() == 2) {
style = ActionItemBadge.BadgeStyle.GREY;
bigStyle = ActionItemBadge.BadgeStyle.GREY_LARGE;
style = ActionItemBadge.BadgeStyles.GREY.getStyle();
bigStyle = ActionItemBadge.BadgeStyles.GREY_LARGE.getStyle();
} else if (iDrawerItem.getIdentifier() == 3) {
style = ActionItemBadge.BadgeStyle.RED;
bigStyle = ActionItemBadge.BadgeStyle.RED_LARGE;
style = ActionItemBadge.BadgeStyles.RED.getStyle();
bigStyle = ActionItemBadge.BadgeStyles.RED_LARGE.getStyle();
} else if (iDrawerItem.getIdentifier() == 4) {
style = ActionItemBadge.BadgeStyle.BLUE;
bigStyle = ActionItemBadge.BadgeStyle.BLUE_LARGE;
style = ActionItemBadge.BadgeStyles.BLUE.getStyle();
bigStyle = ActionItemBadge.BadgeStyles.BLUE_LARGE.getStyle();
} else if (iDrawerItem.getIdentifier() == 5) {
style = ActionItemBadge.BadgeStyle.GREEN;
bigStyle = ActionItemBadge.BadgeStyle.GREEN_LARGE;
style = ActionItemBadge.BadgeStyles.GREEN.getStyle();
bigStyle = ActionItemBadge.BadgeStyles.GREEN_LARGE.getStyle();
} else if (iDrawerItem.getIdentifier() == 6) {
style = ActionItemBadge.BadgeStyle.PURPLE;
bigStyle = ActionItemBadge.BadgeStyle.PURPLE_LARGE;
style = ActionItemBadge.BadgeStyles.PURPLE.getStyle();
bigStyle = ActionItemBadge.BadgeStyles.PURPLE_LARGE.getStyle();
} else if (iDrawerItem.getIdentifier() == 7) {
style = ActionItemBadge.BadgeStyle.YELLOW;
bigStyle = ActionItemBadge.BadgeStyle.YELLOW_LARGE;
style = ActionItemBadge.BadgeStyles.YELLOW.getStyle();
bigStyle = ActionItemBadge.BadgeStyles.YELLOW_LARGE.getStyle();
} else if (iDrawerItem.getIdentifier() == 8) {
style = new BadgeStyle(BadgeStyle.Style.DEFAULT, R.layout.menu_badge, Color.parseColor("#FE0665"), Color.parseColor("#CC0548"), Color.parseColor("#EEEEEE"));
bigStyle = new BadgeStyle(BadgeStyle.Style.LARGE, R.layout.menu_badge_large, Color.parseColor("#FE0665"), Color.parseColor("#CC0548"), Color.parseColor("#EEEEEE"));
} else if (iDrawerItem.getIdentifier() == 9) {
BadgeStyle temp = style;
style = bigStyle;
bigStyle = temp;
Toast.makeText(ToolbarActivity.this, "No icon provided for the previous large style", Toast.LENGTH_LONG).show();
} else if (iDrawerItem.getIdentifier() == 10) {
badgeCount = 10;
} else if (iDrawerItem.getIdentifier() == 11) {
badgeCount = Integer.MIN_VALUE;
}

invalidateOptionsMenu();
Expand Down Expand Up @@ -120,13 +136,13 @@ public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);

if (badgeCount > 0) {
ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, style, badgeCount);
} else {
if (badgeCount == 0) {
ActionItemBadge.hide(menu.findItem(R.id.item_samplebadge));
} else {
ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, style, badgeCount);
}

new ActionItemBadge.Add().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1).showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).build(bigStyle, 1);
new ActionItemBadgeAdder().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1).showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).add(bigStyle, 1);
return true;
}

Expand All @@ -139,7 +155,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (id == R.id.item_samplebadge) {
Toast.makeText(this, R.string.sample_3, Toast.LENGTH_SHORT).show();
badgeCount--;
invalidateOptionsMenu();
ActionItemBadge.update(item, badgeCount);
return true;
} else if (id == SAMPLE2_ID) {
Toast.makeText(this, R.string.sample_4, Toast.LENGTH_SHORT).show();
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=2.5.5
VERSION_CODE=255
VERSION_NAME=3.0.0
VERSION_CODE=300
GROUP=com.mikepenz

POM_DESCRIPTION=Android-ActionItemBadge Library
Expand Down
6 changes: 3 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 255
versionName "2.5.5"
versionCode 300
versionName "3.0.0"
}
buildTypes {
release {
Expand All @@ -20,5 +20,5 @@ android {
apply from: 'gradle-mvn-push.gradle'

dependencies {
compile 'com.mikepenz:iconics:1.1.0'
compile 'com.mikepenz:iconics:1.2.0'
}
Loading

0 comments on commit 21b7c68

Please sign in to comment.