|
23 | 23 | import android.graphics.Typeface;
|
24 | 24 | import android.os.Bundle;
|
25 | 25 | import android.support.design.widget.FloatingActionButton;
|
| 26 | +import android.support.graphics.drawable.VectorDrawableCompat; |
26 | 27 | import android.util.Log;
|
27 | 28 | import android.view.KeyCharacterMap;
|
28 | 29 | import android.view.KeyEvent;
|
@@ -281,10 +282,17 @@ public void onClick(View v) {
|
281 | 282 | mSecondHalfDayToggle.setText(R.string.hours_12_23);
|
282 | 283 | // We need different drawable resources for each case, not a single one that we
|
283 | 284 | // just tint differently, because the orientation of each one is different.
|
284 |
| - final int icon1 = mThemeDark? R.drawable.ic_half_day_1_dark_24dp : R.drawable.ic_half_day_1_24dp; |
285 |
| - final int icon2 = mThemeDark? R.drawable.ic_half_day_2_dark_24dp : R.drawable.ic_half_day_2_24dp; |
286 |
| - mFirstHalfDayToggle.setCompoundDrawablesWithIntrinsicBounds(0, icon1, 0, 0); |
287 |
| - mSecondHalfDayToggle.setCompoundDrawablesWithIntrinsicBounds(0, icon2, 0, 0); |
| 285 | + final int iconRes1 = mThemeDark? R.drawable.ic_half_day_1_dark_24dp : R.drawable.ic_half_day_1_24dp; |
| 286 | + final int iconRes2 = mThemeDark? R.drawable.ic_half_day_2_dark_24dp : R.drawable.ic_half_day_2_24dp; |
| 287 | + VectorDrawableCompat icon1 = VectorDrawableCompat.create(res, iconRes1, ctx.getTheme()); |
| 288 | + VectorDrawableCompat icon2 = VectorDrawableCompat.create(res, iconRes2, ctx.getTheme()); |
| 289 | + if (Utils.checkApiLevel(17)) { |
| 290 | + mFirstHalfDayToggle.setCompoundDrawablesRelativeWithIntrinsicBounds(null, icon1, null, null); |
| 291 | + mSecondHalfDayToggle.setCompoundDrawablesRelativeWithIntrinsicBounds(null, icon2, null, null); |
| 292 | + } else { |
| 293 | + mFirstHalfDayToggle.setCompoundDrawablesWithIntrinsicBounds(null, icon1, null, null); |
| 294 | + mSecondHalfDayToggle.setCompoundDrawablesWithIntrinsicBounds(null, icon2, null, null); |
| 295 | + } |
288 | 296 | } else {
|
289 | 297 | mAmPmTextView.setVisibility(View.VISIBLE);
|
290 | 298 | mAmPmHitspace.setOnClickListener(new OnClickListener() {
|
|
0 commit comments