diff options
author | Scott Jackson <daneren2005@gmail.com> | 2016-07-25 17:35:19 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2016-07-25 17:35:19 -0700 |
commit | 6e4258781771be4735fe482218e2fec7194fbd9b (patch) | |
tree | 9ed4be17958b8e802c24cf211b3c6cd1dccd5b7c /app | |
parent | c6a2210258d0f91e147b091d357652d3f921e916 (diff) | |
download | dsub-6e4258781771be4735fe482218e2fec7194fbd9b.tar.gz dsub-6e4258781771be4735fe482218e2fec7194fbd9b.tar.bz2 dsub-6e4258781771be4735fe482218e2fec7194fbd9b.zip |
Fix dropdown color on newer versions of support lib
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java | 2 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/DrawableTint.java | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java index 06559456..9f73f865 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -192,7 +192,7 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte protected void createCustomActionBarView() { actionBarSpinner = (Spinner) getLayoutInflater().inflate(R.layout.actionbar_spinner, null); if((this instanceof SubsonicFragmentActivity || this instanceof SettingsActivity) && (Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_COLOR_ACTION_BAR, true) || Util.getThemeRes(this) != R.style.Theme_DSub_Light_No_Color)) { - actionBarSpinner.setBackgroundResource(R.drawable.abc_spinner_mtrl_am_alpha); + actionBarSpinner.setBackgroundDrawable(DrawableTint.getTintedDrawableFromColor(this, R.drawable.abc_spinner_mtrl_am_alpha, android.R.color.white)); } spinnerAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); diff --git a/app/src/main/java/github/daneren2005/dsub/util/DrawableTint.java b/app/src/main/java/github/daneren2005/dsub/util/DrawableTint.java index 2da72579..cc8e241d 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/DrawableTint.java +++ b/app/src/main/java/github/daneren2005/dsub/util/DrawableTint.java @@ -21,6 +21,7 @@ import android.content.res.TypedArray; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.support.annotation.AttrRes; +import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; import android.util.TypedValue; @@ -48,6 +49,17 @@ public class DrawableTint { tintedDrawables.put(drawableRes, background); return background; } + public static Drawable getTintedDrawableFromColor(Context context, @DrawableRes int drawableRes, @ColorRes int colorRes) { + if(tintedDrawables.containsKey(drawableRes)) { + return tintedDrawables.get(drawableRes); + } + + int color = context.getResources().getColor(colorRes); + Drawable background = context.getResources().getDrawable(drawableRes); + background.setColorFilter(color, PorterDuff.Mode.SRC_IN); + tintedDrawables.put(drawableRes, background); + return background; + } public static int getColorRes(Context context, @AttrRes int colorAttr) { int color; if(attrMap.containsKey(colorAttr)) { |