Skip to content

Commit

Permalink
1.5.2: Fix legend on pre-lollipop devices
Browse files Browse the repository at this point in the history
  • Loading branch information
caarmen committed Oct 5, 2016
1 parent 41a1d46 commit 0ec263a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ android {
}
defaultConfig {
applicationId "ca.rmen.android.scrumchatter"
versionCode 10501
versionName "1.5.1"
versionCode 10502
versionName "1.5.2"
minSdkVersion 9
targetSdkVersion 24
return true; // Avoid "Not all execution paths return a value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
Expand Down Expand Up @@ -60,8 +61,14 @@ static void addLegendEntry(Context context, ViewGroup legendView, String name, i
memberLegendEntry.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
memberLegendEntry.setPadding(0, 0, context.getResources().getDimensionPixelSize(R.dimen.chart_legend_entry_padding), 0);

Drawable icon = ContextCompat.getDrawable(context, R.drawable.ic_legend_square).mutate();
DrawableCompat.setTint(icon, color);
final Drawable icon;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
icon = ContextCompat.getDrawable(context, R.drawable.ic_legend_square);
memberLegendEntry.setTextColor(color);
} else {
icon = ContextCompat.getDrawable(context, R.drawable.ic_legend_square).mutate();
DrawableCompat.setTint(icon, color);
}
memberLegendEntry.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
legendView.addView(memberLegendEntry);
}
Expand Down

0 comments on commit 0ec263a

Please sign in to comment.