From ab2c219dca81b3ea2d5e2e382a445fb20e5a697d Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Sun, 1 May 2016 00:58:24 +0200 Subject: [PATCH] added badges for profile fixed icon not showing when just added a profile suppressed some annoying warnings --- app/build.gradle | 2 +- .../java/com/idlegandalf/ledd/ColorActivity.java | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a2b8abe..693cb55 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,7 +52,7 @@ android { applicationId "com.idlegandalf.ledd" minSdkVersion 18 targetSdkVersion 23 - versionCode System.getenv("BUILD_NUMBER") as Integer ?: 5 + versionCode System.getenv("BUILD_NUMBER") as Integer ?: 50 versionName "1.0.4-SNAPSHOT" archivesBaseName = "LedD-" + versionName + "-" + versionCode manifestPlaceholders = [HOCKEYAPP_APP_ID: "7febd1d2266a4f0c81667ca4e3d11fd3"] diff --git a/app/src/main/java/com/idlegandalf/ledd/ColorActivity.java b/app/src/main/java/com/idlegandalf/ledd/ColorActivity.java index ac4800f..437d4ee 100644 --- a/app/src/main/java/com/idlegandalf/ledd/ColorActivity.java +++ b/app/src/main/java/com/idlegandalf/ledd/ColorActivity.java @@ -150,7 +150,12 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI ) .addDrawerItems( new DividerDrawerItem(), - menuProfiles = new PrimaryDrawerItem().withName("Profiles").withIcon(R.drawable.ic_save_black_48dp).withSelectable(false).withIsExpanded(true) + menuProfiles = new PrimaryDrawerItem() + .withName("Profiles") + .withIcon(R.drawable.ic_save_black_48dp) + .withSelectable(false) + .withIsExpanded(true) + .withBadgeStyle(new BadgeStyle().withColor(Color.CYAN).withTextColor(Color.WHITE)) ) .build(); @@ -347,13 +352,14 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI profiles.add(profile); List subProfiles = menuProfiles.getSubItems(); - subProfiles.add(0, new SecondaryDrawerItem().withName(profile.getName()).withSelectable(false).withTag(profile.getValues())); + subProfiles.add(0, new SecondaryDrawerItem().withName(profile.getName()).withSelectable(false).withTag(profile.getValues()).withIcon(R.drawable.ic_save_black_48dp)); - menuProfiles.withSubItems(subProfiles); + menuProfiles.withSubItems(subProfiles).withIsExpanded(true).withBadge(String.valueOf(profiles.size())); mDrawer.updateItem(menuProfiles); } } + @SuppressWarnings("deprecated") public void refreshStripes() { if (isRefreshRunning) return; @@ -410,11 +416,13 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI nDaemonMenu.withSubItems(mStripes); nDaemonMenu.withBadge(String.valueOf(mStripes.size())); + //noinspection deprecation nDaemonMenu.withBadgeStyle(new BadgeStyle().withColor(getResources().getColor(R.color.material_drawer_accent)).withTextColor(Color.WHITE)); mDrawer.updateItem(nDaemonMenu); if (selectedItemId != -1) mDrawer.setSelection(selectedItemId); + //noinspection ConstantConditions Snackbar.make(findViewById(android.R.id.content), R.string.snackbar_stripes_reloaded, Snackbar.LENGTH_LONG).show(); } }); @@ -456,6 +464,7 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI @Override public void onGetFailed(int code, String message) { + //noinspection ConstantConditions Snackbar.make(findViewById(android.R.id.content), getString(R.string.snackbar_no_connection_stripes) + message, Snackbar .LENGTH_LONG).show(); @@ -463,6 +472,7 @@ public class ColorActivity extends AppCompatActivity implements Drawer.OnDrawerI @Override public void onConnectionFailed(String message) { + //noinspection ConstantConditions Snackbar.make(findViewById(android.R.id.content), getString(R.string.snackbar_connection_failed) + message, Snackbar .LENGTH_LONG).show(); }